diff --git a/bridge/src/driver.rs b/bridge/src/driver.rs index 2ea095d..7656466 100644 --- a/bridge/src/driver.rs +++ b/bridge/src/driver.rs @@ -229,7 +229,6 @@ impl Driver { #[cfg(test)] mod tests { use super::*; - use std::panic; #[test] fn a_host_saves_and_records_its_world() { @@ -254,12 +253,10 @@ mod tests { #[test] fn a_panic_breaks_the_session_for_good() { - // Keep the expected panic from printing a message into the output. - let previous = panic::take_hook(); - panic::set_hook(Box::new(|_| {})); + // The test harness keeps the message of this expected panic to itself + // and shows it only if the test fails. let mut driver = Driver::host(World::new(1)); let result = driver.guarded(|_| -> u32 { panic!("an internal error") }); - panic::set_hook(previous); assert_eq!(result, None); assert!(driver.is_broken()); diff --git a/game/tests/test_session.gd b/game/tests/test_session.gd index ec44158..c727b23 100644 --- a/game/tests/test_session.gd +++ b/game/tests/test_session.gd @@ -172,7 +172,7 @@ func _host_and_guest() -> Array[GwSession]: _carry(host, guest) host.step() _carry(host, guest) - while guest.pending_ticks() > 0: + for i in guest.pending_ticks(): guest.step() return [host, guest] @@ -191,7 +191,7 @@ func test_a_guest_follows_its_host_through_the_bridge() -> void: host.step() _carry(host, guest) check_eq(guest.pending_ticks(), 25, "the ticks wait until the guest runs them") - while guest.pending_ticks() > 0: + for i in guest.pending_ticks(): guest.step() check_eq(guest.state_hash_hex(), host.state_hash_hex(), "both worlds are the same") check_eq(guest.local_player(), 1, "the guest is player 1") @@ -213,7 +213,7 @@ func test_the_hit_of_a_guest_becomes_a_message_to_the_host() -> void: host.step() _carry(host, guest) var events: Array[Dictionary] = [] - while guest.pending_ticks() > 0: + for i in guest.pending_ticks(): events.append_array(guest.step()) check_eq(events.map(func(event: Dictionary) -> String: return event["type"]), ["tile_hit"], "the guest sees its hit") check_eq(host.damage_codes()[rock.y * host.map_width() + rock.x], 1, "and so does the host")