Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: pkg/observe/test/observable_map_test.dart

Issue 26734004: use symbol literals instead of const ctor in packages (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/observe/test/observable_list_test.dart ('k') | pkg/observe/test/observe_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'observe_test_utils.dart'; 8 import 'observe_test_utils.dart';
9 9
10 main() { 10 main() {
11 // TODO(jmesserly): need all standard Map API tests. 11 // TODO(jmesserly): need all standard Map API tests.
12 12
13 StreamSubscription sub; 13 StreamSubscription sub;
14 14
15 sharedTearDown() { 15 sharedTearDown() {
16 if (sub != null) { 16 if (sub != null) {
17 sub.cancel(); 17 sub.cancel();
18 sub = null; 18 sub = null;
19 } 19 }
20 } 20 }
21 21
22 group('observe length', () { 22 group('observe length', () {
23 ObservableMap map; 23 ObservableMap map;
24 List<ChangeRecord> changes; 24 List<ChangeRecord> changes;
25 25
26 setUp(() { 26 setUp(() {
27 map = toObservable({'a': 1, 'b': 2, 'c': 3}); 27 map = toObservable({'a': 1, 'b': 2, 'c': 3});
28 changes = null; 28 changes = null;
29 sub = map.changes.listen((records) { 29 sub = map.changes.listen((records) {
30 changes = records.where((r) => r.changes(_LENGTH)).toList(); 30 changes = records.where((r) => r.changes(#length)).toList();
31 }); 31 });
32 }); 32 });
33 33
34 tearDown(sharedTearDown); 34 tearDown(sharedTearDown);
35 35
36 observeTest('add item changes length', () { 36 observeTest('add item changes length', () {
37 map['d'] = 4; 37 map['d'] = 4;
38 expect(map, {'a': 1, 'b': 2, 'c': 3, 'd': 4}); 38 expect(map, {'a': 1, 'b': 2, 'c': 3, 'd': 4});
39 performMicrotaskCheckpoint(); 39 performMicrotaskCheckpoint();
40 expectChanges(changes, [_lengthChange]); 40 expectChanges(changes, [_lengthChange]);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 performMicrotaskCheckpoint(); 244 performMicrotaskCheckpoint();
245 expectChanges(records, [ 245 expectChanges(records, [
246 _change('a', isRemove: true), 246 _change('a', isRemove: true),
247 _change('b', isRemove: true), 247 _change('b', isRemove: true),
248 _lengthChange, 248 _lengthChange,
249 ]); 249 ]);
250 }); 250 });
251 }); 251 });
252 } 252 }
253 253
254 254 final _lengthChange = new PropertyChangeRecord(#length);
255 const _LENGTH = const Symbol('length');
256
257 final _lengthChange = new PropertyChangeRecord(_LENGTH);
258 255
259 _change(key, {isInsert: false, isRemove: false}) => 256 _change(key, {isInsert: false, isRemove: false}) =>
260 new MapChangeRecord(key, isInsert: isInsert, isRemove: isRemove); 257 new MapChangeRecord(key, isInsert: isInsert, isRemove: isRemove);
OLDNEW
« no previous file with comments | « pkg/observe/test/observable_list_test.dart ('k') | pkg/observe/test/observe_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698