[Pkg-javascript-commits] [uglifyjs] 50/190: Allow specification beautify options in tests
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Aug 7 23:17:12 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.
commit 335e349314963e1761f7531656a64efaff548ceb
Author: Richard van Velzen <rvanvelzen at experty.com>
Date: Wed Oct 28 20:50:01 2015 +0100
Allow specification beautify options in tests
Caught an error in #847 as well - `output` wasn't passed anywhere which led to an exception. `options` was available though.
---
lib/output.js | 2 +-
test/compress/screw-ie8.js | 18 ++++++++++++++++++
test/run-tests.js | 17 +++++++++--------
3 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/lib/output.js b/lib/output.js
index 5d75e70..b7f6971 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -95,7 +95,7 @@ function OutputStream(options) {
case "\f": return "\\f";
case "\n": return "\\n";
case "\r": return "\\r";
- case "\x0B": return output.option("screw_ie8") ? "\\v" : "\\x0B";
+ case "\x0B": return options.screw_ie8 ? "\\v" : "\\x0B";
case "\u2028": return "\\u2028";
case "\u2029": return "\\u2029";
case '"': ++dq; return '"';
diff --git a/test/compress/screw-ie8.js b/test/compress/screw-ie8.js
new file mode 100644
index 0000000..527aea0
--- /dev/null
+++ b/test/compress/screw-ie8.js
@@ -0,0 +1,18 @@
+do_screw: {
+ options = { screw_ie8: true };
+ beautify = {
+ screw_ie8: true,
+ ascii_only: true
+ };
+
+ input: f("\v");
+ expect_exact: 'f("\\v");';
+}
+
+dont_screw: {
+ options = { screw_ie8: false };
+ beautify = { screw_ie8: false, ascii_only: true };
+
+ input: f("\v");
+ expect_exact: 'f("\\x0B");';
+}
\ No newline at end of file
diff --git a/test/run-tests.js b/test/run-tests.js
index 1e9eb3c..7f6166f 100755
--- a/test/run-tests.js
+++ b/test/run-tests.js
@@ -87,20 +87,21 @@ function run_compress_tests() {
warnings: false
});
var cmp = new U.Compressor(options, true);
+ var output_options = test.beautify || {};
var expect;
if (test.expect) {
- expect = make_code(as_toplevel(test.expect), false);
+ expect = make_code(as_toplevel(test.expect), output_options);
} else {
expect = test.expect_exact;
}
var input = as_toplevel(test.input);
- var input_code = make_code(test.input);
+ var input_code = make_code(test.input, { beautify: true });
if (test.mangle_props) {
input = U.mangle_properties(input, test.mangle_props);
}
var output = input.transform(cmp);
output.figure_out_scope();
- output = make_code(output, false);
+ output = make_code(output, output_options);
if (expect != output) {
log("!!! failed\n---INPUT---\n{input}\n---OUTPUT---\n{output}\n---EXPECTED---\n{expected}\n\n", {
input: input_code,
@@ -144,7 +145,7 @@ function parse_test(file) {
file: file,
line: node.start.line,
col: node.start.col,
- code: make_code(node, false)
+ code: make_code(node, { beautify: false })
}));
}
@@ -191,15 +192,15 @@ function parse_test(file) {
};
}
-function make_code(ast, beautify) {
- if (arguments.length == 1) beautify = true;
- var stream = U.OutputStream({ beautify: beautify, inline_script: true });
+function make_code(ast, options) {
+ options.inline_script = true;
+ var stream = U.OutputStream(options);
ast.print(stream);
return stream.get();
}
function evaluate(code) {
if (code instanceof U.AST_Node)
- code = make_code(code);
+ code = make_code(code, { beautify: true });
return new Function("return(" + code + ")")();
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list