summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests
diff options
context:
space:
mode:
authorA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-07-05 09:40:46 +0200
committerA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-07-05 13:53:56 +0200
commitaa28782be391902e55131524f8d242b70888eb2c (patch)
tree9e76630e2e24ec2d7c906b1e5d51c6cb2c2acc62 /modules/gdscript/tests
parent20ba2f00bd9199b675176a8e1ac151f96bfb5cfa (diff)
downloadredot-engine-aa28782be391902e55131524f8d242b70888eb2c.tar.gz
[GDScript] Fix `get_argument_count` for lambda `Callable`s
Diffstat (limited to 'modules/gdscript/tests')
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.gd18
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.out3
2 files changed, 21 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.gd b/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.gd
new file mode 100644
index 0000000000..67225cad6a
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.gd
@@ -0,0 +1,18 @@
+# https://github.com/godotengine/godot/issues/93952
+
+func foo():
+ pass
+
+func test():
+ var a: int
+
+ var lambda_self := func (x: int) -> void:
+ foo()
+ print(a, x)
+
+ print(lambda_self.get_argument_count()) # Should print 1.
+
+ var lambda_non_self := func (x: int) -> void:
+ print(a, x)
+
+ print(lambda_non_self.get_argument_count()) # Should print 1.
diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.out b/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.out
new file mode 100644
index 0000000000..04b4638adf
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/lambda_bind_argument_count.out
@@ -0,0 +1,3 @@
+GDTEST_OK
+1
+1