[Pkg-javascript-commits] [uglifyjs] 49/77: Clean up unit test breakage
Jonas Smedegaard
dr at jones.dk
Tue May 19 00:02:31 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag v2.4.18
in repository uglifyjs.
commit 61e850ceb5a46b46589b1d985853f072067e2385
Author: Richard van Velzen <rvanvelzen1 at gmail.com>
Date: Wed Feb 11 21:27:21 2015 +0100
Clean up unit test breakage
In 992b6b9fcce47ca67ecb14675f10b172ce7a99b5 unit test broke (which I missed). This was due to undeclared variables not being side-effects free.
However, since they're really not side-effect free, just declare them in the test cases.
---
test/compress/conditionals.js | 2 +
test/compress/dead-code.js | 178 +++++++++++++++++++++---------------------
2 files changed, 91 insertions(+), 89 deletions(-)
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js
index 9af1630..e5a3922 100644
--- a/test/compress/conditionals.js
+++ b/test/compress/conditionals.js
@@ -53,6 +53,7 @@ ifs_3_should_warn: {
booleans : true
};
input: {
+ var x, y;
if (x && !(x + "1") && y) { // 1
var qq;
foo();
@@ -68,6 +69,7 @@ ifs_3_should_warn: {
}
}
expect: {
+ var x, y;
var qq; bar(); // 1
var jj; foo(); // 2
}
diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js
index 0fd066e..5009ae1 100644
--- a/test/compress/dead-code.js
+++ b/test/compress/dead-code.js
@@ -1,89 +1,89 @@
-dead_code_1: {
- options = {
- dead_code: true
- };
- input: {
- function f() {
- a();
- b();
- x = 10;
- return;
- if (x) {
- y();
- }
- }
- }
- expect: {
- function f() {
- a();
- b();
- x = 10;
- return;
- }
- }
-}
-
-dead_code_2_should_warn: {
- options = {
- dead_code: true
- };
- input: {
- function f() {
- g();
- x = 10;
- throw "foo";
- // completely discarding the `if` would introduce some
- // bugs. UglifyJS v1 doesn't deal with this issue; in v2
- // we copy any declarations to the upper scope.
- if (x) {
- y();
- var x;
- function g(){};
- // but nested declarations should not be kept.
- (function(){
- var q;
- function y(){};
- })();
- }
- }
- }
- expect: {
- function f() {
- g();
- x = 10;
- throw "foo";
- var x;
- function g(){};
- }
- }
-}
-
-dead_code_constant_boolean_should_warn_more: {
- options = {
- dead_code : true,
- loops : true,
- booleans : true,
- conditionals : true,
- evaluate : true
- };
- input: {
- while (!((foo && bar) || (x + "0"))) {
- console.log("unreachable");
- var foo;
- function bar() {}
- }
- for (var x = 10; x && (y || x) && (!typeof x); ++x) {
- asdf();
- foo();
- var moo;
- }
- }
- expect: {
- var foo;
- function bar() {}
- // nothing for the while
- // as for the for, it should keep:
- var x = 10;
- var moo;
- }
-}
+dead_code_1: {
+ options = {
+ dead_code: true
+ };
+ input: {
+ function f() {
+ a();
+ b();
+ x = 10;
+ return;
+ if (x) {
+ y();
+ }
+ }
+ }
+ expect: {
+ function f() {
+ a();
+ b();
+ x = 10;
+ return;
+ }
+ }
+}
+
+dead_code_2_should_warn: {
+ options = {
+ dead_code: true
+ };
+ input: {
+ function f() {
+ g();
+ x = 10;
+ throw "foo";
+ // completely discarding the `if` would introduce some
+ // bugs. UglifyJS v1 doesn't deal with this issue; in v2
+ // we copy any declarations to the upper scope.
+ if (x) {
+ y();
+ var x;
+ function g(){};
+ // but nested declarations should not be kept.
+ (function(){
+ var q;
+ function y(){};
+ })();
+ }
+ }
+ }
+ expect: {
+ function f() {
+ g();
+ x = 10;
+ throw "foo";
+ var x;
+ function g(){};
+ }
+ }
+}
+
+dead_code_constant_boolean_should_warn_more: {
+ options = {
+ dead_code : true,
+ loops : true,
+ booleans : true,
+ conditionals : true,
+ evaluate : true
+ };
+ input: {
+ while (!((foo && bar) || (x + "0"))) {
+ console.log("unreachable");
+ var foo;
+ function bar() {}
+ }
+ for (var x = 10, y; x && (y || x) && (!typeof x); ++x) {
+ asdf();
+ foo();
+ var moo;
+ }
+ }
+ expect: {
+ var foo;
+ function bar() {}
+ // nothing for the while
+ // as for the for, it should keep:
+ var x = 10, y;
+ var moo;
+ }
+}
--
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