-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./instance"; | ||
export * from "./types"; | ||
export * from "./relation"; | ||
export * from "./utils"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import expect from "expect"; | ||
import fse from "fs-extra"; | ||
import { searchRecursive } from "../src"; | ||
import { Program } from "../src/ast"; | ||
import { parseProgram } from "../src/parser"; | ||
|
||
function ppProg(p: Program): string { | ||
return p.map((n) => n.pp()).join("\n"); | ||
} | ||
|
||
describe(`Parse Round-trip tests`, () => { | ||
for (const dl of searchRecursive("test/samples/", (name) => name.endsWith(".dl"))) { | ||
describe(`Sample ${dl}`, () => { | ||
let contents: string; | ||
let prog: Program; | ||
let output: string; | ||
let reParsedProg: Program; | ||
|
||
beforeAll(() => { | ||
contents = fse.readFileSync(dl, { encoding: "utf-8" }); | ||
}); | ||
|
||
it("Parses correctly", () => { | ||
expect(() => { | ||
prog = parseProgram(contents); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it("Re-parses after outputting correctly", () => { | ||
expect(() => { | ||
output = ppProg(prog); | ||
reParsedProg = parseProgram(output); | ||
}).not.toThrow(); | ||
}); | ||
|
||
it("Produces an equivalent AST to the original", () => { | ||
expect(output).toEqual(ppProg(reParsedProg)); | ||
}); | ||
}); | ||
} | ||
}); |