else
bar();
}
- expect_exact: 'var x = 3;\n\nif (foo()) do {\n do {\n alert(x);\n } while (--x);\n} while (x); else bar();'
+ expect_exact: [
+ 'var x = 3;',
+ '',
+ 'if (foo()) do {',
+ ' do {',
+ ' alert(x);',
+ ' } while (--x);',
+ '} while (x); else bar();',
+ ]
}
issue_186_beautify_ie8: {
else
bar();
}
- expect_exact: 'var x = 3;\n\nif (foo()) {\n do {\n do {\n alert(x);\n } while (--x);\n } while (x);\n} else bar();'
+ expect_exact: [
+ 'var x = 3;',
+ '',
+ 'if (foo()) {',
+ ' do {',
+ ' do {',
+ ' alert(x);',
+ ' } while (--x);',
+ ' } while (x);',
+ '} else bar();',
+ ]
}
issue_186_bracketize: {
else
bar();
}
- expect_exact: 'var x = 3;\n\nif (foo()) {\n do {\n do {\n alert(x);\n } while (--x);\n } while (x);\n} else {\n bar();\n}'
+ expect_exact: [
+ 'var x = 3;',
+ '',
+ 'if (foo()) {',
+ ' do {',
+ ' do {',
+ ' alert(x);',
+ ' } while (--x);',
+ ' } while (x);',
+ '} else {',
+ ' bar();',
+ '}',
+ ]
}
issue_186_beautify_bracketize_ie8: {
else
bar();
}
- expect_exact: 'var x = 3;\n\nif (foo()) {\n do {\n do {\n alert(x);\n } while (--x);\n } while (x);\n} else {\n bar();\n}'
+ expect_exact: [
+ 'var x = 3;',
+ '',
+ 'if (foo()) {',
+ ' do {',
+ ' do {',
+ ' alert(x);',
+ ' } while (--x);',
+ ' } while (x);',
+ '} else {',
+ ' bar();',
+ '}',
+ ]
}
return { c: 42, d: a(), e: "foo"};
}
}
- expect_exact: 'function f(a){\nreturn{\nc:42,\nd:a(),\ne:"foo"}}'
+ expect_exact: [
+ 'function f(a){',
+ 'return{',
+ 'c:42,',
+ 'd:a(),',
+ 'e:"foo"}}',
+ ]
expect_warnings: [
"WARN: Output exceeds 10 characters"
]
return { c: 42, d: a(), e: "foo"};
}
}
- expect_exact: 'function f(a){\nreturn{c:42,\nd:a(),e:"foo"}\n}'
+ expect_exact: [
+ 'function f(a){',
+ 'return{c:42,',
+ 'd:a(),e:"foo"}',
+ '}',
+ ]
expect_warnings: [
]
}
}));
}
+ function read_string(stat) {
+ if (stat.TYPE === "SimpleStatement") {
+ var body = stat.body;
+ out: switch(body.TYPE) {
+ case "String":
+ return body.value;
+ case "Array":
+ return body.elements.map(function(element) {
+ if (element.TYPE !== "String")
+ throw new Error("Should be array of strings");
+ return element.value;
+ }).join("\n");
+ }
+ }
+ throw new Error("Should be string or array of strings");
+ }
+
function get_one_test(name, block) {
var test = { name: name, options: {} };
var tw = new U.TreeWalker(function(node, descend){
else if (stat.body.length == 0) stat = new U.AST_EmptyStatement();
}
if (node.label.name === "expect_exact") {
- if (!(stat.TYPE === "SimpleStatement" && stat.body.TYPE === "String")) {
- throw new Error(
- "The value of the expect_exact clause should be a string, " +
- "like `expect_exact: \"some.exact.javascript;\"`");
- }
- test[node.label.name] = stat.body.start.value
+ test[node.label.name] = read_string(stat);
} else {
test[node.label.name] = stat;
}