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

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

Issue 131623004: Ternary operator support for polymer_expressions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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/polymer_expressions/lib/visitor.dart ('k') | pkg/polymer_expressions/test/parser_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 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 expectEval('true || false', true); 101 expectEval('true || false', true);
102 expectEval('false || true', true); 102 expectEval('false || true', true);
103 expectEval('false || false', false); 103 expectEval('false || false', false);
104 104
105 expectEval('true && true', true); 105 expectEval('true && true', true);
106 expectEval('true && false', false); 106 expectEval('true && false', false);
107 expectEval('false && true', false); 107 expectEval('false && true', false);
108 expectEval('false && false', false); 108 expectEval('false && false', false);
109 }); 109 });
110 110
111 test('should evaulate ternary operators', () {
112 expectEval('true ? 1 : 2', 1);
113 expectEval('false ? 1 : 2', 2);
114 expectEval('true ? true ? 1 : 2 : 3', 1);
115 expectEval('true ? false ? 1 : 2 : 3', 2);
116 expectEval('false ? true ? 1 : 2 : 3', 3);
117 expectEval('false ? 1 : true ? 2 : 3', 2);
118 expectEval('false ? 1 : false ? 2 : 3', 3);
Jennifer Messerly 2014/01/28 00:03:29 maybe add a test for `null` and some other kind of
justinfagnani 2014/01/28 01:05:21 Done.
119 });
120
111 test('should invoke a method on the model', () { 121 test('should invoke a method on the model', () {
112 var foo = new Foo(name: 'foo', age: 2); 122 var foo = new Foo(name: 'foo', age: 2);
113 expectEval('x()', foo.x(), foo); 123 expectEval('x()', foo.x(), foo);
114 expectEval('name', foo.name, foo); 124 expectEval('name', foo.name, foo);
115 }); 125 });
116 126
117 test('should invoke chained methods', () { 127 test('should invoke chained methods', () {
118 var foo = new Foo(name: 'foo', age: 2); 128 var foo = new Foo(name: 'foo', age: 2);
119 expectEval('name.length', foo.name.length, foo); 129 expectEval('name.length', foo.name.length, foo);
120 expectEval('x().toString()', foo.x().toString(), foo); 130 expectEval('x().toString()', foo.x().toString(), foo);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 return Future.wait([future, new Future(() { 406 return Future.wait([future, new Future(() {
397 expect(passed, true, reason: "Didn't receive a change notification on $s"); 407 expect(passed, true, reason: "Didn't receive a change notification on $s");
398 })]); 408 })]);
399 } 409 }
400 410
401 // Regression test from https://code.google.com/p/dart/issues/detail?id=13459 411 // Regression test from https://code.google.com/p/dart/issues/detail?id=13459
402 class WordElement extends Observable { 412 class WordElement extends Observable {
403 @observable List chars1 = 'abcdefg'.split(''); 413 @observable List chars1 = 'abcdefg'.split('');
404 @reflectable List filteredList(List original) => [original[0], original[1]]; 414 @reflectable List filteredList(List original) => [original[0], original[1]];
405 } 415 }
OLDNEW
« no previous file with comments | « pkg/polymer_expressions/lib/visitor.dart ('k') | pkg/polymer_expressions/test/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698