1
0
mirror of https://github.com/emkay/parser-6502.git synced 2024-12-30 12:31:29 +00:00
parser-6502/test/instruction.js
Michael Matuzak e8ca1f9bcd yep
2016-10-11 17:59:26 -07:00

39 lines
800 B
JavaScript

const tap = require('tap')
const mona = require('mona')
const instructionParser = require('../parsers/instruction')
tap.test('will parse an instruction', (t) => {
t.plan(1)
t.deepEqual(mona.parse(instructionParser(), 'sei\n'), {
args: null,
instruction: 'sei'
})
})
tap.test('will parse an instruction with args', (t) => {
t.plan(1)
t.deepEqual(mona.parse(instructionParser(), 'stx $2000\n'), {
args: [
{
'address': '2000'
}
],
instruction: 'stx'
})
})
tap.test('will parse an instruction with multiple args', (t) => {
t.plan(1)
t.deepEqual(mona.parse(instructionParser(), 'lda background3, x\n'), {
args: [
{
'alphanum': 'background3'
},
{
'alphanum': 'x'
}
],
instruction: 'lda'
})
})