diff --git a/.gitignore b/.gitignore index 69627a2..b9b8530 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ dist-ssr .bsb.lock **/*.res.mjs src/*.mjs +tests/*.mjs diff --git a/tests/SExpTest.mjs b/tests/SExpTest.mjs deleted file mode 100644 index d804ce0..0000000 --- a/tests/SExpTest.mjs +++ /dev/null @@ -1,108 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as SExp from "../src/SExp.mjs"; -import * as Zora from "zora"; -import * as TestUtil from "./TestUtil.mjs"; - -var Util = TestUtil.MakeTerm(SExp); - -Zora.test("parse symbol", (function (t) { - t.test("single char", (function (t) { - Util.testParse(t, "x", { - TAG: "Symbol", - name: "x" - }, undefined); - })); - t.test("multi char", (function (t) { - Util.testParse(t, "xyz", { - TAG: "Symbol", - name: "xyz" - }, undefined); - })); - })); - -Zora.test("parse var", (function (t) { - t.test("single digit", (function (t) { - Util.testParse(t, "\\1", { - TAG: "Var", - idx: 1 - }, undefined); - })); - t.test("multi digit", (function (t) { - Util.testParse(t, "\\234", { - TAG: "Var", - idx: 234 - }, undefined); - })); - })); - -Zora.test("parse schematic", (function (t) { - t.test("empty allowed", (function (t) { - Util.testParse(t, "?1()", { - TAG: "Schematic", - schematic: 1, - allowed: [] - }, undefined); - })); - t.test("one allowed", (function (t) { - Util.testParse(t, "?1(\\1)", { - TAG: "Schematic", - schematic: 1, - allowed: [1] - }, undefined); - })); - t.test("multiple allowed", (function (t) { - Util.testParse(t, "?1(\\1 \\23 \\4)", { - TAG: "Schematic", - schematic: 1, - allowed: [ - 1, - 2, - 4 - ] - }, undefined); - })); - })); - -Zora.test("parse compound", (function (t) { - t.test("unit", (function (t) { - Util.testParse(t, "()", { - TAG: "Compound", - subexps: [] - }, undefined); - })); - t.test("single", (function (t) { - Util.testParse(t, "(a)", { - TAG: "Compound", - subexps: [{ - TAG: "Symbol", - name: "a" - }] - }, undefined); - })); - t.test("multiple", (function (t) { - Util.testParse(t, "(a \\1 ?1())", { - TAG: "Compound", - subexps: [ - { - TAG: "Symbol", - name: "a" - }, - { - TAG: "Var", - idx: 1 - }, - { - TAG: "Schematic", - schematic: 1, - allowed: [] - } - ] - }, undefined); - })); - })); - -export { - Util , -} -/* Util Not a pure module */ diff --git a/tests/TestUtil.mjs b/tests/TestUtil.mjs deleted file mode 100644 index c9148eb..0000000 --- a/tests/TestUtil.mjs +++ /dev/null @@ -1,34 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Caml_option from "rescript/lib/es6/caml_option.js"; -import * as Core__Option from "@rescript/core/src/Core__Option.mjs"; - -function stringifyExn(t) { - return Core__Option.getExn(JSON.stringify(t, undefined, 2), undefined); -} - -function MakeTerm(Term) { - var termEquivalent = function (t, t1, t2, msg) { - t.ok(Term.equivalent(t1, t2), Core__Option.getOr(msg, stringifyExn(t1) + " equivalent to " + stringifyExn(t2))); - }; - var testParse = function (t, input, t2, msg) { - var res = Term.parse(input, [], Caml_option.some(Term.makeGen())); - if (res.TAG === "Ok") { - var res$1 = res._0; - t.equal(res$1[1], "", input + " input consumed"); - t.equal(res$1[0], t2, msg !== undefined ? Caml_option.valFromOption(msg) : undefined); - return ; - } - t.fail("parse failed: " + res._0); - }; - return { - termEquivalent: termEquivalent, - testParse: testParse - }; -} - -export { - stringifyExn , - MakeTerm , -} -/* No side effect */