import { expect, test } from 'bun:test'; import { TestPrograms } from './programs'; import { peggyParse } from '@/parser'; test('primitive operation', async () => { const [operation] = peggyParse(await TestPrograms.AddOneThree); const { primitiveOperation } = operation; expect(primitiveOperation).toEqual({ opr: '+', operands: [{ real: 1 }, { int: 3 }], resultBindings: [{ name: 'result' }], continuations: [], }); }); test('primitive operation with continuation', async () => { const [operation] = peggyParse(await TestPrograms.PrimopScope); const { primitiveOperation } = operation; const continuation = { primitiveOperation: { opr: '-', operands: [{ real: 1 }, { name: 'result' }], resultBindings: [{ name: 'result' }], continuations: [ { primitiveOperation: { opr: '+', operands: [{ name: 'result' }, { real: 0 }], resultBindings: [], continuations: [], }, }, ], }, }; expect(primitiveOperation).toEqual({ opr: '+', operands: [{ real: 1 }, { int: 3 }], resultBindings: [{ name: 'result' }], continuations: [continuation], }); });