426945b480
Please note that these changes were done automatically, using `gulp lint --fix`. Given that the major version number was increased, there's a fair number of (primarily whitespace) changes; please see https://prettier.io/blog/2020/03/21/2.0.0.html In order to reduce the size of these changes somewhat, this patch maintains the old "arrowParens" style for now (once mozilla-central updates Prettier we can simply choose the same formatting, assuming it will differ here).
69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
"use strict";
|
|
|
|
var p2 = require("./preprocessor2.js");
|
|
var fs = require("fs");
|
|
var path = require("path");
|
|
|
|
var errors = 0;
|
|
|
|
var baseDir = path.join(__dirname, "fixtures_esprima");
|
|
var files = fs
|
|
.readdirSync(baseDir)
|
|
.filter(function (name) {
|
|
return /-expected\./.test(name);
|
|
})
|
|
.map(function (name) {
|
|
return path.join(baseDir, name);
|
|
});
|
|
files.forEach(function (expectationFilename) {
|
|
var inFilename = expectationFilename.replace("-expected", "");
|
|
var expectation = fs
|
|
.readFileSync(expectationFilename)
|
|
.toString()
|
|
.trim()
|
|
.replace(/__filename/g, fs.realpathSync(inFilename));
|
|
var input = fs.readFileSync(inFilename).toString();
|
|
|
|
var defines = {
|
|
TRUE: true,
|
|
FALSE: false,
|
|
OBJ: { obj: { i: 1 }, j: 2 },
|
|
TEXT: "text",
|
|
};
|
|
var map = {
|
|
"import-alias": "import-name",
|
|
};
|
|
var ctx = {
|
|
defines: defines,
|
|
map: map,
|
|
rootPath: __dirname + "/../..",
|
|
};
|
|
var out;
|
|
try {
|
|
out = p2.preprocessPDFJSCode(ctx, input);
|
|
} catch (e) {
|
|
out = ("Error: " + e.message).replace(/^/gm, "//");
|
|
}
|
|
if (out !== expectation) {
|
|
errors++;
|
|
|
|
console.log("Assertion failed for " + inFilename);
|
|
console.log("--------------------------------------------------");
|
|
console.log("EXPECTED:");
|
|
console.log(expectation);
|
|
console.log("--------------------------------------------------");
|
|
console.log("ACTUAL");
|
|
console.log(out);
|
|
console.log("--------------------------------------------------");
|
|
console.log();
|
|
}
|
|
});
|
|
|
|
if (errors) {
|
|
console.error("Found " + errors + " expectation failures.");
|
|
process.exit(1);
|
|
} else {
|
|
console.log("All tests completed without errors.");
|
|
process.exit(0);
|
|
}
|