diff options
author | cdemirer <41021322+cdemirer@users.noreply.github.com> | 2022-03-02 19:05:18 +0800 |
---|---|---|
committer | cdemirer <41021322+cdemirer@users.noreply.github.com> | 2022-03-02 19:05:18 +0800 |
commit | 3afe50c2fa8281d8fb8563cf477841c31cf0f0e2 (patch) | |
tree | 20c964635a7e704e75db2c911cbb59c7d5abb0be /modules/gdscript/tests/scripts/parser/features/match_dictionary.gd | |
parent | b7a852a05d3598771bc1b9456ed34c0f5d011652 (diff) |
Fix logic errors in match-statement Array & Dictionary Patterns
Diffstat (limited to 'modules/gdscript/tests/scripts/parser/features/match_dictionary.gd')
-rw-r--r-- | modules/gdscript/tests/scripts/parser/features/match_dictionary.gd | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd b/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd new file mode 100644 index 0000000000..377dd25e9e --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd @@ -0,0 +1,43 @@ +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"}) |