-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add warning when sending non-existing events.
- Loading branch information
Showing
8 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
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
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
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,35 @@ | ||
extends StateChartTestBase | ||
|
||
# Checks that multiple delayed transitions work. | ||
# https://github.com/derkork/godot-statecharts/issues/148 | ||
func test_multiple_delayed_transitions_work(): | ||
var root := compound_state("root") | ||
|
||
var think := atomic_state("think", root) | ||
var explore := atomic_state("explore", root) | ||
var inspect := atomic_state("inspect", root) | ||
|
||
transition(think, explore, "pick_destination") | ||
transition( explore, inspect, "target_reached", "1.0") | ||
transition( explore, think, "", "2.0") | ||
|
||
await finish_setup() | ||
|
||
assert_active(think) | ||
|
||
# when I pick a destination | ||
send_event("pick_destination") | ||
|
||
# then I should be exploring | ||
assert_active(explore) | ||
|
||
# when I now reach the target | ||
await wait_seconds(1.1, "wait for target reached") | ||
send_event("target_reached") | ||
|
||
# then after 1 second I should be inspecting | ||
await wait_seconds(1.1, "wait for inspect") | ||
assert_active(inspect) | ||
|
||
|
||
|
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,26 @@ | ||
extends StateChartTestBase | ||
|
||
# https://github.com/derkork/godot-statecharts/issues/143 | ||
# currently disabled because it doesn't work yet. | ||
func __test_parallel_state_initialization(): | ||
var root := parallel_state("root") | ||
var a := atomic_state("a", root) | ||
var b := compound_state("b", root) | ||
var b1 := atomic_state("b1", b) | ||
var b2 := atomic_state("b2", b) | ||
|
||
transition(b1, b2, "some_event") | ||
a.state_entered.connect(func(): | ||
send_event("some_event") | ||
) | ||
|
||
|
||
await finish_setup() | ||
|
||
# a should be active right now.. | ||
assert_active(a) | ||
|
||
# and b2 should be active | ||
assert_active(b2) | ||
|
||
|
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,22 @@ | ||
extends StateChartTestBase | ||
|
||
func test_warning_on_nonexisting_event(): | ||
var root = compound_state("root") | ||
var a = atomic_state("a", root) | ||
var b = atomic_state("b", root) | ||
transition(a, b, "some_event") | ||
transition(b, a, "some_event") | ||
await finish_setup() | ||
|
||
assert_active(a) | ||
|
||
# when i send the correct event, i move to state b | ||
send_event("some_event") | ||
assert_active(b) | ||
|
||
# when i send a wrong event, nothing happens | ||
send_event("narf") | ||
|
||
assert_active(b) | ||
|
||
|