diff options
author | sanine <sanine.not@pm.me> | 2023-11-10 20:05:18 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-11-10 20:05:18 -0600 |
commit | 2160d6cf566df60a4a2b190965152cd8d5cb5fad (patch) | |
tree | 1c2adcf281f90d6d1b3e0dcb13865059f23742cd /src/simulation/actions.test.js | |
parent | 984f07a24d3d377c13358fc5533c0eda383858f5 (diff) |
add place action
Diffstat (limited to 'src/simulation/actions.test.js')
-rw-r--r-- | src/simulation/actions.test.js | 45 |
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([]); +}); |