mirror of
https://github.com/emkay/parser-6502.git
synced 2024-12-21 15:29:19 +00:00
39 lines
800 B
JavaScript
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'
|
|
})
|
|
})
|