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.
35 lines
698 B
35 lines
698 B
2 years ago
|
#[allow(unused_imports)]
|
||
|
use stackline::prelude::*;
|
||
|
use stackline::signal;
|
||
|
mod common;
|
||
|
|
||
|
#[test]
|
||
|
fn test_prime() {
|
||
|
let mut world = load_test!("tests/other/prime.json");
|
||
|
world.set_signal((4, 0), signal!());
|
||
|
world.init();
|
||
|
|
||
|
run!(world, 500);
|
||
|
|
||
|
assert_stored!(world, 1, 3, signal!([2, 3, 5, 7, 11, 13, 17, 19]));
|
||
|
|
||
|
run!(world, 1500);
|
||
|
|
||
|
let mut signal = signal!([2]);
|
||
|
|
||
|
for n in 3..=53 {
|
||
|
let mut prime = true;
|
||
|
for f in 2..n {
|
||
|
if n % f == 0 {
|
||
|
prime = false;
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
if prime {
|
||
|
signal.push(Value::Number(n.into()));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
assert_stored!(world, 1, 3, signal);
|
||
|
}
|