From 3c5b9d1be3db1ee2657ec10fc316b97a65c03542 Mon Sep 17 00:00:00 2001 From: cdemirer <41021322+cdemirer@users.noreply.github.com> Date: Mon, 4 Apr 2022 15:47:08 +0800 Subject: Fix issues with multiple bind patterns in match statement --- .../parser/errors/match_multiple_variable_binds_in_branch.gd | 4 ++++ .../parser/errors/match_multiple_variable_binds_in_branch.out | 2 ++ .../parser/features/match_multiple_variable_binds_in_pattern.gd | 6 ++++++ .../parser/features/match_multiple_variable_binds_in_pattern.out | 4 ++++ 4 files changed, 16 insertions(+) create mode 100644 modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.gd create mode 100644 modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.out create mode 100644 modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.gd create mode 100644 modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.out (limited to 'modules/gdscript/tests') diff --git a/modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.gd b/modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.gd new file mode 100644 index 0000000000..4608c778aa --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.gd @@ -0,0 +1,4 @@ +func test(): + match 1: + [[[var a]]], 2: + pass diff --git a/modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.out b/modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.out new file mode 100644 index 0000000000..1cdc24683b --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/match_multiple_variable_binds_in_branch.out @@ -0,0 +1,2 @@ +GDTEST_PARSER_ERROR +Cannot use a variable bind with multiple patterns. diff --git a/modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.gd b/modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.gd new file mode 100644 index 0000000000..a0ae7fb17c --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.gd @@ -0,0 +1,6 @@ +func test(): + match [1, 2, 3]: + [var a, var b, var c]: + print(a == 1) + print(b == 2) + print(c == 3) diff --git a/modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.out b/modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.out new file mode 100644 index 0000000000..316db6d748 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/features/match_multiple_variable_binds_in_pattern.out @@ -0,0 +1,4 @@ +GDTEST_OK +true +true +true -- cgit v1.2.3