1
0
mirror of https://github.com/emkay/parser-6502.git synced 2024-06-02 07:41:46 +00:00
parser-6502/test/instruction.js

33 lines
730 B
JavaScript
Raw Normal View History

2016-10-02 21:54:14 +00:00
const tap = require('tap')
const mona = require('mona')
const instructionParser = require('../parsers/instruction')
tap.test('will parse an instruction', (t) => {
t.plan(1)
2016-10-07 22:54:31 +00:00
t.deepEqual(mona.parse(instructionParser(), 'sei\n'), {
2016-10-02 21:54:14 +00:00
args: null,
instruction: 'sei'
})
})
tap.test('will parse an instruction with args', (t) => {
t.plan(1)
2016-10-07 22:54:31 +00:00
t.deepEqual(mona.parse(instructionParser(), 'stx $2000\n'), {
2016-10-07 17:45:55 +00:00
args: [
[
'address',
'2000'
]
],
2016-10-02 21:54:14 +00:00
instruction: 'stx'
})
})
tap.test('will parse an instruction with multiple args', (t) => {
t.plan(1)
2016-10-07 22:54:31 +00:00
t.deepEqual(mona.parse(instructionParser(), 'lda background3, x\n'), {
2016-10-02 21:54:14 +00:00
args: ['background3', 'x'],
instruction: 'lda'
})
})