forked from defunkt/ReefVM
24 lines
460 B
TypeScript
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 }
|
|
]
|
|
})
|
|
})
|
|
|