virtualx-engine/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd
Adam Scott 44d1d72af1 Add GDScript .editorconfig rules
- Uniformize `.gd` unit test files indentation to tabs (where needed)
2023-01-10 12:25:35 -05:00

43 lines
932 B
GDScript

func foo(x):
match x:
{"key1": "value1", "key2": "value2"}:
print('{"key1": "value1", "key2": "value2"}')
{"key1": "value1", "key2"}:
print('{"key1": "value1", "key2"}')
{"key1", "key2": "value2"}:
print('{"key1", "key2": "value2"}')
{"key1", "key2"}:
print('{"key1", "key2"}')
{"key1": "value1"}:
print('{"key1": "value1"}')
{"key1"}:
print('{"key1"}')
_:
print("wildcard")
func bar(x):
match x:
{0}:
print("0")
{1}:
print("1")
{2}:
print("2")
_:
print("wildcard")
func test():
foo({"key1": "value1", "key2": "value2"})
foo({"key1": "value1", "key2": ""})
foo({"key1": "", "key2": "value2"})
foo({"key1": "", "key2": ""})
foo({"key1": "value1"})
foo({"key1": ""})
foo({"key1": "value1", "key2": "value2", "key3": "value3"})
foo({"key1": "value1", "key3": ""})
foo({"key2": "value2"})
foo({"key3": ""})
bar({0: "0"})
bar({1: "1"})
bar({2: "2"})
bar({3: "3"})