cps-interpreter/test/interpreter.spec.ts

29 lines
869 B
TypeScript
Raw Normal View History

2024-02-26 19:58:53 -05:00
import { expect, test } from 'bun:test';
import { TestPrograms } from './programs';
import { peggyParse } from '@/parser';
import { evaluate } from '@/interpreter';
import { testingLogger } from './logger';
test('Add (1 real) and (3 int) => (4 real)', async () => {
const ast = peggyParse(await TestPrograms.AddOneThree);
const result = await evaluate(ast, testingLogger);
expect(result).toEqual({ type: 'real', value: 4 });
});
2024-02-28 12:52:40 -05:00
/*
test('String equality', async () => {
const ast = peggyParse(await TestPrograms.StringEquality);
const result = await evaluate(ast, testingLogger);
expect(result).toEqual({ type: 'int', value: 1 });
});
test('String inequality', async () => {
const ast = peggyParse(await TestPrograms.StringInEquality);
const result = await evaluate(ast, testingLogger);
expect(result).toEqual({ type: 'int', value: 0 });
});
*/