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:async'; | 5 import 'dart:async'; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
8 import 'package:compiler/src/types/types.dart'; | 8 import 'package:compiler/implementation/types/types.dart'; |
9 import 'package:compiler/src/inferrer/concrete_types_inferrer.dart'; | 9 import 'package:compiler/implementation/inferrer/concrete_types_inferrer.dart'; |
10 | 10 |
11 import "compiler_helper.dart"; | 11 import "compiler_helper.dart"; |
12 import "type_mask_test_helper.dart"; | 12 import "type_mask_test_helper.dart"; |
13 | 13 |
14 /** | 14 /** |
15 * Finds the node corresponding to the last occurence of the substring | 15 * Finds the node corresponding to the last occurence of the substring |
16 * [: identifier; :] in the program represented by the visited AST. | 16 * [: identifier; :] in the program represented by the visited AST. |
17 */ | 17 */ |
18 class VariableFinderVisitor extends Visitor { | 18 class VariableFinderVisitor extends Visitor { |
19 final String identifier; | 19 final String identifier; |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 """; | 430 """; |
431 return analyze(source).then((result) { | 431 return analyze(source).then((result) { |
432 result.checkNodeHasType('foo', [result.nullType, result.int, | 432 result.checkNodeHasType('foo', [result.nullType, result.int, |
433 result.string]); | 433 result.string]); |
434 }); | 434 }); |
435 } | 435 } |
436 | 436 |
437 testToplevelVariable3() { | 437 testToplevelVariable3() { |
438 final String source = r""" | 438 final String source = r""" |
439 var top = "a"; | 439 var top = "a"; |
440 | 440 |
441 f() => top; | 441 f() => top; |
442 | 442 |
443 main() { | 443 main() { |
444 var foo = f(); | 444 var foo = f(); |
445 var bar = top; | 445 var bar = top; |
446 top = 42; | 446 top = 42; |
447 var baz = top; | 447 var baz = top; |
448 foo; bar; baz; | 448 foo; bar; baz; |
449 } | 449 } |
450 """; | 450 """; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 """; | 671 """; |
672 return analyze(source).then((result) { | 672 return analyze(source).then((result) { |
673 result.checkNodeHasType('x', [result.int, result.string]); | 673 result.checkNodeHasType('x', [result.int, result.string]); |
674 }); | 674 }); |
675 } | 675 } |
676 | 676 |
677 testToplevelGetters() { | 677 testToplevelGetters() { |
678 final String source = """ | 678 final String source = """ |
679 int _x = 42; | 679 int _x = 42; |
680 get x => _x; | 680 get x => _x; |
681 | 681 |
682 f() => x; | 682 f() => x; |
683 | 683 |
684 main() { | 684 main() { |
685 var foo = f(); | 685 var foo = f(); |
686 var bar = x; | 686 var bar = x; |
687 _x = "a"; | 687 _x = "a"; |
688 var baz = x; | 688 var baz = x; |
689 foo; bar; baz; | 689 foo; bar; baz; |
690 } | 690 } |
691 """; | 691 """; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 [result.int, // new A(..., 42) | 733 [result.int, // new A(..., 42) |
734 result.bool, // a.y = true | 734 result.bool, // a.y = true |
735 result.double]); // dynamic.y = 3.14 | 735 result.double]); // dynamic.y = 3.14 |
736 }); | 736 }); |
737 } | 737 } |
738 | 738 |
739 testToplevelSetters() { | 739 testToplevelSetters() { |
740 final String source = """ | 740 final String source = """ |
741 int _x = 42; | 741 int _x = 42; |
742 set x(y) => _x = y; | 742 set x(y) => _x = y; |
743 | 743 |
744 f(y) { x = y; } | 744 f(y) { x = y; } |
745 | 745 |
746 main() { | 746 main() { |
747 var foo = _x; | 747 var foo = _x; |
748 x = "a"; | 748 x = "a"; |
749 var bar = _x; | 749 var bar = _x; |
750 f(true); | 750 f(true); |
751 var baz = _x; | 751 var baz = _x; |
752 foo; bar; baz; | 752 foo; bar; baz; |
753 } | 753 } |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 } | 1747 } |
1748 class B { | 1748 class B { |
1749 final foo = "abc"; | 1749 final foo = "abc"; |
1750 } | 1750 } |
1751 class C { | 1751 class C { |
1752 final foo = true; | 1752 final foo = true; |
1753 } | 1753 } |
1754 main() { | 1754 main() { |
1755 // We make sure that x doesn't have type dynamic by adding C to the | 1755 // We make sure that x doesn't have type dynamic by adding C to the |
1756 // set of seen classes and by checking that a's type doesn't contain | 1756 // set of seen classes and by checking that a's type doesn't contain |
1757 // bool. | 1757 // bool. |
1758 new C(); | 1758 new C(); |
1759 | 1759 |
1760 var a; | 1760 var a; |
1761 f(x) { | 1761 f(x) { |
1762 a = x.foo; | 1762 a = x.foo; |
1763 } | 1763 } |
1764 f(new A()); | 1764 f(new A()); |
1765 f(new B()); | 1765 f(new B()); |
1766 a; f; | 1766 a; f; |
1767 } | 1767 } |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2135 testClosures10, | 2135 testClosures10, |
2136 testClosures11, | 2136 testClosures11, |
2137 testClosures12, | 2137 testClosures12, |
2138 testRefinement, | 2138 testRefinement, |
2139 testDefaultArguments, | 2139 testDefaultArguments, |
2140 testSuperConstructorCall, | 2140 testSuperConstructorCall, |
2141 testSuperConstructorCall2, | 2141 testSuperConstructorCall2, |
2142 testSuperConstructorCall3, | 2142 testSuperConstructorCall3, |
2143 ], (f) => f())); | 2143 ], (f) => f())); |
2144 } | 2144 } |
OLD | NEW |