Files
UglifyJS/test/compress/typeof.js
kzc fc9804b909 Fix (typeof side_effect()) in boolean context
Fixes #1289 with suggestion by @rvanvelzen
2016-10-06 13:50:11 +02:00

48 lines
1.0 KiB
JavaScript

typeof_evaluation: {
options = {
evaluate: true
};
input: {
a = typeof 1;
b = typeof 'test';
c = typeof [];
d = typeof {};
e = typeof /./;
f = typeof false;
g = typeof function(){};
h = typeof undefined;
}
expect: {
a='number';
b='string';
c=typeof[];
d=typeof{};
e=typeof/./;
f='boolean';
g='function';
h='undefined';
}
}
typeof_in_boolean_context: {
options = {
booleans : true,
evaluate : true,
conditionals : true,
};
input: {
function f1(x) { return typeof x ? "yes" : "no"; }
function f2() { return typeof g()? "Yes" : "No"; }
typeof 0 ? foo() : bar();
!typeof console.log(1);
var a = !typeof console.log(2);
}
expect: {
function f1(x) { return "yes"; }
function f2() { return g(), "Yes"; }
foo();
!(console.log(1), !0);
var a = !(console.log(2), !0);
}
}