[Pkg-javascript-commits] [uglifyjs] 03/11: Added expect_exact for testing the OutputStream

Jonas Smedegaard dr at jones.dk
Tue May 19 00:02:47 UTC 2015


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

js pushed a commit to tag v2.4.21
in repository uglifyjs.

commit de58b0289d8858b60f5f9aa6e5548fae39109d06
Author: Fábio Santos <fabiosantosart at gmail.com>
Date:   Sun Apr 12 14:51:26 2015 +0100

    Added expect_exact for testing the OutputStream
    
    This works almost exactly like `expect`, except that you pass a literal string
    of which the result is compared with the generated output.
---
 test/run-tests.js | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/test/run-tests.js b/test/run-tests.js
index 94bf6ad..215f6af 100755
--- a/test/run-tests.js
+++ b/test/run-tests.js
@@ -84,7 +84,12 @@ function run_compress_tests() {
                 warnings: false
             });
             var cmp = new U.Compressor(options, true);
-            var expect = make_code(as_toplevel(test.expect), false);
+            var expect;
+            if (test.expect) {
+                expect = make_code(as_toplevel(test.expect), false);
+            } else {
+                expect = test.expect_exact;
+            }
             var input = as_toplevel(test.input);
             var input_code = make_code(test.input);
             var output = input.transform(cmp);
@@ -150,7 +155,7 @@ function parse_test(file) {
             }
             if (node instanceof U.AST_LabeledStatement) {
                 assert.ok(
-                    node.label.name == "input" || node.label.name == "expect",
+                    node.label.name == "input" || node.label.name == "expect" || node.label.name == "expect_exact",
                     tmpl("Unsupported label {name} [{line},{col}]", {
                         name: node.label.name,
                         line: node.label.start.line,
@@ -162,7 +167,16 @@ function parse_test(file) {
                     if (stat.body.length == 1) stat = stat.body[0];
                     else if (stat.body.length == 0) stat = new U.AST_EmptyStatement();
                 }
-                test[node.label.name] = stat;
+                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
+                } else {
+                    test[node.label.name] = stat;
+                }
                 return true;
             }
         });

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