parser-6502/test/instruction.js

39 lines
800 B
JavaScript
Raw Permalink 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-12 00:59:26 +00:00
args: null,
2016-10-02 21:54:14 +00:00
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: [
2016-10-12 00:01:15 +00:00
{
'address': '2000'
}
2016-10-07 17:45:55 +00:00
],
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-12 00:01:15 +00:00
args: [
{
'alphanum': 'background3'
},
{
'alphanum': 'x'
}
],
2016-10-02 21:54:14 +00:00
instruction: 'lda'
})
})