diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-02-28 14:59:28 -0500 |
---|---|---|
committer | simponic <elizabeth.hunt@simponic.xyz> | 2024-02-28 14:59:28 -0500 |
commit | 7cc3ef5fa1feec8087618c899441a11052f84c48 (patch) | |
tree | 6d65d585fcf61e9cee7193dfb2af4d719074f732 /test/interpreter.spec.ts | |
parent | c8336ee48791f00378a35e463e2962f4c856beb2 (diff) | |
download | cps-interpreter-7cc3ef5fa1feec8087618c899441a11052f84c48.tar.gz cps-interpreter-7cc3ef5fa1feec8087618c899441a11052f84c48.zip |
builtin_match_signatures (#1)
Co-authored-by: Lizzy Hunt <lizzy.hunt@usu.edu>
Reviewed-on: https://git.simponic.xyz/simponic/cps-interpreter/pulls/1
Co-authored-by: Elizabeth Hunt <elizabeth.hunt@simponic.xyz>
Co-committed-by: Elizabeth Hunt <elizabeth.hunt@simponic.xyz>
Diffstat (limited to 'test/interpreter.spec.ts')
-rw-r--r-- | test/interpreter.spec.ts | 35 |
1 files changed, 35 insertions, 0 deletions
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 }); +}); +*/ |