OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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:uri"; | 5 import "dart:uri"; |
6 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t"; | 6 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t"; |
7 import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da
rt'; | 7 import '../../../sdk/lib/_internal/compiler/implementation/scanner/scannerlib.da
rt'; |
8 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; | 8 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; |
9 import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'; | 9 import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'; |
10 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart'; | 10 import '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart'; |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 var x; | 354 var x; |
355 A(this.x); | 355 A(this.x); |
356 get y => x; | 356 get y => x; |
357 get z => y; | 357 get z => y; |
358 } | 358 } |
359 main() { | 359 main() { |
360 var a = new A(42); | 360 var a = new A(42); |
361 var foo = a.x; | 361 var foo = a.x; |
362 var bar = a.y; | 362 var bar = a.y; |
363 var baz = a.z; | 363 var baz = a.z; |
364 foo; bar; baz; | 364 var qux = null.x; |
| 365 foo; bar; baz; qux; |
365 } | 366 } |
366 """; | 367 """; |
367 AnalysisResult result = analyze(source); | 368 AnalysisResult result = analyze(source); |
368 result.checkNodeHasType('foo', [result.int]); | 369 result.checkNodeHasType('foo', [result.int]); |
369 result.checkNodeHasType('bar', [result.int]); | 370 result.checkNodeHasType('bar', [result.int]); |
370 result.checkNodeHasType('baz', [result.int]); | 371 result.checkNodeHasType('baz', [result.int]); |
| 372 result.checkNodeHasType('qux', []); |
371 } | 373 } |
372 | 374 |
373 testSetters() { | 375 testSetters() { |
374 final String source = r""" | 376 final String source = r""" |
375 class A { | 377 class A { |
376 var x; | 378 var x; |
377 var w; | 379 var w; |
378 A(this.x, this.w); | 380 A(this.x, this.w); |
379 set y(a) { x = a; z = a; } | 381 set y(a) { x = a; z = a; } |
380 set z(a) { w = a; } | 382 set z(a) { w = a; } |
381 } | 383 } |
382 main() { | 384 main() { |
383 var a = new A(42, 42); | 385 var a = new A(42, 42); |
384 a.x = 'abc'; | 386 a.x = 'abc'; |
385 a.y = true; | 387 a.y = true; |
| 388 null.x = 42; // should be ignored |
386 } | 389 } |
387 """; | 390 """; |
388 AnalysisResult result = analyze(source); | 391 AnalysisResult result = analyze(source); |
389 result.checkFieldHasType('A', 'x', [result.int, result.string, result.bool]); | 392 result.checkFieldHasType('A', 'x', [result.int, result.string, result.bool]); |
390 result.checkFieldHasType('A', 'w', [result.int, result.bool]); | 393 result.checkFieldHasType('A', 'w', [result.int, result.bool]); |
391 } | 394 } |
392 | 395 |
393 testNamedParameters() { | 396 testNamedParameters() { |
394 final String source = r""" | 397 final String source = r""" |
395 class A { | 398 class A { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 testListLiterals(); | 611 testListLiterals(); |
609 testMapLiterals(); | 612 testMapLiterals(); |
610 testReturn(); | 613 testReturn(); |
611 // testNoReturn(); // right now we infer the empty type instead of null | 614 // testNoReturn(); // right now we infer the empty type instead of null |
612 testArithmeticOperators(); | 615 testArithmeticOperators(); |
613 testOperators(); | 616 testOperators(); |
614 testCompoundOperators1(); | 617 testCompoundOperators1(); |
615 testCompoundOperators2(); | 618 testCompoundOperators2(); |
616 // testFieldInitialization(); // TODO(polux) | 619 // testFieldInitialization(); // TODO(polux) |
617 } | 620 } |
OLD | NEW |