From 01d13ab2c16aa69a6f81c10dfe4845a50c3e0c63 Mon Sep 17 00:00:00 2001 From: George Marques Date: Wed, 20 Apr 2022 14:22:22 -0300 Subject: GDScript: Allow using self in lambdas --- .../scripts/runtime/features/lambda_use_self.gd | 23 ++++++++++++++++++++++ .../scripts/runtime/features/lambda_use_self.out | 5 +++++ 2 files changed, 28 insertions(+) create mode 100644 modules/gdscript/tests/scripts/runtime/features/lambda_use_self.gd create mode 100644 modules/gdscript/tests/scripts/runtime/features/lambda_use_self.out (limited to 'modules/gdscript/tests') diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_use_self.gd b/modules/gdscript/tests/scripts/runtime/features/lambda_use_self.gd new file mode 100644 index 0000000000..3d063869ab --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/lambda_use_self.gd @@ -0,0 +1,23 @@ +var member = "foo" + +func bar(): + print("bar") + +func test(): + var lambda1 = func(): + print(member) + lambda1.call() + + var lambda2 = func(): + var nested = func(): + print(member) + nested.call() + lambda2.call() + + var lambda3 = func(): + bar() + lambda3.call() + + var lambda4 = func(): + return self + print(lambda4.call() == self) diff --git a/modules/gdscript/tests/scripts/runtime/features/lambda_use_self.out b/modules/gdscript/tests/scripts/runtime/features/lambda_use_self.out new file mode 100644 index 0000000000..53d602b234 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/lambda_use_self.out @@ -0,0 +1,5 @@ +GDTEST_OK +foo +foo +bar +true -- cgit v1.2.3