add test for the comparator bug fixed earlier, split the other test in two

This commit is contained in:
Crispy 2025-04-04 23:49:32 +02:00
parent 8425e89254
commit 1630cf25c8

View file

@ -1,27 +1,35 @@
use marble_machinations::marble_engine::{grid::Grid, Machine}; use marble_machinations::marble_engine::{grid::Grid, Machine};
fn no_input_test(steps: usize, output: &[u8], grid: &str) {
let mut engine = Machine::new_empty();
engine.set_grid(Grid::from_ascii(grid));
for _ in 0..(steps - 1) {
engine.step();
}
assert_ne!(engine.output(), output, "output arrived early");
engine.step();
assert_eq!(engine.output(), output, "expected output");
}
#[test] #[test]
fn creating_marbles_cause_indirect_claim() { fn creating_marbles_cause_indirect_claim() {
let mut eng = Machine::new_empty(); no_input_test(3, &[1], " o \n|-*-|\n| 1 |\n-B B-\n I\n");
eng.set_grid(Grid::from_ascii( }
"
I #[test]
o 2 fn bug_overlapping_marble_creation_blocks_tile_forever() {
B- o no_input_test(
B | |-*-| 7,
|-+o | | &[1, 2, 3],
*-| |* -B B- " I \no 3 o\n2I B+*\n B |1\n |-+\n*-| I\n\nI\n",
);
1 3 }
#[test]
fn bug_equal_comparator_order_lock() {
no_input_test(
I I 6,
", &[1, 2, 3, 4],
)); "I \n I\n21\n o\nBB|*-++\n|=+ |=-\n |+ BB\n\n 34\n\n I\n I\n",
for _ in 0..9 { );
eng.step();
}
assert_eq!(eng.output(), [1, 2, 3]);
} }