fix Ox.isEqual(-0, +0), update tests

This commit is contained in:
rolux 2012-05-27 18:59:40 +02:00
parent 8612218011
commit 45942cc3f2
2 changed files with 6 additions and 4 deletions

View file

@ -142,7 +142,7 @@
/*@ /*@
Ox.getLatLngByXY <f> Returns lat/lng for a given x/y on a 1x1 mercator projection Ox.getLatLngByXY <f> Returns lat/lng for a given x/y on a 1x1 mercator projection
> Ox.getLatLngByXY({x: 0.5, y: 0.5}) > Ox.getLatLngByXY({x: 0.5, y: 0.5})
{lat: 0, lng: 0} {lat: -0, lng: 0}
@*/ @*/
Ox.getLatLngByXY = function(xy) { Ox.getLatLngByXY = function(xy) {
function getValue(value) { function getValue(value) {

View file

@ -111,6 +111,8 @@ Ox.isEqual <function> Returns true if two values are equal
false false
> Ox.isEqual(0, 0) > Ox.isEqual(0, 0)
true true
> Ox.isEqual(-0, +0)
false
> Ox.isEqual({}, {}) > Ox.isEqual({}, {})
true true
> Ox.isEqual({a: 1, b: 2, c: 3}, {c: 3, b: 2, a: 1}) > Ox.isEqual({a: 1, b: 2, c: 3}, {c: 3, b: 2, a: 1})
@ -128,9 +130,9 @@ Ox.isEqual <function> Returns true if two values are equal
@*/ @*/
Ox.isEqual = function(a, b) { Ox.isEqual = function(a, b) {
var ret = false, type = Ox.typeOf(a); var ret = false, type = Ox.typeOf(a);
// 0 === -0, but not equal if (a === b) {
if (a === b && (a !== 0 || 1 / a === 1 / b)) { // 0 === -0, but not equal
ret = true; ret = a !== 0 || 1 / a === 1 / b;
} else if (type == Ox.typeOf(b)) { } else if (type == Ox.typeOf(b)) {
if (a == b) { if (a == b) {
ret = true; ret = true;