Skip to content

Commit

Permalink
fixing failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewplummer committed Sep 6, 2012
1 parent 755c1f1 commit 5d16dab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion unit_tests/environments/sugar/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ test('Function', function () {

equal((function(first){ return first; }).fill(['a','b'])(), ['a','b'], 'Function#fill | can be passed arrays');

equal((function(){ return arguments; }).fill(0)('a'), [0, 'a'], 'Function#fill | falsy values can be passed');
equal((function(){ return Array.prototype.slice.call(arguments); }).fill(0)('a'), [0, 'a'], 'Function#fill | falsy values can be passed');

});

36 changes: 19 additions & 17 deletions unit_tests/javascripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ var runtime;
// Arrays and objects must be treated separately here because in IE arrays with undefined
// elements will not pass the .hasOwnProperty check. For example [undefined].hasOwnProperty('0')
// will report false.
var deepEqual = function(one, two) {
if(one.length && two.length) {
return arrayEqual(one, two);
} else {
return objectEqual(one, two);
}
}

var arrayEqual = function(one, two) {
var i, result = true;
// This MUST be .each as we can have very large sparse arrays in the tests!
Expand Down Expand Up @@ -149,23 +141,33 @@ var objectEqual = function(one, two) {
}

var isEqual = function(one, two) {
if(one === nullScope && two === nullScope) {
// Null scope should always be a strict equal check
return true;
} else if(typeof two == 'number' && typeof one == 'number' && isNaN(two) && isNaN(one)) {
// NaN is NaN: equal
var class1 = Object.prototype.toString.call(one);
var class2 = Object.prototype.toString.call(two);
if(one === two) {
// Strictly equal... return true up front
return true;
} else if(typeof two == 'object' && typeof one == 'object' && two != null && one != null && deepEqual(two, one)) {
// Deeply equal
} else if(one === nullScope && two === nullScope) {
// Null scope should always be a strict equal check
return true;
} else if(two === null && one === null) {
// null is null: equal
return true;
} else if(two === undefined && one === undefined) {
// undefined is undefined: equal
return true;
} else if(one === two) {
// Strictly equal
} else if(class1 === '[object Boolean]' && class2 === '[object Boolean]') {
return one === two;
} else if(class1 === '[object Date]' && class2 === '[object Date]') {
return one.getTime() === two.getTime();
} else if(class1 === '[object RegExp]' && class2 === '[object RegExp]') {
return String(one) === String(two);
} else if(class1 === '[object Array]' && class2 === '[object Array]' && arrayEqual(one, two)) {
return true;
} else if(typeof two == 'number' && typeof one == 'number' && isNaN(two) && isNaN(one)) {
// NaN is NaN: equal
return true;
} else if(typeof two == 'object' && typeof one == 'object' && objectEqual(two, one)) {
// Deeply equal
return true;
} else {
return false;
Expand Down

0 comments on commit 5d16dab

Please sign in to comment.