import {parse} from "./NomScript.peggy"; import {scriptFile} from "./ScriptFile"; import {versionStatement} from "./TopLevelStatement"; describe("ScriptFile", () => { describe("constructor", () => { test("puts the statements into the list", () => { expect(scriptFile([versionStatement(3)])).toEqual({ statements: [versionStatement(3)] }) }); }); describe("parse", () => { test("works with an empty input", () => { expect(() => parse("", {grammarSource: "testData", startRule: "ScriptFile"})).not.toThrow() }); test("works with empty lines", () => { expect(() => parse("\n\n\n\n\n", {grammarSource: "testData", startRule: "ScriptFile"})).not.toThrow() }); test("works with lines filled only with whitespace", () => { expect(() => parse("\n\n \n\t\t \t\n\n", {grammarSource: "testData", startRule: "ScriptFile"})).not.toThrow() }); test("works with lines filled only with comments", () => { expect(() => parse("\n\n /* */ \n// test \n /* */\n", {grammarSource: "testData", startRule: "ScriptFile"})).not.toThrow() }); }); });