aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/resources/webidl2/test/syntax.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/wpt/web-platform-tests/resources/webidl2/test/syntax.js')
-rw-r--r--tests/wpt/web-platform-tests/resources/webidl2/test/syntax.js28
1 files changed, 4 insertions, 24 deletions
diff --git a/tests/wpt/web-platform-tests/resources/webidl2/test/syntax.js b/tests/wpt/web-platform-tests/resources/webidl2/test/syntax.js
index 0838f350cd9..05d647eda10 100644
--- a/tests/wpt/web-platform-tests/resources/webidl2/test/syntax.js
+++ b/tests/wpt/web-platform-tests/resources/webidl2/test/syntax.js
@@ -1,34 +1,14 @@
"use strict";
-const wp = require("../lib/webidl2");
+const { collect } = require("./util/collect");
const expect = require("expect");
-const pth = require("path");
-const fs = require("fs");
-const jdp = require("jsondiffpatch");
const debug = true;
describe("Parses all of the IDLs to produce the correct ASTs", () => {
- const dir = pth.join(__dirname, "syntax/idl");
- const skip = {}; // use if we have a broken test
- const idls = fs.readdirSync(dir)
- .filter(it => (/\.widl$/).test(it) && !skip[it])
- .map(it => pth.join(dir, it));
- const jsons = idls.map(it => pth.join(__dirname, "syntax/json", pth.basename(it).replace(".widl", ".json")));
-
- for (let i = 0, n = idls.length; i < n; i++) {
- const idl = idls[i];
- const json = jsons[i];
-
- it(`should produce the same AST for ${idl}`, () => {
+ for (const test of collect("syntax")) {
+ it(`should produce the same AST for ${test.path}`, () => {
try {
- const optFile = pth.join(__dirname, "syntax/opt", pth.basename(json));
- let opt = undefined;
- if (fs.existsSync(optFile))
- opt = JSON.parse(fs.readFileSync(optFile, "utf8"));
- const diff = jdp.diff(JSON.parse(fs.readFileSync(json, "utf8")),
- wp.parse(fs.readFileSync(idl, "utf8").replace(/\r\n/g, "\n"), opt));
- if (diff && debug) console.log(JSON.stringify(diff, null, 4));
- expect(diff).toBe(undefined);
+ expect(test.diff()).toBeFalsy();
}
catch (e) {
console.log(e.toString());