mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update web-platform-tests to revision 4f397167b4ed552a02201c92d363cfaecfe2c7f0
This commit is contained in:
parent
73b5bf201f
commit
84b40513c3
182 changed files with 4779 additions and 1937 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue