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:logging/logging.dart'; | 6 import 'package:logging/logging.dart'; |
7 import 'package:observe/observe.dart'; | 7 import 'package:observe/observe.dart'; |
8 import 'package:observe/src/dirty_check.dart' as dirty_check; | 8 import 'package:observe/src/dirty_check.dart' as dirty_check; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'observe_test_utils.dart'; | 10 import 'observe_test_utils.dart'; |
11 | 11 |
| 12 // Note: this ensures we run the dartanalyzer on the @observe package. |
| 13 // @static-clean |
| 14 |
12 const _VALUE = const Symbol('value'); | 15 const _VALUE = const Symbol('value'); |
13 | 16 |
14 main() { | 17 main() { |
15 // Note: to test the basic Observable system, we use ObservableBox due to its | 18 // Note: to test the basic Observable system, we use ObservableBox due to its |
16 // simplicity. We also test a variant that is based on dirty-checking. | 19 // simplicity. We also test a variant that is based on dirty-checking. |
17 | 20 |
18 observeTest('no observers at the start', () { | 21 observeTest('no observers at the start', () { |
19 expect(dirty_check.allObservablesCount, 0); | 22 expect(dirty_check.allObservablesCount, 0); |
20 }); | 23 }); |
21 | 24 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 _changedValue(len) => new List.filled(len, new PropertyChangeRecord(_VALUE)); | 244 _changedValue(len) => new List.filled(len, new PropertyChangeRecord(_VALUE)); |
242 | 245 |
243 // A test model based on dirty checking. | 246 // A test model based on dirty checking. |
244 class WatcherModel<T> extends ObservableBase { | 247 class WatcherModel<T> extends ObservableBase { |
245 @observable T value; | 248 @observable T value; |
246 | 249 |
247 WatcherModel([T initialValue]) : value = initialValue; | 250 WatcherModel([T initialValue]) : value = initialValue; |
248 | 251 |
249 String toString() => '#<$runtimeType value: $value>'; | 252 String toString() => '#<$runtimeType value: $value>'; |
250 } | 253 } |
OLD | NEW |