[Pkg-javascript-commits] [uglifyjs] 137/491: allow `expect_stdout` to specify `Error` (#2087)

Jonas Smedegaard dr at jones.dk
Wed Feb 14 19:51:29 UTC 2018


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.

commit fed009655623705f44f12f62ef2ecd7d9be86d86
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Tue Jun 13 04:57:26 2017 +0800

    allow `expect_stdout` to specify `Error` (#2087)
---
 test/compress/node_version.js | 28 +++++++++++++++++++++++++++-
 test/run-tests.js             | 20 ++++++++++++++++++--
 2 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/test/compress/node_version.js b/test/compress/node_version.js
index ad0bfa1..ef62fd7 100644
--- a/test/compress/node_version.js
+++ b/test/compress/node_version.js
@@ -1,4 +1,4 @@
-eval_let: {
+eval_let_6: {
     input: {
         eval("let a;");
         console.log();
@@ -10,3 +10,29 @@ eval_let: {
     expect_stdout: ""
     node_version: ">=6"
 }
+
+eval_let_4: {
+    input: {
+        eval("let a;");
+        console.log();
+    }
+    expect: {
+        eval("let a;");
+        console.log();
+    }
+    expect_stdout: SyntaxError("Block-scoped declarations (let, const, function, class) not yet supported outside strict mode")
+    node_version: "4"
+}
+
+eval_let_0: {
+    input: {
+        eval("let a;");
+        console.log();
+    }
+    expect: {
+        eval("let a;");
+        console.log();
+    }
+    expect_stdout: SyntaxError("Unexpected identifier")
+    node_version: "<=0.12"
+}
diff --git a/test/run-tests.js b/test/run-tests.js
index 8427d4a..188532e 100755
--- a/test/run-tests.js
+++ b/test/run-tests.js
@@ -294,8 +294,24 @@ function parse_test(file) {
                 if (label.name == "expect_exact" || label.name == "node_version") {
                     test[label.name] = read_string(stat);
                 } else if (label.name == "expect_stdout") {
-                    if (stat.TYPE == "SimpleStatement" && stat.body instanceof U.AST_Boolean) {
-                        test[label.name] = stat.body.value;
+                    if (stat.TYPE == "SimpleStatement") {
+                        var body = stat.body;
+                        if (body instanceof U.AST_Boolean) {
+                            test[label.name] = body.value;
+                        } else if (body instanceof U.AST_Call) {
+                            var ctor = global[body.expression.name];
+                            assert.ok(ctor === Error || ctor.prototype instanceof Error, tmpl("Unsupported expect_stdout format [{line},{col}]", {
+                                line: label.start.line,
+                                col: label.start.col
+                            }));
+                            test[label.name] = ctor.apply(null, body.args.map(function(node) {
+                                assert.ok(node instanceof U.AST_Constant, tmpl("Unsupported expect_stdout format [{line},{col}]", {
+                                    line: label.start.line,
+                                    col: label.start.col
+                                }));
+                                return node.value;
+                            }));
+                        }
                     } else {
                         test[label.name] = read_string(stat) + "\n";
                     }

-- 
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