Skip to content

Commit 0c12ecd

Browse files
committed
CLDR-18318 test: update kbd abnf test
- work on windows and improve output
1 parent 6a5e512 commit 0c12ecd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tools/scripts/keyboard-abnf-tests/test/datadriven.test.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,24 @@ import * as assert from "node:assert";
99
import { forEachAbnf } from "../lib/util.mjs";
1010
import { getParseFunction } from "../lib/index.mjs";
1111

12+
function sanitize(str) {
13+
return str.replace(/[\s]+/g, (s) =>
14+
[...s].map((s) => {
15+
if (s === '\n') return '\\n';
16+
if (s === '\r') return '\\r';
17+
if (s === ' ') return ' ';
18+
return `\\u{${s.codePointAt(0).toString(16)}}`;
19+
}));
20+
}
21+
1222
async function assertTest({ t, abnfPath, testText, expect }) {
1323
const parser = await getParseFunction(abnfPath);
1424
for (const str of testText
25+
.replaceAll('\r\n', '\n')
1526
.trim()
1627
.split("\n")
1728
.filter((l) => !/^#/.test(l))) {
18-
await t.test(`"${str}"`, async (t) => {
29+
await t.test(`"${sanitize(str)}"`, async (t) => {
1930
if (!expect) {
2031
assert.throws(
2132
() => parser(str),

0 commit comments

Comments
 (0)