Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(watch_group): fix for NaN !== NaN
Browse files Browse the repository at this point in the history
closes #1139

Closes #1146
  • Loading branch information
vicb authored and chirayuk committed Jul 23, 2014
1 parent 2099993 commit d24ff89
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/change_detection/watch_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,8 @@ class _EvalWatchRecord implements WatchRecord<_Handler> {
if (value is String && current is String && value == current) {
// it is really the same, recover and save so next time identity is same
current = value;
} else if (value is num && value.isNaN && current is num && current.isNaN) {
// we need this for the compiled JavaScript since in JS NaN !== NaN.
} else {
previousValue = current;
currentValue = value;
Expand Down
21 changes: 21 additions & 0 deletions test/change_detection/watch_group_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,27 @@ void main() {
expect(logger).toEqual([]);
});

it('should ignore NaN != NaN', () {
watchGrp.watch(new ClosureAST('NaN', () => double.NAN, []), (_, __) => logger('NaN'));

watchGrp.detectChanges();
expect(logger).toEqual(['NaN']);

logger.clear();
watchGrp.detectChanges();
expect(logger).toEqual([]);
}) ;

it('should test string by value', () {
watchGrp.watch(new ClosureAST('String', () => 'value', []), (v, _) => logger(v));

watchGrp.detectChanges();
expect(logger).toEqual(['value']);

logger.clear();
watchGrp.detectChanges();
expect(logger).toEqual([]);
});

it('should eval method', () {
var obj = new MyClass(logger);
Expand Down

0 comments on commit d24ff89

Please sign in to comment.