1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2026-03-11 13:41:43 +00:00
Files
8bitworkshop/test/parsers/testparser6502.js
2026-02-16 23:20:43 -08:00

41 lines
1.2 KiB
JavaScript

const assert = require('assert');
const { EditorState } = require("@codemirror/state");
const { syntaxTree } = require("@codemirror/language");
const { asm6502 } = require("../../gen/parser/lang-6502.js");
describe('6502 Parser', function () {
it('Should parse basic instructions', function () {
const code = `
lda #$00
sta $1234
rts
`;
// Create an editor state with the new parser
const state = EditorState.create({
doc: code,
extensions: [asm6502()]
});
// Check if the tree is available (basic check that parser didn't crash)
// In a real environment we might traverse the tree to check specific nodes
// but here we just want to ensure it instantiates and runs without throwing.
assert.ok(syntaxTree(state), "Syntax tree should be generated");
});
it('Should handle labels', function () {
const code = `
start:
jmp start
`;
const state = EditorState.create({
doc: code,
extensions: [asm6502()]
});
assert.ok(syntaxTree(state), "Syntax tree should be generated");
});
});