|
|
@ -18,18 +18,9 @@ describe("validate", () => {
|
|
|
|
const input = fs.readFileSync(filename, "utf-8").replace(/\s+$/, "");
|
|
|
|
const input = fs.readFileSync(filename, "utf-8").replace(/\s+$/, "");
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const errors = [];
|
|
|
|
|
|
|
|
const warnings = [];
|
|
|
|
const warnings = [];
|
|
|
|
|
|
|
|
|
|
|
|
svelte.compile(input, {
|
|
|
|
svelte.compile(input, {
|
|
|
|
onerror(error) {
|
|
|
|
|
|
|
|
errors.push({
|
|
|
|
|
|
|
|
message: error.message,
|
|
|
|
|
|
|
|
pos: error.pos,
|
|
|
|
|
|
|
|
loc: error.loc
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onwarn(warning) {
|
|
|
|
onwarn(warning) {
|
|
|
|
warnings.push({
|
|
|
|
warnings.push({
|
|
|
|
message: warning.message,
|
|
|
|
message: warning.message,
|
|
|
@ -39,16 +30,11 @@ describe("validate", () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const expectedErrors =
|
|
|
|
|
|
|
|
tryToLoadJson(`test/validator/samples/${dir}/errors.json`) || [];
|
|
|
|
|
|
|
|
const expectedWarnings =
|
|
|
|
const expectedWarnings =
|
|
|
|
tryToLoadJson(`test/validator/samples/${dir}/warnings.json`) || [];
|
|
|
|
tryToLoadJson(`test/validator/samples/${dir}/warnings.json`) || [];
|
|
|
|
|
|
|
|
|
|
|
|
assert.deepEqual(errors, expectedErrors);
|
|
|
|
|
|
|
|
assert.deepEqual(warnings, expectedWarnings);
|
|
|
|
assert.deepEqual(warnings, expectedWarnings);
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
if (err.name !== "ParseError") throw err;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const expected = require(`./samples/${dir}/errors.json`)[0];
|
|
|
|
const expected = require(`./samples/${dir}/errors.json`)[0];
|
|
|
|
|
|
|
|
|
|
|
|