1
0
mirror of https://github.com/emkay/parser-6502.git synced 2024-12-22 06:29:27 +00:00
parser-6502/test/directive.js

122 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-10-02 21:54:14 +00:00
const tap = require('tap')
const mona = require('mona')
const directiveParser = require('../parsers/directive')
tap.test('will parse a directive', (t) => {
t.plan(1)
t.deepEqual(mona.parse(directiveParser(), '.inesprg 1'), {
args: [
2016-10-07 17:45:55 +00:00
[
'digit',
'1'
]
2016-10-02 21:54:14 +00:00
],
directive: '.inesprg'
})
})
tap.test('will parse a directive with direct address', (t) => {
t.plan(1)
t.deepEqual(mona.parse(directiveParser(), '.inesprg $0000'), {
args: [
2016-10-07 17:45:55 +00:00
[
'address',
'0000'
]
2016-10-02 21:54:14 +00:00
],
directive: '.inesprg'
})
})
tap.test('will parse a directive with hex arg', (t) => {
t.plan(1)
t.deepEqual(mona.parse(directiveParser(), '.inesprg #$FE'), {
args: [
2016-10-07 17:45:55 +00:00
[
'hex',
'FE'
]
2016-10-02 21:54:14 +00:00
],
directive: '.inesprg'
})
})
tap.test('will parse a directive with binary arg', (t) => {
t.plan(2)
t.deepEqual(mona.parse(directiveParser(), '.db %00010001'), {
args: [
2016-10-07 17:45:55 +00:00
[
'binary',
'00010001'
]
2016-10-02 21:54:14 +00:00
],
directive: '.db'
})
t.deepEqual(mona.parse(directiveParser(), '.db #%00010001'), {
args: [
2016-10-07 17:45:55 +00:00
[
'binary',
'00010001'
]
2016-10-02 21:54:14 +00:00
],
directive: '.db'
})
})
tap.test('will parse a directive with multiple args', (t) => {
t.plan(1)
2016-10-07 17:45:55 +00:00
t.deepEqual(mona.parse(directiveParser(), '.db %00010001,%00010001,%00010001'), {
2016-10-02 21:54:14 +00:00
args: [
2016-10-07 17:45:55 +00:00
[
'binary',
'00010001'
],
[
'binary',
'00010001'
],
[
'binary',
'00010001'
]
2016-10-02 21:54:14 +00:00
],
directive: '.db'
})
})
tap.test('will parse a directive with multiple args with spaces between them', (t) => {
t.plan(1)
2016-10-07 17:45:55 +00:00
t.deepEqual(mona.parse(directiveParser(), '.db %00010001, %00010001, %00010001'), {
2016-10-02 21:54:14 +00:00
args: [
2016-10-07 17:45:55 +00:00
[
'binary',
'00010001'
],
[
'binary',
'00010001'
],
[
'binary',
'00010001'
]
2016-10-02 21:54:14 +00:00
],
directive: '.db'
})
})
tap.test('will parse a directive with string arg', (t) => {
t.plan(1)
t.deepEqual(mona.parse(directiveParser(), '.incbin "mario.chr"'), {
args: [
2016-10-07 17:45:55 +00:00
[
'string',
'mario.chr'
]
2016-10-02 21:54:14 +00:00
],
directive: '.incbin'
})
})