Skip to content

Commit a565094

Browse files
test(2019-day-02): specs for running an IntCode program
1 parent eac56a6 commit a565094

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

2019/day-02/intcodeParser.test.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env mocha */
22
const expect = require('chai').expect
3-
const { step } = require('./intcodeParser')
3+
const { step, runProgram } = require('./intcodeParser')
44

55
describe('--- 2019 Day 2: 1202 Program Alarm ---', () => {
66
describe('Part 1', () => {
@@ -26,5 +26,25 @@ describe('--- 2019 Day 2: 1202 Program Alarm ---', () => {
2626
})
2727
})
2828
})
29+
describe('runProgram()', () => {
30+
it('runs through sequential steps of an intCode program', () => {
31+
const testInputs = [
32+
[1, 0, 0, 0, 99],
33+
[2, 3, 0, 3, 99],
34+
[2, 4, 4, 5, 99, 0],
35+
[1, 1, 1, 4, 99, 5, 6, 0, 99]
36+
]
37+
const testOutputs = [
38+
[2, 0, 0, 0, 99],
39+
[2, 3, 0, 6, 99],
40+
[2, 4, 4, 5, 99, 9801],
41+
[30, 1, 1, 4, 2, 5, 6, 0, 99]
42+
]
43+
testInputs.forEach((data, idx) => {
44+
runProgram(data)
45+
expect(data).to.deep.equal(testOutputs[idx])
46+
})
47+
})
48+
})
2949
})
3050
})

0 commit comments

Comments
 (0)