| 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 library eval_test; | 5 library eval_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:polymer_expressions/eval.dart'; | 9 import 'package:polymer_expressions/eval.dart'; |
| 10 import 'package:polymer_expressions/filter.dart'; | 10 import 'package:polymer_expressions/filter.dart'; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 var topLevel = { | 146 var topLevel = { |
| 147 'a': '42', | 147 'a': '42', |
| 148 'parseInt': parseInt, | 148 'parseInt': parseInt, |
| 149 'add': add, | 149 'add': add, |
| 150 }; | 150 }; |
| 151 expectEval('a | parseInt()', 42, null, topLevel); | 151 expectEval('a | parseInt()', 42, null, topLevel); |
| 152 expectEval('a | parseInt(8)', 34, null, topLevel); | 152 expectEval('a | parseInt(8)', 34, null, topLevel); |
| 153 expectEval('a | parseInt() | add(10)', 52, null, topLevel); | 153 expectEval('a | parseInt() | add(10)', 52, null, topLevel); |
| 154 }); | 154 }); |
| 155 | 155 |
| 156 test('should filter a list', () { |
| 157 expectEval('chars1 | filteredList', ['a', 'b'], new WordElement()); |
| 158 }); |
| 159 |
| 156 test('should return null if the receiver of a method is null', () { | 160 test('should return null if the receiver of a method is null', () { |
| 157 expectEval('a.b', null, null, {'a': null}); | 161 expectEval('a.b', null, null, {'a': null}); |
| 158 expectEval('a.b()', null, null, {'a': null}); | 162 expectEval('a.b()', null, null, {'a': null}); |
| 159 }); | 163 }); |
| 160 | 164 |
| 161 test('should return null if null is invoked', () { | 165 test('should return null if null is invoked', () { |
| 162 expectEval('a()', null, null, {'a': null}); | 166 expectEval('a()', null, null, {'a': null}); |
| 163 }); | 167 }); |
| 164 | 168 |
| 165 test('should return null if an operand is null', () { | 169 test('should return null if an operand is null', () { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 expect(value, afterMatcher); | 384 expect(value, afterMatcher); |
| 381 expect(observer.currentValue, afterMatcher); | 385 expect(observer.currentValue, afterMatcher); |
| 382 passed = true; | 386 passed = true; |
| 383 }); | 387 }); |
| 384 mutate(); | 388 mutate(); |
| 385 // fail if we don't receive an update by the next event loop | 389 // fail if we don't receive an update by the next event loop |
| 386 return Future.wait([future, new Future(() { | 390 return Future.wait([future, new Future(() { |
| 387 expect(passed, true, reason: "Didn't receive a change notification on $s"); | 391 expect(passed, true, reason: "Didn't receive a change notification on $s"); |
| 388 })]); | 392 })]); |
| 389 } | 393 } |
| 394 |
| 395 // Regression test from https://code.google.com/p/dart/issues/detail?id=13459 |
| 396 class WordElement extends ObservableBase { |
| 397 @observable List chars1 = 'abcdefg'.split(''); |
| 398 List filteredList(List original) => [original[0], original[1]]; |
| 399 } |
| OLD | NEW |