diff options
| author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-04-19 20:50:52 +0200 |
|---|---|---|
| committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-09-14 18:42:08 +0200 |
| commit | c0083c0f90238f0eec01604dd9c952c8c5dc3c22 (patch) | |
| tree | e7efc33ba4a25d8195f8089bf08be19311722da6 /modules/gdscript/tests/scripts/parser/features/dictionary.gd | |
| parent | a9b600bac0a9a8fdd3b217c6d3cb6639ae80c1f8 (diff) | |
| download | redot-engine-c0083c0f90238f0eec01604dd9c952c8c5dc3c22.tar.gz | |
Add dozens of new integration tests to the GDScript test suite
This also ignores `.out` files in the file format static checks.
Diffstat (limited to 'modules/gdscript/tests/scripts/parser/features/dictionary.gd')
| -rw-r--r-- | modules/gdscript/tests/scripts/parser/features/dictionary.gd | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/parser/features/dictionary.gd b/modules/gdscript/tests/scripts/parser/features/dictionary.gd new file mode 100644 index 0000000000..99afe166c7 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/dictionary.gd @@ -0,0 +1,37 @@ +func test(): + # Non-string keys are valid. + print({ 12: "world" }[12]) + + var contents = { + 0: "zero", + 0.0: "zero point zero", + null: "null", + false: "false", + []: "empty array", + Vector2i(): "zero Vector2i", + 15: { + 22: { + 4: ["nesting", "arrays"], + }, + }, + } + + print(contents[0.0]) + # Making sure declaration order doesn't affect things... + print({ 0.0: "zero point zero", 0: "zero", null: "null", false: "false", []: "empty array" }[0]) + print({ 0.0: "zero point zero", 0: "zero", null: "null", false: "false", []: "empty array" }[0.0]) + + print(contents[null]) + print(contents[false]) + print(contents[[]]) + print(contents[Vector2i()]) + print(contents[15]) + print(contents[15][22]) + print(contents[15][22][4]) + print(contents[15][22][4][0]) + print(contents[15][22][4][1]) + + # Currently fails with "invalid get index 'hello' on base Dictionary". + # Both syntaxes are valid however. + #print({ "hello": "world" }["hello"]) + #print({ "hello": "world" }.hello) |
