jenkins-bot has submitted this change and it was merged.

Change subject: oo.compare: Cover boolean as well as number and string 
primitives
......................................................................


oo.compare: Cover boolean as well as number and string primitives

Change-Id: I5f0b900ef29d54f12d7eca1a37c874532e93a366
---
M src/core.js
M tests/unit/core.test.js
2 files changed, 23 insertions(+), 2 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/core.js b/src/core.js
index f915384..1d3c9e4 100644
--- a/src/core.js
+++ b/src/core.js
@@ -239,7 +239,10 @@
                aType = typeof aValue;
                bType = typeof bValue;
                if ( aType !== bType ||
-                       ( ( aType === 'string' || aType === 'number' ) && 
aValue !== bValue ) ||
+                       (
+                               ( aType === 'string' || aType === 'number' || 
aType === 'boolean' ) &&
+                               aValue !== bValue
+                       ) ||
                        ( aValue === Object( aValue ) && !oo.compare( aValue, 
bValue, asymmetrical ) ) ) {
                        return false;
                }
diff --git a/tests/unit/core.test.js b/tests/unit/core.test.js
index 06b82b0..93638a8 100644
--- a/tests/unit/core.test.js
+++ b/tests/unit/core.test.js
@@ -308,7 +308,7 @@
                );
        } );
 
-       QUnit.test( 'compare', 22, function ( assert ) {
+       QUnit.test( 'compare', 25, function ( assert ) {
                var x, y, z;
 
                assert.strictEqual(
@@ -384,18 +384,36 @@
                );
 
                assert.strictEqual(
+                       oo.compare( [ true ], [ false ] ),
+                       false,
+                       'different booleans in array'
+               );
+
+               assert.strictEqual(
                        oo.compare( [ 42 ], [ 42 ] ),
                        true,
                        'number in array'
                );
 
                assert.strictEqual(
+                       oo.compare( [ 42 ], [ 32 ] ),
+                       false,
+                       'different number in array'
+               );
+
+               assert.strictEqual(
                        oo.compare( [ 'foo' ], [ 'foo' ] ),
                        true,
                        'string in array'
                );
 
                assert.strictEqual(
+                       oo.compare( [ 'foo' ], [ 'bar' ] ),
+                       false,
+                       'different string in array'
+               );
+
+               assert.strictEqual(
                        oo.compare( [], {} ),
                        true,
                        'Empty array equals empty plain object'

-- 
To view, visit https://gerrit.wikimedia.org/r/159639
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5f0b900ef29d54f12d7eca1a37c874532e93a366
Gerrit-PatchSet: 1
Gerrit-Project: oojs/core
Gerrit-Branch: master
Gerrit-Owner: Jforrester <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to