From 7cc3ef5fa1feec8087618c899441a11052f84c48 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Wed, 28 Feb 2024 14:59:28 -0500 Subject: builtin_match_signatures (#1) Co-authored-by: Lizzy Hunt Reviewed-on: https://git.simponic.xyz/simponic/cps-interpreter/pulls/1 Co-authored-by: Elizabeth Hunt Co-committed-by: Elizabeth Hunt --- test/interpreter.spec.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/interpreter.spec.ts (limited to 'test/interpreter.spec.ts') diff --git a/test/interpreter.spec.ts b/test/interpreter.spec.ts new file mode 100644 index 0000000..fa74ef0 --- /dev/null +++ b/test/interpreter.spec.ts @@ -0,0 +1,35 @@ +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 }); +}); + +test('Add (1 real) and (3 int) -> result => (real 1 - result) = -3 done with correct lexical scope', async () => { + const ast = peggyParse(await TestPrograms.PrimopScope); + + const result = await evaluate(ast, testingLogger); + expect(result).toEqual({ type: 'real', value: -3 }); +}); + +/* +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 }); +}); +*/ -- cgit v1.2.3-70-g09d2