Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
bug(equals): incorect comparison of dates
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Feb 23, 2012
1 parent 5d8528c commit ffa8441
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,8 @@ function equals(o1, o2) {
}
return true;
}
} else if (isDate(o1)) {
return isDate(o2) && o1.getTime() == o2.getTime();
} else {
if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2)) return false;
keySet = {};
Expand Down
7 changes: 7 additions & 0 deletions test/AngularSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ describe('angular', function() {
expect(equals(window, window.parent)).toBe(false);
expect(equals(window, undefined)).toBe(false);
});

it('should compare dates', function() {
expect(equals(new Date(0), new Date(0))).toBe(true);
expect(equals(new Date(0), new Date(1))).toBe(false);
expect(equals(new Date(0), 0)).toBe(false);
expect(equals(0, new Date(0))).toBe(false);
});
});

describe('size', function() {
Expand Down

0 comments on commit ffa8441

Please sign in to comment.