| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'package:observe/observe.dart'; | 6 import 'package:observe/observe.dart'; |
| 7 import 'package:observe/src/path_observer.dart' | 7 import 'package:observe/src/path_observer.dart' |
| 8 show getSegmentsOfPropertyPathForTesting, | 8 show getSegmentsOfPropertyPathForTesting, |
| 9 observerSentinelForTesting; | 9 observerSentinelForTesting; |
| 10 | 10 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 expect(new PathObserver(null, '').value, null); | 154 expect(new PathObserver(null, '').value, null); |
| 155 expect(new PathObserver(123, '').value, 123); | 155 expect(new PathObserver(123, '').value, 123); |
| 156 expect(() => new PathObserver(123, 'foo.bar.baz').value, _throwsNSM('foo')); | 156 expect(() => new PathObserver(123, 'foo.bar.baz').value, _throwsNSM('foo')); |
| 157 | 157 |
| 158 // shouldn't throw: | 158 // shouldn't throw: |
| 159 new PathObserver(123, '')..open((_) {})..close(); | 159 new PathObserver(123, '')..open((_) {})..close(); |
| 160 new PropertyPath('').setValueFrom(null, null); | 160 new PropertyPath('').setValueFrom(null, null); |
| 161 new PropertyPath('').setValueFrom(123, 42); | 161 new PropertyPath('').setValueFrom(123, 42); |
| 162 expect(() => new PropertyPath('foo.bar.baz').setValueFrom(123, 42), | 162 expect(() => new PropertyPath('foo.bar.baz').setValueFrom(123, 42), |
| 163 _throwsNSM('foo')); | 163 _throwsNSM('foo')); |
| 164 var foo = {}; | 164 Object foo = {}; |
| 165 expect(new PathObserver(foo, '').value, foo); | 165 expect(new PathObserver(foo, '').value, foo); |
| 166 | 166 |
| 167 foo = new Object(); | 167 foo = new Object(); |
| 168 expect(new PathObserver(foo, '').value, foo); | 168 expect(new PathObserver(foo, '').value, foo); |
| 169 | 169 |
| 170 expect(new PathObserver(foo, 'a/3!').value, null); | 170 expect(new PathObserver(foo, 'a/3!').value, null); |
| 171 }); | 171 }); |
| 172 | 172 |
| 173 test('get value at path ObservableBox', () { | 173 test('get value at path ObservableBox', () { |
| 174 var obj = new ObservableBox(new ObservableBox(new ObservableBox(1))); | 174 var obj = new ObservableBox(new ObservableBox(new ObservableBox(1))); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 if (index == 'foo') return _foo; | 704 if (index == 'foo') return _foo; |
| 705 } | 705 } |
| 706 | 706 |
| 707 operator []=(index, value) { | 707 operator []=(index, value) { |
| 708 log.add('[]= $index $value'); | 708 log.add('[]= $index $value'); |
| 709 if (index == 'foo') _foo = value; | 709 if (index == 'foo') _foo = value; |
| 710 } | 710 } |
| 711 } | 711 } |
| 712 | 712 |
| 713 @reflectable | 713 @reflectable |
| 714 class TestModel extends ChangeNotifier { | 714 class TestModel extends ChangeNotifier implements WatcherModel { |
| 715 var _a, _b, _c; | 715 var _a, _b, _c; |
| 716 | 716 |
| 717 TestModel([this._a, this._b, this._c]); | 717 TestModel([this._a, this._b, this._c]); |
| 718 | 718 |
| 719 get a => _a; | 719 get a => _a; |
| 720 | 720 |
| 721 void set a(newValue) { | 721 void set a(newValue) { |
| 722 _a = notifyPropertyChange(#a, _a, newValue); | 722 _a = notifyPropertyChange(#a, _a, newValue); |
| 723 } | 723 } |
| 724 | 724 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 743 @observable var c; | 743 @observable var c; |
| 744 | 744 |
| 745 WatcherModel(); | 745 WatcherModel(); |
| 746 } | 746 } |
| 747 | 747 |
| 748 class Foo { | 748 class Foo { |
| 749 var value; | 749 var value; |
| 750 Foo(this.value); | 750 Foo(this.value); |
| 751 String toString() => 'Foo$value'; | 751 String toString() => 'Foo$value'; |
| 752 } | 752 } |
| OLD | NEW |