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.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/simulation/actions.test.js b/src/simulation/actions.test.js
index 04111f1..e94605d 100644
--- a/src/simulation/actions.test.js
+++ b/src/simulation/actions.test.js
@@ -6,6 +6,7 @@ import { actions } from './actions.js';
const [
move_forward, move_backward,
turn_left, turn_right,
+ place,
...rest
] = actions;
@@ -114,3 +115,47 @@ test("turn_right", () => {
});
+test("place", () => {
+ 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(place.propose(null, n, [1])).toEqual([
+ { lattice_changes: [
+ {
+ x: 0, y: -1, from: 'empty', to: 'mutable',
+ flags: { emit: [1, 0, 0, 0, 0, 0, 0, 0] }
+ }
+ ]}
+ ]);
+ expect(place.propose(null, s, [1])).toEqual([
+ { lattice_changes: [
+ {
+ x: 0, y: 1, from: 'empty', to: 'mutable',
+ flags: { emit: [1, 0, 0, 0, 0, 0, 0, 0] }
+ }
+ ]}
+ ]);
+ expect(place.propose(null, e, [1])).toEqual([
+ { lattice_changes: [
+ {
+ x: 1, y: 0, from: 'empty', to: 'mutable',
+ flags: { emit: [1, 0, 0, 0, 0, 0, 0, 0] }
+ }
+ ]}
+ ]);
+ expect(place.propose(null, w, [1])).toEqual([
+ { lattice_changes: [
+ {
+ x: -1, y: 0, from: 'empty', to: 'mutable',
+ flags: { emit: [1, 0, 0, 0, 0, 0, 0, 0] }
+ }
+ ]}
+ ]);
+
+ expect(place.propose(null, n, [0])).toEqual([]);
+ expect(place.propose(null, s, [-1])).toEqual([]);
+ expect(place.propose(null, e, [0])).toEqual([]);
+ expect(place.propose(null, w, [-1])).toEqual([]);
+});