Gut
Gut copied to clipboard
Wait until object is freed
I think it could be useful. For example, in my game I want to test that when I hit an enemy, then it dies and is freed. But I found it awkward to await on signals on this soon-to-be null object
Before
enemy.set_name('node_name')
enemy.set_linear_velocity(Vector2.LEFT * 1000)
# Have to wait, but it's hard to guess for how long and slows test runs
wait_seconds(10)
# Or create a custom signal just for the test. It works but gives this awkward error message ==> ERROR: Parameter "obj" is null.
await wait_for_signal(enemy.damaged, 10)
assert_freed(enemy, 'node_name')
After
enemy.set_name('node_name')
enemy.set_linear_velocity(Vector2.LEFT * 1000)
await wait_until_freed(enemy, 10)
assert_freed(enemy, 'node_name')
Thanks! Hey let's hold on for this PR until we resolve https://github.com/bitwes/Gut/issues/585, as it might be a more generic solution. I don't have permission for it, but you can mark it as a "draft PR"
Closing in favor of: https://github.com/bitwes/Gut/pull/609