summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/tests/scripts
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2024-09-12 10:52:47 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2024-09-16 09:58:47 +0200
commitbb7752059966b38f75714914474da1b9f93dc294 (patch)
treedaf6f92a1237b98598a888acdd76c9cc284ee573 /modules/gdscript/tests/scripts
parent10e2318bdeccdc33f95ebdb2c7683b816dda67fb (diff)
downloadredot-engine-bb7752059966b38f75714914474da1b9f93dc294.tar.gz
Object: Add tests about the safety of tail destruction
Diffstat (limited to 'modules/gdscript/tests/scripts')
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/self_destruction.gd50
-rw-r--r--modules/gdscript/tests/scripts/runtime/features/self_destruction.out5
2 files changed, 55 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/features/self_destruction.gd b/modules/gdscript/tests/scripts/runtime/features/self_destruction.gd
new file mode 100644
index 0000000000..442335faeb
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/self_destruction.gd
@@ -0,0 +1,50 @@
+# https://github.com/godotengine/godot/issues/75658
+
+class MyObj:
+ var callable: Callable
+
+ func run():
+ callable.call()
+
+ var prop:
+ set(value):
+ callable.call()
+ get:
+ callable.call()
+ return 0
+
+ func _on_some_signal():
+ callable.call()
+
+ func _init(p_callable: Callable):
+ self.callable = p_callable
+
+signal some_signal
+
+var obj: MyObj
+
+func test():
+ # Call.
+ obj = MyObj.new(nullify_obj)
+ obj.run()
+ print(obj)
+
+ # Get.
+ obj = MyObj.new(nullify_obj)
+ var _aux = obj.prop
+ print(obj)
+
+ # Set.
+ obj = MyObj.new(nullify_obj)
+ obj.prop = 1
+ print(obj)
+
+ # Signal handling.
+ obj = MyObj.new(nullify_obj)
+ @warning_ignore("return_value_discarded")
+ some_signal.connect(obj._on_some_signal)
+ some_signal.emit()
+ print(obj)
+
+func nullify_obj():
+ obj = null
diff --git a/modules/gdscript/tests/scripts/runtime/features/self_destruction.out b/modules/gdscript/tests/scripts/runtime/features/self_destruction.out
new file mode 100644
index 0000000000..ee4024a524
--- /dev/null
+++ b/modules/gdscript/tests/scripts/runtime/features/self_destruction.out
@@ -0,0 +1,5 @@
+GDTEST_OK
+<null>
+<null>
+<null>
+<null>