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
43
addons/gut/one_to_many.gd
Normal file
43
addons/gut/one_to_many.gd
Normal file
|
@ -0,0 +1,43 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
# This datastructure represents a simple one-to-many relationship. It manages
|
||||
# a dictionary of value/array pairs. It ignores duplicates of both the "one"
|
||||
# and the "many".
|
||||
# ------------------------------------------------------------------------------
|
||||
var _items = {}
|
||||
|
||||
|
||||
# return the size of _items or the size of an element in _items if "one" was
|
||||
# specified.
|
||||
func size(one = null):
|
||||
var to_return = 0
|
||||
if one == null:
|
||||
to_return = _items.size()
|
||||
elif _items.has(one):
|
||||
to_return = _items[one].size()
|
||||
return to_return
|
||||
|
||||
|
||||
# Add an element to "one" if it does not already exist
|
||||
func add(one, many_item):
|
||||
if _items.has(one) and !_items[one].has(many_item):
|
||||
_items[one].append(many_item)
|
||||
else:
|
||||
_items[one] = [many_item]
|
||||
|
||||
|
||||
func clear():
|
||||
_items.clear()
|
||||
|
||||
|
||||
func has(one, many_item):
|
||||
var to_return = false
|
||||
if _items.has(one):
|
||||
to_return = _items[one].has(many_item)
|
||||
return to_return
|
||||
|
||||
|
||||
func to_s():
|
||||
var to_return = ""
|
||||
for key in _items:
|
||||
to_return += str(key, ": ", _items[key], "\n")
|
||||
return to_return
|
Loading…
Add table
Add a link
Reference in a new issue