forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Object: Add tests about the safety of tail destruction
- Loading branch information
1 parent
10e2318
commit bb77520
Showing
3 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
modules/gdscript/tests/scripts/runtime/features/self_destruction.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
5 changes: 5 additions & 0 deletions
5
modules/gdscript/tests/scripts/runtime/features/self_destruction.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
GDTEST_OK | ||
<null> | ||
<null> | ||
<null> | ||
<null> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters