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

109 lines
2.1 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)
2016-10-12 00:01:15 +00:00
t.deepEqual(mona.parse(directiveParser(), '.inesprg 1\n'), {
2016-10-02 21:54:14 +00:00
args: [
2016-10-11 04:08:37 +00:00
{
2016-10-12 23:41:28 +00:00
'digit': '1'
2016-10-11 04:08:37 +00:00
}
2016-10-02 21:54:14 +00:00
],
directive: '.inesprg'
})
})
tap.test('will parse a directive with direct address', (t) => {
t.plan(1)
2016-10-12 00:01:15 +00:00
t.deepEqual(mona.parse(directiveParser(), '.inesprg $0000\n'), {
2016-10-02 21:54:14 +00:00
args: [
2016-10-11 04:08:37 +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)
2016-10-12 00:01:15 +00:00
t.deepEqual(mona.parse(directiveParser(), '.inesprg #$FE\n'), {
2016-10-02 21:54:14 +00:00
args: [
2016-10-11 04:08:37 +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)
2016-10-12 00:01:15 +00:00
t.deepEqual(mona.parse(directiveParser(), '.db %00010001\n'), {
2016-10-02 21:54:14 +00:00
args: [
2016-10-11 04:08:37 +00:00
{
'binary': '00010001'
}
2016-10-02 21:54:14 +00:00
],
directive: '.db'
})
2016-10-12 00:01:15 +00:00
t.deepEqual(mona.parse(directiveParser(), '.db #%00010001\n'), {
2016-10-02 21:54:14 +00:00
args: [
2016-10-11 04:08:37 +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-12 00:01:15 +00:00
t.deepEqual(mona.parse(directiveParser(), '.db %00010001,%00010001,%00010001\n'), {
2016-10-02 21:54:14 +00:00
args: [
2016-10-11 04:08:37 +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-12 00:01:15 +00:00
t.deepEqual(mona.parse(directiveParser(), '.db %00010001, %00010001, %00010001\n'), {
2016-10-02 21:54:14 +00:00
args: [
2016-10-11 04:08:37 +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)
2016-10-12 00:01:15 +00:00
t.deepEqual(mona.parse(directiveParser(), '.incbin "mario.chr"\n'), {
2016-10-02 21:54:14 +00:00
args: [
2016-10-11 04:08:37 +00:00
{
'string': 'mario.chr'
}
2016-10-02 21:54:14 +00:00
],
directive: '.incbin'
})
})