summaryrefslogtreecommitdiff
path: root/src/simulation/actions.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulation/actions.test.js')
-rw-r--r--src/simulation/actions.test.js40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/simulation/actions.test.js b/src/simulation/actions.test.js
index e94605d..1ebe9a9 100644
--- a/src/simulation/actions.test.js
+++ b/src/simulation/actions.test.js
@@ -6,7 +6,7 @@ import { actions } from './actions.js';
const [
move_forward, move_backward,
turn_left, turn_right,
- place,
+ place, trigger,
...rest
] = actions;
@@ -159,3 +159,41 @@ test("place", () => {
expect(place.propose(null, e, [0])).toEqual([]);
expect(place.propose(null, w, [-1])).toEqual([]);
});
+
+
+test("trigger", () => {
+ const n = { id: 0, x: 0, y: 0, flags: { orientation: 'n' } };
+ const s = { id: 0, x: 0, y: 0, flags: { orientation: 's' } };
+ const e = { id: 0, x: 0, y: 0, flags: { orientation: 'e' } };
+ const w = { id: 0, x: 0, y: 0, flags: { orientation: 'w' } };
+
+ expect(trigger.propose(null, n, [1])).toEqual([
+ { lattice_changes: [{
+ x: 0, y: -1, from: 'mutable', to: 'active',
+ flags: { emit: [1, 0, 0, 0, 0, 0, 0, 0] },
+ }]},
+ ]);
+ expect(trigger.propose(null, s, [1])).toEqual([
+ { lattice_changes: [{
+ x: 0, y: 1, from: 'mutable', to: 'active',
+ flags: { emit: [1, 0, 0, 0, 0, 0, 0, 0] },
+ }]},
+ ]);
+ expect(trigger.propose(null, e, [1])).toEqual([
+ { lattice_changes: [{
+ x: 1, y: 0, from: 'mutable', to: 'active',
+ flags: { emit: [1, 0, 0, 0, 0, 0, 0, 0] },
+ }]},
+ ]);
+ expect(trigger.propose(null, w, [1])).toEqual([
+ { lattice_changes: [{
+ x: -1, y: 0, from: 'mutable', to: 'active',
+ flags: { emit: [1, 0, 0, 0, 0, 0, 0, 0] },
+ }]},
+ ]);
+
+ expect(trigger.propose(null, n, [0])).toEqual([]);
+ expect(trigger.propose(null, s, [-1])).toEqual([]);
+ expect(trigger.propose(null, e, [0])).toEqual([]);
+ expect(trigger.propose(null, w, [-1])).toEqual([]);
+ });