[Pkg-javascript-commits] [less.js] 37/88: Fix tests, fix a bug in comparing values

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:22:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v1.7.0
in repository less.js.

commit 9749d20c3d71a2e48cd20a9fd5fc74b86bac49e3
Author: Luke Page <luke.a.page at gmail.com>
Date:   Tue Feb 11 21:09:06 2014 +0000

    Fix tests, fix a bug in comparing values
---
 lib/less/functions.js        |  2 +-
 lib/less/tree/dimension.js   | 22 ++++++++++++++++------
 test/css/functions.css       |  9 ++++++---
 test/less/functions.less     | 10 +++++++---
 test/less/mixins-guards.less |  8 +++++++-
 5 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/lib/less/functions.js b/lib/less/functions.js
index 699183c..166356b 100644
--- a/lib/less/functions.js
+++ b/lib/less/functions.js
@@ -309,7 +309,7 @@ tree.functions = {
     max: function () {
         return this._minmax(false, arguments);
     },
-    obtain: function (n) {
+    "get-unit": function (n) {
         return new(tree.Anonymous)(n.unit);
     },
     argb: function (color) {
diff --git a/lib/less/tree/dimension.js b/lib/less/tree/dimension.js
index f96078e..aecec13 100644
--- a/lib/less/tree/dimension.js
+++ b/lib/less/tree/dimension.js
@@ -89,17 +89,27 @@ tree.Dimension.prototype = {
 
     compare: function (other) {
         if (other instanceof tree.Dimension) {
-            var a = this.unify(), b = other.unify(),
-                aValue = a.value, bValue = b.value;
+            var a, b,
+                aValue, bValue;
+            
+            if (this.unit.isEmpty() || other.unit.isEmpty()) {
+                a = this;
+                b = other;
+            } else {
+                a = this.unify();
+                b = other.unify();
+                if (a.unit.compare(b.unit) !== 0) {
+                    return -1;
+                }                
+            }
+            aValue = a.value;
+            bValue = b.value;
 
             if (bValue > aValue) {
                 return -1;
             } else if (bValue < aValue) {
                 return 1;
             } else {
-                if (!b.unit.isEmpty() && a.unit.compare(b.unit) !== 0) {
-                    return -1;
-                }
                 return 0;
             }
         } else {
@@ -108,7 +118,7 @@ tree.Dimension.prototype = {
     },
 
     unify: function () {
-        return this.convertTo({ length: 'm', duration: 's', angle: 'rad' });
+        return this.convertTo({ length: 'px', duration: 's', angle: 'rad' });
     },
 
     convertTo: function (conversions) {
diff --git a/test/css/functions.css b/test/css/functions.css
index 2c7896d..d2444b5 100644
--- a/test/css/functions.css
+++ b/test/css/functions.css
@@ -52,6 +52,8 @@
   eformat: rgb(32, 128, 64);
   unitless: 12;
   unit: 14em;
+  get-unit: px;
+  get-unit-empty: ;
   hue: 98;
   saturation: 12%;
   lightness: 95%;
@@ -82,10 +84,11 @@
   pow: 64;
   pow: 27;
   min: 0;
-  min: min("junk", 5);
-  min: 3pt;
+  min: 5;
+  min: 1pt;
+  min: 3mm;
   max: 3;
-  max: max(8%, 1cm);
+  max: 5em;
   percentage: 20%;
   color: #ff0011;
   tint: #898989;
diff --git a/test/less/functions.less b/test/less/functions.less
index 170a915..863031a 100644
--- a/test/less/functions.less
+++ b/test/less/functions.less
@@ -57,6 +57,9 @@
   
   unitless: unit(12px);
   unit: unit((13px + 1px), em);
+  
+  get-unit: get-unit(10px);
+  get-unit-empty: get-unit(10);
 
   hue: hue(hsl(98, 12%, 95%));
   saturation: saturation(hsl(98, 12%, 95%));
@@ -88,10 +91,11 @@
   pow: pow(4, 3);
   pow: pow(3, 3em);
   min: min(0);
-  min: min("junk", 6, 5);
-  min: min(1pc, 3pt);
+  min: min(6, 5);
+  min: min(1pt, 3pt);
+  min: min(1cm, 3mm);
   max: max(1, 3);
-  max: max(3%, 1cm, 8%, 2mm);
+  max: max(3em, 1em, 2em, 5em);
   percentage: percentage((10px / 50));
   color: color("#ff0011");
   tint: tint(#777777, 13);
diff --git a/test/less/mixins-guards.less b/test/less/mixins-guards.less
index 4d0774d..6a02067 100644
--- a/test/less/mixins-guards.less
+++ b/test/less/mixins-guards.less
@@ -150,4 +150,10 @@
   .call-inner-lock-mixin {
     .inner-locked-mixin();
   }
-}
\ No newline at end of file
+}
+.bug-100cm-1m(@a) when (@a = 1) {
+  .failed {
+    one-hundred: not-equal-to-1;
+  }
+}
+.bug-100cm-1m(100cm);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list