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

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

Issue 336013003: Version 1.5.0-dev.4.14 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 6 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 | « dart/pkg/observe/pubspec.yaml ('k') | dart/pkg/pkg.status » ('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 // This file contains code ported from: 10 // This file contains code ported from:
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 320
321 test('object with noSuchMethod', () { 321 test('object with noSuchMethod', () {
322 var model = new NoSuchMethodModel(); 322 var model = new NoSuchMethodModel();
323 var observer = new PathObserver(model, 'foo'); 323 var observer = new PathObserver(model, 'foo');
324 324
325 expect(observer.value, 42); 325 expect(observer.value, 42);
326 observer.value = 'hi'; 326 observer.value = 'hi';
327 expect(model._foo, 'hi'); 327 expect(model._foo, 'hi');
328 expect(observer.value, 'hi'); 328 expect(observer.value, 'hi');
329 329
330 expect(model.log, [#foo, const Symbol('foo='), #foo]); 330 expect(model.log, [#foo, const Symbol('foo='), #foo, #foo]);
331 331
332 // These shouldn't throw 332 // These shouldn't throw
333 observer = new PathObserver(model, 'bar'); 333 observer = new PathObserver(model, 'bar');
334 expect(observer.value, null, reason: 'path not found'); 334 expect(observer.value, null, reason: 'path not found');
335 observer.value = 42; 335 observer.value = 42;
336 expect(observer.value, null, reason: 'path not found'); 336 expect(observer.value, null, reason: 'path not found');
337 }); 337 });
338 338
339 test('object with indexer', () { 339 test('object with indexer', () {
340 var model = new IndexerModel(); 340 var model = new IndexerModel();
341 var observer = new PathObserver(model, 'foo'); 341 var observer = new PathObserver(model, 'foo');
342 342
343 expect(observer.value, 42); 343 expect(observer.value, 42);
344 expect(model.log, ['[] foo']); 344 expect(model.log, ['[] foo']);
345 model.log.clear(); 345 model.log.clear();
346 346
347 observer.value = 'hi'; 347 observer.value = 'hi';
348 expect(model.log, ['[]= foo hi']); 348 expect(model.log, ['[]= foo hi', '[] foo']);
349 expect(model._foo, 'hi'); 349 expect(model._foo, 'hi');
350 350
351 expect(observer.value, 'hi'); 351 expect(observer.value, 'hi');
352 352
353 // These shouldn't throw 353 // These shouldn't throw
354 model.log.clear(); 354 model.log.clear();
355 observer = new PathObserver(model, 'bar'); 355 observer = new PathObserver(model, 'bar');
356 expect(observer.value, null, reason: 'path not found'); 356 expect(observer.value, null, reason: 'path not found');
357 expect(model.log, ['[] bar']); 357 expect(model.log, ['[] bar']);
358 model.log.clear(); 358 model.log.clear();
359 359
360 observer.value = 42; 360 observer.value = 42;
361 expect(model.log, ['[]= bar 42']); 361 expect(model.log, ['[]= bar 42', '[] bar']);
362 model.log.clear(); 362 model.log.clear();
363 }); 363 });
364 } 364 }
365 365
366 /// A matcher that checks that a closure throws a NoSuchMethodError matching the 366 /// A matcher that checks that a closure throws a NoSuchMethodError matching the
367 /// given [name]. 367 /// given [name].
368 _throwsNSM(String name) => throwsA(_isNoSuchMethodOf(name)); 368 _throwsNSM(String name) => throwsA(_isNoSuchMethodOf(name));
369 369
370 /// A matcher that checkes whether an exception is a NoSuchMethodError matching 370 /// A matcher that checkes whether an exception is a NoSuchMethodError matching
371 /// the given [name]. 371 /// the given [name].
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 449
450 class WatcherModel extends Observable { 450 class WatcherModel extends Observable {
451 // TODO(jmesserly): dart2js does not let these be on the same line: 451 // TODO(jmesserly): dart2js does not let these be on the same line:
452 // @observable var a, b, c; 452 // @observable var a, b, c;
453 @observable var a; 453 @observable var a;
454 @observable var b; 454 @observable var b;
455 @observable var c; 455 @observable var c;
456 456
457 WatcherModel(); 457 WatcherModel();
458 } 458 }
OLDNEW
« no previous file with comments | « dart/pkg/observe/pubspec.yaml ('k') | dart/pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698