Panik-Test ohne globalen Hook, begrenzte Gast-Schleifen
Der Test einer Panik im Kern tauscht den globalen Panik-Hook nicht mehr aus. Das war unnötig, weil der Testläufer die Meldung einer erwarteten Panik ohnehin zurückhält, und es konnte Meldungen anderer, gleichzeitig scheiternder Tests verschlucken. Die Gast-Schleifen in den GDScript-Tests der Brücke laufen höchstens so oft, wie Takte warten, damit ein abgewichener Gast den Testlauf nicht anhält. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user