Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317

This commit is contained in:
Josh Matthews 2018-01-04 13:44:24 -05:00
parent aa199307c8
commit 2b6f573eb5
3440 changed files with 109438 additions and 41750 deletions

View file

@ -1,42 +1,40 @@
// NOTES:
// - the errors actually still need to be reviewed to check that they
// are fully correct interpretations of the IDLs
var wp = process.env.JSCOV ? require("../lib-cov/webidl2") : require("../lib/webidl2")
, expect = require("expect")
, pth = require("path")
, fs = require("fs")
;
describe("Parses all of the invalid IDLs to check that they blow up correctly", function () {
var dir = pth.join(__dirname, "invalid/idl")
, skip = {}
, idls = fs.readdirSync(dir)
.filter(function (it) { return (/\.w?idl$/).test(it) && !skip[it]; })
.map(function (it) { return pth.join(dir, it); })
, errors = idls.map(function (it) { return pth.join(__dirname, "invalid", "json", pth.basename(it).replace(/\.w?idl/, ".json")); })
;
"use strict";
for (var i = 0, n = idls.length; i < n; i++) {
var idl = idls[i], error = JSON.parse(fs.readFileSync(errors[i], "utf8"));
var func = (function (idl, err) {
return function () {
var error;
try {
var ast = wp.parse(fs.readFileSync(idl, "utf8"));
console.log(JSON.stringify(ast, null, 4));
}
catch (e) {
error = e;
}
finally {
expect(error).toExist();
expect(error.message).toEqual(err.message);
expect(error.line).toEqual(err.line);
}
const wp = require("../lib/webidl2");
const expect = require("expect");
const pth = require("path");
const fs = require("fs");
};
}(idl, error));
it("should produce the right error for " + idl, func);
}
describe("Parses all of the invalid IDLs to check that they blow up correctly", () => {
const dir = pth.join(__dirname, "invalid/idl");
const skip = {};
const idls = fs.readdirSync(dir)
.filter(it => (/\.w?idl$/).test(it) && !skip[it])
.map(it => pth.join(dir, it));
const errors = idls.map(it => pth.join(__dirname, "invalid", "json", pth.basename(it).replace(/\.w?idl/, ".json")));
for (let i = 0, n = idls.length; i < n; i++) {
const idl = idls[i];
const err = JSON.parse(fs.readFileSync(errors[i], "utf8"));
it(`should produce the right error for ${idl}`, () => {
let error;
try {
var ast = wp.parse(fs.readFileSync(idl, "utf8"));
console.log(JSON.stringify(ast, null, 4));
}
catch (e) {
error = e;
}
finally {
expect(error).toBeTruthy();
expect(error.message).toEqual(err.message);
expect(error.line).toEqual(err.line);
}
});
}
});