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

Side by Side Diff: pkg/polymer_expressions/test/eval_test.dart

Issue 335943003: merge to trunk all changes from 36817 until 37378 under the packages: polymer, (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
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
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 library eval_test; 5 library eval_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 // Import mirrors to cause all mirrors to be retained by dart2js. 9 // Import mirrors to cause all mirrors to be retained by dart2js.
10 // The tests reflect on LinkedHashMap.length and String.length. 10 // The tests reflect on LinkedHashMap.length and String.length.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 expectEval('5 % -2', 1); 85 expectEval('5 % -2', 1);
86 expectEval('-5 % 2', 1); 86 expectEval('-5 % 2', 1);
87 87
88 expectEval('1 == 1', true); 88 expectEval('1 == 1', true);
89 expectEval('1 == 2', false); 89 expectEval('1 == 2', false);
90 expectEval('1 == null', false); 90 expectEval('1 == null', false);
91 expectEval('1 != 1', false); 91 expectEval('1 != 1', false);
92 expectEval('1 != 2', true); 92 expectEval('1 != 2', true);
93 expectEval('1 != null', true); 93 expectEval('1 != null', true);
94 94
95 var x = {};
96 var y = {};
97 expectEval('x === y', true, null, {'x': x, 'y': x});
98 expectEval('x !== y', false, null, {'x': x, 'y': x});
99 expectEval('x === y', false, null, {'x': x, 'y': y});
100 expectEval('x !== y', true, null, {'x': x, 'y': y});
101
95 expectEval('1 > 1', false); 102 expectEval('1 > 1', false);
96 expectEval('1 > 2', false); 103 expectEval('1 > 2', false);
97 expectEval('2 > 1', true); 104 expectEval('2 > 1', true);
98 expectEval('1 >= 1', true); 105 expectEval('1 >= 1', true);
99 expectEval('1 >= 2', false); 106 expectEval('1 >= 2', false);
100 expectEval('2 >= 1', true); 107 expectEval('2 >= 1', true);
101 expectEval('1 < 1', false); 108 expectEval('1 < 1', false);
102 expectEval('1 < 2', true); 109 expectEval('1 < 2', true);
103 expectEval('2 < 1', false); 110 expectEval('2 < 1', false);
104 expectEval('1 <= 1', true); 111 expectEval('1 <= 1', true);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 class Add extends Transformer<int, int> { 418 class Add extends Transformer<int, int> {
412 final int i; 419 final int i;
413 Add(this.i); 420 Add(this.i);
414 int forward(int x) => x + i; 421 int forward(int x) => x + i;
415 int reverse(int x) => x - i; 422 int reverse(int x) => x - i;
416 } 423 }
417 424
418 Object evalString(String s, [Object model, Map vars]) => 425 Object evalString(String s, [Object model, Map vars]) =>
419 eval(new Parser(s).parse(), new Scope(model: model, variables: vars)); 426 eval(new Parser(s).parse(), new Scope(model: model, variables: vars));
420 427
421 expectEval(String s, dynamic matcher, [Object model, Map vars = const {}]) => 428 expectEval(String s, dynamic matcher, [Object model, Map vars = const {}]) {
422 expect( 429 var expr = new Parser(s).parse();
423 eval(new Parser(s).parse(), new Scope(model: model, variables: vars)), 430 var scope = new Scope(model: model, variables: vars);
424 matcher, 431 expect(eval(expr, scope), matcher, reason: s);
425 reason: s); 432
433 var observer = observe(expr, scope);
434 new Updater(scope).visit(observer);
435 expect(observer.currentValue, matcher, reason: s);
436 }
426 437
427 expectObserve(String s, { 438 expectObserve(String s, {
428 Object model, 439 Object model,
429 Map variables: const {}, 440 Map variables: const {},
430 dynamic beforeMatcher, 441 dynamic beforeMatcher,
431 mutate(), 442 mutate(),
432 dynamic afterMatcher}) { 443 dynamic afterMatcher}) {
433 444
434 var scope = new Scope(model: model, variables: variables); 445 var scope = new Scope(model: model, variables: variables);
435 var observer = observe(new Parser(s).parse(), scope); 446 var observer = observe(new Parser(s).parse(), scope);
(...skipping 10 matching lines...) Expand all
446 return Future.wait([future, new Future(() { 457 return Future.wait([future, new Future(() {
447 expect(passed, true, reason: "Didn't receive a change notification on $s"); 458 expect(passed, true, reason: "Didn't receive a change notification on $s");
448 })]); 459 })]);
449 } 460 }
450 461
451 // Regression test from https://code.google.com/p/dart/issues/detail?id=13459 462 // Regression test from https://code.google.com/p/dart/issues/detail?id=13459
452 class WordElement extends Observable { 463 class WordElement extends Observable {
453 @observable List chars1 = 'abcdefg'.split(''); 464 @observable List chars1 = 'abcdefg'.split('');
454 @reflectable List filteredList(List original) => [original[0], original[1]]; 465 @reflectable List filteredList(List original) => [original[0], original[1]];
455 } 466 }
OLDNEW
« no previous file with comments | « pkg/polymer_expressions/test/bindings_test.dart ('k') | pkg/polymer_expressions/test/globals_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698