react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / handlebars / node_modules / uglify-js / test / compress / dead-code.js
80728 viewsdead_code_1: {1options = {2dead_code: true3};4input: {5function f() {6a();7b();8x = 10;9return;10if (x) {11y();12}13}14}15expect: {16function f() {17a();18b();19x = 10;20return;21}22}23}2425dead_code_2_should_warn: {26options = {27dead_code: true28};29input: {30function f() {31g();32x = 10;33throw "foo";34// completely discarding the `if` would introduce some35// bugs. UglifyJS v1 doesn't deal with this issue; in v236// we copy any declarations to the upper scope.37if (x) {38y();39var x;40function g(){};41// but nested declarations should not be kept.42(function(){43var q;44function y(){};45})();46}47}48}49expect: {50function f() {51g();52x = 10;53throw "foo";54var x;55function g(){};56}57}58}5960dead_code_constant_boolean_should_warn_more: {61options = {62dead_code : true,63loops : true,64booleans : true,65conditionals : true,66evaluate : true67};68input: {69while (!((foo && bar) || (x + "0"))) {70console.log("unreachable");71var foo;72function bar() {}73}74for (var x = 10; x && (y || x) && (!typeof x); ++x) {75asdf();76foo();77var moo;78}79}80expect: {81var foo;82function bar() {}83// nothing for the while84// as for the for, it should keep:85var x = 10;86var moo;87}88}899091