From 2160d6cf566df60a4a2b190965152cd8d5cb5fad Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 10 Nov 2023 20:05:18 -0600 Subject: add place action --- src/simulation/actions.test.js | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/simulation/actions.test.js') 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([]); +}); -- cgit v1.2.1