Skip to content

Commit

Permalink
added compiler test
Browse files Browse the repository at this point in the history
  • Loading branch information
mokawop committed Apr 28, 2024
1 parent 8631c7d commit 8abc42f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
35 changes: 32 additions & 3 deletions test/compiler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,37 @@ describe("Sample Test", () => {
});

// import assert from "node:assert/strict"
// describe("The project setup", () => {
// it("can at least run tests", () => {
// assert.deepEqual(1, 1)
// import compile from "../src/compiler.js"

// const sampleProgram = "print(0);"

// describe("The compiler", () => {
// it("throws when the output type is missing", done => {
// assert.throws(() => compile(sampleProgram), /Unknown output type/)
// done()
// })
// it("throws when the output type is unknown", done => {
// assert.throws(() => compile(sampleProgram, "no such type"), /Unknown output type/)
// done()
// })
// it("accepts the parsed option", done => {
// const compiled = compile(sampleProgram, "parsed")
// assert(compiled.startsWith("Syntax is ok"))
// done()
// })
// it("accepts the analyzed option", done => {
// const compiled = compile(sampleProgram, "analyzed")
// assert(compiled.kind === "Program")
// done()
// })
// it("accepts the optimized option", done => {
// const compiled = compile(sampleProgram, "optimized")
// assert(compiled.kind === "Program")
// done()
// })
// it("generates js code when given the js option", done => {
// const compiled = compile(sampleProgram, "js")
// assert(compiled.startsWith("console.log(0)"))
// done()
// })
// })
2 changes: 1 addition & 1 deletion test/generator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const fixtures = [
source: `
auto a = [true, false, true];
auto b = [10, 20, 30];
c = int[]()
auto c = int[]()
print a[1] b[0];
`,
expected: dedent`
Expand Down

0 comments on commit 8abc42f

Please sign in to comment.