Skip to content

Commit 45d80d2

Browse files
tests: add test for 1t pulse gen using comparator
1 parent c7b0960 commit 45d80d2

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

tests/timings.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
mod common;
22
use common::*;
33

4-
use mchprs_blocks::{blocks::ComparatorMode, BlockDirection};
4+
use mchprs_blocks::blocks::{Block, ComparatorMode};
5+
use mchprs_blocks::BlockDirection;
56

67
test_all_backends!(repeater_t_flip_flop);
78
fn repeater_t_flip_flop(backend: TestBackend) {
@@ -75,4 +76,33 @@ fn pulse_gen_2t(backend: TestBackend) {
7576
}
7677

7778
test_all_backends!(pulse_gen_1t);
78-
fn pulse_gen_1t(backend: TestBackend) {}
79+
fn pulse_gen_1t(backend: TestBackend) {
80+
let output_pos = pos(5, 1, 1);
81+
let lever_pos = pos(0, 1, 1);
82+
83+
let mut world = TestWorld::new(1);
84+
85+
make_wire(&mut world, pos(1, 1, 0));
86+
make_repeater(&mut world, pos(2, 1, 0), 2, BlockDirection::West);
87+
make_wire(&mut world, pos(3, 1, 0));
88+
make_wire(&mut world, pos(4, 1, 0));
89+
90+
make_lever(&mut world, lever_pos);
91+
make_wire(&mut world, pos(1, 1, 1));
92+
make_wire(&mut world, pos(2, 1, 1));
93+
make_comparator(
94+
&mut world,
95+
pos(3, 1, 1),
96+
ComparatorMode::Subtract,
97+
BlockDirection::West,
98+
);
99+
place_on_block(&mut world, pos(4, 1, 1), Block::Sandstone {});
100+
place_on_block(&mut world, output_pos, trapdoor());
101+
102+
let mut runner = BackendRunner::new(world, backend);
103+
104+
runner.use_block(lever_pos);
105+
runner.check_powered_for(output_pos, false, 1);
106+
runner.check_powered_for(output_pos, true, 1);
107+
runner.check_powered_for(output_pos, false, 10);
108+
}

0 commit comments

Comments
 (0)