You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.3 KiB
58 lines
1.3 KiB
#[allow(unused_imports)]
|
|
use stackline::prelude::*;
|
|
use stackline::signal;
|
|
mod common;
|
|
|
|
#[test]
|
|
fn test_reader() {
|
|
let mut world = load_test!("tests/storage/reader.json");
|
|
world.init();
|
|
|
|
world.set_signal((0, 0), signal!(Direction::Down, [0]));
|
|
|
|
run!(world, 5);
|
|
assert_stored!(world, 0, 1, signal!([0]));
|
|
assert_no_stored!(world, 2, 0);
|
|
|
|
world.set_signal((1, 2), signal!(Direction::Up, [-1]));
|
|
run!(world, 5);
|
|
assert_stored!(world, 2, 0, signal!([0]));
|
|
|
|
world.set_signal((0, 0), signal!(Direction::Down, [1]));
|
|
|
|
run!(world, 5);
|
|
assert_stored!(world, 0, 1, signal!([1]));
|
|
assert_stored!(world, 2, 0, signal!([0]));
|
|
}
|
|
|
|
#[test]
|
|
fn test_counter() {
|
|
let mut world = load_test!("tests/storage/counter.json");
|
|
world.init();
|
|
|
|
for n in 1..10 {
|
|
world.set_signal((1, 3), signal!(Direction::Up));
|
|
println!("{}", world);
|
|
run!(world, 11);
|
|
assert_stored!(world, 0, 2, signal!([n]));
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_natural() {
|
|
for n in 1..10 {
|
|
let mut world = load_test!("tests/storage/natural.json");
|
|
world.set_signal((0, 5), signal!());
|
|
world.init();
|
|
|
|
run!(world, n * 11 + 6);
|
|
|
|
let mut signal = signal!();
|
|
for x in 0..n {
|
|
signal.push(Value::Number(x.into()));
|
|
}
|
|
|
|
assert_stored!(world, 3, 4, signal);
|
|
}
|
|
}
|