diff --git a/jest.config.js b/jest.config.js index 1f57e312..1db05826 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,7 +2,12 @@ module.exports = { "collectCoverage": true, - "coverageReporters": ["lcov"], + "coverageReporters": ["lcov", "text"], + "coveragePathIgnorePatterns": [ + "/node_modules/", + "/lib/parser.js", + "/test", + ], "roots": [ "/test", ], diff --git a/lib/compiler/asts.js b/lib/compiler/asts.js index 47753cff..73b0ba6f 100644 --- a/lib/compiler/asts.js +++ b/lib/compiler/asts.js @@ -21,6 +21,8 @@ const asts = { } } + // istanbul ignore next Presence of rules checked using another approach that not involve this function + // Any time when it is called the rules always exist return -1; }, diff --git a/lib/compiler/passes/generate-js.js b/lib/compiler/passes/generate-js.js index 570eb07f..0cb6ba02 100644 --- a/lib/compiler/passes/generate-js.js +++ b/lib/compiler/passes/generate-js.js @@ -134,6 +134,7 @@ function generateJS(ast, options) { + ")"; } case "any": return "peg$anyExpectation()"; + // istanbul ignore next Because we never generate expectation type we cannot reach this branch default: throw new Error("Unknown expectation type (" + JSON.stringify(e) + ")"); } } @@ -525,6 +526,7 @@ function generateJS(ast, options) { ip++; break; + // istanbul ignore next Because we never generate invalid bytecode we cannot reach this branch default: throw new Error("Invalid opcode: " + bc[ip] + "."); } @@ -594,6 +596,7 @@ function generateJS(ast, options) { "", "function peg$SyntaxError(message, expected, found, location) {", " var self = Error.call(this, message);", + " // istanbul ignore next Check is a necessary evil to support older environments", " if (Object.setPrototypeOf) {", " Object.setPrototypeOf(self, peg$SyntaxError.prototype);", " }", diff --git a/lib/grammar-error.js b/lib/grammar-error.js index 06717644..c400d7b6 100644 --- a/lib/grammar-error.js +++ b/lib/grammar-error.js @@ -2,6 +2,7 @@ // See: https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work // This is roughly what typescript generates, it's not called after super(), where it's needed. +// istanbul ignore next This is a special black magic that cannot be covered everywhere const setProtoOf = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function(d, b) { diff --git a/lib/parser.js b/lib/parser.js index 8c46ab7f..99cce8b7 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -30,6 +30,7 @@ function peg$subclass(child, parent) { function peg$SyntaxError(message, expected, found, location) { var self = Error.call(this, message); + // istanbul ignore next Check is a necessary evil to support older environments if (Object.setPrototypeOf) { Object.setPrototypeOf(self, peg$SyntaxError.prototype); } diff --git a/test/cli/run.spec.ts b/test/cli/run.spec.ts index b116224c..87e97c7b 100644 --- a/test/cli/run.spec.ts +++ b/test/cli/run.spec.ts @@ -184,12 +184,12 @@ Options: -h, --help display help for command `; - await expect(await exec({ + await expect(exec({ args: ["-h"], - })).toBe(HELP); - await expect(await exec({ + })).resolves.toBe(HELP); + await expect(exec({ args: ["--help"], - })).toBe(HELP); + })).resolves.toBe(HELP); }); it("rejects invalid options", async() => { diff --git a/test/unit/compiler.spec.js b/test/unit/compiler.spec.js index 2bf29fb9..7b487bdb 100644 --- a/test/unit/compiler.spec.js +++ b/test/unit/compiler.spec.js @@ -21,7 +21,7 @@ describe("Peggy compiler", () => { })).to.throw('Unknown start rule "bar"'); }); - it("checks ouput type", () => { + it("checks output type", () => { const ast = parser.parse("foo='1'"); expect(compiler.compile(ast, compiler.passes, { output: "source",