summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLizzy Hunt <lizzy.hunt@usu.edu>2024-03-05 14:49:46 -0700
committerLizzy Hunt <lizzy.hunt@usu.edu>2024-03-05 14:56:17 -0700
commit5e9a34e64254000b9922d69697774c430cdeca36 (patch)
treece6c14e7ff698c668d209282720a66e6af1674d0 /test
parent2f77b3fb5a102224c83db2f1fa093c278db716e5 (diff)
downloadcps-interpreter-5e9a34e64254000b9922d69697774c430cdeca36.tar.gz
cps-interpreter-5e9a34e64254000b9922d69697774c430cdeca36.zip
fix parsing of RecordExpressions
Diffstat (limited to 'test')
-rw-r--r--test/interpreter.spec.ts7
-rw-r--r--test/programs/index.ts3
-rw-r--r--test/programs/record.cps7
3 files changed, 17 insertions, 0 deletions
diff --git a/test/interpreter.spec.ts b/test/interpreter.spec.ts
index 6d3189a..acca7bb 100644
--- a/test/interpreter.spec.ts
+++ b/test/interpreter.spec.ts
@@ -45,3 +45,10 @@ test('Application of identity function', async () => {
const result = await evaluate(ast, testingLogger);
expect(result).toEqual({ type: 'int', value: 3 });
});
+
+test('Record construction', async () => {
+ const ast = peggyParse(await TestPrograms.RecordConstruction);
+
+ const result = await evaluate(ast, testingLogger);
+ expect(result).toEqual({ type: 'int', value: 3 });
+});
diff --git a/test/programs/index.ts b/test/programs/index.ts
index fae3b59..71ae303 100644
--- a/test/programs/index.ts
+++ b/test/programs/index.ts
@@ -19,4 +19,7 @@ export namespace TestPrograms {
export const Application = Bun.file(
join(import.meta.dir, 'application.cps'),
).text();
+ export const RecordConstruction = Bun.file(
+ join(import.meta.dir, 'record.cps'),
+ ).text();
}
diff --git a/test/programs/record.cps b/test/programs/record.cps
new file mode 100644
index 0000000..fe82668
--- /dev/null
+++ b/test/programs/record.cps
@@ -0,0 +1,7 @@
+RECORD([(INT 1, OFFp 0), (INT 2, OFFp 0)], record,
+ SELECT(0, VAR one, record,
+ SELECT(1, VAR two, record,
+ PRIMOP(+, [VAR one, VAR two], [result], [])
+ )
+ )
+) \ No newline at end of file