summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests/scripts
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-07-08 19:13:42 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-07-08 19:13:42 +0200
commit6deaa15590d7a939b6fb13f505cf1611b26ed141 (patch)
tree8356954ba2a8c22080539457700797cc46ec7d97 /modules/gdscript/tests/scripts
parent3ced38cf282fc30b3a0a4d07f69dea82694fb664 (diff)
parentf68ab70a6ae4ddfdf955912af3dcb66284880b4d (diff)
downloadredot-engine-6deaa15590d7a939b6fb13f505cf1611b26ed141.tar.gz
Merge pull request #94076 from AThousandShips/lambda_get_method_fix
[GDScript] Fix `get_method` for lambda self `Callable`s
Diffstat (limited to 'modules/gdscript/tests/scripts')
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/lambda_get_method.gd21
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/lambda_get_method.out5
2 files changed, 26 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_get_method.gd b/modules/gdscript/tests/scripts/runtime/features/lambda_get_method.gd
new file mode 100644
index 0000000000..160e43a797
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/lambda_get_method.gd
@@ -0,0 +1,21 @@
+# https://github.com/godotengine/godot/issues/94074
+
+func foo():
+ pass
+
+func test():
+ var lambda_self := func test() -> void:
+ foo()
+ var anon_lambda_self := func() -> void:
+ foo()
+
+ print(lambda_self.get_method()) # Should print "test".
+ print(anon_lambda_self.get_method()) # Should print "<anonymous lambda>".
+
+ var lambda_non_self := func test() -> void:
+ pass
+ var anon_lambda_non_self := func() -> void:
+ pass
+
+ print(lambda_non_self.get_method()) # Should print "test".
+ print(anon_lambda_non_self.get_method()) # Should print "<anonymous lambda>".
diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_get_method.out b/modules/gdscript/tests/scripts/runtime/features/lambda_get_method.out
new file mode 100644
index 0000000000..17ee47fca2
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/lambda_get_method.out
@@ -0,0 +1,5 @@
+GDTEST_OK
+test
+<anonymous lambda>
+test
+<anonymous lambda>