summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/tests')
-rw-r--r--modules/gdscript/tests/gdscript_test_runner.cpp23
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.gd3
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.gd3
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.gd3
-rw-r--r--modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.gd9
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/enum_typecheck_inner_class.gd3
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.gd6
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/unassigned_builtin_typed.gd7
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/unassigned_builtin_typed.out2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/warning_ignore_warnings.gd2
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/enum_without_default_value.gd9
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/enum_without_default_value.out7
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/unsafe_cast.gd24
-rw-r--r--modules/gdscript/tests/scripts/analyzer/warnings/unsafe_cast.out33
-rw-r--r--modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_autocomplete.cfg9
-rw-r--r--modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_autocomplete.gd4
-rw-r--r--modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_values_autocompletion.cfg5
-rw-r--r--modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_values_autocompletion.gd4
-rw-r--r--modules/gdscript/tests/scripts/parser/features/constants.out32
-rw-r--r--modules/gdscript/tests/scripts/parser/features/continuation_lines_comments.bin.gd12
-rw-r--r--modules/gdscript/tests/scripts/parser/features/continuation_lines_comments.bin.out2
-rw-r--r--modules/gdscript/tests/scripts/parser/features/match_array.gd33
-rw-r--r--modules/gdscript/tests/scripts/parser/features/match_array.out6
-rw-r--r--modules/gdscript/tests/scripts/parser/features/match_dictionary.gd21
-rw-r--r--modules/gdscript/tests/scripts/parser/features/match_dictionary.out3
-rw-r--r--modules/gdscript/tests/scripts/parser/features/static_typing.out20
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.gd11
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out15
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unused_constant.gd4
-rw-r--r--modules/gdscript/tests/scripts/parser/warnings/unused_constant.out5
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.gd4
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.out6
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.gd4
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.out6
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.gd4
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.out6
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.gd4
-rw-r--r--modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.out6
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.gd25
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.out4
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/member_info.gd1
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd2
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/type_casting.gd24
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/type_casting.out10
49 files changed, 373 insertions, 63 deletions
diff --git a/modules/gdscript/tests/gdscript_test_runner.cpp b/modules/gdscript/tests/gdscript_test_runner.cpp
index a0329eb8d2..e3d16eaf42 100644
--- a/modules/gdscript/tests/gdscript_test_runner.cpp
+++ b/modules/gdscript/tests/gdscript_test_runner.cpp
@@ -300,14 +300,23 @@ bool GDScriptTestRunner::make_tests_for_dir(const String &p_dir) {
#endif
String out_file = next.get_basename() + ".out";
- if (!is_generating && !dir->file_exists(out_file)) {
- ERR_FAIL_V_MSG(false, "Could not find output file for " + next);
- }
- GDScriptTest test(current_dir.path_join(next), current_dir.path_join(out_file), source_dir);
- if (binary_tokens) {
- test.set_tokenizer_mode(GDScriptTest::TOKENIZER_BUFFER);
+ ERR_FAIL_COND_V_MSG(!is_generating && !dir->file_exists(out_file), false, "Could not find output file for " + next);
+
+ if (next.ends_with(".bin.gd")) {
+ // Test text mode first.
+ GDScriptTest text_test(current_dir.path_join(next), current_dir.path_join(out_file), source_dir);
+ tests.push_back(text_test);
+ // Test binary mode even without `--use-binary-tokens`.
+ GDScriptTest bin_test(current_dir.path_join(next), current_dir.path_join(out_file), source_dir);
+ bin_test.set_tokenizer_mode(GDScriptTest::TOKENIZER_BUFFER);
+ tests.push_back(bin_test);
+ } else {
+ GDScriptTest test(current_dir.path_join(next), current_dir.path_join(out_file), source_dir);
+ if (binary_tokens) {
+ test.set_tokenizer_mode(GDScriptTest::TOKENIZER_BUFFER);
+ }
+ tests.push_back(test);
}
- tests.push_back(test);
}
}
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.gd b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.gd
new file mode 100644
index 0000000000..b53e814eea
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.gd
@@ -0,0 +1,3 @@
+func test():
+ var integer := 1
+ print(integer as Array)
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.out b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.out
new file mode 100644
index 0000000000..e3e82c2b7e
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_array.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Invalid cast. Cannot convert from "int" to "Array".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.gd b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.gd
new file mode 100644
index 0000000000..323e367f8e
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.gd
@@ -0,0 +1,3 @@
+func test():
+ var integer := 1
+ print(integer as Node)
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.out b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.out
new file mode 100644
index 0000000000..7de40418bf
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/cast_int_to_object.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Invalid cast. Cannot convert from "int" to "Node".
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.gd b/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.gd
new file mode 100644
index 0000000000..f6cd5e217e
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.gd
@@ -0,0 +1,3 @@
+func test():
+ var object := RefCounted.new()
+ print(object as int)
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.out b/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.out
new file mode 100644
index 0000000000..8af0847577
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/errors/cast_object_to_int.out
@@ -0,0 +1,2 @@
+GDTEST_ANALYZER_ERROR
+Invalid cast. Cannot convert from "RefCounted" to "int".
diff --git a/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.gd b/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.gd
new file mode 100644
index 0000000000..77ef9e2073
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.gd
@@ -0,0 +1,9 @@
+# GH-85882
+
+enum Foo { A, B, C }
+
+func test():
+ var a := Foo.A
+ var b := a as int + 1
+ print(b)
+
diff --git a/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.out b/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.out
new file mode 100644
index 0000000000..a7f1357bb2
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/cast_enum_to_int.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+1
diff --git a/modules/gdscript/tests/scripts/analyzer/features/enum_typecheck_inner_class.gd b/modules/gdscript/tests/scripts/analyzer/features/enum_typecheck_inner_class.gd
index 1c4b19d8e0..0444051831 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/enum_typecheck_inner_class.gd
+++ b/modules/gdscript/tests/scripts/analyzer/features/enum_typecheck_inner_class.gd
@@ -11,6 +11,7 @@ class InnerClass:
var e2: InnerClass.MyEnum
var e3: EnumTypecheckOuterClass.InnerClass.MyEnum
+ @warning_ignore("unassigned_variable")
print("Self ", e1, e2, e3)
e1 = MyEnum.V1
e2 = MyEnum.V1
@@ -48,6 +49,7 @@ func test_outer_from_outer():
var e1: MyEnum
var e2: EnumTypecheckOuterClass.MyEnum
+ @warning_ignore("unassigned_variable")
print("Self ", e1, e2)
e1 = MyEnum.V1
e2 = MyEnum.V1
@@ -66,6 +68,7 @@ func test_inner_from_outer():
var e1: InnerClass.MyEnum
var e2: EnumTypecheckOuterClass.InnerClass.MyEnum
+ @warning_ignore("unassigned_variable")
print("Inner ", e1, e2)
e1 = InnerClass.MyEnum.V1
e2 = InnerClass.MyEnum.V1
diff --git a/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.gd b/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.gd
new file mode 100644
index 0000000000..c83a3a8a14
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.gd
@@ -0,0 +1,6 @@
+# GH-88082
+
+func test():
+ var x = 1
+ var message := "value: %s" % x
+ print(message)
diff --git a/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.out b/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.out
new file mode 100644
index 0000000000..cf6464a4c3
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/infer_type_on_string_format.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+value: 1
diff --git a/modules/gdscript/tests/scripts/analyzer/features/unassigned_builtin_typed.gd b/modules/gdscript/tests/scripts/analyzer/features/unassigned_builtin_typed.gd
new file mode 100644
index 0000000000..8099b366f3
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/unassigned_builtin_typed.gd
@@ -0,0 +1,7 @@
+# GH-88117, GH-85796
+
+func test():
+ var array: Array
+ # Should not emit unassigned warning because the Array type has a default value.
+ array.assign([1, 2, 3])
+ print(array)
diff --git a/modules/gdscript/tests/scripts/analyzer/features/unassigned_builtin_typed.out b/modules/gdscript/tests/scripts/analyzer/features/unassigned_builtin_typed.out
new file mode 100644
index 0000000000..6d85a6cc07
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/features/unassigned_builtin_typed.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+[1, 2, 3]
diff --git a/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_warnings.gd b/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_warnings.gd
index 8a1ab6f406..333950d64e 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_warnings.gd
+++ b/modules/gdscript/tests/scripts/analyzer/features/warning_ignore_warnings.gd
@@ -31,8 +31,8 @@ func int_func() -> int:
func test_warnings(unused_private_class_variable):
var t = 1
- @warning_ignore("unassigned_variable")
var unassigned_variable
+ @warning_ignore("unassigned_variable")
print(unassigned_variable)
var _unassigned_variable_op_assign
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/enum_without_default_value.gd b/modules/gdscript/tests/scripts/analyzer/warnings/enum_without_default_value.gd
new file mode 100644
index 0000000000..13e3edf93f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/enum_without_default_value.gd
@@ -0,0 +1,9 @@
+enum HasZero { A = 0, B = 1 }
+enum HasNoZero { A = 1, B = 2 }
+var has_zero: HasZero # No warning, because the default `0` is valid.
+var has_no_zero: HasNoZero # Warning, because there is no `0` in the enum.
+
+
+func test():
+ print(has_zero)
+ print(has_no_zero)
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/enum_without_default_value.out b/modules/gdscript/tests/scripts/analyzer/warnings/enum_without_default_value.out
new file mode 100644
index 0000000000..ae40e0bc8c
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/enum_without_default_value.out
@@ -0,0 +1,7 @@
+GDTEST_OK
+>> WARNING
+>> Line: 4
+>> ENUM_VARIABLE_WITHOUT_DEFAULT
+>> The variable "has_no_zero" has an enum type and does not set an explicit default value. The default will be set to "0".
+0
+0
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_cast.gd b/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_cast.gd
new file mode 100644
index 0000000000..1a6d10f8f7
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_cast.gd
@@ -0,0 +1,24 @@
+# We don't want to execute it because of errors, just analyze.
+func no_exec_test():
+ var weak_int = 1
+ print(weak_int as Variant) # No warning.
+ print(weak_int as int)
+ print(weak_int as Node)
+
+ var weak_node = Node.new()
+ print(weak_node as Variant) # No warning.
+ print(weak_node as int)
+ print(weak_node as Node)
+
+ var weak_variant = null
+ print(weak_variant as Variant) # No warning.
+ print(weak_variant as int)
+ print(weak_variant as Node)
+
+ var hard_variant: Variant = null
+ print(hard_variant as Variant) # No warning.
+ print(hard_variant as int)
+ print(hard_variant as Node)
+
+func test():
+ pass
diff --git a/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_cast.out b/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_cast.out
new file mode 100644
index 0000000000..c1e683d942
--- /dev/null
+++ b/modules/gdscript/tests/scripts/analyzer/warnings/unsafe_cast.out
@@ -0,0 +1,33 @@
+GDTEST_OK
+>> WARNING
+>> Line: 5
+>> UNSAFE_CAST
+>> Casting "Variant" to "int" is unsafe.
+>> WARNING
+>> Line: 6
+>> UNSAFE_CAST
+>> Casting "Variant" to "Node" is unsafe.
+>> WARNING
+>> Line: 10
+>> UNSAFE_CAST
+>> Casting "Variant" to "int" is unsafe.
+>> WARNING
+>> Line: 11
+>> UNSAFE_CAST
+>> Casting "Variant" to "Node" is unsafe.
+>> WARNING
+>> Line: 15
+>> UNSAFE_CAST
+>> Casting "Variant" to "int" is unsafe.
+>> WARNING
+>> Line: 16
+>> UNSAFE_CAST
+>> Casting "Variant" to "Node" is unsafe.
+>> WARNING
+>> Line: 20
+>> UNSAFE_CAST
+>> Casting "Variant" to "int" is unsafe.
+>> WARNING
+>> Line: 21
+>> UNSAFE_CAST
+>> Casting "Variant" to "Node" is unsafe.
diff --git a/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_autocomplete.cfg b/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_autocomplete.cfg
new file mode 100644
index 0000000000..7c7b465f26
--- /dev/null
+++ b/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_autocomplete.cfg
@@ -0,0 +1,9 @@
+[output]
+include=[
+ {"display": "DrawMode",
+ "location": 256},
+ {"display": "Anchor",
+ "location": 257},
+ {"display": "TextureRepeat",
+ "location": 258},
+]
diff --git a/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_autocomplete.gd b/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_autocomplete.gd
new file mode 100644
index 0000000000..83f4b17a86
--- /dev/null
+++ b/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_autocomplete.gd
@@ -0,0 +1,4 @@
+extends Control
+
+func _ready():
+ var t = BaseButton.➡
diff --git a/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_values_autocompletion.cfg b/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_values_autocompletion.cfg
new file mode 100644
index 0000000000..7ccfa550e2
--- /dev/null
+++ b/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_values_autocompletion.cfg
@@ -0,0 +1,5 @@
+[output]
+include=[
+ {"display": "HEURISTIC_MAX"},
+ {"display": "HEURISTIC_OCTILE"},
+]
diff --git a/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_values_autocompletion.gd b/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_values_autocompletion.gd
new file mode 100644
index 0000000000..99e38be6b9
--- /dev/null
+++ b/modules/gdscript/tests/scripts/completion/builtin_enum/builtin_enum_values_autocompletion.gd
@@ -0,0 +1,4 @@
+extends Control
+
+func _ready():
+ AStarGrid2D.Heuristic.➡
diff --git a/modules/gdscript/tests/scripts/parser/features/constants.out b/modules/gdscript/tests/scripts/parser/features/constants.out
index 7ec33470d3..d73c5eb7cd 100644
--- a/modules/gdscript/tests/scripts/parser/features/constants.out
+++ b/modules/gdscript/tests/scripts/parser/features/constants.out
@@ -1,33 +1 @@
GDTEST_OK
->> WARNING
->> Line: 2
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_TEST" is declared but never used in the block. If this is intended, prefix it with an underscore: "__TEST".
->> WARNING
->> Line: 3
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_STRING" is declared but never used in the block. If this is intended, prefix it with an underscore: "__STRING".
->> WARNING
->> Line: 4
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_VECTOR" is declared but never used in the block. If this is intended, prefix it with an underscore: "__VECTOR".
->> WARNING
->> Line: 5
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_ARRAY" is declared but never used in the block. If this is intended, prefix it with an underscore: "__ARRAY".
->> WARNING
->> Line: 6
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_DICTIONARY" is declared but never used in the block. If this is intended, prefix it with an underscore: "__DICTIONARY".
->> WARNING
->> Line: 9
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_HELLO" is declared but never used in the block. If this is intended, prefix it with an underscore: "__HELLO".
->> WARNING
->> Line: 10
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INFINITY" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INFINITY".
->> WARNING
->> Line: 11
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_NOT_A_NUMBER" is declared but never used in the block. If this is intended, prefix it with an underscore: "__NOT_A_NUMBER".
diff --git a/modules/gdscript/tests/scripts/parser/features/continuation_lines_comments.bin.gd b/modules/gdscript/tests/scripts/parser/features/continuation_lines_comments.bin.gd
new file mode 100644
index 0000000000..cb0bc94d2e
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/continuation_lines_comments.bin.gd
@@ -0,0 +1,12 @@
+# GH-89403
+
+func test():
+ var x := 1
+ if x == 0 \
+ # Comment.
+ # Comment.
+ and (x < 1 or x > 2) \
+ # Comment.
+ and x != 3:
+ pass
+ print("Ok")
diff --git a/modules/gdscript/tests/scripts/parser/features/continuation_lines_comments.bin.out b/modules/gdscript/tests/scripts/parser/features/continuation_lines_comments.bin.out
new file mode 100644
index 0000000000..0e9f482af4
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/continuation_lines_comments.bin.out
@@ -0,0 +1,2 @@
+GDTEST_OK
+Ok
diff --git a/modules/gdscript/tests/scripts/parser/features/match_array.gd b/modules/gdscript/tests/scripts/parser/features/match_array.gd
new file mode 100644
index 0000000000..9103092cb4
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/match_array.gd
@@ -0,0 +1,33 @@
+func foo(x):
+ match x:
+ ["value1"]:
+ print('["value1"]')
+ ["value1", "value2"]:
+ print('["value1", "value2"]')
+
+func bar(x):
+ match x:
+ [
+ "value1"
+ ]:
+ print('multiline ["value1"]')
+ [
+ "value1",
+ "value2",
+ ]:
+ print('multiline ["value1", "value2",]')
+ [
+ "value1",
+ [
+ "value2",
+ ..,
+ ],
+ ]:
+ print('multiline ["value1", ["value2", ..,],]')
+
+func test():
+ foo(["value1"])
+ foo(["value1", "value2"])
+ bar(["value1"])
+ bar(["value1", "value2"])
+ bar(["value1", ["value2", "value3"]])
diff --git a/modules/gdscript/tests/scripts/parser/features/match_array.out b/modules/gdscript/tests/scripts/parser/features/match_array.out
new file mode 100644
index 0000000000..d0111f07b1
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/features/match_array.out
@@ -0,0 +1,6 @@
+GDTEST_OK
+["value1"]
+["value1", "value2"]
+multiline ["value1"]
+multiline ["value1", "value2",]
+multiline ["value1", ["value2", ..,],]
diff --git a/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd b/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd
index 75857fb8ff..7685622e5a 100644
--- a/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd
+++ b/modules/gdscript/tests/scripts/parser/features/match_dictionary.gd
@@ -26,6 +26,24 @@ func bar(x):
_:
print("wildcard")
+func baz(x):
+ match x:
+ {
+ "key1": "value1"
+ }:
+ print('multiline {"key1": "value1"}')
+ {
+ "key2": "value2",
+ }:
+ print('multiline {"key2": "value2",}')
+ {
+ "key3": {
+ "key1",
+ ..,
+ },
+ }:
+ print('multiline {"key3": {"key1", ..,},}')
+
func test():
foo({"key1": "value1", "key2": "value2"})
foo({"key1": "value1", "key2": ""})
@@ -41,3 +59,6 @@ func test():
bar({1: "1"})
bar({2: "2"})
bar({3: "3"})
+ baz({"key1": "value1"})
+ baz({"key2": "value2"})
+ baz({"key3": {"key1": "value1", "key2": "value2"}})
diff --git a/modules/gdscript/tests/scripts/parser/features/match_dictionary.out b/modules/gdscript/tests/scripts/parser/features/match_dictionary.out
index 4dee886927..f9adcbd331 100644
--- a/modules/gdscript/tests/scripts/parser/features/match_dictionary.out
+++ b/modules/gdscript/tests/scripts/parser/features/match_dictionary.out
@@ -13,3 +13,6 @@ wildcard
1
2
wildcard
+multiline {"key1": "value1"}
+multiline {"key2": "value2",}
+multiline {"key3": {"key1", ..,},}
diff --git a/modules/gdscript/tests/scripts/parser/features/static_typing.out b/modules/gdscript/tests/scripts/parser/features/static_typing.out
index 40a8f97416..d73c5eb7cd 100644
--- a/modules/gdscript/tests/scripts/parser/features/static_typing.out
+++ b/modules/gdscript/tests/scripts/parser/features/static_typing.out
@@ -1,21 +1 @@
GDTEST_OK
->> WARNING
->> Line: 11
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INTEGER" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER".
->> WARNING
->> Line: 12
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INTEGER_REDUNDANT_TYPED" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_TYPED".
->> WARNING
->> Line: 13
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INTEGER_REDUNDANT_TYPED2" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_TYPED2".
->> WARNING
->> Line: 14
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INTEGER_REDUNDANT_INFERRED" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_INFERRED".
->> WARNING
->> Line: 15
->> UNUSED_LOCAL_CONSTANT
->> The local constant "_INTEGER_REDUNDANT_INFERRED2" is declared but never used in the block. If this is intended, prefix it with an underscore: "__INTEGER_REDUNDANT_INFERRED2".
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.gd b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.gd
index afb5059eea..b38cffb754 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.gd
+++ b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.gd
@@ -1,2 +1,11 @@
func test():
- var __
+ var unassigned
+ print(unassigned)
+ unassigned = "something" # Assigned only after use.
+
+ var a
+ print(a) # Unassigned, warn.
+ if a: # Still unassigned, warn.
+ a = 1
+ print(a) # Assigned (dead code), don't warn.
+ print(a) # "Maybe" assigned, don't warn.
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out
index 10f89be132..36db304ef4 100644
--- a/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out
+++ b/modules/gdscript/tests/scripts/parser/warnings/unassigned_variable.out
@@ -1,5 +1,16 @@
GDTEST_OK
>> WARNING
->> Line: 2
+>> Line: 3
>> UNASSIGNED_VARIABLE
->> The variable "__" was used but never assigned a value.
+>> The variable "unassigned" was used before being assigned a value.
+>> WARNING
+>> Line: 7
+>> UNASSIGNED_VARIABLE
+>> The variable "a" was used before being assigned a value.
+>> WARNING
+>> Line: 8
+>> UNASSIGNED_VARIABLE
+>> The variable "a" was used before being assigned a value.
+<null>
+<null>
+<null>
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unused_constant.gd b/modules/gdscript/tests/scripts/parser/warnings/unused_constant.gd
new file mode 100644
index 0000000000..3d355197e1
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/warnings/unused_constant.gd
@@ -0,0 +1,4 @@
+func test():
+ const UNUSED = "not used"
+
+ const _UNUSED = "not used, but no warning since the constant name starts with an underscore"
diff --git a/modules/gdscript/tests/scripts/parser/warnings/unused_constant.out b/modules/gdscript/tests/scripts/parser/warnings/unused_constant.out
new file mode 100644
index 0000000000..99ced48433
--- /dev/null
+++ b/modules/gdscript/tests/scripts/parser/warnings/unused_constant.out
@@ -0,0 +1,5 @@
+GDTEST_OK
+>> WARNING
+>> Line: 2
+>> UNUSED_LOCAL_CONSTANT
+>> The local constant "UNUSED" is declared but never used in the block. If this is intended, prefix it with an underscore: "_UNUSED".
diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.gd b/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.gd
new file mode 100644
index 0000000000..6b766f4d3d
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.gd
@@ -0,0 +1,4 @@
+func test():
+ var node := Node.new()
+ node.free()
+ print(node as Node2D)
diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.out b/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.out
new file mode 100644
index 0000000000..90d81dd9a1
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/cast_freed_object.out
@@ -0,0 +1,6 @@
+GDTEST_RUNTIME_ERROR
+>> SCRIPT ERROR
+>> on function: test()
+>> runtime/errors/cast_freed_object.gd
+>> 4
+>> Trying to cast a freed object.
diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.gd b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.gd
new file mode 100644
index 0000000000..00817c588f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.gd
@@ -0,0 +1,4 @@
+func test():
+ var integer: Variant = 1
+ @warning_ignore("unsafe_cast")
+ print(integer as Array)
diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.out b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.out
new file mode 100644
index 0000000000..545d7a4906
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_array.out
@@ -0,0 +1,6 @@
+GDTEST_RUNTIME_ERROR
+>> SCRIPT ERROR
+>> on function: test()
+>> runtime/errors/cast_int_to_array.gd
+>> 4
+>> Invalid cast: could not convert value to 'Array'.
diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.gd b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.gd
new file mode 100644
index 0000000000..44673a4513
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.gd
@@ -0,0 +1,4 @@
+func test():
+ var integer: Variant = 1
+ @warning_ignore("unsafe_cast")
+ print(integer as Node)
diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.out b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.out
new file mode 100644
index 0000000000..7c39b46396
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/cast_int_to_object.out
@@ -0,0 +1,6 @@
+GDTEST_RUNTIME_ERROR
+>> SCRIPT ERROR
+>> on function: test()
+>> runtime/errors/cast_int_to_object.gd
+>> 4
+>> Invalid cast: can't convert a non-object value to an object type.
diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.gd b/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.gd
new file mode 100644
index 0000000000..830d0c0c4a
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.gd
@@ -0,0 +1,4 @@
+func test():
+ var object: Variant = RefCounted.new()
+ @warning_ignore("unsafe_cast")
+ print(object as int)
diff --git a/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.out b/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.out
new file mode 100644
index 0000000000..f922199fb3
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/errors/cast_object_to_int.out
@@ -0,0 +1,6 @@
+GDTEST_RUNTIME_ERROR
+>> SCRIPT ERROR
+>> on function: test()
+>> runtime/errors/cast_object_to_int.gd
+>> 4
+>> Invalid cast: could not convert value to 'int'.
diff --git a/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.gd b/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.gd
new file mode 100644
index 0000000000..ff0001676d
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.gd
@@ -0,0 +1,25 @@
+signal no_parameters()
+signal one_parameter(number)
+signal two_parameters(number1, number2)
+
+func await_no_parameters():
+ var result = await no_parameters
+ print(result)
+
+func await_one_parameter():
+ var result = await one_parameter
+ print(result)
+
+func await_two_parameters():
+ var result = await two_parameters
+ print(result)
+
+func test():
+ await_no_parameters()
+ no_parameters.emit()
+
+ await_one_parameter()
+ one_parameter.emit(1)
+
+ await_two_parameters()
+ two_parameters.emit(1, 2)
diff --git a/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.out b/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.out
new file mode 100644
index 0000000000..9e203c601c
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.out
@@ -0,0 +1,4 @@
+GDTEST_OK
+<null>
+1
+[1, 2]
diff --git a/modules/gdscript/tests/scripts/runtime/features/member_info.gd b/modules/gdscript/tests/scripts/runtime/features/member_info.gd
index d7485f49e6..42b29eee43 100644
--- a/modules/gdscript/tests/scripts/runtime/features/member_info.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/member_info.gd
@@ -23,6 +23,7 @@ var test_var_hard_int: int
var test_var_hard_variant_type: Variant.Type
@export var test_var_hard_variant_type_exported: Variant.Type
var test_var_hard_node_process_mode: Node.ProcessMode
+@warning_ignore("enum_variable_without_default")
var test_var_hard_my_enum: MyEnum
var test_var_hard_array: Array
var test_var_hard_array_int: Array[int]
diff --git a/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd b/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd
index c45f8dce48..2bd5362f2a 100644
--- a/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd
@@ -7,6 +7,7 @@ func test():
var b
if true:
var c
+ @warning_ignore("unassigned_variable")
prints("Begin:", i, a, b, c)
a = 1
b = 1
@@ -20,6 +21,7 @@ func test():
var b
if true:
var c
+ @warning_ignore("unassigned_variable")
prints("Begin:", j, a, b, c)
a = 1
b = 1
diff --git a/modules/gdscript/tests/scripts/runtime/features/type_casting.gd b/modules/gdscript/tests/scripts/runtime/features/type_casting.gd
new file mode 100644
index 0000000000..c63ea16c32
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/type_casting.gd
@@ -0,0 +1,24 @@
+func print_value(value: Variant) -> void:
+ if value is Object:
+ @warning_ignore("unsafe_method_access")
+ print("<%s>" % value.get_class())
+ else:
+ print(var_to_str(value))
+
+func test():
+ var int_value := 1
+ print_value(int_value as Variant)
+ print_value(int_value as int)
+ print_value(int_value as float)
+
+ var node_value := Node.new()
+ print_value(node_value as Variant)
+ print_value(node_value as Object)
+ print_value(node_value as Node)
+ print_value(node_value as Node2D)
+ node_value.free()
+
+ var null_value = null
+ print_value(null_value as Variant)
+ @warning_ignore("unsafe_cast")
+ print_value(null_value as Node)
diff --git a/modules/gdscript/tests/scripts/runtime/features/type_casting.out b/modules/gdscript/tests/scripts/runtime/features/type_casting.out
new file mode 100644
index 0000000000..7da5a4c0a4
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/type_casting.out
@@ -0,0 +1,10 @@
+GDTEST_OK
+1
+1
+1.0
+<Node>
+<Node>
+<Node>
+null
+null
+null