summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/interpreter.spec.ts13
-rw-r--r--test/programs/application.cps1
-rw-r--r--test/programs/index.ts13
-rw-r--r--test/programs/string-equal.cps2
-rw-r--r--test/programs/string-unequal.cps2
5 files changed, 20 insertions, 11 deletions
diff --git a/test/interpreter.spec.ts b/test/interpreter.spec.ts
index 49b741e..6d3189a 100644
--- a/test/interpreter.spec.ts
+++ b/test/interpreter.spec.ts
@@ -25,18 +25,23 @@ test('Branching', async () => {
expect(result).toEqual({ type: 'real', value: 2 });
});
-/*
test('String equality', async () => {
const ast = peggyParse(await TestPrograms.StringEquality);
const result = await evaluate(ast, testingLogger);
- expect(result).toEqual({ type: 'int', value: 1 });
+ expect(result).toEqual({ type: 'bool', 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 });
+ expect(result).toEqual({ type: 'bool', value: 0 });
+});
+
+test('Application of identity function', async () => {
+ const ast = peggyParse(await TestPrograms.Application);
+
+ const result = await evaluate(ast, testingLogger);
+ expect(result).toEqual({ type: 'int', value: 3 });
});
-*/
diff --git a/test/programs/application.cps b/test/programs/application.cps
new file mode 100644
index 0000000..169329e
--- /dev/null
+++ b/test/programs/application.cps
@@ -0,0 +1 @@
+PRIMOP(+, [INT 1, INT 2], [result], [APP(LABEL id, [VAR result])]) \ No newline at end of file
diff --git a/test/programs/index.ts b/test/programs/index.ts
index 864169f..fae3b59 100644
--- a/test/programs/index.ts
+++ b/test/programs/index.ts
@@ -2,18 +2,21 @@ import { join } from 'path';
export namespace TestPrograms {
export const AddOneThree = Bun.file(
- join(import.meta.dir + '/add-1-3.cps'),
+ join(import.meta.dir, 'add-1-3.cps'),
).text();
export const PrimopScope = Bun.file(
- join(import.meta.dir + '/primop-scope.cps'),
+ join(import.meta.dir, 'primop-scope.cps'),
).text();
export const Branching = Bun.file(
- join(import.meta.dir + '/branching.cps'),
+ join(import.meta.dir, 'branching.cps'),
).text();
export const StringEquality = Bun.file(
- join(import.meta.dir + '/string-equal.cps'),
+ join(import.meta.dir, 'string-equal.cps'),
).text();
export const StringInEquality = Bun.file(
- join(import.meta.dir + '/string-unequal.cps'),
+ join(import.meta.dir, 'string-unequal.cps'),
+ ).text();
+ export const Application = Bun.file(
+ join(import.meta.dir, 'application.cps'),
).text();
}
diff --git a/test/programs/string-equal.cps b/test/programs/string-equal.cps
index ea49b22..5a32526 100644
--- a/test/programs/string-equal.cps
+++ b/test/programs/string-equal.cps
@@ -1 +1 @@
-PRIMOP(==, ["asdf", "asdf"], [result], []) \ No newline at end of file
+PRIMOP(==, [STRING "asdf", STRING "asdf"], [result], []) \ No newline at end of file
diff --git a/test/programs/string-unequal.cps b/test/programs/string-unequal.cps
index ccd278e..79ee7cf 100644
--- a/test/programs/string-unequal.cps
+++ b/test/programs/string-unequal.cps
@@ -1 +1 @@
-PRIMOP(==, ["asdfasdf", "asdf"], [result], [])
+PRIMOP(==, [STRING "asdfasdf", STRING "asdf"], [result], [])