aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/compress.js4
-rw-r--r--test/compress/conditionals.js74
2 files changed, 78 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index a2666fa9..f49486a0 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2651,6 +2651,10 @@ merge(Compressor.prototype, {
// y?true:false --> !!y
if (is_true(consequent) && is_false(alternative)) {
+ if (self.condition.is_boolean()) {
+ // boolean_expression ? true : false --> boolean_expression
+ return self.condition;
+ }
self.condition = self.condition.negate(compressor);
return make_node(AST_UnaryPrefix, self.condition, {
operator: "!",
diff --git a/test/compress/conditionals.js b/test/compress/conditionals.js
index 65cfea64..db0d8000 100644
--- a/test/compress/conditionals.js
+++ b/test/compress/conditionals.js
@@ -738,3 +738,77 @@ conditional_or: {
a = condition + 3 || null;
}
}
+
+trivial_boolean_ternary_expressions : {
+ options = {
+ conditionals: true,
+ evaluate : true,
+ booleans : true
+ };
+ input: {
+ f('foo' in m ? true : false);
+ f('foo' in m ? false : true);
+
+ f(g ? true : false);
+ f(foo() ? true : false);
+ f("bar" ? true : false);
+ f(5 ? true : false);
+ f(5.7 ? true : false);
+ f(x - y ? true : false);
+
+ f(x == y ? true : false);
+ f(x === y ? !0 : !1);
+ f(x < y ? !0 : false);
+ f(x <= y ? true : false);
+ f(x > y ? true : !1);
+ f(x >= y ? !0 : !1);
+
+ f(g ? false : true);
+ f(foo() ? false : true);
+ f("bar" ? false : true);
+ f(5 ? false : true);
+ f(5.7 ? false : true);
+ f(x - y ? false : true);
+
+ f(x == y ? !1 : !0);
+ f(x === y ? false : true);
+
+ f(x < y ? false : true);
+ f(x <= y ? false : !0);
+ f(x > y ? !1 : true);
+ f(x >= y ? !1 : !0);
+ }
+ expect: {
+ f('foo' in m);
+ f(!('foo' in m));
+
+ f(!!g);
+ f(!!foo());
+ f(!0);
+ f(!0);
+ f(!0);
+ f(!!(x - y));
+
+ f(x == y);
+ f(x === y);
+ f(x < y);
+ f(x <= y);
+ f(x > y);
+ f(x >= y);
+
+ f(!g);
+ f(!foo());
+ f(!1);
+ f(!1);
+ f(!1);
+ f(!(x - y));
+
+ f(x != y);
+ f(x !== y);
+
+ f(!(x < y));
+ f(!(x <= y));
+ f(!(x > y));
+ f(!(x >= y));
+ }
+}
taller/final.scm: New file. * gnu/installer/locale.scm (locale->configuration): New exported procedure. * gnu/installer/newt.scm (newt-installer): Add final page. * gnu/installer/newt/final.scm: New file. * gnu/installer/record.scm (installer): Add final-page field. * gnu/installer/timezone.scm (posix-tz->configuration): New exported procedure. * gnu/installer/steps.scm (installer-step): Rename configuration-proc field to configuration-formatter. (%installer-configuration-file): New exported parameter, (%installer-target-dir): ditto, (%configuration-file-width): ditto, (format-configuration): new exported procedure, (configuration->file): new exported procedure. Mathieu Othacehe 2019-01-17installer: Move everything to the build side....* gnu/installer.scm: Rename to ... * gnu/installer/record.scm: ... this. * gnu/installer/build-installer.scm: Move everything to the build side and rename to gnu/installer.scm. * gnu/installer/newt.scm: Remove all the gexps and add depencies to newt modules as this code will only be used on the build side by now. * gnu/local.mk (GNU_SYSTEM_MODULES): Adapt it, (dist_installer_DATA): New rule to install installer's aux-files. * gnu/system/install.scm (%installation-services): Use only 'installer-program' from (gnu installer). The installer is now choosen on the build side. * guix/self.scm (*system-modules*): Restore previous behaviour and add all installer files to #:extra-files field of the scheme-node. * po/guix/POTFILES.in: Adapt it. Mathieu Othacehe 2019-01-17installer: newt: Locate the logo within local-file....* gnu/installer/newt.scm (logo): Remove it, (welcome-page): Use a relative path to locate the logo. Mathieu Othacehe 2019-01-17installer: newt: Use scheme-modules* instead of scheme-modules....* gnu/installer/newt.scm (modules): Use scheme-modules*. Mathieu Othacehe 2019-01-17gnu: Add graphical installer support....* configure.ac: Require that guile-newt is available. * gnu/installer.scm: New file. * gnu/installer/aux-files/logo.txt: New file. * gnu/installer/build-installer.scm: New file. * gnu/installer/connman.scm: New file. * gnu/installer/keymap.scm: New file. * gnu/installer/locale.scm: New file. * gnu/installer/newt.scm: New file. * gnu/installer/newt/ethernet.scm: New file. * gnu/installer/newt/hostname.scm: New file. * gnu/installer/newt/keymap.scm: New file. * gnu/installer/newt/locale.scm: New file. * gnu/installer/newt/menu.scm: New file. * gnu/installer/newt/network.scm: New file. * gnu/installer/newt/page.scm: New file. * gnu/installer/newt/timezone.scm: New file. * gnu/installer/newt/user.scm: New file. * gnu/installer/newt/utils.scm: New file. * gnu/installer/newt/welcome.scm: New file. * gnu/installer/newt/wifi.scm: New file. * gnu/installer/steps.scm: New file. * gnu/installer/timezone.scm: New file. * gnu/installer/utils.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add previous files. * gnu/system.scm: Export %root-account. * gnu/system/install.scm (%installation-services): Use kmscon instead of linux VT for all tty. (installation-os)[users]: Add the graphical installer as shell of the root account. [packages]: Add font related packages. * po/guix/POTFILES.in: Add installer files. Mathieu Othacehe