fix top-level directives in compress tests (#1615)
`input` and `expect` are parsed as `AST_BlockStatement` which does not support `AST_Directive` by default. Emulate that by transforming preceding `AST_SimpleStatement`s of `AST_String` into `AST_Directive`.
This commit is contained in:
@@ -49,4 +49,3 @@ mangle_keep_fnames_true: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,29 @@
|
|||||||
do_screw: {
|
do_screw: {
|
||||||
options = { screw_ie8: true };
|
options = {
|
||||||
|
screw_ie8: true,
|
||||||
|
}
|
||||||
beautify = {
|
beautify = {
|
||||||
screw_ie8: true,
|
screw_ie8: true,
|
||||||
ascii_only: true
|
ascii_only: true,
|
||||||
};
|
}
|
||||||
|
input: {
|
||||||
input: f("\v");
|
f("\v");
|
||||||
expect_exact: 'f("\\v");';
|
}
|
||||||
|
expect_exact: 'f("\\v");'
|
||||||
}
|
}
|
||||||
|
|
||||||
dont_screw: {
|
dont_screw: {
|
||||||
options = { screw_ie8: false };
|
options = {
|
||||||
beautify = { screw_ie8: false, ascii_only: true };
|
screw_ie8: false,
|
||||||
|
}
|
||||||
input: f("\v");
|
beautify = {
|
||||||
expect_exact: 'f("\\x0B");';
|
screw_ie8: false,
|
||||||
|
ascii_only: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
f("\v");
|
||||||
|
}
|
||||||
|
expect_exact: 'f("\\x0B");'
|
||||||
}
|
}
|
||||||
|
|
||||||
do_screw_constants: {
|
do_screw_constants: {
|
||||||
|
|||||||
@@ -72,10 +72,15 @@ function test_directory(dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function as_toplevel(input, mangle_options) {
|
function as_toplevel(input, mangle_options) {
|
||||||
if (input instanceof U.AST_BlockStatement) input = input.body;
|
if (!(input instanceof U.AST_BlockStatement))
|
||||||
else if (input instanceof U.AST_Statement) input = [ input ];
|
throw new Error("Unsupported input syntax");
|
||||||
else throw new Error("Unsupported input syntax");
|
for (var i = 0; i < input.body.length; i++) {
|
||||||
var toplevel = new U.AST_Toplevel({ body: input });
|
var stat = input.body[i];
|
||||||
|
if (stat instanceof U.AST_SimpleStatement && stat.body instanceof U.AST_String)
|
||||||
|
input.body[i] = new U.AST_Directive(stat.body);
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
var toplevel = new U.AST_Toplevel(input);
|
||||||
toplevel.figure_out_scope(mangle_options);
|
toplevel.figure_out_scope(mangle_options);
|
||||||
return toplevel;
|
return toplevel;
|
||||||
}
|
}
|
||||||
@@ -299,10 +304,6 @@ function parse_test(file) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
var stat = node.body;
|
var stat = node.body;
|
||||||
if (stat instanceof U.AST_BlockStatement) {
|
|
||||||
if (stat.body.length == 1) stat = stat.body[0];
|
|
||||||
else if (stat.body.length == 0) stat = new U.AST_EmptyStatement();
|
|
||||||
}
|
|
||||||
if (label.name == "expect_exact") {
|
if (label.name == "expect_exact") {
|
||||||
test[label.name] = read_string(stat);
|
test[label.name] = read_string(stat);
|
||||||
} else if (label.name == "expect_stdout") {
|
} else if (label.name == "expect_stdout") {
|
||||||
|
|||||||
Reference in New Issue
Block a user