ReefVM/tests/bytecode.test.ts
2025-10-05 13:43:13 -07:00

24 lines
460 B
TypeScript

import { test, expect } from "bun:test"
import { toBytecode } from "#bytecode"
import { OpCode } from "#opcode"
test("string compilation", () => {
const str = `
PUSH 1
PUSH 5
ADD
`
expect(toBytecode(str)).toEqual({
instructions: [
{ op: OpCode.PUSH, operand: 0 },
{ op: OpCode.PUSH, operand: 1 },
{ op: OpCode.ADD },
],
constants: [
{ type: 'number', value: 1 },
{ type: 'number', value: 5 }
]
})
})