Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions .github/workflows/gh-pages.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x, 21.x, 22.x, 23.x]
node-version: [20, 22, 23]
platform: [ubuntu-latest]

runs-on: ${{ matrix.platform }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
node-version: 22
registry-url: 'https://registry.npmjs.org'
cache: pnpm
- run: pnpm i -r
Expand Down
11 changes: 0 additions & 11 deletions .npmignore

This file was deleted.

3 changes: 2 additions & 1 deletion lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
* @param {TestPeggyOptions} [opts] Options for processing.
* @returns {Promise<TestCounts>}
*/
export function testPeggy<T>(grammarUrl: URL | string, starts: PeggyTestOptions<T>[], opts?: TestPeggyOptions | undefined): Promise<TestCounts>;
export function testPeggy<T>(grammarUrl: URL | string, starts: PeggyTestOptions<T>[], opts?: TestPeggyOptions): Promise<TestCounts>;
export type TestCounts = {
valid: number;
invalid: number;
total: number;
grammarPath: string;
modifiedPath: string;
};
Expand Down
22 changes: 19 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ok,
throws,
} from "node:assert/strict";
import { SourceNode } from "source-map-generator";
import { SourceNode } from "source-map";
import { fileURLToPath } from "node:url";
import fs from "node:fs/promises";
import path from "node:path";
Expand Down Expand Up @@ -70,7 +70,7 @@ let counter = 0;
* @param {string} text
*/
function format(e, source, text) {
const er = /** @type {import('peggy').parser.SyntaxError} */(e);
const er = /** @type {import('peggy').parser.PeggySyntaxError} */(e);
if (typeof er?.format === "function") {
er.message = er.format([{ source, text }]);
}
Expand Down Expand Up @@ -149,6 +149,10 @@ function checkParserStarts(grammar, starts, modified, counts) {
throw new Error(`Failed in library context: ${source}`);
}

// @ts-expect-error This is for testing.
delete lib.peg$success;
// @ts-expect-error This is for testing.
delete lib.peg$throw;
// @ts-expect-error This is for testing.
delete lib.peg$maxFailExpected;
if (peg$maxFailPos === undefined) {
Expand All @@ -171,6 +175,10 @@ function checkParserStarts(grammar, starts, modified, counts) {
...options,
});

// @ts-expect-error This is for testing.
delete lib.peg$success;
// @ts-expect-error This is for testing.
delete lib.peg$throw;
// @ts-expect-error This is for testing.
delete lib.peg$maxFailExpected;
if (peg$maxFailPos === undefined) {
Expand Down Expand Up @@ -415,11 +423,19 @@ export async function testPeggy(grammarUrl, starts, opts) {
peg$endExpectation(),
peg$otherExpectation('one'),
], "", loc);
peg$padEnd("foo", 2);
const oldMax = peg$maxFailPos;
peg$maxFailPos = Infinity;
peg$fail();
peg$maxFailPos = oldMax;

const {unicode} = RegExp.prototype;
delete RegExp.prototype.unicode;
const u_err = peg$buildStructuredError([
peg$otherExpectation('one'),
peg$anyExpectation(),
], "\u{1F4A9}", loc);
RegExp.prototype.unicode = unicode
peg$getUnicode(Infinity);
})();
//#endregion

Expand Down
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"decription": "Generate better code coverage for Peggy grammars",
"main": "lib/index.js",
"type": "module",
"files": [
"lib/"
],
"keywords": [
"peggy,",
"pegjs,",
Expand All @@ -23,24 +26,24 @@
"url": "https://github.com/peggyjs/coverage/issues"
},
"scripts": {
"build": "peggy --format es test/minimal.peggy && tsc",
"build": "peggy -c peggy.config.js && tsc",
"docs": "typedoc",
"lint": "eslint .",
"test": "c8 node --test test/*.test.js"
},
"dependencies": {
"peggy": "4.2.0",
"source-map-generator": "0.8.0"
"peggy": "5.0.0",
"source-map": "0.7.4"
},
"devDependencies": {
"@peggyjs/eslint-config": "5.0.3",
"@types/node": "22.13.4",
"@peggyjs/eslint-config": "6.0.0",
"@types/node": "22.15.3",
"c8": "10.1.3",
"eslint": "9.20.1",
"typedoc": "0.27.7",
"typescript": "5.7.3"
"eslint": "9.26.0",
"typedoc": "0.28.3",
"typescript": "5.8.3"
},
"packageManager": "pnpm@10.4.0",
"packageManager": "pnpm@10.10.0",
"engines": {
"node": ">=18"
}
Expand Down
8 changes: 8 additions & 0 deletions peggy.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
input: "test/minimal.peggy",
format: "es",
allowedStartRules: [
"foo",
"not_lib",
],
};
Loading