}
}
+ // x=y?true:false --> x=!!y
+ if (consequent instanceof AST_True
+ && alternative instanceof AST_False) {
+ self.condition = self.condition.negate(compressor);
+ return make_node(AST_UnaryPrefix, self.condition, {
+ operator: "!",
+ expression: self.condition
+ });
+ }
+ // x=y?false:true --> x=!y
+ if (consequent instanceof AST_False
+ && alternative instanceof AST_True) {
+ return self.condition.negate(compressor)
+ }
return self;
});
x = (y, 2);
}
}
+
+cond_8: {
+ options = {
+ conditionals: true,
+ evaluate : true
+ };
+ input: {
+ // compress these
+ a = condition ? true : false;
+
+ a = !condition ? true : false;
+
+ a = condition() ? true : false;
+
+ if (condition) {
+ a = true;
+ } else {
+ a = false;
+ }
+
+ a = condition ? false : true;
+
+ a = !condition ? false : true;
+
+ a = condition() ? false : true;
+
+ if (condition) {
+ a = false;
+ } else {
+ a = true;
+ }
+
+ // don't compress these
+ a = condition ? 1 : false;
+
+ a = !condition ? true : 0;
+
+ a = condition ? 1 : 0;
+
+ }
+ expect: {
+ a = !!condition;
+ a = !condition;
+ a = !!condition();
+ a = !!condition;
+ a = !condition;
+ a = !!condition;
+ a = !condition();
+ a = !condition;
+ a = condition ? 1 : false;
+ a = condition ? 0 : true;
+ a = condition ? 1 : 0;
+ }
+}
\ No newline at end of file