| 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import "package:compiler/implementation/resolution/resolution.dart"; | 10 import "package:compiler/implementation/resolution/resolution.dart"; |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 Expect.isTrue(bNode.modifiers.isVar); | 668 Expect.isTrue(bNode.modifiers.isVar); |
| 669 }); | 669 }); |
| 670 } | 670 } |
| 671 | 671 |
| 672 Future resolveConstructor( | 672 Future resolveConstructor( |
| 673 String script, String statement, String className, | 673 String script, String statement, String className, |
| 674 String constructor, int expectedElementCount, | 674 String constructor, int expectedElementCount, |
| 675 {List expectedWarnings: const [], | 675 {List expectedWarnings: const [], |
| 676 List expectedErrors: const [], | 676 List expectedErrors: const [], |
| 677 List expectedInfos: const [], | 677 List expectedInfos: const [], |
| 678 String corelib: DEFAULT_CORELIB}) { | 678 Map corelib}) { |
| 679 MockCompiler compiler = new MockCompiler.internal(coreSource: corelib); | 679 MockCompiler compiler = new MockCompiler.internal(coreSource: corelib); |
| 680 return compiler.init().then((_) { | 680 return compiler.init().then((_) { |
| 681 compiler.parseScript(script); | 681 compiler.parseScript(script); |
| 682 compiler.resolveStatement(statement); | 682 compiler.resolveStatement(statement); |
| 683 ClassElement classElement = compiler.mainApp.find(className); | 683 ClassElement classElement = compiler.mainApp.find(className); |
| 684 Element element; | 684 Element element; |
| 685 if (constructor != '') { | 685 if (constructor != '') { |
| 686 element = classElement.lookupConstructor( | 686 element = classElement.lookupConstructor( |
| 687 new Selector.callConstructor(constructor, classElement.library)); | 687 new Selector.callConstructor(constructor, classElement.library)); |
| 688 } else { | 688 } else { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 } | 904 } |
| 905 class B extends A { | 905 class B extends A { |
| 906 B() : super(0), super(1); | 906 B() : super(0), super(1); |
| 907 }"""; | 907 }"""; |
| 908 return resolveConstructor(script, "B b = new B();", "B", "", 2, | 908 return resolveConstructor(script, "B b = new B();", "B", "", 2, |
| 909 expectedWarnings: [], | 909 expectedWarnings: [], |
| 910 expectedErrors: [MessageKind.DUPLICATE_SUPER_INITIALIZER]); | 910 expectedErrors: [MessageKind.DUPLICATE_SUPER_INITIALIZER]); |
| 911 }, | 911 }, |
| 912 () { | 912 () { |
| 913 String script = ""; | 913 String script = ""; |
| 914 final String CORELIB_WITH_INVALID_OBJECT = | 914 final INVALID_OBJECT = |
| 915 '''print(var obj) {} | 915 const { 'Object': 'class Object { Object() : super(); }' }; |
| 916 class int {} | |
| 917 class double {} | |
| 918 class bool {} | |
| 919 class String {} | |
| 920 class num {} | |
| 921 class Function {} | |
| 922 class List<E> {} | |
| 923 class Map {} | |
| 924 class Closure {} | |
| 925 class Null {} | |
| 926 class StackTrace {} | |
| 927 class Dynamic_ {} | |
| 928 class Type {} | |
| 929 class Object { Object() : super(); } | |
| 930 const proxy = 0;'''; | |
| 931 return resolveConstructor(script, | 916 return resolveConstructor(script, |
| 932 "Object o = new Object();", "Object", "", 1, | 917 "Object o = new Object();", "Object", "", 1, |
| 933 expectedWarnings: [], | 918 expectedWarnings: [], |
| 934 expectedErrors: [MessageKind.SUPER_INITIALIZER_IN_OBJECT], | 919 expectedErrors: [MessageKind.SUPER_INITIALIZER_IN_OBJECT], |
| 935 corelib: CORELIB_WITH_INVALID_OBJECT); | 920 corelib: INVALID_OBJECT); |
| 936 }, | 921 }, |
| 937 ], (f) => f()); | 922 ], (f) => f()); |
| 938 } | 923 } |
| 939 | 924 |
| 940 map(ResolverVisitor visitor) { | 925 map(ResolverVisitor visitor) { |
| 941 CollectingTreeElements elements = visitor.registry.mapping; | 926 CollectingTreeElements elements = visitor.registry.mapping; |
| 942 return elements.map; | 927 return elements.map; |
| 943 } | 928 } |
| 944 | 929 |
| 945 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1); | 930 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 }"""; | 1062 }"""; |
| 1078 asyncTest(() => compileScript(script2).then((compiler) { | 1063 asyncTest(() => compileScript(script2).then((compiler) { |
| 1079 expect(compiler, | 1064 expect(compiler, |
| 1080 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], | 1065 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], |
| 1081 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1066 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1082 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1067 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1083 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, | 1068 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, |
| 1084 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); | 1069 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); |
| 1085 })); | 1070 })); |
| 1086 } | 1071 } |
| OLD | NEW |