summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/tests')
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/lambda_captures.gd26
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/lambda_captures.out5
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/metatypes.gd12
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/metatypes.out5
4 files changed, 48 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_captures.gd b/modules/gdscript/tests/scripts/runtime/features/lambda_captures.gd
new file mode 100644
index 0000000000..bbdf745540
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/lambda_captures.gd
@@ -0,0 +1,26 @@
+# GH-92217
+# TODO: Add more tests.
+
+static var static_var: int:
+ set(value):
+ prints("set static_var", value)
+ get:
+ print("get static_var")
+ return 0
+
+var member_var: int:
+ set(value):
+ prints("set member_var", value)
+ get:
+ print("get member_var")
+ return 0
+
+func test():
+ var lambda := func ():
+ var _tmp := static_var
+ _tmp = member_var
+
+ static_var = 1
+ member_var = 1
+
+ lambda.call()
diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_captures.out b/modules/gdscript/tests/scripts/runtime/features/lambda_captures.out
new file mode 100644
index 0000000000..0bdf74a43f
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/lambda_captures.out
@@ -0,0 +1,5 @@
+GDTEST_OK
+get static_var
+get member_var
+set static_var 1
+set member_var 1
diff --git a/modules/gdscript/tests/scripts/runtime/features/metatypes.gd b/modules/gdscript/tests/scripts/runtime/features/metatypes.gd
index 6c5df32ffe..fd23ea0db5 100644
--- a/modules/gdscript/tests/scripts/runtime/features/metatypes.gd
+++ b/modules/gdscript/tests/scripts/runtime/features/metatypes.gd
@@ -25,12 +25,24 @@ func test():
if str(property.name).begins_with("test_"):
print(Utils.get_property_signature(property))
+ print("---")
check_gdscript_native_class(test_native)
check_gdscript(test_script)
check_gdscript(test_class)
check_enum(test_enum)
+ print("---")
print(test_native.stringify([]))
print(test_script.TEST)
print(test_class.TEST)
print(test_enum.keys())
+
+ print("---")
+ # Some users add unnecessary type hints to `const`-`preload`, which removes metatypes.
+ # For **constant** `GDScript` we still check the class members, despite the wider type.
+ const ScriptNoMeta: GDScript = Other
+ const ClassNoMeta: GDScript = MyClass
+ var a := ScriptNoMeta.TEST
+ var b := ClassNoMeta.TEST
+ print(a)
+ print(b)
diff --git a/modules/gdscript/tests/scripts/runtime/features/metatypes.out b/modules/gdscript/tests/scripts/runtime/features/metatypes.out
index 352d1caa59..c42287438c 100644
--- a/modules/gdscript/tests/scripts/runtime/features/metatypes.out
+++ b/modules/gdscript/tests/scripts/runtime/features/metatypes.out
@@ -3,11 +3,16 @@ var test_native: GDScriptNativeClass
var test_script: GDScript
var test_class: GDScript
var test_enum: Dictionary
+---
GDScriptNativeClass
GDScript
GDScript
{ "A": 0, "B": 1, "C": 2 }
+---
[]
100
10
["A", "B", "C"]
+---
+100
+10