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 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 'parseInt': parseInt, | 250 'parseInt': parseInt, |
251 'add': add, | 251 'add': add, |
252 }; | 252 }; |
253 var scope = new Scope(model: foo, variables: globals); | 253 var scope = new Scope(model: foo, variables: globals); |
254 assign(parse('age | add(7)'), 29, scope); | 254 assign(parse('age | add(7)'), 29, scope); |
255 expect(foo.age, 22); | 255 expect(foo.age, 22); |
256 assign(parse('name | parseInt() | add(10)'), 29, scope); | 256 assign(parse('name | parseInt() | add(10)'), 29, scope); |
257 expect(foo.name, '19'); | 257 expect(foo.name, '19'); |
258 }); | 258 }); |
259 | 259 |
| 260 test('should throw on assignments to properties on null', () { |
| 261 assign(parse('name'), 'b', new Scope(model: null)); |
| 262 }); |
| 263 |
260 }); | 264 }); |
261 | 265 |
262 group('scope', () { | 266 group('scope', () { |
263 test('should return fields on the model', () { | 267 test('should return fields on the model', () { |
264 var foo = new Foo(name: 'a', age: 1); | 268 var foo = new Foo(name: 'a', age: 1); |
265 var scope = new Scope(model: foo); | 269 var scope = new Scope(model: foo); |
266 expect(scope['name'], 'a'); | 270 expect(scope['name'], 'a'); |
267 expect(scope['age'], 1); | 271 expect(scope['age'], 1); |
268 }); | 272 }); |
269 | 273 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 return Future.wait([future, new Future(() { | 404 return Future.wait([future, new Future(() { |
401 expect(passed, true, reason: "Didn't receive a change notification on $s"); | 405 expect(passed, true, reason: "Didn't receive a change notification on $s"); |
402 })]); | 406 })]); |
403 } | 407 } |
404 | 408 |
405 // Regression test from https://code.google.com/p/dart/issues/detail?id=13459 | 409 // Regression test from https://code.google.com/p/dart/issues/detail?id=13459 |
406 class WordElement extends Observable { | 410 class WordElement extends Observable { |
407 @observable List chars1 = 'abcdefg'.split(''); | 411 @observable List chars1 = 'abcdefg'.split(''); |
408 @reflectable List filteredList(List original) => [original[0], original[1]]; | 412 @reflectable List filteredList(List original) => [original[0], original[1]]; |
409 } | 413 } |
OLD | NEW |