|
1 | 1 | extends "res://addons/gut/test.gd"
|
2 | 2 |
|
3 | 3 | func test_signal_connection_script_instantiation():
|
4 |
| - var script = SignalTest.new() |
5 |
| - get_tree().root.add_child(script) |
6 |
| - assert_eq(script.is_connected("no_param_signal_delegate", Callable(script.other_script, "hook_no_param")), true, "signal \"no_param_signal_delegate\" should be connected to \"otherScript::hook_no_param\"") |
7 |
| - assert_eq(script.is_connected("one_param_signal_delegate", Callable(script.other_script, "hook_one_param")), true, "signal \"one_param_signal_delegate\" should be connected to \"otherScript::hook_one_param\"") |
8 |
| - assert_eq(script.is_connected("two_param_signal_delegate", Callable(script.other_script, "hook_two_param")), true, "signal \"two_param_signal_delegate\" should be connected to \"otherScript::hook_two_param\"") |
| 4 | + var script = SignalTest.new() |
| 5 | + get_tree().root.add_child(script) |
| 6 | + assert_eq(script.is_connected("no_param_signal_delegate", Callable(script.other_script, "hook_no_param")), true, "signal \"no_param_signal_delegate\" should be connected to \"otherScript::hook_no_param\"") |
| 7 | + assert_eq(script.is_connected("one_param_signal_delegate", Callable(script.other_script, "hook_one_param")), true, "signal \"one_param_signal_delegate\" should be connected to \"otherScript::hook_one_param\"") |
| 8 | + assert_eq(script.is_connected("two_param_signal_delegate", Callable(script.other_script, "hook_two_param")), true, "signal \"two_param_signal_delegate\" should be connected to \"otherScript::hook_two_param\"") |
9 | 9 |
|
10 |
| - assert_eq(script.is_connected("no_param_signal_field", Callable(script.other_script, "hook_no_param")), true, "signal \"no_param_signal_field\" should be connected to \"otherScript::hook_no_param\"") |
11 |
| - assert_eq(script.is_connected("one_param_signal_field", Callable(script.other_script, "hook_one_param")), true, "signal \"one_param_signal_field\" should be connected to \"otherScript::hook_one_param\"") |
12 |
| - assert_eq(script.is_connected("two_param_signal_field", Callable(script.other_script, "hook_two_param")), true, "signal \"two_param_signal_field\" should be connected to \"otherScript::hook_two_param\"") |
| 10 | + assert_eq(script.is_connected("no_param_signal_field", Callable(script.other_script, "hook_no_param")), true, "signal \"no_param_signal_field\" should be connected to \"otherScript::hook_no_param\"") |
| 11 | + assert_eq(script.is_connected("one_param_signal_field", Callable(script.other_script, "hook_one_param")), true, "signal \"one_param_signal_field\" should be connected to \"otherScript::hook_one_param\"") |
| 12 | + assert_eq(script.is_connected("two_param_signal_field", Callable(script.other_script, "hook_two_param")), true, "signal \"two_param_signal_field\" should be connected to \"otherScript::hook_two_param\"") |
13 | 13 |
|
14 |
| - script.free() |
| 14 | + script.free() |
15 | 15 |
|
16 | 16 | func test_signal_connection_code():
|
17 |
| - var invocation_script = load("res://Spatial.tscn").instantiate() |
18 |
| - get_tree().root.add_child(invocation_script) |
19 |
| - assert_eq(invocation_script.button.is_connected("pressed", Callable(invocation_script.invocation, "hook_no_param")), true, "signal \"pressed\" of button should be connected to \"invocation_script.invocation::hook_no_param\"") |
20 |
| - invocation_script.free() |
| 17 | + var invocation_script = load("res://Spatial.tscn").instantiate() |
| 18 | + get_tree().root.add_child(invocation_script) |
| 19 | + assert_eq(invocation_script.button.is_connected("pressed", Callable(invocation_script.invocation, "hook_no_param")), true, "signal \"pressed\" of button should be connected to \"invocation_script.invocation::hook_no_param\"") |
| 20 | + invocation_script.free() |
21 | 21 |
|
22 | 22 | func test_signal_emitted_with_multiple_targets():
|
23 |
| - var script = SignalTest.new() |
24 |
| - get_tree().root.add_child(script) |
25 |
| - assert_eq(script.array.size(), 16) |
26 |
| - assert_eq(script.array[0], Vector2(0,0)) |
27 |
| - assert_eq(script.array[1], Vector2(1,1)) |
28 |
| - assert_eq(script.array[2], Vector2(1,2)) |
29 |
| - assert_eq(script.array[3], Vector2(1,3)) |
30 |
| - assert_eq(script.array[4], Vector2(1,4)) |
31 |
| - assert_eq(script.array[5], Vector2(1,5)) |
32 |
| - assert_eq(script.array[6], Vector2(1,6)) |
33 |
| - assert_eq(script.array[7], Vector2(1,7)) |
34 |
| - assert_eq(script.array[8], Vector2(1,7)) |
35 |
| - assert_eq(script.array[9], Vector2(1,6)) |
36 |
| - assert_eq(script.array[10], Vector2(1,5)) |
37 |
| - assert_eq(script.array[11], Vector2(1,4)) |
38 |
| - assert_eq(script.array[12], Vector2(1,3)) |
39 |
| - assert_eq(script.array[13], Vector2(1,2)) |
40 |
| - assert_eq(script.array[14], Vector2(1,1)) |
41 |
| - assert_eq(script.array[15], Vector2(0,0)) |
42 |
| - script.free() |
| 23 | + var script = SignalTest.new() |
| 24 | + get_tree().root.add_child(script) |
| 25 | + assert_eq(script.array.size(), 16) |
| 26 | + assert_eq(script.array[0], Vector2(0,0)) |
| 27 | + assert_eq(script.array[1], Vector2(1,1)) |
| 28 | + assert_eq(script.array[2], Vector2(1,2)) |
| 29 | + assert_eq(script.array[3], Vector2(1,3)) |
| 30 | + assert_eq(script.array[4], Vector2(1,4)) |
| 31 | + assert_eq(script.array[5], Vector2(1,5)) |
| 32 | + assert_eq(script.array[6], Vector2(1,6)) |
| 33 | + assert_eq(script.array[7], Vector2(1,7)) |
| 34 | + assert_eq(script.array[8], Vector2(1,7)) |
| 35 | + assert_eq(script.array[9], Vector2(1,6)) |
| 36 | + assert_eq(script.array[10], Vector2(1,5)) |
| 37 | + assert_eq(script.array[11], Vector2(1,4)) |
| 38 | + assert_eq(script.array[12], Vector2(1,3)) |
| 39 | + assert_eq(script.array[13], Vector2(1,2)) |
| 40 | + assert_eq(script.array[14], Vector2(1,1)) |
| 41 | + assert_eq(script.array[15], Vector2(0,0)) |
| 42 | + script.free() |
0 commit comments