mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-05 12:44:24 +02:00
Add GUT (CLI only) and remove gd-plug
Commit GUT directly to the git repo and remove gd-plug as it is no longer required to install GUT. Modify GUT to be used by command-line only. For example: ``` cp test/.gutconfig.ci.json .gutconfig.json godot --no-window -s addons/gut/gut_cmdln.gd ```
This commit is contained in:
parent
b14ea64492
commit
d784b53e25
52 changed files with 11394 additions and 1174 deletions
51
addons/gut/thing_counter.gd
Normal file
51
addons/gut/thing_counter.gd
Normal file
|
@ -0,0 +1,51 @@
|
|||
var things = {}
|
||||
|
||||
|
||||
func get_unique_count():
|
||||
return things.size()
|
||||
|
||||
|
||||
func add(thing):
|
||||
if things.has(thing):
|
||||
things[thing] += 1
|
||||
else:
|
||||
things[thing] = 1
|
||||
|
||||
|
||||
func has(thing):
|
||||
return things.has(thing)
|
||||
|
||||
|
||||
func get(thing):
|
||||
var to_return = 0
|
||||
if things.has(thing):
|
||||
to_return = things[thing]
|
||||
return to_return
|
||||
|
||||
|
||||
func sum():
|
||||
var count = 0
|
||||
for key in things:
|
||||
count += things[key]
|
||||
return count
|
||||
|
||||
|
||||
func to_s():
|
||||
var to_return = ""
|
||||
for key in things:
|
||||
to_return += str(key, ": ", things[key], "\n")
|
||||
to_return += str("sum: ", sum())
|
||||
return to_return
|
||||
|
||||
|
||||
func get_max_count():
|
||||
var max_val = null
|
||||
for key in things:
|
||||
if max_val == null or things[key] > max_val:
|
||||
max_val = things[key]
|
||||
return max_val
|
||||
|
||||
|
||||
func add_array_items(array):
|
||||
for i in range(array.size()):
|
||||
add(array[i])
|
Loading…
Add table
Add a link
Reference in a new issue