| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 |
| 3 library engine.resolver_test; | 4 library engine.resolver_test; |
| 5 |
| 4 import 'package:analyzer/src/generated/java_core.dart'; | 6 import 'package:analyzer/src/generated/java_core.dart'; |
| 5 import 'package:analyzer/src/generated/java_junit.dart'; | 7 import 'package:analyzer/src/generated/java_junit.dart'; |
| 6 import 'package:analyzer/src/generated/source_io.dart'; | 8 import 'package:analyzer/src/generated/source_io.dart'; |
| 7 import 'package:analyzer/src/generated/error.dart'; | 9 import 'package:analyzer/src/generated/error.dart'; |
| 8 import 'package:analyzer/src/generated/scanner.dart'; | 10 import 'package:analyzer/src/generated/scanner.dart'; |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 11 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 12 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 11 import 'package:analyzer/src/generated/element.dart'; | 13 import 'package:analyzer/src/generated/element.dart'; |
| 12 import 'package:analyzer/src/generated/resolver.dart'; | 14 import 'package:analyzer/src/generated/resolver.dart'; |
| 13 import 'package:analyzer/src/generated/engine.dart'; | 15 import 'package:analyzer/src/generated/engine.dart'; |
| 14 import 'package:analyzer/src/generated/java_engine_io.dart'; | 16 import 'package:analyzer/src/generated/java_engine_io.dart'; |
| 15 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 17 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
| 16 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; | 18 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; |
| 17 import 'package:unittest/unittest.dart' as _ut; | 19 import 'package:unittest/unittest.dart' as _ut; |
| 18 import 'test_support.dart'; | 20 import 'test_support.dart'; |
| 19 import 'ast_test.dart' show ASTFactory; | 21 import 'ast_test.dart' show ASTFactory; |
| 20 import 'element_test.dart' show ElementFactory; | 22 import 'element_test.dart' show ElementFactory; |
| 23 |
| 21 class TypePropagationTest extends ResolverTestCase { | 24 class TypePropagationTest extends ResolverTestCase { |
| 22 void fail_propagatedReturnType_functionExpression() { | 25 void fail_propagatedReturnType_functionExpression() { |
| 23 String code = EngineTestCase.createSource(["main() {", " var v = (() {retur
n 42;})();", "}"]); | 26 String code = EngineTestCase.createSource(["main() {", " var v = (() {retur
n 42;})();", "}"]); |
| 24 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); | 27 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); |
| 25 } | 28 } |
| 29 |
| 26 void test_as() { | 30 void test_as() { |
| 27 Source source = addSource(EngineTestCase.createSource([ | 31 Source source = addSource(EngineTestCase.createSource([ |
| 28 "class A {", | 32 "class A {", |
| 29 " bool get g => true;", | 33 " bool get g => true;", |
| 30 "}", | 34 "}", |
| 31 "A f(var p) {", | 35 "A f(var p) {", |
| 32 " if ((p as A).g) {", | 36 " if ((p as A).g) {", |
| 33 " return p;", | 37 " return p;", |
| 34 " } else {", | 38 " } else {", |
| 35 " return null;", | 39 " return null;", |
| 36 " }", | 40 " }", |
| 37 "}"])); | 41 "}"])); |
| 38 LibraryElement library = resolve(source); | 42 LibraryElement library = resolve(source); |
| 39 assertNoErrors(source); | 43 assertNoErrors(source); |
| 40 verify([source]); | 44 verify([source]); |
| 41 CompilationUnit unit = resolveCompilationUnit(source, library); | 45 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 42 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 46 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 43 InterfaceType typeA = classA.element.type; | 47 InterfaceType typeA = classA.element.type; |
| 44 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 48 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 45 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 49 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 46 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 50 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 47 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 51 ReturnStatement statement = (ifStatement.thenStatement as Block).statements[
0] as ReturnStatement; |
| 48 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 52 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 49 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 53 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 50 } | 54 } |
| 55 |
| 51 void test_assert() { | 56 void test_assert() { |
| 52 Source source = addSource(EngineTestCase.createSource([ | 57 Source source = addSource(EngineTestCase.createSource([ |
| 53 "class A {}", | 58 "class A {}", |
| 54 "A f(var p) {", | 59 "A f(var p) {", |
| 55 " assert (p is A);", | 60 " assert (p is A);", |
| 56 " return p;", | 61 " return p;", |
| 57 "}"])); | 62 "}"])); |
| 58 LibraryElement library = resolve(source); | 63 LibraryElement library = resolve(source); |
| 59 assertNoErrors(source); | 64 assertNoErrors(source); |
| 60 verify([source]); | 65 verify([source]); |
| 61 CompilationUnit unit = resolveCompilationUnit(source, library); | 66 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 62 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 67 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 63 InterfaceType typeA = classA.element.type; | 68 InterfaceType typeA = classA.element.type; |
| 64 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 69 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 65 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 70 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 66 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 71 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 67 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 72 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 68 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 73 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 69 } | 74 } |
| 75 |
| 70 void test_assignment() { | 76 void test_assignment() { |
| 71 Source source = addSource(EngineTestCase.createSource(["f() {", " var v;",
" v = 0;", " return v;", "}"])); | 77 Source source = addSource(EngineTestCase.createSource(["f() {", " var v;",
" v = 0;", " return v;", "}"])); |
| 72 LibraryElement library = resolve(source); | 78 LibraryElement library = resolve(source); |
| 73 assertNoErrors(source); | 79 assertNoErrors(source); |
| 74 verify([source]); | 80 verify([source]); |
| 75 CompilationUnit unit = resolveCompilationUnit(source, library); | 81 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 76 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 82 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 77 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 83 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 78 ReturnStatement statement = body.block.statements[2] as ReturnStatement; | 84 ReturnStatement statement = body.block.statements[2] as ReturnStatement; |
| 79 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 85 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 80 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType); | 86 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType); |
| 81 } | 87 } |
| 88 |
| 82 void test_assignment_afterInitializer() { | 89 void test_assignment_afterInitializer() { |
| 83 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " v = 1.0;", " return v;", "}"])); | 90 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " v = 1.0;", " return v;", "}"])); |
| 84 LibraryElement library = resolve(source); | 91 LibraryElement library = resolve(source); |
| 85 assertNoErrors(source); | 92 assertNoErrors(source); |
| 86 verify([source]); | 93 verify([source]); |
| 87 CompilationUnit unit = resolveCompilationUnit(source, library); | 94 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 88 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 95 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 89 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 96 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 90 ReturnStatement statement = body.block.statements[2] as ReturnStatement; | 97 ReturnStatement statement = body.block.statements[2] as ReturnStatement; |
| 91 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 98 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 92 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.propagatedTyp
e); | 99 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.propagatedTyp
e); |
| 93 } | 100 } |
| 101 |
| 94 void test_forEach() { | 102 void test_forEach() { |
| 95 String code = EngineTestCase.createSource([ | 103 String code = EngineTestCase.createSource([ |
| 96 "f(List<String> p) {", | 104 "f(List<String> p) {", |
| 97 " for (var e in p) {", | 105 " for (var e in p) {", |
| 98 " e;", | 106 " e;", |
| 99 " }", | 107 " }", |
| 100 "}"]); | 108 "}"]); |
| 101 Source source = addSource(code); | 109 Source source = addSource(code); |
| 102 LibraryElement library = resolve(source); | 110 LibraryElement library = resolve(source); |
| 103 assertNoErrors(source); | 111 assertNoErrors(source); |
| 104 verify([source]); | 112 verify([source]); |
| 105 CompilationUnit unit = resolveCompilationUnit(source, library); | 113 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 106 InterfaceType stringType = typeProvider.stringType; | 114 InterfaceType stringType = typeProvider.stringType; |
| 107 { | 115 { |
| 108 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e in",
SimpleIdentifier); | 116 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e in",
SimpleIdentifier); |
| 109 JUnitTestCase.assertSame(stringType, identifier.propagatedType); | 117 JUnitTestCase.assertSame(stringType, identifier.propagatedType); |
| 110 } | 118 } |
| 111 { | 119 { |
| 112 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e;", Si
mpleIdentifier); | 120 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e;", Si
mpleIdentifier); |
| 113 JUnitTestCase.assertSame(stringType, identifier.propagatedType); | 121 JUnitTestCase.assertSame(stringType, identifier.propagatedType); |
| 114 } | 122 } |
| 115 } | 123 } |
| 124 |
| 116 void test_functionExpression_asInvocationArgument() { | 125 void test_functionExpression_asInvocationArgument() { |
| 117 String code = EngineTestCase.createSource([ | 126 String code = EngineTestCase.createSource([ |
| 118 "class MyMap<K, V> {", | 127 "class MyMap<K, V> {", |
| 119 " forEach(f(K key, V value)) {}", | 128 " forEach(f(K key, V value)) {}", |
| 120 "}", | 129 "}", |
| 121 "f(MyMap<int, String> m) {", | 130 "f(MyMap<int, String> m) {", |
| 122 " m.forEach((k, v) {", | 131 " m.forEach((k, v) {", |
| 123 " k;", | 132 " k;", |
| 124 " v;", | 133 " v;", |
| 125 " });", | 134 " });", |
| 126 "}"]); | 135 "}"]); |
| 127 Source source = addSource(code); | 136 Source source = addSource(code); |
| 128 LibraryElement library = resolve(source); | 137 LibraryElement library = resolve(source); |
| 129 assertNoErrors(source); | 138 assertNoErrors(source); |
| 130 verify([source]); | 139 verify([source]); |
| 131 CompilationUnit unit = resolveCompilationUnit(source, library); | 140 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 132 Type2 intType = typeProvider.intType; | 141 Type2 intType = typeProvider.intType; |
| 133 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp
leFormalParameter); | 142 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp
leFormalParameter); |
| 134 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType); | 143 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType); |
| 135 SimpleIdentifier kIdentifier = EngineTestCase.findNode(unit, code, "k;", Sim
pleIdentifier); | 144 SimpleIdentifier kIdentifier = EngineTestCase.findNode(unit, code, "k;", Sim
pleIdentifier); |
| 136 JUnitTestCase.assertSame(intType, kIdentifier.propagatedType); | 145 JUnitTestCase.assertSame(intType, kIdentifier.propagatedType); |
| 137 JUnitTestCase.assertSame(typeProvider.dynamicType, kIdentifier.staticType); | 146 JUnitTestCase.assertSame(typeProvider.dynamicType, kIdentifier.staticType); |
| 138 Type2 stringType = typeProvider.stringType; | 147 Type2 stringType = typeProvider.stringType; |
| 139 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); | 148 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); |
| 140 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); | 149 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); |
| 141 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); | 150 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); |
| 142 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); | 151 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); |
| 143 JUnitTestCase.assertSame(typeProvider.dynamicType, vIdentifier.staticType); | 152 JUnitTestCase.assertSame(typeProvider.dynamicType, vIdentifier.staticType); |
| 144 } | 153 } |
| 154 |
| 145 void test_functionExpression_asInvocationArgument_fromInferredInvocation() { | 155 void test_functionExpression_asInvocationArgument_fromInferredInvocation() { |
| 146 String code = EngineTestCase.createSource([ | 156 String code = EngineTestCase.createSource([ |
| 147 "class MyMap<K, V> {", | 157 "class MyMap<K, V> {", |
| 148 " forEach(f(K key, V value)) {}", | 158 " forEach(f(K key, V value)) {}", |
| 149 "}", | 159 "}", |
| 150 "f(MyMap<int, String> m) {", | 160 "f(MyMap<int, String> m) {", |
| 151 " var m2 = m;", | 161 " var m2 = m;", |
| 152 " m2.forEach((k, v) {});", | 162 " m2.forEach((k, v) {});", |
| 153 "}"]); | 163 "}"]); |
| 154 Source source = addSource(code); | 164 Source source = addSource(code); |
| 155 LibraryElement library = resolve(source); | 165 LibraryElement library = resolve(source); |
| 156 assertNoErrors(source); | 166 assertNoErrors(source); |
| 157 verify([source]); | 167 verify([source]); |
| 158 CompilationUnit unit = resolveCompilationUnit(source, library); | 168 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 159 Type2 intType = typeProvider.intType; | 169 Type2 intType = typeProvider.intType; |
| 160 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp
leFormalParameter); | 170 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp
leFormalParameter); |
| 161 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType); | 171 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType); |
| 162 Type2 stringType = typeProvider.stringType; | 172 Type2 stringType = typeProvider.stringType; |
| 163 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); | 173 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); |
| 164 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); | 174 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); |
| 165 } | 175 } |
| 176 |
| 166 void test_functionExpression_asInvocationArgument_functionExpressionInvocation
() { | 177 void test_functionExpression_asInvocationArgument_functionExpressionInvocation
() { |
| 167 String code = EngineTestCase.createSource([ | 178 String code = EngineTestCase.createSource([ |
| 168 "main() {", | 179 "main() {", |
| 169 " (f(String value)) {} ((v) {", | 180 " (f(String value)) {} ((v) {", |
| 170 " v;", | 181 " v;", |
| 171 " });", | 182 " });", |
| 172 "}"]); | 183 "}"]); |
| 173 Source source = addSource(code); | 184 Source source = addSource(code); |
| 174 LibraryElement library = resolve(source); | 185 LibraryElement library = resolve(source); |
| 175 assertNoErrors(source); | 186 assertNoErrors(source); |
| 176 verify([source]); | 187 verify([source]); |
| 177 CompilationUnit unit = resolveCompilationUnit(source, library); | 188 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 178 Type2 dynamicType = typeProvider.dynamicType; | 189 Type2 dynamicType = typeProvider.dynamicType; |
| 179 Type2 stringType = typeProvider.stringType; | 190 Type2 stringType = typeProvider.stringType; |
| 180 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Forma
lParameter); | 191 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Forma
lParameter); |
| 181 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); | 192 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); |
| 182 JUnitTestCase.assertSame(dynamicType, vParameter.identifier.staticType); | 193 JUnitTestCase.assertSame(dynamicType, vParameter.identifier.staticType); |
| 183 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); | 194 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); |
| 184 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); | 195 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); |
| 185 JUnitTestCase.assertSame(dynamicType, vIdentifier.staticType); | 196 JUnitTestCase.assertSame(dynamicType, vIdentifier.staticType); |
| 186 } | 197 } |
| 198 |
| 187 void test_functionExpression_asInvocationArgument_keepIfLessSpecific() { | 199 void test_functionExpression_asInvocationArgument_keepIfLessSpecific() { |
| 188 String code = EngineTestCase.createSource([ | 200 String code = EngineTestCase.createSource([ |
| 189 "class MyList {", | 201 "class MyList {", |
| 190 " forEach(f(Object value)) {}", | 202 " forEach(f(Object value)) {}", |
| 191 "}", | 203 "}", |
| 192 "f(MyList list) {", | 204 "f(MyList list) {", |
| 193 " list.forEach((int v) {", | 205 " list.forEach((int v) {", |
| 194 " v;", | 206 " v;", |
| 195 " });", | 207 " });", |
| 196 "}"]); | 208 "}"]); |
| 197 Source source = addSource(code); | 209 Source source = addSource(code); |
| 198 LibraryElement library = resolve(source); | 210 LibraryElement library = resolve(source); |
| 199 assertNoErrors(source); | 211 assertNoErrors(source); |
| 200 verify([source]); | 212 verify([source]); |
| 201 CompilationUnit unit = resolveCompilationUnit(source, library); | 213 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 202 Type2 intType = typeProvider.intType; | 214 Type2 intType = typeProvider.intType; |
| 203 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); | 215 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); |
| 204 JUnitTestCase.assertSame(null, vParameter.identifier.propagatedType); | 216 JUnitTestCase.assertSame(null, vParameter.identifier.propagatedType); |
| 205 JUnitTestCase.assertSame(intType, vParameter.identifier.staticType); | 217 JUnitTestCase.assertSame(intType, vParameter.identifier.staticType); |
| 206 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); | 218 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); |
| 207 JUnitTestCase.assertSame(intType, vIdentifier.staticType); | 219 JUnitTestCase.assertSame(intType, vIdentifier.staticType); |
| 208 JUnitTestCase.assertSame(null, vIdentifier.propagatedType); | 220 JUnitTestCase.assertSame(null, vIdentifier.propagatedType); |
| 209 } | 221 } |
| 222 |
| 210 void test_functionExpression_asInvocationArgument_replaceIfMoreSpecific() { | 223 void test_functionExpression_asInvocationArgument_replaceIfMoreSpecific() { |
| 211 String code = EngineTestCase.createSource([ | 224 String code = EngineTestCase.createSource([ |
| 212 "class MyList<E> {", | 225 "class MyList<E> {", |
| 213 " forEach(f(E value)) {}", | 226 " forEach(f(E value)) {}", |
| 214 "}", | 227 "}", |
| 215 "f(MyList<String> list) {", | 228 "f(MyList<String> list) {", |
| 216 " list.forEach((Object v) {", | 229 " list.forEach((Object v) {", |
| 217 " v;", | 230 " v;", |
| 218 " });", | 231 " });", |
| 219 "}"]); | 232 "}"]); |
| 220 Source source = addSource(code); | 233 Source source = addSource(code); |
| 221 LibraryElement library = resolve(source); | 234 LibraryElement library = resolve(source); |
| 222 assertNoErrors(source); | 235 assertNoErrors(source); |
| 223 verify([source]); | 236 verify([source]); |
| 224 CompilationUnit unit = resolveCompilationUnit(source, library); | 237 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 225 Type2 stringType = typeProvider.stringType; | 238 Type2 stringType = typeProvider.stringType; |
| 226 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); | 239 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); |
| 227 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); | 240 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); |
| 228 JUnitTestCase.assertSame(typeProvider.objectType, vParameter.identifier.stat
icType); | 241 JUnitTestCase.assertSame(typeProvider.objectType, vParameter.identifier.stat
icType); |
| 229 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); | 242 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); |
| 230 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); | 243 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); |
| 231 } | 244 } |
| 245 |
| 232 void test_Future_then() { | 246 void test_Future_then() { |
| 233 String code = EngineTestCase.createSource([ | 247 String code = EngineTestCase.createSource([ |
| 234 "import 'dart:async';", | 248 "import 'dart:async';", |
| 235 "main(Future<int> firstFuture) {", | 249 "main(Future<int> firstFuture) {", |
| 236 " firstFuture.then((p1) {", | 250 " firstFuture.then((p1) {", |
| 237 " return 1.0;", | 251 " return 1.0;", |
| 238 " }).then((p2) {", | 252 " }).then((p2) {", |
| 239 " return new Future<String>.value('str');", | 253 " return new Future<String>.value('str');", |
| 240 " }).then((p3) {", | 254 " }).then((p3) {", |
| 241 " });", | 255 " });", |
| 242 "}"]); | 256 "}"]); |
| 243 Source source = addSource(code); | 257 Source source = addSource(code); |
| 244 LibraryElement library = resolve(source); | 258 LibraryElement library = resolve(source); |
| 245 assertNoErrors(source); | 259 assertNoErrors(source); |
| 246 verify([source]); | 260 verify([source]); |
| 247 CompilationUnit unit = resolveCompilationUnit(source, library); | 261 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 248 FormalParameter p1 = EngineTestCase.findNode(unit, code, "p1) {", SimpleForm
alParameter); | 262 FormalParameter p1 = EngineTestCase.findNode(unit, code, "p1) {", SimpleForm
alParameter); |
| 249 JUnitTestCase.assertSame(typeProvider.intType, p1.identifier.propagatedType)
; | 263 JUnitTestCase.assertSame(typeProvider.intType, p1.identifier.propagatedType)
; |
| 250 FormalParameter p2 = EngineTestCase.findNode(unit, code, "p2) {", SimpleForm
alParameter); | 264 FormalParameter p2 = EngineTestCase.findNode(unit, code, "p2) {", SimpleForm
alParameter); |
| 251 JUnitTestCase.assertSame(typeProvider.doubleType, p2.identifier.propagatedTy
pe); | 265 JUnitTestCase.assertSame(typeProvider.doubleType, p2.identifier.propagatedTy
pe); |
| 252 FormalParameter p3 = EngineTestCase.findNode(unit, code, "p3) {", SimpleForm
alParameter); | 266 FormalParameter p3 = EngineTestCase.findNode(unit, code, "p3) {", SimpleForm
alParameter); |
| 253 JUnitTestCase.assertSame(typeProvider.stringType, p3.identifier.propagatedTy
pe); | 267 JUnitTestCase.assertSame(typeProvider.stringType, p3.identifier.propagatedTy
pe); |
| 254 } | 268 } |
| 269 |
| 255 void test_initializer() { | 270 void test_initializer() { |
| 256 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " return v;", "}"])); | 271 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " return v;", "}"])); |
| 257 LibraryElement library = resolve(source); | 272 LibraryElement library = resolve(source); |
| 258 assertNoErrors(source); | 273 assertNoErrors(source); |
| 259 verify([source]); | 274 verify([source]); |
| 260 CompilationUnit unit = resolveCompilationUnit(source, library); | 275 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 261 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 276 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 262 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 277 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 263 NodeList<Statement> statements = body.block.statements; | 278 NodeList<Statement> statements = body.block.statements; |
| 264 { | 279 { |
| 265 VariableDeclarationStatement statement = statements[0] as VariableDeclarat
ionStatement; | 280 VariableDeclarationStatement statement = statements[0] as VariableDeclarat
ionStatement; |
| 266 SimpleIdentifier variableName = statement.variables.variables[0].name; | 281 SimpleIdentifier variableName = statement.variables.variables[0].name; |
| 267 JUnitTestCase.assertSame(typeProvider.dynamicType, variableName.staticType
); | 282 JUnitTestCase.assertSame(typeProvider.dynamicType, variableName.staticType
); |
| 268 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType
); | 283 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType
); |
| 269 } | 284 } |
| 270 { | 285 { |
| 271 ReturnStatement statement = statements[1] as ReturnStatement; | 286 ReturnStatement statement = statements[1] as ReturnStatement; |
| 272 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 287 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 273 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType
); | 288 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType
); |
| 274 } | 289 } |
| 275 } | 290 } |
| 291 |
| 276 void test_initializer_dereference() { | 292 void test_initializer_dereference() { |
| 277 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = '
String';", " v.", "}"])); | 293 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = '
String';", " v.", "}"])); |
| 278 LibraryElement library = resolve(source); | 294 LibraryElement library = resolve(source); |
| 279 CompilationUnit unit = resolveCompilationUnit(source, library); | 295 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 280 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 296 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 281 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 297 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 282 ExpressionStatement statement = body.block.statements[1] as ExpressionStatem
ent; | 298 ExpressionStatement statement = body.block.statements[1] as ExpressionStatem
ent; |
| 283 PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier; | 299 PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier; |
| 284 SimpleIdentifier variableName = invocation.prefix; | 300 SimpleIdentifier variableName = invocation.prefix; |
| 285 JUnitTestCase.assertSame(typeProvider.stringType, variableName.propagatedTyp
e); | 301 JUnitTestCase.assertSame(typeProvider.stringType, variableName.propagatedTyp
e); |
| 286 } | 302 } |
| 303 |
| 287 void test_is_conditional() { | 304 void test_is_conditional() { |
| 288 Source source = addSource(EngineTestCase.createSource([ | 305 Source source = addSource(EngineTestCase.createSource([ |
| 289 "class A {}", | 306 "class A {}", |
| 290 "A f(var p) {", | 307 "A f(var p) {", |
| 291 " return (p is A) ? p : null;", | 308 " return (p is A) ? p : null;", |
| 292 "}"])); | 309 "}"])); |
| 293 LibraryElement library = resolve(source); | 310 LibraryElement library = resolve(source); |
| 294 assertNoErrors(source); | 311 assertNoErrors(source); |
| 295 verify([source]); | 312 verify([source]); |
| 296 CompilationUnit unit = resolveCompilationUnit(source, library); | 313 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 297 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 314 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 298 InterfaceType typeA = classA.element.type; | 315 InterfaceType typeA = classA.element.type; |
| 299 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 316 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 300 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 317 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 301 ReturnStatement statement = body.block.statements[0] as ReturnStatement; | 318 ReturnStatement statement = body.block.statements[0] as ReturnStatement; |
| 302 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; | 319 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; |
| 303 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi
er; | 320 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi
er; |
| 304 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 321 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 305 } | 322 } |
| 323 |
| 306 void test_is_if() { | 324 void test_is_if() { |
| 307 Source source = addSource(EngineTestCase.createSource([ | 325 Source source = addSource(EngineTestCase.createSource([ |
| 308 "class A {}", | 326 "class A {}", |
| 309 "A f(var p) {", | 327 "A f(var p) {", |
| 310 " if (p is A) {", | 328 " if (p is A) {", |
| 311 " return p;", | 329 " return p;", |
| 312 " } else {", | 330 " } else {", |
| 313 " return null;", | 331 " return null;", |
| 314 " }", | 332 " }", |
| 315 "}"])); | 333 "}"])); |
| 316 LibraryElement library = resolve(source); | 334 LibraryElement library = resolve(source); |
| 317 assertNoErrors(source); | 335 assertNoErrors(source); |
| 318 verify([source]); | 336 verify([source]); |
| 319 CompilationUnit unit = resolveCompilationUnit(source, library); | 337 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 320 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 338 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 321 InterfaceType typeA = classA.element.type; | 339 InterfaceType typeA = classA.element.type; |
| 322 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 340 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 323 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 341 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 324 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 342 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 325 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 343 ReturnStatement statement = (ifStatement.thenStatement as Block).statements[
0] as ReturnStatement; |
| 326 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 344 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 327 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 345 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 328 } | 346 } |
| 347 |
| 329 void test_is_if_lessSpecific() { | 348 void test_is_if_lessSpecific() { |
| 330 Source source = addSource(EngineTestCase.createSource([ | 349 Source source = addSource(EngineTestCase.createSource([ |
| 331 "class A {}", | 350 "class A {}", |
| 332 "A f(A p) {", | 351 "A f(A p) {", |
| 333 " if (p is String) {", | 352 " if (p is String) {", |
| 334 " return p;", | 353 " return p;", |
| 335 " } else {", | 354 " } else {", |
| 336 " return null;", | 355 " return null;", |
| 337 " }", | 356 " }", |
| 338 "}"])); | 357 "}"])); |
| 339 LibraryElement library = resolve(source); | 358 LibraryElement library = resolve(source); |
| 340 assertNoErrors(source); | 359 assertNoErrors(source); |
| 341 verify([source]); | 360 verify([source]); |
| 342 CompilationUnit unit = resolveCompilationUnit(source, library); | 361 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 343 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 362 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 344 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 363 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 345 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 364 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 346 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 365 ReturnStatement statement = (ifStatement.thenStatement as Block).statements[
0] as ReturnStatement; |
| 347 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 366 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 348 JUnitTestCase.assertSame(null, variableName.propagatedType); | 367 JUnitTestCase.assertSame(null, variableName.propagatedType); |
| 349 } | 368 } |
| 369 |
| 350 void test_is_if_logicalAnd() { | 370 void test_is_if_logicalAnd() { |
| 351 Source source = addSource(EngineTestCase.createSource([ | 371 Source source = addSource(EngineTestCase.createSource([ |
| 352 "class A {}", | 372 "class A {}", |
| 353 "A f(var p) {", | 373 "A f(var p) {", |
| 354 " if (p is A && p != null) {", | 374 " if (p is A && p != null) {", |
| 355 " return p;", | 375 " return p;", |
| 356 " } else {", | 376 " } else {", |
| 357 " return null;", | 377 " return null;", |
| 358 " }", | 378 " }", |
| 359 "}"])); | 379 "}"])); |
| 360 LibraryElement library = resolve(source); | 380 LibraryElement library = resolve(source); |
| 361 assertNoErrors(source); | 381 assertNoErrors(source); |
| 362 verify([source]); | 382 verify([source]); |
| 363 CompilationUnit unit = resolveCompilationUnit(source, library); | 383 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 364 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 384 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 365 InterfaceType typeA = classA.element.type; | 385 InterfaceType typeA = classA.element.type; |
| 366 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 386 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 367 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 387 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 368 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 388 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 369 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 389 ReturnStatement statement = (ifStatement.thenStatement as Block).statements[
0] as ReturnStatement; |
| 370 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 390 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 371 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 391 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 372 } | 392 } |
| 393 |
| 373 void test_is_postConditional() { | 394 void test_is_postConditional() { |
| 374 Source source = addSource(EngineTestCase.createSource([ | 395 Source source = addSource(EngineTestCase.createSource([ |
| 375 "class A {}", | 396 "class A {}", |
| 376 "A f(var p) {", | 397 "A f(var p) {", |
| 377 " A a = (p is A) ? p : throw null;", | 398 " A a = (p is A) ? p : throw null;", |
| 378 " return p;", | 399 " return p;", |
| 379 "}"])); | 400 "}"])); |
| 380 LibraryElement library = resolve(source); | 401 LibraryElement library = resolve(source); |
| 381 assertNoErrors(source); | 402 assertNoErrors(source); |
| 382 verify([source]); | 403 verify([source]); |
| 383 CompilationUnit unit = resolveCompilationUnit(source, library); | 404 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 384 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 405 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 385 InterfaceType typeA = classA.element.type; | 406 InterfaceType typeA = classA.element.type; |
| 386 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 407 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 387 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 408 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 388 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 409 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 389 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 410 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 390 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 411 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 391 } | 412 } |
| 413 |
| 392 void test_is_postIf() { | 414 void test_is_postIf() { |
| 393 Source source = addSource(EngineTestCase.createSource([ | 415 Source source = addSource(EngineTestCase.createSource([ |
| 394 "class A {}", | 416 "class A {}", |
| 395 "A f(var p) {", | 417 "A f(var p) {", |
| 396 " if (p is A) {", | 418 " if (p is A) {", |
| 397 " A a = p;", | 419 " A a = p;", |
| 398 " } else {", | 420 " } else {", |
| 399 " return null;", | 421 " return null;", |
| 400 " }", | 422 " }", |
| 401 " return p;", | 423 " return p;", |
| 402 "}"])); | 424 "}"])); |
| 403 LibraryElement library = resolve(source); | 425 LibraryElement library = resolve(source); |
| 404 assertNoErrors(source); | 426 assertNoErrors(source); |
| 405 verify([source]); | 427 verify([source]); |
| 406 CompilationUnit unit = resolveCompilationUnit(source, library); | 428 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 407 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 429 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 408 InterfaceType typeA = classA.element.type; | 430 InterfaceType typeA = classA.element.type; |
| 409 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 431 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 410 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 432 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 411 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 433 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 412 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 434 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 413 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 435 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 414 } | 436 } |
| 437 |
| 415 void test_is_subclass() { | 438 void test_is_subclass() { |
| 416 Source source = addSource(EngineTestCase.createSource([ | 439 Source source = addSource(EngineTestCase.createSource([ |
| 417 "class A {}", | 440 "class A {}", |
| 418 "class B extends A {", | 441 "class B extends A {", |
| 419 " B m() => this;", | 442 " B m() => this;", |
| 420 "}", | 443 "}", |
| 421 "A f(A p) {", | 444 "A f(A p) {", |
| 422 " if (p is B) {", | 445 " if (p is B) {", |
| 423 " return p.m();", | 446 " return p.m();", |
| 424 " }", | 447 " }", |
| 425 "}"])); | 448 "}"])); |
| 426 LibraryElement library = resolve(source); | 449 LibraryElement library = resolve(source); |
| 427 assertNoErrors(source); | 450 assertNoErrors(source); |
| 428 CompilationUnit unit = resolveCompilationUnit(source, library); | 451 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 429 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration; | 452 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration; |
| 430 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 453 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 431 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 454 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 432 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 455 ReturnStatement statement = (ifStatement.thenStatement as Block).statements[
0] as ReturnStatement; |
| 433 MethodInvocation invocation = statement.expression as MethodInvocation; | 456 MethodInvocation invocation = statement.expression as MethodInvocation; |
| 434 JUnitTestCase.assertNotNull(invocation.methodName.propagatedElement); | 457 JUnitTestCase.assertNotNull(invocation.methodName.propagatedElement); |
| 435 } | 458 } |
| 459 |
| 436 void test_is_while() { | 460 void test_is_while() { |
| 437 Source source = addSource(EngineTestCase.createSource([ | 461 Source source = addSource(EngineTestCase.createSource([ |
| 438 "class A {}", | 462 "class A {}", |
| 439 "A f(var p) {", | 463 "A f(var p) {", |
| 440 " while (p is A) {", | 464 " while (p is A) {", |
| 441 " return p;", | 465 " return p;", |
| 442 " }", | 466 " }", |
| 443 "}"])); | 467 "}"])); |
| 444 LibraryElement library = resolve(source); | 468 LibraryElement library = resolve(source); |
| 445 assertNoErrors(source); | 469 assertNoErrors(source); |
| 446 verify([source]); | 470 verify([source]); |
| 447 CompilationUnit unit = resolveCompilationUnit(source, library); | 471 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 448 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 472 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 449 InterfaceType typeA = classA.element.type; | 473 InterfaceType typeA = classA.element.type; |
| 450 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 474 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 451 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 475 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 452 WhileStatement whileStatement = body.block.statements[0] as WhileStatement; | 476 WhileStatement whileStatement = body.block.statements[0] as WhileStatement; |
| 453 ReturnStatement statement = ((whileStatement.body as Block)).statements[0] a
s ReturnStatement; | 477 ReturnStatement statement = (whileStatement.body as Block).statements[0] as
ReturnStatement; |
| 454 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 478 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 455 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 479 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 456 } | 480 } |
| 481 |
| 457 void test_isNot_conditional() { | 482 void test_isNot_conditional() { |
| 458 Source source = addSource(EngineTestCase.createSource([ | 483 Source source = addSource(EngineTestCase.createSource([ |
| 459 "class A {}", | 484 "class A {}", |
| 460 "A f(var p) {", | 485 "A f(var p) {", |
| 461 " return (p is! A) ? null : p;", | 486 " return (p is! A) ? null : p;", |
| 462 "}"])); | 487 "}"])); |
| 463 LibraryElement library = resolve(source); | 488 LibraryElement library = resolve(source); |
| 464 assertNoErrors(source); | 489 assertNoErrors(source); |
| 465 verify([source]); | 490 verify([source]); |
| 466 CompilationUnit unit = resolveCompilationUnit(source, library); | 491 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 467 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 492 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 468 InterfaceType typeA = classA.element.type; | 493 InterfaceType typeA = classA.element.type; |
| 469 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 494 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 470 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 495 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 471 ReturnStatement statement = body.block.statements[0] as ReturnStatement; | 496 ReturnStatement statement = body.block.statements[0] as ReturnStatement; |
| 472 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; | 497 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; |
| 473 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi
er; | 498 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi
er; |
| 474 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 499 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 475 } | 500 } |
| 501 |
| 476 void test_isNot_if() { | 502 void test_isNot_if() { |
| 477 Source source = addSource(EngineTestCase.createSource([ | 503 Source source = addSource(EngineTestCase.createSource([ |
| 478 "class A {}", | 504 "class A {}", |
| 479 "A f(var p) {", | 505 "A f(var p) {", |
| 480 " if (p is! A) {", | 506 " if (p is! A) {", |
| 481 " return null;", | 507 " return null;", |
| 482 " } else {", | 508 " } else {", |
| 483 " return p;", | 509 " return p;", |
| 484 " }", | 510 " }", |
| 485 "}"])); | 511 "}"])); |
| 486 LibraryElement library = resolve(source); | 512 LibraryElement library = resolve(source); |
| 487 assertNoErrors(source); | 513 assertNoErrors(source); |
| 488 verify([source]); | 514 verify([source]); |
| 489 CompilationUnit unit = resolveCompilationUnit(source, library); | 515 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 490 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 516 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 491 InterfaceType typeA = classA.element.type; | 517 InterfaceType typeA = classA.element.type; |
| 492 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 518 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 493 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 519 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 494 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 520 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 495 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement
s[0] as ReturnStatement; | 521 ReturnStatement statement = (ifStatement.elseStatement as Block).statements[
0] as ReturnStatement; |
| 496 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 522 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 497 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 523 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 498 } | 524 } |
| 525 |
| 499 void test_isNot_if_logicalOr() { | 526 void test_isNot_if_logicalOr() { |
| 500 Source source = addSource(EngineTestCase.createSource([ | 527 Source source = addSource(EngineTestCase.createSource([ |
| 501 "class A {}", | 528 "class A {}", |
| 502 "A f(var p) {", | 529 "A f(var p) {", |
| 503 " if (p is! A || null == p) {", | 530 " if (p is! A || null == p) {", |
| 504 " return null;", | 531 " return null;", |
| 505 " } else {", | 532 " } else {", |
| 506 " return p;", | 533 " return p;", |
| 507 " }", | 534 " }", |
| 508 "}"])); | 535 "}"])); |
| 509 LibraryElement library = resolve(source); | 536 LibraryElement library = resolve(source); |
| 510 assertNoErrors(source); | 537 assertNoErrors(source); |
| 511 CompilationUnit unit = resolveCompilationUnit(source, library); | 538 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 512 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 539 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 513 InterfaceType typeA = classA.element.type; | 540 InterfaceType typeA = classA.element.type; |
| 514 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 541 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 515 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 542 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 516 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 543 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 517 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement
s[0] as ReturnStatement; | 544 ReturnStatement statement = (ifStatement.elseStatement as Block).statements[
0] as ReturnStatement; |
| 518 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 545 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 519 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 546 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 520 } | 547 } |
| 548 |
| 521 void test_isNot_postConditional() { | 549 void test_isNot_postConditional() { |
| 522 Source source = addSource(EngineTestCase.createSource([ | 550 Source source = addSource(EngineTestCase.createSource([ |
| 523 "class A {}", | 551 "class A {}", |
| 524 "A f(var p) {", | 552 "A f(var p) {", |
| 525 " A a = (p is! A) ? throw null : p;", | 553 " A a = (p is! A) ? throw null : p;", |
| 526 " return p;", | 554 " return p;", |
| 527 "}"])); | 555 "}"])); |
| 528 LibraryElement library = resolve(source); | 556 LibraryElement library = resolve(source); |
| 529 assertNoErrors(source); | 557 assertNoErrors(source); |
| 530 verify([source]); | 558 verify([source]); |
| 531 CompilationUnit unit = resolveCompilationUnit(source, library); | 559 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 532 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 560 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 533 InterfaceType typeA = classA.element.type; | 561 InterfaceType typeA = classA.element.type; |
| 534 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 562 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 535 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 563 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 536 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 564 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 537 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 565 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 538 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 566 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 539 } | 567 } |
| 568 |
| 540 void test_isNot_postIf() { | 569 void test_isNot_postIf() { |
| 541 Source source = addSource(EngineTestCase.createSource([ | 570 Source source = addSource(EngineTestCase.createSource([ |
| 542 "class A {}", | 571 "class A {}", |
| 543 "A f(var p) {", | 572 "A f(var p) {", |
| 544 " if (p is! A) {", | 573 " if (p is! A) {", |
| 545 " return null;", | 574 " return null;", |
| 546 " }", | 575 " }", |
| 547 " return p;", | 576 " return p;", |
| 548 "}"])); | 577 "}"])); |
| 549 LibraryElement library = resolve(source); | 578 LibraryElement library = resolve(source); |
| 550 assertNoErrors(source); | 579 assertNoErrors(source); |
| 551 verify([source]); | 580 verify([source]); |
| 552 CompilationUnit unit = resolveCompilationUnit(source, library); | 581 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 553 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 582 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 554 InterfaceType typeA = classA.element.type; | 583 InterfaceType typeA = classA.element.type; |
| 555 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 584 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 556 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 585 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 557 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 586 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 558 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 587 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 559 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 588 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 560 } | 589 } |
| 590 |
| 561 void test_listLiteral_different() { | 591 void test_listLiteral_different() { |
| 562 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, '1', 2];", " return v[2];", "}"])); | 592 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, '1', 2];", " return v[2];", "}"])); |
| 563 LibraryElement library = resolve(source); | 593 LibraryElement library = resolve(source); |
| 564 assertNoErrors(source); | 594 assertNoErrors(source); |
| 565 verify([source]); | 595 verify([source]); |
| 566 CompilationUnit unit = resolveCompilationUnit(source, library); | 596 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 567 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 597 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 568 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 598 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 569 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 599 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 570 IndexExpression indexExpression = statement.expression as IndexExpression; | 600 IndexExpression indexExpression = statement.expression as IndexExpression; |
| 571 JUnitTestCase.assertNull(indexExpression.propagatedType); | 601 JUnitTestCase.assertNull(indexExpression.propagatedType); |
| 572 } | 602 } |
| 603 |
| 573 void test_listLiteral_same() { | 604 void test_listLiteral_same() { |
| 574 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, 1, 2];", " return v[2];", "}"])); | 605 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, 1, 2];", " return v[2];", "}"])); |
| 575 LibraryElement library = resolve(source); | 606 LibraryElement library = resolve(source); |
| 576 assertNoErrors(source); | 607 assertNoErrors(source); |
| 577 verify([source]); | 608 verify([source]); |
| 578 CompilationUnit unit = resolveCompilationUnit(source, library); | 609 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 579 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 610 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 580 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 611 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 581 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 612 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 582 IndexExpression indexExpression = statement.expression as IndexExpression; | 613 IndexExpression indexExpression = statement.expression as IndexExpression; |
| 583 JUnitTestCase.assertSame(typeProvider.intType, indexExpression.propagatedTyp
e); | 614 JUnitTestCase.assertSame(typeProvider.intType, indexExpression.propagatedTyp
e); |
| 584 } | 615 } |
| 616 |
| 585 void test_mapLiteral_different() { | 617 void test_mapLiteral_different() { |
| 586 Source source = addSource(EngineTestCase.createSource([ | 618 Source source = addSource(EngineTestCase.createSource([ |
| 587 "f() {", | 619 "f() {", |
| 588 " var v = {'0' : 0, 1 : '1', '2' : 2};", | 620 " var v = {'0' : 0, 1 : '1', '2' : 2};", |
| 589 " return v;", | 621 " return v;", |
| 590 "}"])); | 622 "}"])); |
| 591 LibraryElement library = resolve(source); | 623 LibraryElement library = resolve(source); |
| 592 assertNoErrors(source); | 624 assertNoErrors(source); |
| 593 verify([source]); | 625 verify([source]); |
| 594 CompilationUnit unit = resolveCompilationUnit(source, library); | 626 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 595 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 627 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 596 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 628 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 597 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 629 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 598 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; | 630 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; |
| 599 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; | 631 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; |
| 600 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen
t); | 632 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen
t); |
| 601 List<Type2> typeArguments = propagatedType.typeArguments; | 633 List<Type2> typeArguments = propagatedType.typeArguments; |
| 602 EngineTestCase.assertLength(2, typeArguments); | 634 EngineTestCase.assertLength(2, typeArguments); |
| 603 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[0]); | 635 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[0]); |
| 604 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[1]); | 636 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[1]); |
| 605 } | 637 } |
| 638 |
| 606 void test_mapLiteral_same() { | 639 void test_mapLiteral_same() { |
| 607 Source source = addSource(EngineTestCase.createSource([ | 640 Source source = addSource(EngineTestCase.createSource([ |
| 608 "f() {", | 641 "f() {", |
| 609 " var v = {'a' : 0, 'b' : 1, 'c' : 2};", | 642 " var v = {'a' : 0, 'b' : 1, 'c' : 2};", |
| 610 " return v;", | 643 " return v;", |
| 611 "}"])); | 644 "}"])); |
| 612 LibraryElement library = resolve(source); | 645 LibraryElement library = resolve(source); |
| 613 assertNoErrors(source); | 646 assertNoErrors(source); |
| 614 verify([source]); | 647 verify([source]); |
| 615 CompilationUnit unit = resolveCompilationUnit(source, library); | 648 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 616 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 649 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 617 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 650 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 618 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 651 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 619 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; | 652 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; |
| 620 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; | 653 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; |
| 621 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen
t); | 654 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen
t); |
| 622 List<Type2> typeArguments = propagatedType.typeArguments; | 655 List<Type2> typeArguments = propagatedType.typeArguments; |
| 623 EngineTestCase.assertLength(2, typeArguments); | 656 EngineTestCase.assertLength(2, typeArguments); |
| 624 JUnitTestCase.assertSame(typeProvider.stringType, typeArguments[0]); | 657 JUnitTestCase.assertSame(typeProvider.stringType, typeArguments[0]); |
| 625 JUnitTestCase.assertSame(typeProvider.intType, typeArguments[1]); | 658 JUnitTestCase.assertSame(typeProvider.intType, typeArguments[1]); |
| 626 } | 659 } |
| 660 |
| 627 void test_propagatedReturnType_function_hasReturnType_returnsNull() { | 661 void test_propagatedReturnType_function_hasReturnType_returnsNull() { |
| 628 String code = EngineTestCase.createSource(["String f() => null;", "main() {"
, " var v = f();", "}"]); | 662 String code = EngineTestCase.createSource(["String f() => null;", "main() {"
, " var v = f();", "}"]); |
| 629 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.stri
ngType); | 663 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.stri
ngType); |
| 630 } | 664 } |
| 665 |
| 631 void test_propagatedReturnType_function_lessSpecificStaticReturnType() { | 666 void test_propagatedReturnType_function_lessSpecificStaticReturnType() { |
| 632 String code = EngineTestCase.createSource(["Object f() => 42;", "main() {",
" var v = f();", "}"]); | 667 String code = EngineTestCase.createSource(["Object f() => 42;", "main() {",
" var v = f();", "}"]); |
| 633 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); | 668 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); |
| 634 } | 669 } |
| 670 |
| 635 void test_propagatedReturnType_function_moreSpecificStaticReturnType() { | 671 void test_propagatedReturnType_function_moreSpecificStaticReturnType() { |
| 636 String code = EngineTestCase.createSource([ | 672 String code = EngineTestCase.createSource([ |
| 637 "int f(v) => (v as num);", | 673 "int f(v) => (v as num);", |
| 638 "main() {", | 674 "main() {", |
| 639 " var v = f(3);", | 675 " var v = f(3);", |
| 640 "}"]); | 676 "}"]); |
| 641 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); | 677 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); |
| 642 } | 678 } |
| 679 |
| 643 void test_propagatedReturnType_function_noReturnTypeName_blockBody_multipleRet
urns() { | 680 void test_propagatedReturnType_function_noReturnTypeName_blockBody_multipleRet
urns() { |
| 644 String code = EngineTestCase.createSource([ | 681 String code = EngineTestCase.createSource([ |
| 645 "f() {", | 682 "f() {", |
| 646 " if (true) return 0;", | 683 " if (true) return 0;", |
| 647 " return 1.0;", | 684 " return 1.0;", |
| 648 "}", | 685 "}", |
| 649 "main() {", | 686 "main() {", |
| 650 " var v = f();", | 687 " var v = f();", |
| 651 "}"]); | 688 "}"]); |
| 652 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.numT
ype); | 689 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.numT
ype); |
| 653 } | 690 } |
| 691 |
| 654 void test_propagatedReturnType_function_noReturnTypeName_blockBody_oneReturn()
{ | 692 void test_propagatedReturnType_function_noReturnTypeName_blockBody_oneReturn()
{ |
| 655 String code = EngineTestCase.createSource([ | 693 String code = EngineTestCase.createSource([ |
| 656 "f() {", | 694 "f() {", |
| 657 " var z = 42;", | 695 " var z = 42;", |
| 658 " return z;", | 696 " return z;", |
| 659 "}", | 697 "}", |
| 660 "main() {", | 698 "main() {", |
| 661 " var v = f();", | 699 " var v = f();", |
| 662 "}"]); | 700 "}"]); |
| 663 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); | 701 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); |
| 664 } | 702 } |
| 703 |
| 665 void test_propagatedReturnType_function_noReturnTypeName_expressionBody() { | 704 void test_propagatedReturnType_function_noReturnTypeName_expressionBody() { |
| 666 String code = EngineTestCase.createSource(["f() => 42;", "main() {", " var
v = f();", "}"]); | 705 String code = EngineTestCase.createSource(["f() => 42;", "main() {", " var
v = f();", "}"]); |
| 667 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); | 706 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); |
| 668 } | 707 } |
| 708 |
| 669 void test_propagatedReturnType_localFunction() { | 709 void test_propagatedReturnType_localFunction() { |
| 670 String code = EngineTestCase.createSource(["main() {", " f() => 42;", " va
r v = f();", "}"]); | 710 String code = EngineTestCase.createSource(["main() {", " f() => 42;", " va
r v = f();", "}"]); |
| 671 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); | 711 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); |
| 672 } | 712 } |
| 713 |
| 673 void test_query() { | 714 void test_query() { |
| 674 Source source = addSource(EngineTestCase.createSource([ | 715 Source source = addSource(EngineTestCase.createSource([ |
| 675 "import 'dart:html';", | 716 "import 'dart:html';", |
| 676 "", | 717 "", |
| 677 "main() {", | 718 "main() {", |
| 678 " var v1 = query('a');", | 719 " var v1 = query('a');", |
| 679 " var v2 = query('A');", | 720 " var v2 = query('A');", |
| 680 " var v3 = query('body:active');", | 721 " var v3 = query('body:active');", |
| 681 " var v4 = query('button[foo=\"bar\"]');", | 722 " var v4 = query('button[foo=\"bar\"]');", |
| 682 " var v5 = query('div.class');", | 723 " var v5 = query('div.class');", |
| 683 " var v6 = query('input#id');", | 724 " var v6 = query('input#id');", |
| 684 " var v7 = query('select#id');", | 725 " var v7 = query('select#id');", |
| 685 " // invocation of method", | 726 " // invocation of method", |
| 686 " var m1 = document.query('div');", | 727 " var m1 = document.query('div');", |
| 687 " // unsupported currently", | 728 " // unsupported currently", |
| 688 " var b1 = query('noSuchTag');", | 729 " var b1 = query('noSuchTag');", |
| 689 " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');", | 730 " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');", |
| 690 " var b3 = query('body div');", | 731 " var b3 = query('body div');", |
| 691 " return [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", | 732 " return [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", |
| 692 "}"])); | 733 "}"])); |
| 693 LibraryElement library = resolve(source); | 734 LibraryElement library = resolve(source); |
| 694 assertNoErrors(source); | 735 assertNoErrors(source); |
| 695 verify([source]); | 736 verify([source]); |
| 696 CompilationUnit unit = resolveCompilationUnit(source, library); | 737 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 697 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration; | 738 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration; |
| 698 BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody; | 739 BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody; |
| 699 ReturnStatement statement = body.block.statements[11] as ReturnStatement; | 740 ReturnStatement statement = body.block.statements[11] as ReturnStatement; |
| 700 NodeList<Expression> elements = ((statement.expression as ListLiteral)).elem
ents; | 741 NodeList<Expression> elements = (statement.expression as ListLiteral).elemen
ts; |
| 701 JUnitTestCase.assertEquals("AnchorElement", elements[0].propagatedType.name)
; | 742 JUnitTestCase.assertEquals("AnchorElement", elements[0].propagatedType.name)
; |
| 702 JUnitTestCase.assertEquals("AnchorElement", elements[1].propagatedType.name)
; | 743 JUnitTestCase.assertEquals("AnchorElement", elements[1].propagatedType.name)
; |
| 703 JUnitTestCase.assertEquals("BodyElement", elements[2].propagatedType.name); | 744 JUnitTestCase.assertEquals("BodyElement", elements[2].propagatedType.name); |
| 704 JUnitTestCase.assertEquals("ButtonElement", elements[3].propagatedType.name)
; | 745 JUnitTestCase.assertEquals("ButtonElement", elements[3].propagatedType.name)
; |
| 705 JUnitTestCase.assertEquals("DivElement", elements[4].propagatedType.name); | 746 JUnitTestCase.assertEquals("DivElement", elements[4].propagatedType.name); |
| 706 JUnitTestCase.assertEquals("InputElement", elements[5].propagatedType.name); | 747 JUnitTestCase.assertEquals("InputElement", elements[5].propagatedType.name); |
| 707 JUnitTestCase.assertEquals("SelectElement", elements[6].propagatedType.name)
; | 748 JUnitTestCase.assertEquals("SelectElement", elements[6].propagatedType.name)
; |
| 708 JUnitTestCase.assertEquals("DivElement", elements[7].propagatedType.name); | 749 JUnitTestCase.assertEquals("DivElement", elements[7].propagatedType.name); |
| 709 JUnitTestCase.assertEquals("Element", elements[8].propagatedType.name); | 750 JUnitTestCase.assertEquals("Element", elements[8].propagatedType.name); |
| 710 JUnitTestCase.assertEquals("Element", elements[9].propagatedType.name); | 751 JUnitTestCase.assertEquals("Element", elements[9].propagatedType.name); |
| 711 JUnitTestCase.assertEquals("Element", elements[10].propagatedType.name); | 752 JUnitTestCase.assertEquals("Element", elements[10].propagatedType.name); |
| 712 } | 753 } |
| 713 | 754 |
| 714 /** | 755 /** |
| 715 * @param code the code that assigns the value to the variable "v", no matter
how. We check that | 756 * @param code the code that assigns the value to the variable "v", no matter
how. We check that |
| 716 * "v" has expected static and propagated type. | 757 * "v" has expected static and propagated type. |
| 717 */ | 758 */ |
| 718 void check_propagatedReturnType(String code, Type2 expectedStaticType, Type2 e
xpectedPropagatedType) { | 759 void check_propagatedReturnType(String code, Type2 expectedStaticType, Type2 e
xpectedPropagatedType) { |
| 719 Source source = addSource(code); | 760 Source source = addSource(code); |
| 720 LibraryElement library = resolve(source); | 761 LibraryElement library = resolve(source); |
| 721 assertNoErrors(source); | 762 assertNoErrors(source); |
| 722 verify([source]); | 763 verify([source]); |
| 723 CompilationUnit unit = resolveCompilationUnit(source, library); | 764 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 724 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v = ", Si
mpleIdentifier); | 765 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v = ", Si
mpleIdentifier); |
| 725 JUnitTestCase.assertSame(expectedStaticType, identifier.staticType); | 766 JUnitTestCase.assertSame(expectedStaticType, identifier.staticType); |
| 726 JUnitTestCase.assertSame(expectedPropagatedType, identifier.propagatedType); | 767 JUnitTestCase.assertSame(expectedPropagatedType, identifier.propagatedType); |
| 727 } | 768 } |
| 769 |
| 728 static dartSuite() { | 770 static dartSuite() { |
| 729 _ut.group('TypePropagationTest', () { | 771 _ut.group('TypePropagationTest', () { |
| 730 _ut.test('test_Future_then', () { | 772 _ut.test('test_Future_then', () { |
| 731 final __test = new TypePropagationTest(); | 773 final __test = new TypePropagationTest(); |
| 732 runJUnitTest(__test, __test.test_Future_then); | 774 runJUnitTest(__test, __test.test_Future_then); |
| 733 }); | 775 }); |
| 734 _ut.test('test_as', () { | 776 _ut.test('test_as', () { |
| 735 final __test = new TypePropagationTest(); | 777 final __test = new TypePropagationTest(); |
| 736 runJUnitTest(__test, __test.test_as); | 778 runJUnitTest(__test, __test.test_as); |
| 737 }); | 779 }); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 final __test = new TypePropagationTest(); | 917 final __test = new TypePropagationTest(); |
| 876 runJUnitTest(__test, __test.test_propagatedReturnType_localFunction); | 918 runJUnitTest(__test, __test.test_propagatedReturnType_localFunction); |
| 877 }); | 919 }); |
| 878 _ut.test('test_query', () { | 920 _ut.test('test_query', () { |
| 879 final __test = new TypePropagationTest(); | 921 final __test = new TypePropagationTest(); |
| 880 runJUnitTest(__test, __test.test_query); | 922 runJUnitTest(__test, __test.test_query); |
| 881 }); | 923 }); |
| 882 }); | 924 }); |
| 883 } | 925 } |
| 884 } | 926 } |
| 927 |
| 885 class NonErrorResolverTest extends ResolverTestCase { | 928 class NonErrorResolverTest extends ResolverTestCase { |
| 886 void test_ambiguousExport() { | 929 void test_ambiguousExport() { |
| 887 Source source = addSource(EngineTestCase.createSource([ | 930 Source source = addSource(EngineTestCase.createSource([ |
| 888 "library L;", | 931 "library L;", |
| 889 "export 'lib1.dart';", | 932 "export 'lib1.dart';", |
| 890 "export 'lib2.dart';"])); | 933 "export 'lib2.dart';"])); |
| 891 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s M {}"])); | 934 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s M {}"])); |
| 892 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 935 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 893 resolve(source); | 936 resolve(source); |
| 894 assertNoErrors(source); | 937 assertNoErrors(source); |
| 895 verify([source]); | 938 verify([source]); |
| 896 } | 939 } |
| 940 |
| 897 void test_ambiguousExport_combinators_hide() { | 941 void test_ambiguousExport_combinators_hide() { |
| 898 Source source = addSource(EngineTestCase.createSource([ | 942 Source source = addSource(EngineTestCase.createSource([ |
| 899 "library L;", | 943 "library L;", |
| 900 "export 'lib1.dart';", | 944 "export 'lib1.dart';", |
| 901 "export 'lib2.dart' hide B;"])); | 945 "export 'lib2.dart' hide B;"])); |
| 902 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class
A {}", "class B {}"])); | 946 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class
A {}", "class B {}"])); |
| 903 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class
B {}", "class C {}"])); | 947 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class
B {}", "class C {}"])); |
| 904 resolve(source); | 948 resolve(source); |
| 905 assertNoErrors(source); | 949 assertNoErrors(source); |
| 906 verify([source]); | 950 verify([source]); |
| 907 } | 951 } |
| 952 |
| 908 void test_ambiguousExport_combinators_show() { | 953 void test_ambiguousExport_combinators_show() { |
| 909 Source source = addSource(EngineTestCase.createSource([ | 954 Source source = addSource(EngineTestCase.createSource([ |
| 910 "library L;", | 955 "library L;", |
| 911 "export 'lib1.dart';", | 956 "export 'lib1.dart';", |
| 912 "export 'lib2.dart' show C;"])); | 957 "export 'lib2.dart' show C;"])); |
| 913 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class
A {}", "class B {}"])); | 958 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class
A {}", "class B {}"])); |
| 914 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class
B {}", "class C {}"])); | 959 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class
B {}", "class C {}"])); |
| 915 resolve(source); | 960 resolve(source); |
| 916 assertNoErrors(source); | 961 assertNoErrors(source); |
| 917 verify([source]); | 962 verify([source]); |
| 918 } | 963 } |
| 964 |
| 965 void test_ambiguousExport_sameDeclaration() { |
| 966 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib.dart';", "export 'lib.dart';"])); |
| 967 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
N {}"])); |
| 968 resolve(source); |
| 969 assertNoErrors(source); |
| 970 verify([source]); |
| 971 } |
| 972 |
| 919 void test_argumentDefinitionTestNonParameter_formalParameter() { | 973 void test_argumentDefinitionTestNonParameter_formalParameter() { |
| 920 Source source = addSource(EngineTestCase.createSource(["f(var v) {", " retu
rn ?v;", "}"])); | 974 Source source = addSource(EngineTestCase.createSource(["f(var v) {", " retu
rn ?v;", "}"])); |
| 921 resolve(source); | 975 resolve(source); |
| 922 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); | 976 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); |
| 923 verify([source]); | 977 verify([source]); |
| 924 } | 978 } |
| 979 |
| 925 void test_argumentDefinitionTestNonParameter_namedParameter() { | 980 void test_argumentDefinitionTestNonParameter_namedParameter() { |
| 926 Source source = addSource(EngineTestCase.createSource(["f({var v : 0}) {", "
return ?v;", "}"])); | 981 Source source = addSource(EngineTestCase.createSource(["f({var v : 0}) {", "
return ?v;", "}"])); |
| 927 resolve(source); | 982 resolve(source); |
| 928 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); | 983 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); |
| 929 verify([source]); | 984 verify([source]); |
| 930 } | 985 } |
| 986 |
| 931 void test_argumentDefinitionTestNonParameter_optionalParameter() { | 987 void test_argumentDefinitionTestNonParameter_optionalParameter() { |
| 932 Source source = addSource(EngineTestCase.createSource(["f([var v]) {", " re
turn ?v;", "}"])); | 988 Source source = addSource(EngineTestCase.createSource(["f([var v]) {", " re
turn ?v;", "}"])); |
| 933 resolve(source); | 989 resolve(source); |
| 934 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); | 990 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); |
| 935 verify([source]); | 991 verify([source]); |
| 936 } | 992 } |
| 993 |
| 937 void test_argumentTypeNotAssignable_classWithCall_Function() { | 994 void test_argumentTypeNotAssignable_classWithCall_Function() { |
| 938 Source source = addSource(EngineTestCase.createSource([ | 995 Source source = addSource(EngineTestCase.createSource([ |
| 939 " caller(Function callee) {", | 996 " caller(Function callee) {", |
| 940 " callee();", | 997 " callee();", |
| 941 " }", | 998 " }", |
| 942 "", | 999 "", |
| 943 " class CallMeBack {", | 1000 " class CallMeBack {", |
| 944 " call() => 0;", | 1001 " call() => 0;", |
| 945 " }", | 1002 " }", |
| 946 "", | 1003 "", |
| 947 " main() {", | 1004 " main() {", |
| 948 " caller(new CallMeBack());", | 1005 " caller(new CallMeBack());", |
| 949 " }"])); | 1006 " }"])); |
| 950 resolve(source); | 1007 resolve(source); |
| 951 assertNoErrors(source); | 1008 assertNoErrors(source); |
| 952 verify([source]); | 1009 verify([source]); |
| 953 } | 1010 } |
| 1011 |
| 954 void test_argumentTypeNotAssignable_fieldFormalParameterElement_member() { | 1012 void test_argumentTypeNotAssignable_fieldFormalParameterElement_member() { |
| 955 Source source = addSource(EngineTestCase.createSource([ | 1013 Source source = addSource(EngineTestCase.createSource([ |
| 956 "class ObjectSink<T> {", | 1014 "class ObjectSink<T> {", |
| 957 " void sink(T object) {", | 1015 " void sink(T object) {", |
| 958 " new TimestampedObject<T>(object);", | 1016 " new TimestampedObject<T>(object);", |
| 959 " }", | 1017 " }", |
| 960 "}", | 1018 "}", |
| 961 "class TimestampedObject<E> {", | 1019 "class TimestampedObject<E> {", |
| 962 " E object2;", | 1020 " E object2;", |
| 963 " TimestampedObject(this.object2);", | 1021 " TimestampedObject(this.object2);", |
| 964 "}"])); | 1022 "}"])); |
| 965 resolve(source); | 1023 resolve(source); |
| 966 assertNoErrors(source); | 1024 assertNoErrors(source); |
| 967 verify([source]); | 1025 verify([source]); |
| 968 } | 1026 } |
| 1027 |
| 969 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() { | 1028 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() { |
| 970 Source source = addSource(EngineTestCase.createSource([ | 1029 Source source = addSource(EngineTestCase.createSource([ |
| 971 "class A<K> {", | 1030 "class A<K> {", |
| 972 " m(f(K k), K v) {", | 1031 " m(f(K k), K v) {", |
| 973 " f(v);", | 1032 " f(v);", |
| 974 " }", | 1033 " }", |
| 975 "}"])); | 1034 "}"])); |
| 976 resolve(source); | 1035 resolve(source); |
| 977 assertNoErrors(source); | 1036 assertNoErrors(source); |
| 978 verify([source]); | 1037 verify([source]); |
| 979 } | 1038 } |
| 1039 |
| 980 void test_argumentTypeNotAssignable_invocation_typedef_generic() { | 1040 void test_argumentTypeNotAssignable_invocation_typedef_generic() { |
| 981 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);",
"f(A<int> a) {", " a(1);", "}"])); | 1041 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);",
"f(A<int> a) {", " a(1);", "}"])); |
| 982 resolve(source); | 1042 resolve(source); |
| 983 assertNoErrors(source); | 1043 assertNoErrors(source); |
| 984 verify([source]); | 1044 verify([source]); |
| 985 } | 1045 } |
| 1046 |
| 986 void test_argumentTypeNotAssignable_Object_Function() { | 1047 void test_argumentTypeNotAssignable_Object_Function() { |
| 987 Source source = addSource(EngineTestCase.createSource([ | 1048 Source source = addSource(EngineTestCase.createSource([ |
| 988 "main() {", | 1049 "main() {", |
| 989 " process(() {});", | 1050 " process(() {});", |
| 990 "}", | 1051 "}", |
| 991 "process(Object x) {}"])); | 1052 "process(Object x) {}"])); |
| 992 resolve(source); | 1053 resolve(source); |
| 993 assertNoErrors(source); | 1054 assertNoErrors(source); |
| 994 verify([source]); | 1055 verify([source]); |
| 995 } | 1056 } |
| 1057 |
| 996 void test_argumentTypeNotAssignable_typedef_local() { | 1058 void test_argumentTypeNotAssignable_typedef_local() { |
| 997 Source source = addSource(EngineTestCase.createSource([ | 1059 Source source = addSource(EngineTestCase.createSource([ |
| 998 "typedef A(int p1, String p2);", | 1060 "typedef A(int p1, String p2);", |
| 999 "A getA() => null;", | 1061 "A getA() => null;", |
| 1000 "f() {", | 1062 "f() {", |
| 1001 " A a = getA();", | 1063 " A a = getA();", |
| 1002 " a(1, '2');", | 1064 " a(1, '2');", |
| 1003 "}"])); | 1065 "}"])); |
| 1004 resolve(source); | 1066 resolve(source); |
| 1005 assertNoErrors(source); | 1067 assertNoErrors(source); |
| 1006 verify([source]); | 1068 verify([source]); |
| 1007 } | 1069 } |
| 1070 |
| 1008 void test_argumentTypeNotAssignable_typedef_parameter() { | 1071 void test_argumentTypeNotAssignable_typedef_parameter() { |
| 1009 Source source = addSource(EngineTestCase.createSource([ | 1072 Source source = addSource(EngineTestCase.createSource([ |
| 1010 "typedef A(int p1, String p2);", | 1073 "typedef A(int p1, String p2);", |
| 1011 "f(A a) {", | 1074 "f(A a) {", |
| 1012 " a(1, '2');", | 1075 " a(1, '2');", |
| 1013 "}"])); | 1076 "}"])); |
| 1014 resolve(source); | 1077 resolve(source); |
| 1015 assertNoErrors(source); | 1078 assertNoErrors(source); |
| 1016 verify([source]); | 1079 verify([source]); |
| 1017 } | 1080 } |
| 1081 |
| 1018 void test_assignmentToFinal_prefixNegate() { | 1082 void test_assignmentToFinal_prefixNegate() { |
| 1019 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " -x;", "}"])); | 1083 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " -x;", "}"])); |
| 1020 resolve(source); | 1084 resolve(source); |
| 1021 assertNoErrors(source); | 1085 assertNoErrors(source); |
| 1022 verify([source]); | 1086 verify([source]); |
| 1023 } | 1087 } |
| 1088 |
| 1024 void test_assignmentToFinals_importWithPrefix() { | 1089 void test_assignmentToFinals_importWithPrefix() { |
| 1025 Source source = addSource(EngineTestCase.createSource([ | 1090 Source source = addSource(EngineTestCase.createSource([ |
| 1026 "library lib;", | 1091 "library lib;", |
| 1027 "import 'lib1.dart' as foo;", | 1092 "import 'lib1.dart' as foo;", |
| 1028 "main() {", | 1093 "main() {", |
| 1029 " foo.x = true;", | 1094 " foo.x = true;", |
| 1030 "}"])); | 1095 "}"])); |
| 1031 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "bool
x = false;"])); | 1096 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "bool
x = false;"])); |
| 1032 resolve(source); | 1097 resolve(source); |
| 1033 assertNoErrors(source); | 1098 assertNoErrors(source); |
| 1034 verify([source]); | 1099 verify([source]); |
| 1035 } | 1100 } |
| 1101 |
| 1036 void test_breakWithoutLabelInSwitch() { | 1102 void test_breakWithoutLabelInSwitch() { |
| 1037 Source source = addSource(EngineTestCase.createSource([ | 1103 Source source = addSource(EngineTestCase.createSource([ |
| 1038 "class A {", | 1104 "class A {", |
| 1039 " void m(int i) {", | 1105 " void m(int i) {", |
| 1040 " switch (i) {", | 1106 " switch (i) {", |
| 1041 " case 0:", | 1107 " case 0:", |
| 1042 " break;", | 1108 " break;", |
| 1043 " }", | 1109 " }", |
| 1044 " }", | 1110 " }", |
| 1045 "}"])); | 1111 "}"])); |
| 1046 resolve(source); | 1112 resolve(source); |
| 1047 assertNoErrors(source); | 1113 assertNoErrors(source); |
| 1048 verify([source]); | 1114 verify([source]); |
| 1049 } | 1115 } |
| 1116 |
| 1050 void test_builtInIdentifierAsType_dynamic() { | 1117 void test_builtInIdentifierAsType_dynamic() { |
| 1051 Source source = addSource(EngineTestCase.createSource(["f() {", " dynamic x
;", "}"])); | 1118 Source source = addSource(EngineTestCase.createSource(["f() {", " dynamic x
;", "}"])); |
| 1052 resolve(source); | 1119 resolve(source); |
| 1053 assertNoErrors(source); | 1120 assertNoErrors(source); |
| 1054 verify([source]); | 1121 verify([source]); |
| 1055 } | 1122 } |
| 1123 |
| 1056 void test_caseBlockNotTerminated() { | 1124 void test_caseBlockNotTerminated() { |
| 1057 Source source = addSource(EngineTestCase.createSource([ | 1125 Source source = addSource(EngineTestCase.createSource([ |
| 1058 "f(int p) {", | 1126 "f(int p) {", |
| 1059 " for (int i = 0; i < 10; i++) {", | 1127 " for (int i = 0; i < 10; i++) {", |
| 1060 " switch (p) {", | 1128 " switch (p) {", |
| 1061 " case 0:", | 1129 " case 0:", |
| 1062 " break;", | 1130 " break;", |
| 1063 " case 1:", | 1131 " case 1:", |
| 1064 " continue;", | 1132 " continue;", |
| 1065 " case 2:", | 1133 " case 2:", |
| 1066 " return;", | 1134 " return;", |
| 1067 " case 3:", | 1135 " case 3:", |
| 1068 " throw new Object();", | 1136 " throw new Object();", |
| 1069 " case 4:", | 1137 " case 4:", |
| 1070 " case 5:", | 1138 " case 5:", |
| 1071 " return;", | 1139 " return;", |
| 1072 " case 6:", | 1140 " case 6:", |
| 1073 " default:", | 1141 " default:", |
| 1074 " return;", | 1142 " return;", |
| 1075 " }", | 1143 " }", |
| 1076 " }", | 1144 " }", |
| 1077 "}"])); | 1145 "}"])); |
| 1078 resolve(source); | 1146 resolve(source); |
| 1079 assertNoErrors(source); | 1147 assertNoErrors(source); |
| 1080 verify([source]); | 1148 verify([source]); |
| 1081 } | 1149 } |
| 1150 |
| 1082 void test_caseBlockNotTerminated_lastCase() { | 1151 void test_caseBlockNotTerminated_lastCase() { |
| 1083 Source source = addSource(EngineTestCase.createSource([ | 1152 Source source = addSource(EngineTestCase.createSource([ |
| 1084 "f(int p) {", | 1153 "f(int p) {", |
| 1085 " switch (p) {", | 1154 " switch (p) {", |
| 1086 " case 0:", | 1155 " case 0:", |
| 1087 " p = p + 1;", | 1156 " p = p + 1;", |
| 1088 " }", | 1157 " }", |
| 1089 "}"])); | 1158 "}"])); |
| 1090 resolve(source); | 1159 resolve(source); |
| 1091 assertNoErrors(source); | 1160 assertNoErrors(source); |
| 1092 verify([source]); | 1161 verify([source]); |
| 1093 } | 1162 } |
| 1163 |
| 1094 void test_caseExpressionTypeImplementsEquals_int() { | 1164 void test_caseExpressionTypeImplementsEquals_int() { |
| 1095 Source source = addSource(EngineTestCase.createSource([ | 1165 Source source = addSource(EngineTestCase.createSource([ |
| 1096 "f(int i) {", | 1166 "f(int i) {", |
| 1097 " switch(i) {", | 1167 " switch(i) {", |
| 1098 " case(1) : return 1;", | 1168 " case(1) : return 1;", |
| 1099 " default: return 0;", | 1169 " default: return 0;", |
| 1100 " }", | 1170 " }", |
| 1101 "}"])); | 1171 "}"])); |
| 1102 resolve(source); | 1172 resolve(source); |
| 1103 assertNoErrors(source); | 1173 assertNoErrors(source); |
| 1104 verify([source]); | 1174 verify([source]); |
| 1105 } | 1175 } |
| 1176 |
| 1106 void test_caseExpressionTypeImplementsEquals_Object() { | 1177 void test_caseExpressionTypeImplementsEquals_Object() { |
| 1107 Source source = addSource(EngineTestCase.createSource([ | 1178 Source source = addSource(EngineTestCase.createSource([ |
| 1108 "class IntWrapper {", | 1179 "class IntWrapper {", |
| 1109 " final int value;", | 1180 " final int value;", |
| 1110 " const IntWrapper(this.value);", | 1181 " const IntWrapper(this.value);", |
| 1111 "}", | 1182 "}", |
| 1112 "", | 1183 "", |
| 1113 "f(IntWrapper intWrapper) {", | 1184 "f(IntWrapper intWrapper) {", |
| 1114 " switch(intWrapper) {", | 1185 " switch(intWrapper) {", |
| 1115 " case(const IntWrapper(1)) : return 1;", | 1186 " case(const IntWrapper(1)) : return 1;", |
| 1116 " default: return 0;", | 1187 " default: return 0;", |
| 1117 " }", | 1188 " }", |
| 1118 "}"])); | 1189 "}"])); |
| 1119 resolve(source); | 1190 resolve(source); |
| 1120 assertNoErrors(source); | 1191 assertNoErrors(source); |
| 1121 verify([source]); | 1192 verify([source]); |
| 1122 } | 1193 } |
| 1194 |
| 1123 void test_caseExpressionTypeImplementsEquals_String() { | 1195 void test_caseExpressionTypeImplementsEquals_String() { |
| 1124 Source source = addSource(EngineTestCase.createSource([ | 1196 Source source = addSource(EngineTestCase.createSource([ |
| 1125 "f(String s) {", | 1197 "f(String s) {", |
| 1126 " switch(s) {", | 1198 " switch(s) {", |
| 1127 " case('1') : return 1;", | 1199 " case('1') : return 1;", |
| 1128 " default: return 0;", | 1200 " default: return 0;", |
| 1129 " }", | 1201 " }", |
| 1130 "}"])); | 1202 "}"])); |
| 1131 resolve(source); | 1203 resolve(source); |
| 1132 assertNoErrors(source); | 1204 assertNoErrors(source); |
| 1133 verify([source]); | 1205 verify([source]); |
| 1134 } | 1206 } |
| 1207 |
| 1135 void test_concreteClassWithAbstractMember() { | 1208 void test_concreteClassWithAbstractMember() { |
| 1136 Source source = addSource(EngineTestCase.createSource(["abstract class A {",
" m();", "}"])); | 1209 Source source = addSource(EngineTestCase.createSource(["abstract class A {",
" m();", "}"])); |
| 1137 resolve(source); | 1210 resolve(source); |
| 1138 assertNoErrors(source); | 1211 assertNoErrors(source); |
| 1139 verify([source]); | 1212 verify([source]); |
| 1140 } | 1213 } |
| 1214 |
| 1141 void test_conflictingInstanceGetterAndSuperclassMember_instance() { | 1215 void test_conflictingInstanceGetterAndSuperclassMember_instance() { |
| 1142 Source source = addSource(EngineTestCase.createSource([ | 1216 Source source = addSource(EngineTestCase.createSource([ |
| 1143 "class A {", | 1217 "class A {", |
| 1144 " get v => 0;", | 1218 " get v => 0;", |
| 1145 "}", | 1219 "}", |
| 1146 "class B extends A {", | 1220 "class B extends A {", |
| 1147 " get v => 1;", | 1221 " get v => 1;", |
| 1148 "}"])); | 1222 "}"])); |
| 1149 resolve(source); | 1223 resolve(source); |
| 1150 assertNoErrors(source); | 1224 assertNoErrors(source); |
| 1151 verify([source]); | 1225 verify([source]); |
| 1152 } | 1226 } |
| 1227 |
| 1153 void test_conflictingStaticGetterAndInstanceSetter_thisClass() { | 1228 void test_conflictingStaticGetterAndInstanceSetter_thisClass() { |
| 1154 Source source = addSource(EngineTestCase.createSource([ | 1229 Source source = addSource(EngineTestCase.createSource([ |
| 1155 "class A {", | 1230 "class A {", |
| 1156 " static get x => 0;", | 1231 " static get x => 0;", |
| 1157 " static set x(int p) {}", | 1232 " static set x(int p) {}", |
| 1158 "}"])); | 1233 "}"])); |
| 1159 resolve(source); | 1234 resolve(source); |
| 1160 assertNoErrors(source); | 1235 assertNoErrors(source); |
| 1161 verify([source]); | 1236 verify([source]); |
| 1162 } | 1237 } |
| 1238 |
| 1163 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() { | 1239 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() { |
| 1164 Source source = addSource(EngineTestCase.createSource([ | 1240 Source source = addSource(EngineTestCase.createSource([ |
| 1165 "class A {", | 1241 "class A {", |
| 1166 " static x() {}", | 1242 " static x() {}", |
| 1167 " static set x(int p) {}", | 1243 " static set x(int p) {}", |
| 1168 "}"])); | 1244 "}"])); |
| 1169 resolve(source); | 1245 resolve(source); |
| 1170 assertNoErrors(source); | 1246 assertNoErrors(source); |
| 1171 verify([source]); | 1247 verify([source]); |
| 1172 } | 1248 } |
| 1249 |
| 1173 void test_constConstructorWithNonConstSuper_redirectingFactory() { | 1250 void test_constConstructorWithNonConstSuper_redirectingFactory() { |
| 1174 Source source = addSource(EngineTestCase.createSource([ | 1251 Source source = addSource(EngineTestCase.createSource([ |
| 1175 "class A {", | 1252 "class A {", |
| 1176 " A();", | 1253 " A();", |
| 1177 "}", | 1254 "}", |
| 1178 "class B implements C {", | 1255 "class B implements C {", |
| 1179 " const B();", | 1256 " const B();", |
| 1180 "}", | 1257 "}", |
| 1181 "class C extends A {", | 1258 "class C extends A {", |
| 1182 " const factory C() = B;", | 1259 " const factory C() = B;", |
| 1183 "}"])); | 1260 "}"])); |
| 1184 resolve(source); | 1261 resolve(source); |
| 1185 assertNoErrors(source); | 1262 assertNoErrors(source); |
| 1186 verify([source]); | 1263 verify([source]); |
| 1187 } | 1264 } |
| 1265 |
| 1188 void test_constConstructorWithNonFinalField_finalInstanceVar() { | 1266 void test_constConstructorWithNonFinalField_finalInstanceVar() { |
| 1189 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " const A();", "}"])); | 1267 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " const A();", "}"])); |
| 1190 resolve(source); | 1268 resolve(source); |
| 1191 assertNoErrors(source); | 1269 assertNoErrors(source); |
| 1192 verify([source]); | 1270 verify([source]); |
| 1193 } | 1271 } |
| 1272 |
| 1194 void test_constConstructorWithNonFinalField_mixin() { | 1273 void test_constConstructorWithNonFinalField_mixin() { |
| 1195 Source source = addSource(EngineTestCase.createSource([ | 1274 Source source = addSource(EngineTestCase.createSource([ |
| 1196 "class A {", | 1275 "class A {", |
| 1197 " a() {}", | 1276 " a() {}", |
| 1198 "}", | 1277 "}", |
| 1199 "class B extends Object with A {", | 1278 "class B extends Object with A {", |
| 1200 " const B();", | 1279 " const B();", |
| 1201 "}"])); | 1280 "}"])); |
| 1202 resolve(source); | 1281 resolve(source); |
| 1203 assertNoErrors(source); | 1282 assertNoErrors(source); |
| 1204 verify([source]); | 1283 verify([source]); |
| 1205 } | 1284 } |
| 1285 |
| 1206 void test_constConstructorWithNonFinalField_static() { | 1286 void test_constConstructorWithNonFinalField_static() { |
| 1207 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " const A();", "}"])); | 1287 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " const A();", "}"])); |
| 1208 resolve(source); | 1288 resolve(source); |
| 1209 assertNoErrors(source); | 1289 assertNoErrors(source); |
| 1210 verify([source]); | 1290 verify([source]); |
| 1211 } | 1291 } |
| 1292 |
| 1212 void test_constConstructorWithNonFinalField_syntheticField() { | 1293 void test_constConstructorWithNonFinalField_syntheticField() { |
| 1213 Source source = addSource(EngineTestCase.createSource([ | 1294 Source source = addSource(EngineTestCase.createSource([ |
| 1214 "class A {", | 1295 "class A {", |
| 1215 " const A();", | 1296 " const A();", |
| 1216 " set x(value) {}", | 1297 " set x(value) {}", |
| 1217 " get x {return 0;}", | 1298 " get x {return 0;}", |
| 1218 "}"])); | 1299 "}"])); |
| 1219 resolve(source); | 1300 resolve(source); |
| 1220 assertNoErrors(source); | 1301 assertNoErrors(source); |
| 1221 verify([source]); | 1302 verify([source]); |
| 1222 } | 1303 } |
| 1304 |
| 1305 void test_constEval_functionTypeLiteral() { |
| 1306 Source source = addSource(EngineTestCase.createSource(["typedef F();", "cons
t C = F;"])); |
| 1307 resolve(source); |
| 1308 assertNoErrors(source); |
| 1309 verify([source]); |
| 1310 } |
| 1311 |
| 1223 void test_constEval_propertyExtraction_fieldStatic_targetType() { | 1312 void test_constEval_propertyExtraction_fieldStatic_targetType() { |
| 1224 addSource2("/math.dart", EngineTestCase.createSource(["library math;", "cons
t PI = 3.14;"])); | 1313 addSource2("/math.dart", EngineTestCase.createSource(["library math;", "cons
t PI = 3.14;"])); |
| 1225 Source source = addSource(EngineTestCase.createSource(["import 'math.dart' a
s math;", "const C = math.PI;"])); | 1314 Source source = addSource(EngineTestCase.createSource(["import 'math.dart' a
s math;", "const C = math.PI;"])); |
| 1226 resolve(source); | 1315 resolve(source); |
| 1227 assertNoErrors(source); | 1316 assertNoErrors(source); |
| 1228 verify([source]); | 1317 verify([source]); |
| 1229 } | 1318 } |
| 1319 |
| 1230 void test_constEval_propertyExtraction_methodStatic_targetType() { | 1320 void test_constEval_propertyExtraction_methodStatic_targetType() { |
| 1231 Source source = addSource(EngineTestCase.createSource([ | 1321 Source source = addSource(EngineTestCase.createSource([ |
| 1232 "class A {", | 1322 "class A {", |
| 1233 " const A();", | 1323 " const A();", |
| 1234 " static m() {}", | 1324 " static m() {}", |
| 1235 "}", | 1325 "}", |
| 1236 "const C = A.m;"])); | 1326 "const C = A.m;"])); |
| 1237 resolve(source); | 1327 resolve(source); |
| 1238 assertNoErrors(source); | 1328 assertNoErrors(source); |
| 1239 verify([source]); | 1329 verify([source]); |
| 1240 } | 1330 } |
| 1331 |
| 1241 void test_constEval_symbol() { | 1332 void test_constEval_symbol() { |
| 1242 addSource2("/math.dart", EngineTestCase.createSource(["library math;", "cons
t PI = 3.14;"])); | 1333 addSource2("/math.dart", EngineTestCase.createSource(["library math;", "cons
t PI = 3.14;"])); |
| 1243 Source source = addSource(EngineTestCase.createSource(["const C = #foo;", "f
oo() {}"])); | 1334 Source source = addSource(EngineTestCase.createSource(["const C = #foo;", "f
oo() {}"])); |
| 1244 resolve(source); | 1335 resolve(source); |
| 1245 assertNoErrors(source); | 1336 assertNoErrors(source); |
| 1246 verify([source]); | 1337 verify([source]); |
| 1247 } | 1338 } |
| 1339 |
| 1248 void test_constEvalTypeBoolNumString_equal() { | 1340 void test_constEvalTypeBoolNumString_equal() { |
| 1249 Source source = addSource(EngineTestCase.createSource([ | 1341 Source source = addSource(EngineTestCase.createSource([ |
| 1250 "class A {", | 1342 "class A {", |
| 1251 " const A();", | 1343 " const A();", |
| 1252 "}", | 1344 "}", |
| 1253 "class B {", | 1345 "class B {", |
| 1254 " final v;", | 1346 " final v;", |
| 1255 " const B.a1(bool p) : v = p == true;", | 1347 " const B.a1(bool p) : v = p == true;", |
| 1256 " const B.a2(bool p) : v = p == false;", | 1348 " const B.a2(bool p) : v = p == false;", |
| 1257 " const B.a3(bool p) : v = p == 0;", | 1349 " const B.a3(bool p) : v = p == 0;", |
| 1258 " const B.a4(bool p) : v = p == 0.0;", | 1350 " const B.a4(bool p) : v = p == 0.0;", |
| 1259 " const B.a5(bool p) : v = p == '';", | 1351 " const B.a5(bool p) : v = p == '';", |
| 1260 " const B.b1(int p) : v = p == true;", | 1352 " const B.b1(int p) : v = p == true;", |
| 1261 " const B.b2(int p) : v = p == false;", | 1353 " const B.b2(int p) : v = p == false;", |
| 1262 " const B.b3(int p) : v = p == 0;", | 1354 " const B.b3(int p) : v = p == 0;", |
| 1263 " const B.b4(int p) : v = p == 0.0;", | 1355 " const B.b4(int p) : v = p == 0.0;", |
| 1264 " const B.b5(int p) : v = p == '';", | 1356 " const B.b5(int p) : v = p == '';", |
| 1265 " const B.c1(String p) : v = p == true;", | 1357 " const B.c1(String p) : v = p == true;", |
| 1266 " const B.c2(String p) : v = p == false;", | 1358 " const B.c2(String p) : v = p == false;", |
| 1267 " const B.c3(String p) : v = p == 0;", | 1359 " const B.c3(String p) : v = p == 0;", |
| 1268 " const B.c4(String p) : v = p == 0.0;", | 1360 " const B.c4(String p) : v = p == 0.0;", |
| 1269 " const B.c5(String p) : v = p == '';", | 1361 " const B.c5(String p) : v = p == '';", |
| 1270 " const B.n1(num p) : v = p == null;", | 1362 " const B.n1(num p) : v = p == null;", |
| 1271 " const B.n2(num p) : v = null == p;", | 1363 " const B.n2(num p) : v = null == p;", |
| 1272 "}"])); | 1364 "}"])); |
| 1273 resolve(source); | 1365 resolve(source); |
| 1274 assertNoErrors(source); | 1366 assertNoErrors(source); |
| 1275 } | 1367 } |
| 1368 |
| 1276 void test_constEvalTypeBoolNumString_notEqual() { | 1369 void test_constEvalTypeBoolNumString_notEqual() { |
| 1277 Source source = addSource(EngineTestCase.createSource([ | 1370 Source source = addSource(EngineTestCase.createSource([ |
| 1278 "class A {", | 1371 "class A {", |
| 1279 " const A();", | 1372 " const A();", |
| 1280 "}", | 1373 "}", |
| 1281 "class B {", | 1374 "class B {", |
| 1282 " final v;", | 1375 " final v;", |
| 1283 " const B.a1(bool p) : v = p != true;", | 1376 " const B.a1(bool p) : v = p != true;", |
| 1284 " const B.a2(bool p) : v = p != false;", | 1377 " const B.a2(bool p) : v = p != false;", |
| 1285 " const B.a3(bool p) : v = p != 0;", | 1378 " const B.a3(bool p) : v = p != 0;", |
| 1286 " const B.a4(bool p) : v = p != 0.0;", | 1379 " const B.a4(bool p) : v = p != 0.0;", |
| 1287 " const B.a5(bool p) : v = p != '';", | 1380 " const B.a5(bool p) : v = p != '';", |
| 1288 " const B.b1(int p) : v = p != true;", | 1381 " const B.b1(int p) : v = p != true;", |
| 1289 " const B.b2(int p) : v = p != false;", | 1382 " const B.b2(int p) : v = p != false;", |
| 1290 " const B.b3(int p) : v = p != 0;", | 1383 " const B.b3(int p) : v = p != 0;", |
| 1291 " const B.b4(int p) : v = p != 0.0;", | 1384 " const B.b4(int p) : v = p != 0.0;", |
| 1292 " const B.b5(int p) : v = p != '';", | 1385 " const B.b5(int p) : v = p != '';", |
| 1293 " const B.c1(String p) : v = p != true;", | 1386 " const B.c1(String p) : v = p != true;", |
| 1294 " const B.c2(String p) : v = p != false;", | 1387 " const B.c2(String p) : v = p != false;", |
| 1295 " const B.c3(String p) : v = p != 0;", | 1388 " const B.c3(String p) : v = p != 0;", |
| 1296 " const B.c4(String p) : v = p != 0.0;", | 1389 " const B.c4(String p) : v = p != 0.0;", |
| 1297 " const B.c5(String p) : v = p != '';", | 1390 " const B.c5(String p) : v = p != '';", |
| 1298 " const B.n1(num p) : v = p != null;", | 1391 " const B.n1(num p) : v = p != null;", |
| 1299 " const B.n2(num p) : v = null != p;", | 1392 " const B.n2(num p) : v = null != p;", |
| 1300 "}"])); | 1393 "}"])); |
| 1301 resolve(source); | 1394 resolve(source); |
| 1302 assertNoErrors(source); | 1395 assertNoErrors(source); |
| 1303 verify([source]); | 1396 verify([source]); |
| 1304 } | 1397 } |
| 1398 |
| 1305 void test_constNotInitialized_field() { | 1399 void test_constNotInitialized_field() { |
| 1306 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c const int x = 0;", "}"])); | 1400 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c const int x = 0;", "}"])); |
| 1307 resolve(source); | 1401 resolve(source); |
| 1308 assertNoErrors(source); | 1402 assertNoErrors(source); |
| 1309 verify([source]); | 1403 verify([source]); |
| 1310 } | 1404 } |
| 1405 |
| 1311 void test_constNotInitialized_local() { | 1406 void test_constNotInitialized_local() { |
| 1312 Source source = addSource(EngineTestCase.createSource(["main() {", " const
int x = 0;", "}"])); | 1407 Source source = addSource(EngineTestCase.createSource(["main() {", " const
int x = 0;", "}"])); |
| 1313 resolve(source); | 1408 resolve(source); |
| 1314 assertNoErrors(source); | 1409 assertNoErrors(source); |
| 1315 verify([source]); | 1410 verify([source]); |
| 1316 } | 1411 } |
| 1412 |
| 1317 void test_constructorDeclaration_scope_signature() { | 1413 void test_constructorDeclaration_scope_signature() { |
| 1318 Source source = addSource(EngineTestCase.createSource([ | 1414 Source source = addSource(EngineTestCase.createSource([ |
| 1319 "const app = 0;", | 1415 "const app = 0;", |
| 1320 "class A {", | 1416 "class A {", |
| 1321 " A(@app int app) {}", | 1417 " A(@app int app) {}", |
| 1322 "}"])); | 1418 "}"])); |
| 1323 resolve(source); | 1419 resolve(source); |
| 1324 assertNoErrors(source); | 1420 assertNoErrors(source); |
| 1325 verify([source]); | 1421 verify([source]); |
| 1326 } | 1422 } |
| 1423 |
| 1327 void test_constWithNonConstantArgument_literals() { | 1424 void test_constWithNonConstantArgument_literals() { |
| 1328 Source source = addSource(EngineTestCase.createSource([ | 1425 Source source = addSource(EngineTestCase.createSource([ |
| 1329 "class A {", | 1426 "class A {", |
| 1330 " const A(a, b, c, d);", | 1427 " const A(a, b, c, d);", |
| 1331 "}", | 1428 "}", |
| 1332 "f() { return const A(true, 0, 1.0, '2'); }"])); | 1429 "f() { return const A(true, 0, 1.0, '2'); }"])); |
| 1333 resolve(source); | 1430 resolve(source); |
| 1334 assertNoErrors(source); | 1431 assertNoErrors(source); |
| 1335 verify([source]); | 1432 verify([source]); |
| 1336 } | 1433 } |
| 1434 |
| 1337 void test_constWithTypeParameters_direct() { | 1435 void test_constWithTypeParameters_direct() { |
| 1338 Source source = addSource(EngineTestCase.createSource([ | 1436 Source source = addSource(EngineTestCase.createSource([ |
| 1339 "class A<T> {", | 1437 "class A<T> {", |
| 1340 " static const V = const A<int>();", | 1438 " static const V = const A<int>();", |
| 1341 " const A();", | 1439 " const A();", |
| 1342 "}"])); | 1440 "}"])); |
| 1343 resolve(source); | 1441 resolve(source); |
| 1344 assertNoErrors(source); | 1442 assertNoErrors(source); |
| 1345 verify([source]); | 1443 verify([source]); |
| 1346 } | 1444 } |
| 1445 |
| 1347 void test_constWithUndefinedConstructor() { | 1446 void test_constWithUndefinedConstructor() { |
| 1348 Source source = addSource(EngineTestCase.createSource([ | 1447 Source source = addSource(EngineTestCase.createSource([ |
| 1349 "class A {", | 1448 "class A {", |
| 1350 " const A.name();", | 1449 " const A.name();", |
| 1351 "}", | 1450 "}", |
| 1352 "f() {", | 1451 "f() {", |
| 1353 " return const A.name();", | 1452 " return const A.name();", |
| 1354 "}"])); | 1453 "}"])); |
| 1355 resolve(source); | 1454 resolve(source); |
| 1356 assertNoErrors(source); | 1455 assertNoErrors(source); |
| 1357 verify([source]); | 1456 verify([source]); |
| 1358 } | 1457 } |
| 1458 |
| 1359 void test_constWithUndefinedConstructorDefault() { | 1459 void test_constWithUndefinedConstructorDefault() { |
| 1360 Source source = addSource(EngineTestCase.createSource([ | 1460 Source source = addSource(EngineTestCase.createSource([ |
| 1361 "class A {", | 1461 "class A {", |
| 1362 " const A();", | 1462 " const A();", |
| 1363 "}", | 1463 "}", |
| 1364 "f() {", | 1464 "f() {", |
| 1365 " return const A();", | 1465 " return const A();", |
| 1366 "}"])); | 1466 "}"])); |
| 1367 resolve(source); | 1467 resolve(source); |
| 1368 assertNoErrors(source); | 1468 assertNoErrors(source); |
| 1369 verify([source]); | 1469 verify([source]); |
| 1370 } | 1470 } |
| 1471 |
| 1371 void test_defaultValueInFunctionTypeAlias() { | 1472 void test_defaultValueInFunctionTypeAlias() { |
| 1372 Source source = addSource(EngineTestCase.createSource(["typedef F([x]);"])); | 1473 Source source = addSource(EngineTestCase.createSource(["typedef F([x]);"])); |
| 1373 resolve(source); | 1474 resolve(source); |
| 1374 assertNoErrors(source); | 1475 assertNoErrors(source); |
| 1375 verify([source]); | 1476 verify([source]); |
| 1376 } | 1477 } |
| 1478 |
| 1377 void test_defaultValueInFunctionTypedParameter_named() { | 1479 void test_defaultValueInFunctionTypedParameter_named() { |
| 1378 Source source = addSource(EngineTestCase.createSource(["f(g({p})) {}"])); | 1480 Source source = addSource(EngineTestCase.createSource(["f(g({p})) {}"])); |
| 1379 resolve(source); | 1481 resolve(source); |
| 1380 assertNoErrors(source); | 1482 assertNoErrors(source); |
| 1381 verify([source]); | 1483 verify([source]); |
| 1382 } | 1484 } |
| 1485 |
| 1383 void test_defaultValueInFunctionTypedParameter_optional() { | 1486 void test_defaultValueInFunctionTypedParameter_optional() { |
| 1384 Source source = addSource(EngineTestCase.createSource(["f(g([p])) {}"])); | 1487 Source source = addSource(EngineTestCase.createSource(["f(g([p])) {}"])); |
| 1385 resolve(source); | 1488 resolve(source); |
| 1386 assertNoErrors(source); | 1489 assertNoErrors(source); |
| 1387 verify([source]); | 1490 verify([source]); |
| 1388 } | 1491 } |
| 1492 |
| 1389 void test_duplicateDefinition_emptyName() { | 1493 void test_duplicateDefinition_emptyName() { |
| 1390 Source source = addSource(EngineTestCase.createSource([ | 1494 Source source = addSource(EngineTestCase.createSource([ |
| 1391 "Map _globalMap = {", | 1495 "Map _globalMap = {", |
| 1392 " 'a' : () {},", | 1496 " 'a' : () {},", |
| 1393 " 'b' : () {}", | 1497 " 'b' : () {}", |
| 1394 "};"])); | 1498 "};"])); |
| 1395 resolve(source); | 1499 resolve(source); |
| 1396 assertNoErrors(source); | 1500 assertNoErrors(source); |
| 1397 verify([source]); | 1501 verify([source]); |
| 1398 } | 1502 } |
| 1503 |
| 1399 void test_duplicateDefinition_getter() { | 1504 void test_duplicateDefinition_getter() { |
| 1400 Source source = addSource(EngineTestCase.createSource(["bool get a => true;"
])); | 1505 Source source = addSource(EngineTestCase.createSource(["bool get a => true;"
])); |
| 1401 resolve(source); | 1506 resolve(source); |
| 1402 assertNoErrors(source); | 1507 assertNoErrors(source); |
| 1403 verify([source]); | 1508 verify([source]); |
| 1404 } | 1509 } |
| 1510 |
| 1405 void test_dynamicIdentifier() { | 1511 void test_dynamicIdentifier() { |
| 1406 Source source = addSource(EngineTestCase.createSource(["main() {", " var v
= dynamic;", "}"])); | 1512 Source source = addSource(EngineTestCase.createSource(["main() {", " var v
= dynamic;", "}"])); |
| 1407 resolve(source); | 1513 resolve(source); |
| 1408 assertNoErrors(source); | 1514 assertNoErrors(source); |
| 1409 verify([source]); | 1515 verify([source]); |
| 1410 } | 1516 } |
| 1517 |
| 1411 void test_expectedOneListTypeArgument() { | 1518 void test_expectedOneListTypeArgument() { |
| 1412 Source source = addSource(EngineTestCase.createSource(["main() {", " <int>
[];", "}"])); | 1519 Source source = addSource(EngineTestCase.createSource(["main() {", " <int>
[];", "}"])); |
| 1413 resolve(source); | 1520 resolve(source); |
| 1414 assertNoErrors(source); | 1521 assertNoErrors(source); |
| 1415 verify([source]); | 1522 verify([source]); |
| 1416 } | 1523 } |
| 1524 |
| 1417 void test_expectedTwoMapTypeArguments() { | 1525 void test_expectedTwoMapTypeArguments() { |
| 1418 Source source = addSource(EngineTestCase.createSource(["main() {", " <int,
int> {};", "}"])); | 1526 Source source = addSource(EngineTestCase.createSource(["main() {", " <int,
int> {};", "}"])); |
| 1419 resolve(source); | 1527 resolve(source); |
| 1420 assertNoErrors(source); | 1528 assertNoErrors(source); |
| 1421 verify([source]); | 1529 verify([source]); |
| 1422 } | 1530 } |
| 1531 |
| 1423 void test_exportOfNonLibrary_libraryDeclared() { | 1532 void test_exportOfNonLibrary_libraryDeclared() { |
| 1424 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); | 1533 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); |
| 1425 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); | 1534 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); |
| 1426 resolve(source); | 1535 resolve(source); |
| 1427 assertNoErrors(source); | 1536 assertNoErrors(source); |
| 1428 verify([source]); | 1537 verify([source]); |
| 1429 } | 1538 } |
| 1539 |
| 1430 void test_exportOfNonLibrary_libraryNotDeclared() { | 1540 void test_exportOfNonLibrary_libraryNotDeclared() { |
| 1431 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); | 1541 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); |
| 1432 addSource2("/lib1.dart", EngineTestCase.createSource([""])); | 1542 addSource2("/lib1.dart", EngineTestCase.createSource([""])); |
| 1433 resolve(source); | 1543 resolve(source); |
| 1434 assertNoErrors(source); | 1544 assertNoErrors(source); |
| 1435 verify([source]); | 1545 verify([source]); |
| 1436 } | 1546 } |
| 1547 |
| 1437 void test_extraPositionalArguments_function() { | 1548 void test_extraPositionalArguments_function() { |
| 1438 Source source = addSource(EngineTestCase.createSource(["f(p1, p2) {}", "main
() {", " f(1, 2);", "}"])); | 1549 Source source = addSource(EngineTestCase.createSource(["f(p1, p2) {}", "main
() {", " f(1, 2);", "}"])); |
| 1439 resolve(source); | 1550 resolve(source); |
| 1440 assertNoErrors(source); | 1551 assertNoErrors(source); |
| 1441 verify([source]); | 1552 verify([source]); |
| 1442 } | 1553 } |
| 1554 |
| 1443 void test_extraPositionalArguments_Function() { | 1555 void test_extraPositionalArguments_Function() { |
| 1444 Source source = addSource(EngineTestCase.createSource(["f(Function a) {", "
a(1, 2);", "}"])); | 1556 Source source = addSource(EngineTestCase.createSource(["f(Function a) {", "
a(1, 2);", "}"])); |
| 1445 resolve(source); | 1557 resolve(source); |
| 1446 assertNoErrors(source); | 1558 assertNoErrors(source); |
| 1447 verify([source]); | 1559 verify([source]); |
| 1448 } | 1560 } |
| 1561 |
| 1449 void test_extraPositionalArguments_typedef_local() { | 1562 void test_extraPositionalArguments_typedef_local() { |
| 1450 Source source = addSource(EngineTestCase.createSource([ | 1563 Source source = addSource(EngineTestCase.createSource([ |
| 1451 "typedef A(p1, p2);", | 1564 "typedef A(p1, p2);", |
| 1452 "A getA() => null;", | 1565 "A getA() => null;", |
| 1453 "f() {", | 1566 "f() {", |
| 1454 " A a = getA();", | 1567 " A a = getA();", |
| 1455 " a(1, 2);", | 1568 " a(1, 2);", |
| 1456 "}"])); | 1569 "}"])); |
| 1457 resolve(source); | 1570 resolve(source); |
| 1458 assertNoErrors(source); | 1571 assertNoErrors(source); |
| 1459 verify([source]); | 1572 verify([source]); |
| 1460 } | 1573 } |
| 1574 |
| 1461 void test_extraPositionalArguments_typedef_parameter() { | 1575 void test_extraPositionalArguments_typedef_parameter() { |
| 1462 Source source = addSource(EngineTestCase.createSource(["typedef A(p1, p2);",
"f(A a) {", " a(1, 2);", "}"])); | 1576 Source source = addSource(EngineTestCase.createSource(["typedef A(p1, p2);",
"f(A a) {", " a(1, 2);", "}"])); |
| 1463 resolve(source); | 1577 resolve(source); |
| 1464 assertNoErrors(source); | 1578 assertNoErrors(source); |
| 1465 verify([source]); | 1579 verify([source]); |
| 1466 } | 1580 } |
| 1581 |
| 1467 void test_fieldInitializedByMultipleInitializers() { | 1582 void test_fieldInitializedByMultipleInitializers() { |
| 1468 Source source = addSource(EngineTestCase.createSource([ | 1583 Source source = addSource(EngineTestCase.createSource([ |
| 1469 "class A {", | 1584 "class A {", |
| 1470 " int x;", | 1585 " int x;", |
| 1471 " int y;", | 1586 " int y;", |
| 1472 " A() : x = 0, y = 0 {}", | 1587 " A() : x = 0, y = 0 {}", |
| 1473 "}"])); | 1588 "}"])); |
| 1474 resolve(source); | 1589 resolve(source); |
| 1475 assertNoErrors(source); | 1590 assertNoErrors(source); |
| 1476 verify([source]); | 1591 verify([source]); |
| 1477 } | 1592 } |
| 1593 |
| 1478 void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() { | 1594 void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() { |
| 1479 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
= 0;", " A() : x = 1 {}", "}"])); | 1595 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
= 0;", " A() : x = 1 {}", "}"])); |
| 1480 resolve(source); | 1596 resolve(source); |
| 1481 assertNoErrors(source); | 1597 assertNoErrors(source); |
| 1482 verify([source]); | 1598 verify([source]); |
| 1483 } | 1599 } |
| 1600 |
| 1484 void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() { | 1601 void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() { |
| 1485 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() : x = 1 {}", "}"])); | 1602 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() : x = 1 {}", "}"])); |
| 1486 resolve(source); | 1603 resolve(source); |
| 1487 assertNoErrors(source); | 1604 assertNoErrors(source); |
| 1488 verify([source]); | 1605 verify([source]); |
| 1489 } | 1606 } |
| 1607 |
| 1490 void test_fieldInitializerOutsideConstructor() { | 1608 void test_fieldInitializerOutsideConstructor() { |
| 1491 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); | 1609 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); |
| 1492 resolve(source); | 1610 resolve(source); |
| 1493 assertNoErrors(source); | 1611 assertNoErrors(source); |
| 1494 verify([source]); | 1612 verify([source]); |
| 1495 } | 1613 } |
| 1614 |
| 1496 void test_fieldInitializerOutsideConstructor_defaultParameters() { | 1615 void test_fieldInitializerOutsideConstructor_defaultParameters() { |
| 1497 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A([this.x]) {}", "}"])); | 1616 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A([this.x]) {}", "}"])); |
| 1498 resolve(source); | 1617 resolve(source); |
| 1499 assertNoErrors(source); | 1618 assertNoErrors(source); |
| 1500 verify([source]); | 1619 verify([source]); |
| 1501 } | 1620 } |
| 1621 |
| 1502 void test_fieldInitializerRedirectingConstructor_super() { | 1622 void test_fieldInitializerRedirectingConstructor_super() { |
| 1503 Source source = addSource(EngineTestCase.createSource([ | 1623 Source source = addSource(EngineTestCase.createSource([ |
| 1504 "class A {", | 1624 "class A {", |
| 1505 " A() {}", | 1625 " A() {}", |
| 1506 "}", | 1626 "}", |
| 1507 "class B extends A {", | 1627 "class B extends A {", |
| 1508 " int x;", | 1628 " int x;", |
| 1509 " B(this.x) : super();", | 1629 " B(this.x) : super();", |
| 1510 "}"])); | 1630 "}"])); |
| 1511 resolve(source); | 1631 resolve(source); |
| 1512 assertNoErrors(source); | 1632 assertNoErrors(source); |
| 1513 verify([source]); | 1633 verify([source]); |
| 1514 } | 1634 } |
| 1635 |
| 1515 void test_finalInitializedInDeclarationAndConstructor_initializer() { | 1636 void test_finalInitializedInDeclarationAndConstructor_initializer() { |
| 1516 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A() : x = 1 {}", "}"])); | 1637 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A() : x = 1 {}", "}"])); |
| 1517 resolve(source); | 1638 resolve(source); |
| 1518 assertNoErrors(source); | 1639 assertNoErrors(source); |
| 1519 verify([source]); | 1640 verify([source]); |
| 1520 } | 1641 } |
| 1642 |
| 1521 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { | 1643 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { |
| 1522 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x) {}", "}"])); | 1644 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x) {}", "}"])); |
| 1523 resolve(source); | 1645 resolve(source); |
| 1524 assertNoErrors(source); | 1646 assertNoErrors(source); |
| 1525 verify([source]); | 1647 verify([source]); |
| 1526 } | 1648 } |
| 1649 |
| 1527 void test_finalNotInitialized_atDeclaration() { | 1650 void test_finalNotInitialized_atDeclaration() { |
| 1528 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " A() {}", "}"])); | 1651 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " A() {}", "}"])); |
| 1529 resolve(source); | 1652 resolve(source); |
| 1530 assertNoErrors(source); | 1653 assertNoErrors(source); |
| 1531 verify([source]); | 1654 verify([source]); |
| 1532 } | 1655 } |
| 1656 |
| 1533 void test_finalNotInitialized_fieldFormal() { | 1657 void test_finalNotInitialized_fieldFormal() { |
| 1534 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " A() {}", "}"])); | 1658 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " A() {}", "}"])); |
| 1535 resolve(source); | 1659 resolve(source); |
| 1536 assertNoErrors(source); | 1660 assertNoErrors(source); |
| 1537 verify([source]); | 1661 verify([source]); |
| 1538 } | 1662 } |
| 1663 |
| 1539 void test_finalNotInitialized_functionTypedFieldFormal() { | 1664 void test_finalNotInitialized_functionTypedFieldFormal() { |
| 1540 Source source = addSource(EngineTestCase.createSource([ | 1665 Source source = addSource(EngineTestCase.createSource([ |
| 1541 "class A {", | 1666 "class A {", |
| 1542 " final Function x;", | 1667 " final Function x;", |
| 1543 " A(int this.x(int p)) {}", | 1668 " A(int this.x(int p)) {}", |
| 1544 "}"])); | 1669 "}"])); |
| 1545 resolve(source); | 1670 resolve(source); |
| 1546 assertNoErrors(source); | 1671 assertNoErrors(source); |
| 1547 verify([source]); | 1672 verify([source]); |
| 1548 } | 1673 } |
| 1674 |
| 1549 void test_finalNotInitialized_hasNativeClause_hasConstructor() { | 1675 void test_finalNotInitialized_hasNativeClause_hasConstructor() { |
| 1550 Source source = addSource(EngineTestCase.createSource([ | 1676 Source source = addSource(EngineTestCase.createSource([ |
| 1551 "class A native 'something' {", | 1677 "class A native 'something' {", |
| 1552 " final int x;", | 1678 " final int x;", |
| 1553 " A() {}", | 1679 " A() {}", |
| 1554 "}"])); | 1680 "}"])); |
| 1555 resolve(source); | 1681 resolve(source); |
| 1556 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); | 1682 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); |
| 1557 verify([source]); | 1683 verify([source]); |
| 1558 } | 1684 } |
| 1685 |
| 1559 void test_finalNotInitialized_hasNativeClause_noConstructor() { | 1686 void test_finalNotInitialized_hasNativeClause_noConstructor() { |
| 1560 Source source = addSource(EngineTestCase.createSource(["class A native 'some
thing' {", " final int x;", "}"])); | 1687 Source source = addSource(EngineTestCase.createSource(["class A native 'some
thing' {", " final int x;", "}"])); |
| 1561 resolve(source); | 1688 resolve(source); |
| 1562 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); | 1689 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); |
| 1563 verify([source]); | 1690 verify([source]); |
| 1564 } | 1691 } |
| 1692 |
| 1565 void test_finalNotInitialized_initializer() { | 1693 void test_finalNotInitialized_initializer() { |
| 1566 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() : x = 0 {}", "}"])); | 1694 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() : x = 0 {}", "}"])); |
| 1567 resolve(source); | 1695 resolve(source); |
| 1568 assertNoErrors(source); | 1696 assertNoErrors(source); |
| 1569 verify([source]); | 1697 verify([source]); |
| 1570 } | 1698 } |
| 1699 |
| 1571 void test_finalNotInitialized_redirectingConstructor() { | 1700 void test_finalNotInitialized_redirectingConstructor() { |
| 1572 Source source = addSource(EngineTestCase.createSource([ | 1701 Source source = addSource(EngineTestCase.createSource([ |
| 1573 "class A {", | 1702 "class A {", |
| 1574 " final int x;", | 1703 " final int x;", |
| 1575 " A(this.x);", | 1704 " A(this.x);", |
| 1576 " A.named() : this (42);", | 1705 " A.named() : this (42);", |
| 1577 "}"])); | 1706 "}"])); |
| 1578 resolve(source); | 1707 resolve(source); |
| 1579 assertNoErrors(source); | 1708 assertNoErrors(source); |
| 1580 verify([source]); | 1709 verify([source]); |
| 1581 } | 1710 } |
| 1711 |
| 1582 void test_functionDeclaration_scope_returnType() { | 1712 void test_functionDeclaration_scope_returnType() { |
| 1583 Source source = addSource(EngineTestCase.createSource(["int f(int) {}"])); | 1713 Source source = addSource(EngineTestCase.createSource(["int f(int) {}"])); |
| 1584 resolve(source); | 1714 resolve(source); |
| 1585 assertNoErrors(source); | 1715 assertNoErrors(source); |
| 1586 verify([source]); | 1716 verify([source]); |
| 1587 } | 1717 } |
| 1718 |
| 1588 void test_functionDeclaration_scope_signature() { | 1719 void test_functionDeclaration_scope_signature() { |
| 1589 Source source = addSource(EngineTestCase.createSource(["const app = 0;", "f(
@app int app) {}"])); | 1720 Source source = addSource(EngineTestCase.createSource(["const app = 0;", "f(
@app int app) {}"])); |
| 1590 resolve(source); | 1721 resolve(source); |
| 1591 assertNoErrors(source); | 1722 assertNoErrors(source); |
| 1592 verify([source]); | 1723 verify([source]); |
| 1593 } | 1724 } |
| 1725 |
| 1594 void test_functionTypeAlias_scope_returnType() { | 1726 void test_functionTypeAlias_scope_returnType() { |
| 1595 Source source = addSource(EngineTestCase.createSource(["typedef int f(int);"
])); | 1727 Source source = addSource(EngineTestCase.createSource(["typedef int f(int);"
])); |
| 1596 resolve(source); | 1728 resolve(source); |
| 1597 assertNoErrors(source); | 1729 assertNoErrors(source); |
| 1598 verify([source]); | 1730 verify([source]); |
| 1599 } | 1731 } |
| 1732 |
| 1600 void test_functionTypeAlias_scope_signature() { | 1733 void test_functionTypeAlias_scope_signature() { |
| 1601 Source source = addSource(EngineTestCase.createSource(["const app = 0;", "ty
pedef int f(@app int app);"])); | 1734 Source source = addSource(EngineTestCase.createSource(["const app = 0;", "ty
pedef int f(@app int app);"])); |
| 1602 resolve(source); | 1735 resolve(source); |
| 1603 assertNoErrors(source); | 1736 assertNoErrors(source); |
| 1604 verify([source]); | 1737 verify([source]); |
| 1605 } | 1738 } |
| 1739 |
| 1606 void test_functionWithoutCall() { | 1740 void test_functionWithoutCall() { |
| 1607 Source source = addSource(EngineTestCase.createSource([ | 1741 Source source = addSource(EngineTestCase.createSource([ |
| 1608 "abstract class A implements Function {", | 1742 "abstract class A implements Function {", |
| 1609 "}", | 1743 "}", |
| 1610 "class B implements A {", | 1744 "class B implements A {", |
| 1611 " void call() {}", | 1745 " void call() {}", |
| 1612 "}", | 1746 "}", |
| 1613 "class C extends A {", | 1747 "class C extends A {", |
| 1614 " void call() {}", | 1748 " void call() {}", |
| 1615 "}", | 1749 "}", |
| 1616 "class D extends C {", | 1750 "class D extends C {", |
| 1617 "}"])); | 1751 "}"])); |
| 1618 resolve(source); | 1752 resolve(source); |
| 1619 assertNoErrors(source); | 1753 assertNoErrors(source); |
| 1620 verify([source]); | 1754 verify([source]); |
| 1621 } | 1755 } |
| 1756 |
| 1622 void test_implicitThisReferenceInInitializer_constructorName() { | 1757 void test_implicitThisReferenceInInitializer_constructorName() { |
| 1623 Source source = addSource(EngineTestCase.createSource([ | 1758 Source source = addSource(EngineTestCase.createSource([ |
| 1624 "class A {", | 1759 "class A {", |
| 1625 " A.named() {}", | 1760 " A.named() {}", |
| 1626 "}", | 1761 "}", |
| 1627 "class B {", | 1762 "class B {", |
| 1628 " var v;", | 1763 " var v;", |
| 1629 " B() : v = new A.named();", | 1764 " B() : v = new A.named();", |
| 1630 "}"])); | 1765 "}"])); |
| 1631 resolve(source); | 1766 resolve(source); |
| 1632 assertNoErrors(source); | 1767 assertNoErrors(source); |
| 1633 verify([source]); | 1768 verify([source]); |
| 1634 } | 1769 } |
| 1770 |
| 1771 void test_implicitThisReferenceInInitializer_importPrefix() { |
| 1772 Source source = addSource(EngineTestCase.createSource([ |
| 1773 "import 'dart:async' as abstract;", |
| 1774 "class A {", |
| 1775 " var v = new abstract.Completer();", |
| 1776 "}"])); |
| 1777 resolve(source); |
| 1778 assertNoErrors(source); |
| 1779 verify([source]); |
| 1780 } |
| 1781 |
| 1635 void test_implicitThisReferenceInInitializer_prefixedIdentifier() { | 1782 void test_implicitThisReferenceInInitializer_prefixedIdentifier() { |
| 1636 Source source = addSource(EngineTestCase.createSource([ | 1783 Source source = addSource(EngineTestCase.createSource([ |
| 1637 "class A {", | 1784 "class A {", |
| 1638 " var f;", | 1785 " var f;", |
| 1639 "}", | 1786 "}", |
| 1640 "class B {", | 1787 "class B {", |
| 1641 " var v;", | 1788 " var v;", |
| 1642 " B(A a) : v = a.f;", | 1789 " B(A a) : v = a.f;", |
| 1643 "}"])); | 1790 "}"])); |
| 1644 resolve(source); | 1791 resolve(source); |
| 1645 assertNoErrors(source); | 1792 assertNoErrors(source); |
| 1646 verify([source]); | 1793 verify([source]); |
| 1647 } | 1794 } |
| 1795 |
| 1648 void test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() { | 1796 void test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() { |
| 1649 Source source = addSource(EngineTestCase.createSource([ | 1797 Source source = addSource(EngineTestCase.createSource([ |
| 1650 "class A {", | 1798 "class A {", |
| 1651 " f() {}", | 1799 " f() {}", |
| 1652 "}", | 1800 "}", |
| 1653 "class B {", | 1801 "class B {", |
| 1654 " var v;", | 1802 " var v;", |
| 1655 " B() : v = new A().f();", | 1803 " B() : v = new A().f();", |
| 1656 "}"])); | 1804 "}"])); |
| 1657 resolve(source); | 1805 resolve(source); |
| 1658 assertNoErrors(source); | 1806 assertNoErrors(source); |
| 1659 verify([source]); | 1807 verify([source]); |
| 1660 } | 1808 } |
| 1809 |
| 1661 void test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() { | 1810 void test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() { |
| 1662 Source source = addSource(EngineTestCase.createSource([ | 1811 Source source = addSource(EngineTestCase.createSource([ |
| 1663 "class A {", | 1812 "class A {", |
| 1664 " var f;", | 1813 " var f;", |
| 1665 "}", | 1814 "}", |
| 1666 "class B {", | 1815 "class B {", |
| 1667 " var v;", | 1816 " var v;", |
| 1668 " B() : v = new A().f;", | 1817 " B() : v = new A().f;", |
| 1669 "}"])); | 1818 "}"])); |
| 1670 resolve(source); | 1819 resolve(source); |
| 1671 assertNoErrors(source); | 1820 assertNoErrors(source); |
| 1672 verify([source]); | 1821 verify([source]); |
| 1673 } | 1822 } |
| 1823 |
| 1674 void test_implicitThisReferenceInInitializer_staticField_thisClass() { | 1824 void test_implicitThisReferenceInInitializer_staticField_thisClass() { |
| 1675 Source source = addSource(EngineTestCase.createSource([ | 1825 Source source = addSource(EngineTestCase.createSource([ |
| 1676 "class A {", | 1826 "class A {", |
| 1677 " var v;", | 1827 " var v;", |
| 1678 " A() : v = f;", | 1828 " A() : v = f;", |
| 1679 " static var f;", | 1829 " static var f;", |
| 1680 "}"])); | 1830 "}"])); |
| 1681 resolve(source); | 1831 resolve(source); |
| 1682 assertNoErrors(source); | 1832 assertNoErrors(source); |
| 1683 verify([source]); | 1833 verify([source]); |
| 1684 } | 1834 } |
| 1835 |
| 1685 void test_implicitThisReferenceInInitializer_staticGetter() { | 1836 void test_implicitThisReferenceInInitializer_staticGetter() { |
| 1686 Source source = addSource(EngineTestCase.createSource([ | 1837 Source source = addSource(EngineTestCase.createSource([ |
| 1687 "class A {", | 1838 "class A {", |
| 1688 " var v;", | 1839 " var v;", |
| 1689 " A() : v = f;", | 1840 " A() : v = f;", |
| 1690 " static get f => 42;", | 1841 " static get f => 42;", |
| 1691 "}"])); | 1842 "}"])); |
| 1692 resolve(source); | 1843 resolve(source); |
| 1693 assertNoErrors(source); | 1844 assertNoErrors(source); |
| 1694 verify([source]); | 1845 verify([source]); |
| 1695 } | 1846 } |
| 1847 |
| 1696 void test_implicitThisReferenceInInitializer_staticMethod() { | 1848 void test_implicitThisReferenceInInitializer_staticMethod() { |
| 1697 Source source = addSource(EngineTestCase.createSource([ | 1849 Source source = addSource(EngineTestCase.createSource([ |
| 1698 "class A {", | 1850 "class A {", |
| 1699 " var v;", | 1851 " var v;", |
| 1700 " A() : v = f();", | 1852 " A() : v = f();", |
| 1701 " static f() => 42;", | 1853 " static f() => 42;", |
| 1702 "}"])); | 1854 "}"])); |
| 1703 resolve(source); | 1855 resolve(source); |
| 1704 assertNoErrors(source); | 1856 assertNoErrors(source); |
| 1705 verify([source]); | 1857 verify([source]); |
| 1706 } | 1858 } |
| 1859 |
| 1707 void test_implicitThisReferenceInInitializer_topLevelField() { | 1860 void test_implicitThisReferenceInInitializer_topLevelField() { |
| 1708 Source source = addSource(EngineTestCase.createSource([ | 1861 Source source = addSource(EngineTestCase.createSource([ |
| 1709 "class A {", | 1862 "class A {", |
| 1710 " var v;", | 1863 " var v;", |
| 1711 " A() : v = f;", | 1864 " A() : v = f;", |
| 1712 "}", | 1865 "}", |
| 1713 "var f = 42;"])); | 1866 "var f = 42;"])); |
| 1714 resolve(source); | 1867 resolve(source); |
| 1715 assertNoErrors(source); | 1868 assertNoErrors(source); |
| 1716 verify([source]); | 1869 verify([source]); |
| 1717 } | 1870 } |
| 1871 |
| 1718 void test_implicitThisReferenceInInitializer_topLevelFunction() { | 1872 void test_implicitThisReferenceInInitializer_topLevelFunction() { |
| 1719 Source source = addSource(EngineTestCase.createSource([ | 1873 Source source = addSource(EngineTestCase.createSource([ |
| 1720 "class A {", | 1874 "class A {", |
| 1721 " var v;", | 1875 " var v;", |
| 1722 " A() : v = f();", | 1876 " A() : v = f();", |
| 1723 "}", | 1877 "}", |
| 1724 "f() => 42;"])); | 1878 "f() => 42;"])); |
| 1725 resolve(source); | 1879 resolve(source); |
| 1726 assertNoErrors(source); | 1880 assertNoErrors(source); |
| 1727 verify([source]); | 1881 verify([source]); |
| 1728 } | 1882 } |
| 1883 |
| 1729 void test_implicitThisReferenceInInitializer_topLevelGetter() { | 1884 void test_implicitThisReferenceInInitializer_topLevelGetter() { |
| 1730 Source source = addSource(EngineTestCase.createSource([ | 1885 Source source = addSource(EngineTestCase.createSource([ |
| 1731 "class A {", | 1886 "class A {", |
| 1732 " var v;", | 1887 " var v;", |
| 1733 " A() : v = f;", | 1888 " A() : v = f;", |
| 1734 "}", | 1889 "}", |
| 1735 "get f => 42;"])); | 1890 "get f => 42;"])); |
| 1736 resolve(source); | 1891 resolve(source); |
| 1737 assertNoErrors(source); | 1892 assertNoErrors(source); |
| 1738 verify([source]); | 1893 verify([source]); |
| 1739 } | 1894 } |
| 1895 |
| 1740 void test_implicitThisReferenceInInitializer_typeParameter() { | 1896 void test_implicitThisReferenceInInitializer_typeParameter() { |
| 1741 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " va
r v;", " A(p) : v = (p is T);", "}"])); | 1897 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " va
r v;", " A(p) : v = (p is T);", "}"])); |
| 1742 resolve(source); | 1898 resolve(source); |
| 1743 assertNoErrors(source); | 1899 assertNoErrors(source); |
| 1744 verify([source]); | 1900 verify([source]); |
| 1745 } | 1901 } |
| 1902 |
| 1746 void test_importDuplicatedLibraryName() { | 1903 void test_importDuplicatedLibraryName() { |
| 1747 Source source = addSource(EngineTestCase.createSource([ | 1904 Source source = addSource(EngineTestCase.createSource([ |
| 1748 "library test;", | 1905 "library test;", |
| 1749 "import 'lib.dart';", | 1906 "import 'lib.dart';", |
| 1750 "import 'lib.dart';"])); | 1907 "import 'lib.dart';"])); |
| 1751 addSource2("/lib.dart", "library lib;"); | 1908 addSource2("/lib.dart", "library lib;"); |
| 1752 resolve(source); | 1909 resolve(source); |
| 1753 assertErrors(source, [ | 1910 assertErrors(source, [ |
| 1754 HintCode.UNUSED_IMPORT, | 1911 HintCode.UNUSED_IMPORT, |
| 1755 HintCode.UNUSED_IMPORT, | 1912 HintCode.UNUSED_IMPORT, |
| 1756 HintCode.DUPLICATE_IMPORT]); | 1913 HintCode.DUPLICATE_IMPORT]); |
| 1757 verify([source]); | 1914 verify([source]); |
| 1758 } | 1915 } |
| 1916 |
| 1759 void test_importOfNonLibrary_libraryDeclared() { | 1917 void test_importOfNonLibrary_libraryDeclared() { |
| 1760 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); | 1918 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); |
| 1761 addSource2("/part.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); | 1919 addSource2("/part.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); |
| 1762 resolve(source); | 1920 resolve(source); |
| 1763 assertNoErrors(source); | 1921 assertNoErrors(source); |
| 1764 verify([source]); | 1922 verify([source]); |
| 1765 } | 1923 } |
| 1924 |
| 1766 void test_importOfNonLibrary_libraryNotDeclared() { | 1925 void test_importOfNonLibrary_libraryNotDeclared() { |
| 1767 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); | 1926 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); |
| 1768 addSource2("/part.dart", EngineTestCase.createSource(["class A {}"])); | 1927 addSource2("/part.dart", EngineTestCase.createSource(["class A {}"])); |
| 1769 resolve(source); | 1928 resolve(source); |
| 1770 assertNoErrors(source); | 1929 assertNoErrors(source); |
| 1771 verify([source]); | 1930 verify([source]); |
| 1772 } | 1931 } |
| 1932 |
| 1773 void test_importPrefixes_withFirstLetterDifference() { | 1933 void test_importPrefixes_withFirstLetterDifference() { |
| 1774 Source source = addSource(EngineTestCase.createSource([ | 1934 Source source = addSource(EngineTestCase.createSource([ |
| 1775 "library L;", | 1935 "library L;", |
| 1776 "import 'lib1.dart' as math;", | 1936 "import 'lib1.dart' as math;", |
| 1777 "import 'lib2.dart' as path;", | 1937 "import 'lib2.dart' as path;", |
| 1778 "main() {", | 1938 "main() {", |
| 1779 " math.test1();", | 1939 " math.test1();", |
| 1780 " path.test2();", | 1940 " path.test2();", |
| 1781 "}"])); | 1941 "}"])); |
| 1782 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "test
1() {}"])); | 1942 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "test
1() {}"])); |
| 1783 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "test
2() {}"])); | 1943 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "test
2() {}"])); |
| 1784 resolve(source); | 1944 resolve(source); |
| 1785 assertNoErrors(source); | 1945 assertNoErrors(source); |
| 1786 verify([source]); | 1946 verify([source]); |
| 1787 } | 1947 } |
| 1948 |
| 1788 void test_inconsistentCaseExpressionTypes() { | 1949 void test_inconsistentCaseExpressionTypes() { |
| 1789 Source source = addSource(EngineTestCase.createSource([ | 1950 Source source = addSource(EngineTestCase.createSource([ |
| 1790 "f(var p) {", | 1951 "f(var p) {", |
| 1791 " switch (p) {", | 1952 " switch (p) {", |
| 1792 " case 1:", | 1953 " case 1:", |
| 1793 " break;", | 1954 " break;", |
| 1794 " case 2:", | 1955 " case 2:", |
| 1795 " break;", | 1956 " break;", |
| 1796 " }", | 1957 " }", |
| 1797 "}"])); | 1958 "}"])); |
| 1798 resolve(source); | 1959 resolve(source); |
| 1799 assertNoErrors(source); | 1960 assertNoErrors(source); |
| 1800 verify([source]); | 1961 verify([source]); |
| 1801 } | 1962 } |
| 1963 |
| 1802 void test_inconsistentMethodInheritance_accessors_typeParameter2() { | 1964 void test_inconsistentMethodInheritance_accessors_typeParameter2() { |
| 1803 Source source = addSource(EngineTestCase.createSource([ | 1965 Source source = addSource(EngineTestCase.createSource([ |
| 1804 "abstract class A<E> {", | 1966 "abstract class A<E> {", |
| 1805 " E get x {return 1;}", | 1967 " E get x {return 1;}", |
| 1806 "}", | 1968 "}", |
| 1807 "class B<E> {", | 1969 "class B<E> {", |
| 1808 " E get x {return 1;}", | 1970 " E get x {return 1;}", |
| 1809 "}", | 1971 "}", |
| 1810 "class C<E> extends A<E> implements B<E> {", | 1972 "class C<E> extends A<E> implements B<E> {", |
| 1811 "}"])); | 1973 "}"])); |
| 1812 resolve(source); | 1974 resolve(source); |
| 1813 assertNoErrors(source); | 1975 assertNoErrors(source); |
| 1814 verify([source]); | 1976 verify([source]); |
| 1815 } | 1977 } |
| 1978 |
| 1816 void test_inconsistentMethodInheritance_accessors_typeParameters_diamond() { | 1979 void test_inconsistentMethodInheritance_accessors_typeParameters_diamond() { |
| 1817 Source source = addSource(EngineTestCase.createSource([ | 1980 Source source = addSource(EngineTestCase.createSource([ |
| 1818 "abstract class F<E> extends B<E> {}", | 1981 "abstract class F<E> extends B<E> {}", |
| 1819 "class D<E> extends F<E> {", | 1982 "class D<E> extends F<E> {", |
| 1820 " external E get g;", | 1983 " external E get g;", |
| 1821 "}", | 1984 "}", |
| 1822 "abstract class C<E> {", | 1985 "abstract class C<E> {", |
| 1823 " E get g;", | 1986 " E get g;", |
| 1824 "}", | 1987 "}", |
| 1825 "abstract class B<E> implements C<E> {", | 1988 "abstract class B<E> implements C<E> {", |
| 1826 " E get g { return null; }", | 1989 " E get g { return null; }", |
| 1827 "}", | 1990 "}", |
| 1828 "class A<E> extends B<E> implements D<E> {", | 1991 "class A<E> extends B<E> implements D<E> {", |
| 1829 "}"])); | 1992 "}"])); |
| 1830 resolve(source); | 1993 resolve(source); |
| 1831 assertNoErrors(source); | 1994 assertNoErrors(source); |
| 1832 verify([source]); | 1995 verify([source]); |
| 1833 } | 1996 } |
| 1997 |
| 1834 void test_inconsistentMethodInheritance_accessors_typeParameters1() { | 1998 void test_inconsistentMethodInheritance_accessors_typeParameters1() { |
| 1835 Source source = addSource(EngineTestCase.createSource([ | 1999 Source source = addSource(EngineTestCase.createSource([ |
| 1836 "abstract class A<E> {", | 2000 "abstract class A<E> {", |
| 1837 " E get x;", | 2001 " E get x;", |
| 1838 "}", | 2002 "}", |
| 1839 "abstract class B<E> {", | 2003 "abstract class B<E> {", |
| 1840 " E get x;", | 2004 " E get x;", |
| 1841 "}", | 2005 "}", |
| 1842 "class C<E> implements A<E>, B<E> {", | 2006 "class C<E> implements A<E>, B<E> {", |
| 1843 " E get x => 1;", | 2007 " E get x => 1;", |
| 1844 "}"])); | 2008 "}"])); |
| 1845 resolve(source); | 2009 resolve(source); |
| 1846 assertNoErrors(source); | 2010 assertNoErrors(source); |
| 1847 verify([source]); | 2011 verify([source]); |
| 1848 } | 2012 } |
| 2013 |
| 1849 void test_inconsistentMethodInheritance_methods_typeParameter2() { | 2014 void test_inconsistentMethodInheritance_methods_typeParameter2() { |
| 1850 Source source = addSource(EngineTestCase.createSource([ | 2015 Source source = addSource(EngineTestCase.createSource([ |
| 1851 "class A<E> {", | 2016 "class A<E> {", |
| 1852 " x(E e) {}", | 2017 " x(E e) {}", |
| 1853 "}", | 2018 "}", |
| 1854 "class B<E> {", | 2019 "class B<E> {", |
| 1855 " x(E e) {}", | 2020 " x(E e) {}", |
| 1856 "}", | 2021 "}", |
| 1857 "class C<E> extends A<E> implements B<E> {", | 2022 "class C<E> extends A<E> implements B<E> {", |
| 1858 " x(E e) {}", | 2023 " x(E e) {}", |
| 1859 "}"])); | 2024 "}"])); |
| 1860 resolve(source); | 2025 resolve(source); |
| 1861 assertNoErrors(source); | 2026 assertNoErrors(source); |
| 1862 verify([source]); | 2027 verify([source]); |
| 1863 } | 2028 } |
| 2029 |
| 1864 void test_inconsistentMethodInheritance_methods_typeParameters1() { | 2030 void test_inconsistentMethodInheritance_methods_typeParameters1() { |
| 1865 Source source = addSource(EngineTestCase.createSource([ | 2031 Source source = addSource(EngineTestCase.createSource([ |
| 1866 "class A<E> {", | 2032 "class A<E> {", |
| 1867 " x(E e) {}", | 2033 " x(E e) {}", |
| 1868 "}", | 2034 "}", |
| 1869 "class B<E> {", | 2035 "class B<E> {", |
| 1870 " x(E e) {}", | 2036 " x(E e) {}", |
| 1871 "}", | 2037 "}", |
| 1872 "class C<E> implements A<E>, B<E> {", | 2038 "class C<E> implements A<E>, B<E> {", |
| 1873 " x(E e) {}", | 2039 " x(E e) {}", |
| 1874 "}"])); | 2040 "}"])); |
| 1875 resolve(source); | 2041 resolve(source); |
| 1876 assertNoErrors(source); | 2042 assertNoErrors(source); |
| 1877 verify([source]); | 2043 verify([source]); |
| 1878 } | 2044 } |
| 2045 |
| 1879 void test_inconsistentMethodInheritance_simple() { | 2046 void test_inconsistentMethodInheritance_simple() { |
| 1880 Source source = addSource(EngineTestCase.createSource([ | 2047 Source source = addSource(EngineTestCase.createSource([ |
| 1881 "abstract class A {", | 2048 "abstract class A {", |
| 1882 " x();", | 2049 " x();", |
| 1883 "}", | 2050 "}", |
| 1884 "abstract class B {", | 2051 "abstract class B {", |
| 1885 " x();", | 2052 " x();", |
| 1886 "}", | 2053 "}", |
| 1887 "class C implements A, B {", | 2054 "class C implements A, B {", |
| 1888 " x() {}", | 2055 " x() {}", |
| 1889 "}"])); | 2056 "}"])); |
| 1890 resolve(source); | 2057 resolve(source); |
| 1891 assertNoErrors(source); | 2058 assertNoErrors(source); |
| 1892 verify([source]); | 2059 verify([source]); |
| 1893 } | 2060 } |
| 2061 |
| 1894 void test_initializingFormalForNonExistantField() { | 2062 void test_initializingFormalForNonExistantField() { |
| 1895 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); | 2063 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); |
| 1896 resolve(source); | 2064 resolve(source); |
| 1897 assertNoErrors(source); | 2065 assertNoErrors(source); |
| 1898 verify([source]); | 2066 verify([source]); |
| 1899 } | 2067 } |
| 2068 |
| 1900 void test_instanceAccessToStaticMember_fromComment() { | 2069 void test_instanceAccessToStaticMember_fromComment() { |
| 1901 Source source = addSource(EngineTestCase.createSource([ | 2070 Source source = addSource(EngineTestCase.createSource([ |
| 1902 "class A {", | 2071 "class A {", |
| 1903 " static m() {}", | 2072 " static m() {}", |
| 1904 "}", | 2073 "}", |
| 1905 "/// [A.m]", | 2074 "/// [A.m]", |
| 1906 "main() {", | 2075 "main() {", |
| 1907 "}"])); | 2076 "}"])); |
| 1908 resolve(source); | 2077 resolve(source); |
| 1909 assertNoErrors(source); | 2078 assertNoErrors(source); |
| 1910 verify([source]); | 2079 verify([source]); |
| 1911 } | 2080 } |
| 2081 |
| 1912 void test_instanceAccessToStaticMember_topLevel() { | 2082 void test_instanceAccessToStaticMember_topLevel() { |
| 1913 Source source = addSource(EngineTestCase.createSource(["m() {}", "main() {",
" m();", "}"])); | 2083 Source source = addSource(EngineTestCase.createSource(["m() {}", "main() {",
" m();", "}"])); |
| 1914 resolve(source); | 2084 resolve(source); |
| 1915 assertNoErrors(source); | 2085 assertNoErrors(source); |
| 1916 verify([source]); | 2086 verify([source]); |
| 1917 } | 2087 } |
| 2088 |
| 1918 void test_instanceMemberAccessFromStatic_fromComment() { | 2089 void test_instanceMemberAccessFromStatic_fromComment() { |
| 1919 Source source = addSource(EngineTestCase.createSource([ | 2090 Source source = addSource(EngineTestCase.createSource([ |
| 1920 "class A {", | 2091 "class A {", |
| 1921 " m() {}", | 2092 " m() {}", |
| 1922 " /// [m]", | 2093 " /// [m]", |
| 1923 " static foo() {", | 2094 " static foo() {", |
| 1924 " }", | 2095 " }", |
| 1925 "}"])); | 2096 "}"])); |
| 1926 resolve(source); | 2097 resolve(source); |
| 1927 assertNoErrors(source); | 2098 assertNoErrors(source); |
| 1928 verify([source]); | 2099 verify([source]); |
| 1929 } | 2100 } |
| 2101 |
| 1930 void test_instanceMethodNameCollidesWithSuperclassStatic_field() { | 2102 void test_instanceMethodNameCollidesWithSuperclassStatic_field() { |
| 1931 Source source = addSource(EngineTestCase.createSource([ | 2103 Source source = addSource(EngineTestCase.createSource([ |
| 1932 "import 'lib.dart';", | 2104 "import 'lib.dart';", |
| 1933 "class B extends A {", | 2105 "class B extends A {", |
| 1934 " _m() {}", | 2106 " _m() {}", |
| 1935 "}"])); | 2107 "}"])); |
| 1936 addSource2("/lib.dart", EngineTestCase.createSource(["library L;", "class A
{", " static var _m;", "}"])); | 2108 addSource2("/lib.dart", EngineTestCase.createSource(["library L;", "class A
{", " static var _m;", "}"])); |
| 1937 resolve(source); | 2109 resolve(source); |
| 1938 assertNoErrors(source); | 2110 assertNoErrors(source); |
| 1939 verify([source]); | 2111 verify([source]); |
| 1940 } | 2112 } |
| 2113 |
| 1941 void test_instanceMethodNameCollidesWithSuperclassStatic_method() { | 2114 void test_instanceMethodNameCollidesWithSuperclassStatic_method() { |
| 1942 Source source = addSource(EngineTestCase.createSource([ | 2115 Source source = addSource(EngineTestCase.createSource([ |
| 1943 "import 'lib.dart';", | 2116 "import 'lib.dart';", |
| 1944 "class B extends A {", | 2117 "class B extends A {", |
| 1945 " _m() {}", | 2118 " _m() {}", |
| 1946 "}"])); | 2119 "}"])); |
| 1947 addSource2("/lib.dart", EngineTestCase.createSource(["library L;", "class A
{", " static _m() {}", "}"])); | 2120 addSource2("/lib.dart", EngineTestCase.createSource(["library L;", "class A
{", " static _m() {}", "}"])); |
| 1948 resolve(source); | 2121 resolve(source); |
| 1949 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); | 2122 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); |
| 1950 verify([source]); | 2123 verify([source]); |
| 1951 } | 2124 } |
| 1952 void test_invalidAnnotation_constantVariable() { | 2125 |
| 2126 void test_invalidAnnotation_constantVariable_field() { |
| 2127 Source source = addSource(EngineTestCase.createSource(["@A.C", "class A {",
" static const C = 0;", "}"])); |
| 2128 resolve(source); |
| 2129 assertNoErrors(source); |
| 2130 verify([source]); |
| 2131 } |
| 2132 |
| 2133 void test_invalidAnnotation_constantVariable_field_importWithPrefix() { |
| 2134 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {", " static const C = 0;", "}"])); |
| 2135 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.A.C", "main() {", "}"])); |
| 2136 resolve(source); |
| 2137 assertNoErrors(source); |
| 2138 verify([source]); |
| 2139 } |
| 2140 |
| 2141 void test_invalidAnnotation_constantVariable_topLevel() { |
| 1953 Source source = addSource(EngineTestCase.createSource(["const C = 0;", "@C",
"main() {", "}"])); | 2142 Source source = addSource(EngineTestCase.createSource(["const C = 0;", "@C",
"main() {", "}"])); |
| 1954 resolve(source); | 2143 resolve(source); |
| 1955 assertNoErrors(source); | 2144 assertNoErrors(source); |
| 1956 verify([source]); | 2145 verify([source]); |
| 1957 } | 2146 } |
| 1958 void test_invalidAnnotation_importWithPrefix_constantVariable() { | 2147 |
| 2148 void test_invalidAnnotation_constantVariable_topLevel_importWithPrefix() { |
| 1959 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "const
C = 0;"])); | 2149 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "const
C = 0;"])); |
| 1960 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.C", "main() {", "}"])); | 2150 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.C", "main() {", "}"])); |
| 1961 resolve(source); | 2151 resolve(source); |
| 1962 assertNoErrors(source); | 2152 assertNoErrors(source); |
| 1963 verify([source]); | 2153 verify([source]); |
| 1964 } | 2154 } |
| 1965 void test_invalidAnnotation_importWithPrefix_constConstructor() { | 2155 |
| 2156 void test_invalidAnnotation_constConstructor_importWithPrefix() { |
| 2157 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {", " const A(int p);", "}"])); |
| 2158 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.A(42)", "main() {", "}"])); |
| 2159 resolve(source); |
| 2160 assertNoErrors(source); |
| 2161 verify([source]); |
| 2162 } |
| 2163 |
| 2164 void test_invalidAnnotation_constConstructor_named_importWithPrefix() { |
| 1966 addSource2("/lib.dart", EngineTestCase.createSource([ | 2165 addSource2("/lib.dart", EngineTestCase.createSource([ |
| 1967 "library lib;", | 2166 "library lib;", |
| 1968 "class A {", | 2167 "class A {", |
| 1969 " const A.named(int p);", | 2168 " const A.named(int p);", |
| 1970 "}"])); | 2169 "}"])); |
| 1971 Source source = addSource(EngineTestCase.createSource([ | 2170 Source source = addSource(EngineTestCase.createSource([ |
| 1972 "import 'lib.dart' as p;", | 2171 "import 'lib.dart' as p;", |
| 1973 "@p.A.named(42)", | 2172 "@p.A.named(42)", |
| 1974 "main() {", | 2173 "main() {", |
| 1975 "}"])); | 2174 "}"])); |
| 1976 resolve(source); | 2175 resolve(source); |
| 1977 assertNoErrors(source); | 2176 assertNoErrors(source); |
| 1978 verify([source]); | 2177 verify([source]); |
| 1979 } | 2178 } |
| 2179 |
| 1980 void test_invalidAssignment() { | 2180 void test_invalidAssignment() { |
| 1981 Source source = addSource(EngineTestCase.createSource(["f() {", " var x;",
" var y;", " x = y;", "}"])); | 2181 Source source = addSource(EngineTestCase.createSource(["f() {", " var x;",
" var y;", " x = y;", "}"])); |
| 1982 resolve(source); | 2182 resolve(source); |
| 1983 assertNoErrors(source); | 2183 assertNoErrors(source); |
| 1984 verify([source]); | 2184 verify([source]); |
| 1985 } | 2185 } |
| 2186 |
| 1986 void test_invalidAssignment_compoundAssignment() { | 2187 void test_invalidAssignment_compoundAssignment() { |
| 1987 Source source = addSource(EngineTestCase.createSource([ | 2188 Source source = addSource(EngineTestCase.createSource([ |
| 1988 "class byte {", | 2189 "class byte {", |
| 1989 " int _value;", | 2190 " int _value;", |
| 1990 " byte(this._value);", | 2191 " byte(this._value);", |
| 1991 " byte operator +(int val) {}", | 2192 " byte operator +(int val) {}", |
| 1992 "}", | 2193 "}", |
| 1993 "", | 2194 "", |
| 1994 "void main() {", | 2195 "void main() {", |
| 1995 " byte b = new byte(52);", | 2196 " byte b = new byte(52);", |
| 1996 " b += 3;", | 2197 " b += 3;", |
| 1997 "}"])); | 2198 "}"])); |
| 1998 resolve(source); | 2199 resolve(source); |
| 1999 assertNoErrors(source); | 2200 assertNoErrors(source); |
| 2000 verify([source]); | 2201 verify([source]); |
| 2001 } | 2202 } |
| 2203 |
| 2002 void test_invalidAssignment_defaultValue_named() { | 2204 void test_invalidAssignment_defaultValue_named() { |
| 2003 Source source = addSource(EngineTestCase.createSource(["f({String x: '0'}) {
", "}"])); | 2205 Source source = addSource(EngineTestCase.createSource(["f({String x: '0'}) {
", "}"])); |
| 2004 resolve(source); | 2206 resolve(source); |
| 2005 assertNoErrors(source); | 2207 assertNoErrors(source); |
| 2006 verify([source]); | 2208 verify([source]); |
| 2007 } | 2209 } |
| 2210 |
| 2008 void test_invalidAssignment_defaultValue_optional() { | 2211 void test_invalidAssignment_defaultValue_optional() { |
| 2009 Source source = addSource(EngineTestCase.createSource(["f([String x = '0'])
{", "}"])); | 2212 Source source = addSource(EngineTestCase.createSource(["f([String x = '0'])
{", "}"])); |
| 2010 resolve(source); | 2213 resolve(source); |
| 2011 assertNoErrors(source); | 2214 assertNoErrors(source); |
| 2012 verify([source]); | 2215 verify([source]); |
| 2013 } | 2216 } |
| 2217 |
| 2014 void test_invalidAssignment_toDynamic() { | 2218 void test_invalidAssignment_toDynamic() { |
| 2015 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;",
" g = () => 0;", "}"])); | 2219 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;",
" g = () => 0;", "}"])); |
| 2016 resolve(source); | 2220 resolve(source); |
| 2017 assertNoErrors(source); | 2221 assertNoErrors(source); |
| 2018 verify([source]); | 2222 verify([source]); |
| 2019 } | 2223 } |
| 2224 |
| 2020 void test_invalidFactoryNameNotAClass() { | 2225 void test_invalidFactoryNameNotAClass() { |
| 2021 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() {}", "}"])); | 2226 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() {}", "}"])); |
| 2022 resolve(source); | 2227 resolve(source); |
| 2023 assertNoErrors(source); | 2228 assertNoErrors(source); |
| 2024 verify([source]); | 2229 verify([source]); |
| 2025 } | 2230 } |
| 2231 |
| 2026 void test_invalidMethodOverrideNamedParamType() { | 2232 void test_invalidMethodOverrideNamedParamType() { |
| 2027 Source source = addSource(EngineTestCase.createSource([ | 2233 Source source = addSource(EngineTestCase.createSource([ |
| 2028 "class A {", | 2234 "class A {", |
| 2029 " m({int a}) {}", | 2235 " m({int a}) {}", |
| 2030 "}", | 2236 "}", |
| 2031 "class B implements A {", | 2237 "class B implements A {", |
| 2032 " m({int a, int b}) {}", | 2238 " m({int a, int b}) {}", |
| 2033 "}"])); | 2239 "}"])); |
| 2034 resolve(source); | 2240 resolve(source); |
| 2035 assertNoErrors(source); | 2241 assertNoErrors(source); |
| 2036 verify([source]); | 2242 verify([source]); |
| 2037 } | 2243 } |
| 2244 |
| 2038 void test_invalidOverrideDifferentDefaultValues_named() { | 2245 void test_invalidOverrideDifferentDefaultValues_named() { |
| 2039 Source source = addSource(EngineTestCase.createSource([ | 2246 Source source = addSource(EngineTestCase.createSource([ |
| 2040 "class A {", | 2247 "class A {", |
| 2041 " m({int p : 0}) {}", | 2248 " m({int p : 0}) {}", |
| 2042 "}", | 2249 "}", |
| 2043 "class B extends A {", | 2250 "class B extends A {", |
| 2044 " m({int p : 0}) {}", | 2251 " m({int p : 0}) {}", |
| 2045 "}"])); | 2252 "}"])); |
| 2046 resolve(source); | 2253 resolve(source); |
| 2047 assertNoErrors(source); | 2254 assertNoErrors(source); |
| 2048 verify([source]); | 2255 verify([source]); |
| 2049 } | 2256 } |
| 2257 |
| 2258 void test_invalidOverrideDifferentDefaultValues_named_function() { |
| 2259 Source source = addSource(EngineTestCase.createSource([ |
| 2260 "nothing() => 'nothing';", |
| 2261 "class A {", |
| 2262 " thing(String a, {orElse : nothing}) {}", |
| 2263 "}", |
| 2264 "class B extends A {", |
| 2265 " thing(String a, {orElse : nothing}) {}", |
| 2266 "}"])); |
| 2267 resolve(source); |
| 2268 assertNoErrors(source); |
| 2269 verify([source]); |
| 2270 } |
| 2271 |
| 2050 void test_invalidOverrideDifferentDefaultValues_positional() { | 2272 void test_invalidOverrideDifferentDefaultValues_positional() { |
| 2051 Source source = addSource(EngineTestCase.createSource([ | 2273 Source source = addSource(EngineTestCase.createSource([ |
| 2052 "class A {", | 2274 "class A {", |
| 2053 " m([int p = 0]) {}", | 2275 " m([int p = 0]) {}", |
| 2054 "}", | 2276 "}", |
| 2055 "class B extends A {", | 2277 "class B extends A {", |
| 2056 " m([int p = 0]) {}", | 2278 " m([int p = 0]) {}", |
| 2057 "}"])); | 2279 "}"])); |
| 2058 resolve(source); | 2280 resolve(source); |
| 2059 assertNoErrors(source); | 2281 assertNoErrors(source); |
| 2060 verify([source]); | 2282 verify([source]); |
| 2061 } | 2283 } |
| 2284 |
| 2062 void test_invalidOverrideDifferentDefaultValues_positional_changedOrder() { | 2285 void test_invalidOverrideDifferentDefaultValues_positional_changedOrder() { |
| 2063 Source source = addSource(EngineTestCase.createSource([ | 2286 Source source = addSource(EngineTestCase.createSource([ |
| 2064 "class A {", | 2287 "class A {", |
| 2065 " m([int a = 0, String b = '0']) {}", | 2288 " m([int a = 0, String b = '0']) {}", |
| 2066 "}", | 2289 "}", |
| 2067 "class B extends A {", | 2290 "class B extends A {", |
| 2068 " m([int b = 0, String a = '0']) {}", | 2291 " m([int b = 0, String a = '0']) {}", |
| 2069 "}"])); | 2292 "}"])); |
| 2070 resolve(source); | 2293 resolve(source); |
| 2071 assertNoErrors(source); | 2294 assertNoErrors(source); |
| 2072 verify([source]); | 2295 verify([source]); |
| 2073 } | 2296 } |
| 2297 |
| 2298 void test_invalidOverrideDifferentDefaultValues_positional_function() { |
| 2299 Source source = addSource(EngineTestCase.createSource([ |
| 2300 "nothing() => 'nothing';", |
| 2301 "class A {", |
| 2302 " thing(String a, [orElse = nothing]) {}", |
| 2303 "}", |
| 2304 "class B extends A {", |
| 2305 " thing(String a, [orElse = nothing]) {}", |
| 2306 "}"])); |
| 2307 resolve(source); |
| 2308 assertNoErrors(source); |
| 2309 verify([source]); |
| 2310 } |
| 2311 |
| 2074 void test_invalidOverrideNamed_unorderedNamedParameter() { | 2312 void test_invalidOverrideNamed_unorderedNamedParameter() { |
| 2075 Source source = addSource(EngineTestCase.createSource([ | 2313 Source source = addSource(EngineTestCase.createSource([ |
| 2076 "class A {", | 2314 "class A {", |
| 2077 " m({a, b}) {}", | 2315 " m({a, b}) {}", |
| 2078 "}", | 2316 "}", |
| 2079 "class B extends A {", | 2317 "class B extends A {", |
| 2080 " m({b, a}) {}", | 2318 " m({b, a}) {}", |
| 2081 "}"])); | 2319 "}"])); |
| 2082 resolve(source); | 2320 resolve(source); |
| 2083 assertNoErrors(source); | 2321 assertNoErrors(source); |
| 2084 verify([source]); | 2322 verify([source]); |
| 2085 } | 2323 } |
| 2324 |
| 2086 void test_invalidOverrideRequired_less() { | 2325 void test_invalidOverrideRequired_less() { |
| 2087 Source source = addSource(EngineTestCase.createSource([ | 2326 Source source = addSource(EngineTestCase.createSource([ |
| 2088 "class A {", | 2327 "class A {", |
| 2089 " m(a, b) {}", | 2328 " m(a, b) {}", |
| 2090 "}", | 2329 "}", |
| 2091 "class B extends A {", | 2330 "class B extends A {", |
| 2092 " m(a, [b]) {}", | 2331 " m(a, [b]) {}", |
| 2093 "}"])); | 2332 "}"])); |
| 2094 resolve(source); | 2333 resolve(source); |
| 2095 assertNoErrors(source); | 2334 assertNoErrors(source); |
| 2096 verify([source]); | 2335 verify([source]); |
| 2097 } | 2336 } |
| 2337 |
| 2098 void test_invalidOverrideRequired_same() { | 2338 void test_invalidOverrideRequired_same() { |
| 2099 Source source = addSource(EngineTestCase.createSource([ | 2339 Source source = addSource(EngineTestCase.createSource([ |
| 2100 "class A {", | 2340 "class A {", |
| 2101 " m(a) {}", | 2341 " m(a) {}", |
| 2102 "}", | 2342 "}", |
| 2103 "class B extends A {", | 2343 "class B extends A {", |
| 2104 " m(a) {}", | 2344 " m(a) {}", |
| 2105 "}"])); | 2345 "}"])); |
| 2106 resolve(source); | 2346 resolve(source); |
| 2107 assertNoErrors(source); | 2347 assertNoErrors(source); |
| 2108 verify([source]); | 2348 verify([source]); |
| 2109 } | 2349 } |
| 2350 |
| 2110 void test_invalidOverrideReturnType_returnType_interface() { | 2351 void test_invalidOverrideReturnType_returnType_interface() { |
| 2111 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2352 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 2112 "abstract class A {", | 2353 "abstract class A {", |
| 2113 " num m();", | 2354 " num m();", |
| 2114 "}", | 2355 "}", |
| 2115 "class B implements A {", | 2356 "class B implements A {", |
| 2116 " int m() { return 1; }", | 2357 " int m() { return 1; }", |
| 2117 "}"])); | 2358 "}"])); |
| 2118 resolve(source); | 2359 resolve(source); |
| 2119 assertNoErrors(source); | 2360 assertNoErrors(source); |
| 2120 verify([source]); | 2361 verify([source]); |
| 2121 } | 2362 } |
| 2363 |
| 2122 void test_invalidOverrideReturnType_returnType_interface2() { | 2364 void test_invalidOverrideReturnType_returnType_interface2() { |
| 2123 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2365 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 2124 "abstract class A {", | 2366 "abstract class A {", |
| 2125 " num m();", | 2367 " num m();", |
| 2126 "}", | 2368 "}", |
| 2127 "abstract class B implements A {", | 2369 "abstract class B implements A {", |
| 2128 "}", | 2370 "}", |
| 2129 "class C implements B {", | 2371 "class C implements B {", |
| 2130 " int m() { return 1; }", | 2372 " int m() { return 1; }", |
| 2131 "}"])); | 2373 "}"])); |
| 2132 resolve(source); | 2374 resolve(source); |
| 2133 assertNoErrors(source); | 2375 assertNoErrors(source); |
| 2134 verify([source]); | 2376 verify([source]); |
| 2135 } | 2377 } |
| 2378 |
| 2136 void test_invalidOverrideReturnType_returnType_mixin() { | 2379 void test_invalidOverrideReturnType_returnType_mixin() { |
| 2137 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2380 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 2138 "class A {", | 2381 "class A {", |
| 2139 " num m() { return 0; }", | 2382 " num m() { return 0; }", |
| 2140 "}", | 2383 "}", |
| 2141 "class B extends Object with A {", | 2384 "class B extends Object with A {", |
| 2142 " int m() { return 1; }", | 2385 " int m() { return 1; }", |
| 2143 "}"])); | 2386 "}"])); |
| 2144 resolve(source); | 2387 resolve(source); |
| 2145 assertNoErrors(source); | 2388 assertNoErrors(source); |
| 2146 verify([source]); | 2389 verify([source]); |
| 2147 } | 2390 } |
| 2391 |
| 2148 void test_invalidOverrideReturnType_returnType_parameterizedTypes() { | 2392 void test_invalidOverrideReturnType_returnType_parameterizedTypes() { |
| 2149 Source source = addSource(EngineTestCase.createSource([ | 2393 Source source = addSource(EngineTestCase.createSource([ |
| 2150 "abstract class A<E> {", | 2394 "abstract class A<E> {", |
| 2151 " List<E> m();", | 2395 " List<E> m();", |
| 2152 "}", | 2396 "}", |
| 2153 "class B extends A<dynamic> {", | 2397 "class B extends A<dynamic> {", |
| 2154 " List<dynamic> m() { return new List<dynamic>(); }", | 2398 " List<dynamic> m() { return new List<dynamic>(); }", |
| 2155 "}"])); | 2399 "}"])); |
| 2156 resolve(source); | 2400 resolve(source); |
| 2157 assertNoErrors(source); | 2401 assertNoErrors(source); |
| 2158 verify([source]); | 2402 verify([source]); |
| 2159 } | 2403 } |
| 2404 |
| 2160 void test_invalidOverrideReturnType_returnType_sameType() { | 2405 void test_invalidOverrideReturnType_returnType_sameType() { |
| 2161 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2406 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 2162 "class A {", | 2407 "class A {", |
| 2163 " int m() { return 0; }", | 2408 " int m() { return 0; }", |
| 2164 "}", | 2409 "}", |
| 2165 "class B extends A {", | 2410 "class B extends A {", |
| 2166 " int m() { return 1; }", | 2411 " int m() { return 1; }", |
| 2167 "}"])); | 2412 "}"])); |
| 2168 resolve(source); | 2413 resolve(source); |
| 2169 assertNoErrors(source); | 2414 assertNoErrors(source); |
| 2170 verify([source]); | 2415 verify([source]); |
| 2171 } | 2416 } |
| 2417 |
| 2172 void test_invalidOverrideReturnType_returnType_superclass() { | 2418 void test_invalidOverrideReturnType_returnType_superclass() { |
| 2173 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2419 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 2174 "class A {", | 2420 "class A {", |
| 2175 " num m() { return 0; }", | 2421 " num m() { return 0; }", |
| 2176 "}", | 2422 "}", |
| 2177 "class B extends A {", | 2423 "class B extends A {", |
| 2178 " int m() { return 1; }", | 2424 " int m() { return 1; }", |
| 2179 "}"])); | 2425 "}"])); |
| 2180 resolve(source); | 2426 resolve(source); |
| 2181 assertNoErrors(source); | 2427 assertNoErrors(source); |
| 2182 verify([source]); | 2428 verify([source]); |
| 2183 } | 2429 } |
| 2430 |
| 2184 void test_invalidOverrideReturnType_returnType_superclass2() { | 2431 void test_invalidOverrideReturnType_returnType_superclass2() { |
| 2185 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2432 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 2186 "class A {", | 2433 "class A {", |
| 2187 " num m() { return 0; }", | 2434 " num m() { return 0; }", |
| 2188 "}", | 2435 "}", |
| 2189 "class B extends A {", | 2436 "class B extends A {", |
| 2190 "}", | 2437 "}", |
| 2191 "class C extends B {", | 2438 "class C extends B {", |
| 2192 " int m() { return 1; }", | 2439 " int m() { return 1; }", |
| 2193 "}"])); | 2440 "}"])); |
| 2194 resolve(source); | 2441 resolve(source); |
| 2195 assertNoErrors(source); | 2442 assertNoErrors(source); |
| 2196 verify([source]); | 2443 verify([source]); |
| 2197 } | 2444 } |
| 2445 |
| 2198 void test_invalidOverrideReturnType_returnType_void() { | 2446 void test_invalidOverrideReturnType_returnType_void() { |
| 2199 Source source = addSource(EngineTestCase.createSource([ | 2447 Source source = addSource(EngineTestCase.createSource([ |
| 2200 "class A {", | 2448 "class A {", |
| 2201 " void m() {}", | 2449 " void m() {}", |
| 2202 "}", | 2450 "}", |
| 2203 "class B extends A {", | 2451 "class B extends A {", |
| 2204 " int m() {}", | 2452 " int m() {}", |
| 2205 "}"])); | 2453 "}"])); |
| 2206 resolve(source); | 2454 resolve(source); |
| 2207 assertNoErrors(source); | 2455 assertNoErrors(source); |
| 2208 verify([source]); | 2456 verify([source]); |
| 2209 } | 2457 } |
| 2458 |
| 2210 void test_invalidReferenceToThis_constructor() { | 2459 void test_invalidReferenceToThis_constructor() { |
| 2211 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
", " var v = this;", " }", "}"])); | 2460 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
", " var v = this;", " }", "}"])); |
| 2212 resolve(source); | 2461 resolve(source); |
| 2213 assertNoErrors(source); | 2462 assertNoErrors(source); |
| 2214 verify([source]); | 2463 verify([source]); |
| 2215 } | 2464 } |
| 2465 |
| 2216 void test_invalidReferenceToThis_instanceMethod() { | 2466 void test_invalidReferenceToThis_instanceMethod() { |
| 2217 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
", " var v = this;", " }", "}"])); | 2467 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
", " var v = this;", " }", "}"])); |
| 2218 resolve(source); | 2468 resolve(source); |
| 2219 assertNoErrors(source); | 2469 assertNoErrors(source); |
| 2220 verify([source]); | 2470 verify([source]); |
| 2221 } | 2471 } |
| 2472 |
| 2222 void test_invalidTypeArgumentForKey() { | 2473 void test_invalidTypeArgumentForKey() { |
| 2223 Source source = addSource(EngineTestCase.createSource([ | 2474 Source source = addSource(EngineTestCase.createSource([ |
| 2224 "class A {", | 2475 "class A {", |
| 2225 " m() {", | 2476 " m() {", |
| 2226 " return const <int, int>{};", | 2477 " return const <int, int>{};", |
| 2227 " }", | 2478 " }", |
| 2228 "}"])); | 2479 "}"])); |
| 2229 resolve(source); | 2480 resolve(source); |
| 2230 assertNoErrors(source); | 2481 assertNoErrors(source); |
| 2231 verify([source]); | 2482 verify([source]); |
| 2232 } | 2483 } |
| 2484 |
| 2233 void test_invalidTypeArgumentInConstList() { | 2485 void test_invalidTypeArgumentInConstList() { |
| 2234 Source source = addSource(EngineTestCase.createSource([ | 2486 Source source = addSource(EngineTestCase.createSource([ |
| 2235 "class A<E> {", | 2487 "class A<E> {", |
| 2236 " m() {", | 2488 " m() {", |
| 2237 " return <E>[];", | 2489 " return <E>[];", |
| 2238 " }", | 2490 " }", |
| 2239 "}"])); | 2491 "}"])); |
| 2240 resolve(source); | 2492 resolve(source); |
| 2241 assertNoErrors(source); | 2493 assertNoErrors(source); |
| 2242 verify([source]); | 2494 verify([source]); |
| 2243 } | 2495 } |
| 2496 |
| 2244 void test_invalidTypeArgumentInConstMap() { | 2497 void test_invalidTypeArgumentInConstMap() { |
| 2245 Source source = addSource(EngineTestCase.createSource([ | 2498 Source source = addSource(EngineTestCase.createSource([ |
| 2246 "class A<E> {", | 2499 "class A<E> {", |
| 2247 " m() {", | 2500 " m() {", |
| 2248 " return <String, E>{};", | 2501 " return <String, E>{};", |
| 2249 " }", | 2502 " }", |
| 2250 "}"])); | 2503 "}"])); |
| 2251 resolve(source); | 2504 resolve(source); |
| 2252 assertNoErrors(source); | 2505 assertNoErrors(source); |
| 2253 verify([source]); | 2506 verify([source]); |
| 2254 } | 2507 } |
| 2508 |
| 2255 void test_invocationOfNonFunction_dynamic() { | 2509 void test_invocationOfNonFunction_dynamic() { |
| 2256 Source source = addSource(EngineTestCase.createSource([ | 2510 Source source = addSource(EngineTestCase.createSource([ |
| 2257 "class A {", | 2511 "class A {", |
| 2258 " var f;", | 2512 " var f;", |
| 2259 "}", | 2513 "}", |
| 2260 "class B extends A {", | 2514 "class B extends A {", |
| 2261 " g() {", | 2515 " g() {", |
| 2262 " f();", | 2516 " f();", |
| 2263 " }", | 2517 " }", |
| 2264 "}"])); | 2518 "}"])); |
| 2265 resolve(source); | 2519 resolve(source); |
| 2266 assertNoErrors(source); | 2520 assertNoErrors(source); |
| 2267 verify([source]); | 2521 verify([source]); |
| 2268 } | 2522 } |
| 2523 |
| 2269 void test_invocationOfNonFunction_getter() { | 2524 void test_invocationOfNonFunction_getter() { |
| 2270 Source source = addSource(EngineTestCase.createSource([ | 2525 Source source = addSource(EngineTestCase.createSource([ |
| 2271 "class A {", | 2526 "class A {", |
| 2272 " var g;", | 2527 " var g;", |
| 2273 "}", | 2528 "}", |
| 2274 "f() {", | 2529 "f() {", |
| 2275 " A a;", | 2530 " A a;", |
| 2276 " a.g();", | 2531 " a.g();", |
| 2277 "}"])); | 2532 "}"])); |
| 2278 resolve(source); | 2533 resolve(source); |
| 2279 assertNoErrors(source); | 2534 assertNoErrors(source); |
| 2280 verify([source]); | 2535 verify([source]); |
| 2281 } | 2536 } |
| 2537 |
| 2282 void test_invocationOfNonFunction_localVariable() { | 2538 void test_invocationOfNonFunction_localVariable() { |
| 2283 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;",
" g();", "}"])); | 2539 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;",
" g();", "}"])); |
| 2284 resolve(source); | 2540 resolve(source); |
| 2285 assertNoErrors(source); | 2541 assertNoErrors(source); |
| 2286 verify([source]); | 2542 verify([source]); |
| 2287 } | 2543 } |
| 2544 |
| 2288 void test_invocationOfNonFunction_localVariable_dynamic() { | 2545 void test_invocationOfNonFunction_localVariable_dynamic() { |
| 2289 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" var v = f;", " v();", "}"])); | 2546 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" var v = f;", " v();", "}"])); |
| 2290 resolve(source); | 2547 resolve(source); |
| 2291 assertNoErrors(source); | 2548 assertNoErrors(source); |
| 2292 verify([source]); | 2549 verify([source]); |
| 2293 } | 2550 } |
| 2551 |
| 2294 void test_invocationOfNonFunction_localVariable_dynamic2() { | 2552 void test_invocationOfNonFunction_localVariable_dynamic2() { |
| 2295 Source source = addSource(EngineTestCase.createSource([ | 2553 Source source = addSource(EngineTestCase.createSource([ |
| 2296 "f() {}", | 2554 "f() {}", |
| 2297 "main() {", | 2555 "main() {", |
| 2298 " var v = f;", | 2556 " var v = f;", |
| 2299 " v = 1;", | 2557 " v = 1;", |
| 2300 " v();", | 2558 " v();", |
| 2301 "}"])); | 2559 "}"])); |
| 2302 resolve(source); | 2560 resolve(source); |
| 2303 assertNoErrors(source); | 2561 assertNoErrors(source); |
| 2304 verify([source]); | 2562 verify([source]); |
| 2305 } | 2563 } |
| 2564 |
| 2306 void test_invocationOfNonFunction_Object() { | 2565 void test_invocationOfNonFunction_Object() { |
| 2307 Source source = addSource(EngineTestCase.createSource(["main() {", " Object
v = null;", " v();", "}"])); | 2566 Source source = addSource(EngineTestCase.createSource(["main() {", " Object
v = null;", " v();", "}"])); |
| 2308 resolve(source); | 2567 resolve(source); |
| 2309 assertNoErrors(source); | 2568 assertNoErrors(source); |
| 2310 verify([source]); | 2569 verify([source]); |
| 2311 } | 2570 } |
| 2571 |
| 2312 void test_listElementTypeNotAssignable() { | 2572 void test_listElementTypeNotAssignable() { |
| 2313 Source source = addSource(EngineTestCase.createSource(["var v1 = <int> [42];
", "var v2 = const <int> [42];"])); | 2573 Source source = addSource(EngineTestCase.createSource(["var v1 = <int> [42];
", "var v2 = const <int> [42];"])); |
| 2314 resolve(source); | 2574 resolve(source); |
| 2315 assertNoErrors(source); | 2575 assertNoErrors(source); |
| 2316 verify([source]); | 2576 verify([source]); |
| 2317 } | 2577 } |
| 2578 |
| 2318 void test_mapKeyTypeNotAssignable() { | 2579 void test_mapKeyTypeNotAssignable() { |
| 2319 Source source = addSource(EngineTestCase.createSource(["var v = <String, int
> {'a' : 1};"])); | 2580 Source source = addSource(EngineTestCase.createSource(["var v = <String, int
> {'a' : 1};"])); |
| 2320 resolve(source); | 2581 resolve(source); |
| 2321 assertNoErrors(source); | 2582 assertNoErrors(source); |
| 2322 verify([source]); | 2583 verify([source]); |
| 2323 } | 2584 } |
| 2585 |
| 2324 void test_memberWithClassName_setter() { | 2586 void test_memberWithClassName_setter() { |
| 2325 Source source = addSource(EngineTestCase.createSource(["class A {", " set A
(v) {}", "}"])); | 2587 Source source = addSource(EngineTestCase.createSource(["class A {", " set A
(v) {}", "}"])); |
| 2326 resolve(source); | 2588 resolve(source); |
| 2327 assertNoErrors(source); | 2589 assertNoErrors(source); |
| 2328 verify([source]); | 2590 verify([source]); |
| 2329 } | 2591 } |
| 2592 |
| 2330 void test_methodDeclaration_scope_signature() { | 2593 void test_methodDeclaration_scope_signature() { |
| 2331 Source source = addSource(EngineTestCase.createSource([ | 2594 Source source = addSource(EngineTestCase.createSource([ |
| 2332 "const app = 0;", | 2595 "const app = 0;", |
| 2333 "class A {", | 2596 "class A {", |
| 2334 " foo(@app int app) {}", | 2597 " foo(@app int app) {}", |
| 2335 "}"])); | 2598 "}"])); |
| 2336 resolve(source); | 2599 resolve(source); |
| 2337 assertNoErrors(source); | 2600 assertNoErrors(source); |
| 2338 verify([source]); | 2601 verify([source]); |
| 2339 } | 2602 } |
| 2603 |
| 2340 void test_misMatchedGetterAndSetterTypes_instance_sameTypes() { | 2604 void test_misMatchedGetterAndSetterTypes_instance_sameTypes() { |
| 2341 Source source = addSource(EngineTestCase.createSource([ | 2605 Source source = addSource(EngineTestCase.createSource([ |
| 2342 "class C {", | 2606 "class C {", |
| 2343 " int get x => 0;", | 2607 " int get x => 0;", |
| 2344 " set x(int v) {}", | 2608 " set x(int v) {}", |
| 2345 "}"])); | 2609 "}"])); |
| 2346 resolve(source); | 2610 resolve(source); |
| 2347 assertNoErrors(source); | 2611 assertNoErrors(source); |
| 2348 verify([source]); | 2612 verify([source]); |
| 2349 } | 2613 } |
| 2614 |
| 2350 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() { | 2615 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() { |
| 2351 Source source = addSource(EngineTestCase.createSource(["class C {", " get x
=> 0;", " set x(String v) {}", "}"])); | 2616 Source source = addSource(EngineTestCase.createSource(["class C {", " get x
=> 0;", " set x(String v) {}", "}"])); |
| 2352 resolve(source); | 2617 resolve(source); |
| 2353 assertNoErrors(source); | 2618 assertNoErrors(source); |
| 2354 verify([source]); | 2619 verify([source]); |
| 2355 } | 2620 } |
| 2621 |
| 2356 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() { | 2622 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() { |
| 2357 Source source = addSource(EngineTestCase.createSource(["class C {", " int g
et x => 0;", " set x(v) {}", "}"])); | 2623 Source source = addSource(EngineTestCase.createSource(["class C {", " int g
et x => 0;", " set x(v) {}", "}"])); |
| 2358 resolve(source); | 2624 resolve(source); |
| 2359 assertNoErrors(source); | 2625 assertNoErrors(source); |
| 2360 verify([source]); | 2626 verify([source]); |
| 2361 } | 2627 } |
| 2628 |
| 2362 void test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() { | 2629 void test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() { |
| 2363 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s
et x(int v) {}"])); | 2630 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s
et x(int v) {}"])); |
| 2364 resolve(source); | 2631 resolve(source); |
| 2365 assertNoErrors(source); | 2632 assertNoErrors(source); |
| 2366 verify([source]); | 2633 verify([source]); |
| 2367 } | 2634 } |
| 2635 |
| 2368 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() { | 2636 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() { |
| 2369 Source source = addSource(EngineTestCase.createSource(["get x => 0;", "set x
(String v) {}"])); | 2637 Source source = addSource(EngineTestCase.createSource(["get x => 0;", "set x
(String v) {}"])); |
| 2370 resolve(source); | 2638 resolve(source); |
| 2371 assertNoErrors(source); | 2639 assertNoErrors(source); |
| 2372 verify([source]); | 2640 verify([source]); |
| 2373 } | 2641 } |
| 2642 |
| 2374 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() { | 2643 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() { |
| 2375 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s
et x(v) {}"])); | 2644 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s
et x(v) {}"])); |
| 2376 resolve(source); | 2645 resolve(source); |
| 2377 assertNoErrors(source); | 2646 assertNoErrors(source); |
| 2378 verify([source]); | 2647 verify([source]); |
| 2379 } | 2648 } |
| 2649 |
| 2380 void test_mixedReturnTypes_differentScopes() { | 2650 void test_mixedReturnTypes_differentScopes() { |
| 2381 Source source = addSource(EngineTestCase.createSource([ | 2651 Source source = addSource(EngineTestCase.createSource([ |
| 2382 "class C {", | 2652 "class C {", |
| 2383 " m(int x) {", | 2653 " m(int x) {", |
| 2384 " f(int y) {", | 2654 " f(int y) {", |
| 2385 " return;", | 2655 " return;", |
| 2386 " }", | 2656 " }", |
| 2387 " f(x);", | 2657 " f(x);", |
| 2388 " return 0;", | 2658 " return 0;", |
| 2389 " }", | 2659 " }", |
| 2390 "}"])); | 2660 "}"])); |
| 2391 resolve(source); | 2661 resolve(source); |
| 2392 assertNoErrors(source); | 2662 assertNoErrors(source); |
| 2393 verify([source]); | 2663 verify([source]); |
| 2394 } | 2664 } |
| 2665 |
| 2666 void test_mixedReturnTypes_ignoreImplicit() { |
| 2667 Source source = addSource(EngineTestCase.createSource([ |
| 2668 "f(bool p) {", |
| 2669 " if (p) return 42;", |
| 2670 " // implicit 'return;' is ignored", |
| 2671 "}"])); |
| 2672 resolve(source); |
| 2673 assertNoErrors(source); |
| 2674 verify([source]); |
| 2675 } |
| 2676 |
| 2677 void test_mixedReturnTypes_ignoreImplicit2() { |
| 2678 Source source = addSource(EngineTestCase.createSource([ |
| 2679 "f(bool p) {", |
| 2680 " if (p) {", |
| 2681 " return 42;", |
| 2682 " } else {", |
| 2683 " return 42;", |
| 2684 " }", |
| 2685 " // implicit 'return;' is ignored", |
| 2686 "}"])); |
| 2687 resolve(source); |
| 2688 assertNoErrors(source); |
| 2689 verify([source]); |
| 2690 } |
| 2691 |
| 2395 void test_mixedReturnTypes_sameKind() { | 2692 void test_mixedReturnTypes_sameKind() { |
| 2396 Source source = addSource(EngineTestCase.createSource([ | 2693 Source source = addSource(EngineTestCase.createSource([ |
| 2397 "class C {", | 2694 "class C {", |
| 2398 " m(int x) {", | 2695 " m(int x) {", |
| 2399 " if (x < 0) {", | 2696 " if (x < 0) {", |
| 2400 " return 1;", | 2697 " return 1;", |
| 2401 " }", | 2698 " }", |
| 2402 " return 0;", | 2699 " return 0;", |
| 2403 " }", | 2700 " }", |
| 2404 "}"])); | 2701 "}"])); |
| 2405 resolve(source); | 2702 resolve(source); |
| 2406 assertNoErrors(source); | 2703 assertNoErrors(source); |
| 2407 verify([source]); | 2704 verify([source]); |
| 2408 } | 2705 } |
| 2706 |
| 2409 void test_mixinDeclaresConstructor() { | 2707 void test_mixinDeclaresConstructor() { |
| 2410 Source source = addSource(EngineTestCase.createSource([ | 2708 Source source = addSource(EngineTestCase.createSource([ |
| 2411 "class A {", | 2709 "class A {", |
| 2412 " m() {}", | 2710 " m() {}", |
| 2413 "}", | 2711 "}", |
| 2414 "class B extends Object with A {}"])); | 2712 "class B extends Object with A {}"])); |
| 2415 resolve(source); | 2713 resolve(source); |
| 2416 assertNoErrors(source); | 2714 assertNoErrors(source); |
| 2417 verify([source]); | 2715 verify([source]); |
| 2418 } | 2716 } |
| 2717 |
| 2419 void test_mixinDeclaresConstructor_factory() { | 2718 void test_mixinDeclaresConstructor_factory() { |
| 2420 Source source = addSource(EngineTestCase.createSource([ | 2719 Source source = addSource(EngineTestCase.createSource([ |
| 2421 "class A {", | 2720 "class A {", |
| 2422 " factory A() {}", | 2721 " factory A() {}", |
| 2423 "}", | 2722 "}", |
| 2424 "class B extends Object with A {}"])); | 2723 "class B extends Object with A {}"])); |
| 2425 resolve(source); | 2724 resolve(source); |
| 2426 assertNoErrors(source); | 2725 assertNoErrors(source); |
| 2427 verify([source]); | 2726 verify([source]); |
| 2428 } | 2727 } |
| 2728 |
| 2429 void test_mixinInheritsFromNotObject_classDeclaration_mixTypeAlias() { | 2729 void test_mixinInheritsFromNotObject_classDeclaration_mixTypeAlias() { |
| 2430 Source source = addSource(EngineTestCase.createSource([ | 2730 Source source = addSource(EngineTestCase.createSource([ |
| 2431 "class A {}", | 2731 "class A {}", |
| 2432 "class B = Object with A;", | 2732 "class B = Object with A;", |
| 2433 "class C extends Object with B {}"])); | 2733 "class C extends Object with B {}"])); |
| 2434 resolve(source); | 2734 resolve(source); |
| 2435 assertNoErrors(source); | 2735 assertNoErrors(source); |
| 2436 verify([source]); | 2736 verify([source]); |
| 2437 } | 2737 } |
| 2738 |
| 2438 void test_mixinInheritsFromNotObject_typedef_mixTypeAlias() { | 2739 void test_mixinInheritsFromNotObject_typedef_mixTypeAlias() { |
| 2439 Source source = addSource(EngineTestCase.createSource([ | 2740 Source source = addSource(EngineTestCase.createSource([ |
| 2440 "class A {}", | 2741 "class A {}", |
| 2441 "class B = Object with A;", | 2742 "class B = Object with A;", |
| 2442 "class C = Object with B;"])); | 2743 "class C = Object with B;"])); |
| 2443 resolve(source); | 2744 resolve(source); |
| 2444 assertNoErrors(source); | 2745 assertNoErrors(source); |
| 2445 verify([source]); | 2746 verify([source]); |
| 2446 } | 2747 } |
| 2748 |
| 2447 void test_multipleSuperInitializers_no() { | 2749 void test_multipleSuperInitializers_no() { |
| 2448 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A {", " B() {}", "}"])); | 2750 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A {", " B() {}", "}"])); |
| 2449 resolve(source); | 2751 resolve(source); |
| 2450 assertNoErrors(source); | 2752 assertNoErrors(source); |
| 2451 verify([source]); | 2753 verify([source]); |
| 2452 } | 2754 } |
| 2755 |
| 2453 void test_multipleSuperInitializers_single() { | 2756 void test_multipleSuperInitializers_single() { |
| 2454 Source source = addSource(EngineTestCase.createSource([ | 2757 Source source = addSource(EngineTestCase.createSource([ |
| 2455 "class A {}", | 2758 "class A {}", |
| 2456 "class B extends A {", | 2759 "class B extends A {", |
| 2457 " B() : super() {}", | 2760 " B() : super() {}", |
| 2458 "}"])); | 2761 "}"])); |
| 2459 resolve(source); | 2762 resolve(source); |
| 2460 assertNoErrors(source); | 2763 assertNoErrors(source); |
| 2461 verify([source]); | 2764 verify([source]); |
| 2462 } | 2765 } |
| 2766 |
| 2463 void test_newWithAbstractClass_factory() { | 2767 void test_newWithAbstractClass_factory() { |
| 2464 Source source = addSource(EngineTestCase.createSource([ | 2768 Source source = addSource(EngineTestCase.createSource([ |
| 2465 "abstract class A {", | 2769 "abstract class A {", |
| 2466 " factory A() { return new B(); }", | 2770 " factory A() { return new B(); }", |
| 2467 "}", | 2771 "}", |
| 2468 "class B implements A {", | 2772 "class B implements A {", |
| 2469 " B() {}", | 2773 " B() {}", |
| 2470 "}", | 2774 "}", |
| 2471 "A f() {", | 2775 "A f() {", |
| 2472 " return new A();", | 2776 " return new A();", |
| 2473 "}"])); | 2777 "}"])); |
| 2474 resolve(source); | 2778 resolve(source); |
| 2475 assertNoErrors(source); | 2779 assertNoErrors(source); |
| 2476 verify([source]); | 2780 verify([source]); |
| 2477 } | 2781 } |
| 2782 |
| 2478 void test_newWithUndefinedConstructor() { | 2783 void test_newWithUndefinedConstructor() { |
| 2479 Source source = addSource(EngineTestCase.createSource([ | 2784 Source source = addSource(EngineTestCase.createSource([ |
| 2480 "class A {", | 2785 "class A {", |
| 2481 " A.name() {}", | 2786 " A.name() {}", |
| 2482 "}", | 2787 "}", |
| 2483 "f() {", | 2788 "f() {", |
| 2484 " new A.name();", | 2789 " new A.name();", |
| 2485 "}"])); | 2790 "}"])); |
| 2486 resolve(source); | 2791 resolve(source); |
| 2487 assertNoErrors(source); | 2792 assertNoErrors(source); |
| 2488 verify([source]); | 2793 verify([source]); |
| 2489 } | 2794 } |
| 2795 |
| 2490 void test_newWithUndefinedConstructorDefault() { | 2796 void test_newWithUndefinedConstructorDefault() { |
| 2491 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "f() {", " new A();", "}"])); | 2797 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "f() {", " new A();", "}"])); |
| 2492 resolve(source); | 2798 resolve(source); |
| 2493 assertNoErrors(source); | 2799 assertNoErrors(source); |
| 2494 verify([source]); | 2800 verify([source]); |
| 2495 } | 2801 } |
| 2802 |
| 2496 void test_nonAbstractClassInheritsAbstractMemberOne_abstractOverridesConcrete_
accessor() { | 2803 void test_nonAbstractClassInheritsAbstractMemberOne_abstractOverridesConcrete_
accessor() { |
| 2497 Source source = addSource(EngineTestCase.createSource([ | 2804 Source source = addSource(EngineTestCase.createSource([ |
| 2498 "class A {", | 2805 "class A {", |
| 2499 " int get g => 0;", | 2806 " int get g => 0;", |
| 2500 "}", | 2807 "}", |
| 2501 "abstract class B extends A {", | 2808 "abstract class B extends A {", |
| 2502 " int get g;", | 2809 " int get g;", |
| 2503 "}", | 2810 "}", |
| 2504 "class C extends B {", | 2811 "class C extends B {", |
| 2505 "}"])); | 2812 "}"])); |
| 2506 resolve(source); | 2813 resolve(source); |
| 2507 assertNoErrors(source); | 2814 assertNoErrors(source); |
| 2508 verify([source]); | 2815 verify([source]); |
| 2509 } | 2816 } |
| 2817 |
| 2510 void test_nonAbstractClassInheritsAbstractMemberOne_abstractOverridesConcrete_
method() { | 2818 void test_nonAbstractClassInheritsAbstractMemberOne_abstractOverridesConcrete_
method() { |
| 2511 Source source = addSource(EngineTestCase.createSource([ | 2819 Source source = addSource(EngineTestCase.createSource([ |
| 2512 "class A {", | 2820 "class A {", |
| 2513 " m(p) {}", | 2821 " m(p) {}", |
| 2514 "}", | 2822 "}", |
| 2515 "abstract class B extends A {", | 2823 "abstract class B extends A {", |
| 2516 " m(p);", | 2824 " m(p);", |
| 2517 "}", | 2825 "}", |
| 2518 "class C extends B {", | 2826 "class C extends B {", |
| 2519 "}"])); | 2827 "}"])); |
| 2520 resolve(source); | 2828 resolve(source); |
| 2521 assertNoErrors(source); | 2829 assertNoErrors(source); |
| 2522 verify([source]); | 2830 verify([source]); |
| 2523 } | 2831 } |
| 2832 |
| 2524 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_accessor() { | 2833 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_accessor() { |
| 2525 Source source = addSource(EngineTestCase.createSource([ | 2834 Source source = addSource(EngineTestCase.createSource([ |
| 2526 "abstract class A {", | 2835 "abstract class A {", |
| 2527 " int get g;", | 2836 " int get g;", |
| 2528 "}", | 2837 "}", |
| 2529 "class B extends A {", | 2838 "class B extends A {", |
| 2530 " noSuchMethod(v) => '';", | 2839 " noSuchMethod(v) => '';", |
| 2531 "}"])); | 2840 "}"])); |
| 2532 resolve(source); | 2841 resolve(source); |
| 2533 assertNoErrors(source); | 2842 assertNoErrors(source); |
| 2534 verify([source]); | 2843 verify([source]); |
| 2535 } | 2844 } |
| 2845 |
| 2536 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_method() { | 2846 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_method() { |
| 2537 Source source = addSource(EngineTestCase.createSource([ | 2847 Source source = addSource(EngineTestCase.createSource([ |
| 2538 "abstract class A {", | 2848 "abstract class A {", |
| 2539 " m(p);", | 2849 " m(p);", |
| 2540 "}", | 2850 "}", |
| 2541 "class B extends A {", | 2851 "class B extends A {", |
| 2542 " noSuchMethod(v) => '';", | 2852 " noSuchMethod(v) => '';", |
| 2543 "}"])); | 2853 "}"])); |
| 2544 resolve(source); | 2854 resolve(source); |
| 2545 assertNoErrors(source); | 2855 assertNoErrors(source); |
| 2546 verify([source]); | 2856 verify([source]); |
| 2547 } | 2857 } |
| 2858 |
| 2548 void test_nonBoolExpression_functionType() { | 2859 void test_nonBoolExpression_functionType() { |
| 2549 Source source = addSource(EngineTestCase.createSource([ | 2860 Source source = addSource(EngineTestCase.createSource([ |
| 2550 "bool makeAssertion() => true;", | 2861 "bool makeAssertion() => true;", |
| 2551 "f() {", | 2862 "f() {", |
| 2552 " assert(makeAssertion);", | 2863 " assert(makeAssertion);", |
| 2553 "}"])); | 2864 "}"])); |
| 2554 resolve(source); | 2865 resolve(source); |
| 2555 assertNoErrors(source); | 2866 assertNoErrors(source); |
| 2556 verify([source]); | 2867 verify([source]); |
| 2557 } | 2868 } |
| 2869 |
| 2558 void test_nonBoolExpression_interfaceType() { | 2870 void test_nonBoolExpression_interfaceType() { |
| 2559 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(tr
ue);", "}"])); | 2871 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(tr
ue);", "}"])); |
| 2560 resolve(source); | 2872 resolve(source); |
| 2561 assertNoErrors(source); | 2873 assertNoErrors(source); |
| 2562 verify([source]); | 2874 verify([source]); |
| 2563 } | 2875 } |
| 2876 |
| 2564 void test_nonBoolNegationExpression() { | 2877 void test_nonBoolNegationExpression() { |
| 2565 Source source = addSource(EngineTestCase.createSource([ | 2878 Source source = addSource(EngineTestCase.createSource([ |
| 2566 "f(bool pb, pd) {", | 2879 "f(bool pb, pd) {", |
| 2567 " !true;", | 2880 " !true;", |
| 2568 " !false;", | 2881 " !false;", |
| 2569 " !pb;", | 2882 " !pb;", |
| 2570 " !pd;", | 2883 " !pd;", |
| 2571 "}"])); | 2884 "}"])); |
| 2572 resolve(source); | 2885 resolve(source); |
| 2573 assertNoErrors(source); | 2886 assertNoErrors(source); |
| 2574 verify([source]); | 2887 verify([source]); |
| 2575 } | 2888 } |
| 2889 |
| 2576 void test_nonConstantDefaultValue_function_named() { | 2890 void test_nonConstantDefaultValue_function_named() { |
| 2577 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"])
); | 2891 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"])
); |
| 2578 resolve(source); | 2892 resolve(source); |
| 2579 assertNoErrors(source); | 2893 assertNoErrors(source); |
| 2580 verify([source]); | 2894 verify([source]); |
| 2581 } | 2895 } |
| 2896 |
| 2582 void test_nonConstantDefaultValue_function_positional() { | 2897 void test_nonConstantDefaultValue_function_positional() { |
| 2583 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"])
); | 2898 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"])
); |
| 2584 resolve(source); | 2899 resolve(source); |
| 2585 assertNoErrors(source); | 2900 assertNoErrors(source); |
| 2586 verify([source]); | 2901 verify([source]); |
| 2587 } | 2902 } |
| 2903 |
| 2588 void test_nonConstantDefaultValue_inConstructor_named() { | 2904 void test_nonConstantDefaultValue_inConstructor_named() { |
| 2589 Source source = addSource(EngineTestCase.createSource(["class A {", " A({x
: 2 + 3}) {}", "}"])); | 2905 Source source = addSource(EngineTestCase.createSource(["class A {", " A({x
: 2 + 3}) {}", "}"])); |
| 2590 resolve(source); | 2906 resolve(source); |
| 2591 assertNoErrors(source); | 2907 assertNoErrors(source); |
| 2592 verify([source]); | 2908 verify([source]); |
| 2593 } | 2909 } |
| 2910 |
| 2594 void test_nonConstantDefaultValue_inConstructor_positional() { | 2911 void test_nonConstantDefaultValue_inConstructor_positional() { |
| 2595 Source source = addSource(EngineTestCase.createSource(["class A {", " A([x
= 2 + 3]) {}", "}"])); | 2912 Source source = addSource(EngineTestCase.createSource(["class A {", " A([x
= 2 + 3]) {}", "}"])); |
| 2596 resolve(source); | 2913 resolve(source); |
| 2597 assertNoErrors(source); | 2914 assertNoErrors(source); |
| 2598 verify([source]); | 2915 verify([source]); |
| 2599 } | 2916 } |
| 2917 |
| 2600 void test_nonConstantDefaultValue_method_named() { | 2918 void test_nonConstantDefaultValue_method_named() { |
| 2601 Source source = addSource(EngineTestCase.createSource(["class A {", " m({x
: 2 + 3}) {}", "}"])); | 2919 Source source = addSource(EngineTestCase.createSource(["class A {", " m({x
: 2 + 3}) {}", "}"])); |
| 2602 resolve(source); | 2920 resolve(source); |
| 2603 assertNoErrors(source); | 2921 assertNoErrors(source); |
| 2604 verify([source]); | 2922 verify([source]); |
| 2605 } | 2923 } |
| 2924 |
| 2606 void test_nonConstantDefaultValue_method_positional() { | 2925 void test_nonConstantDefaultValue_method_positional() { |
| 2607 Source source = addSource(EngineTestCase.createSource(["class A {", " m([x
= 2 + 3]) {}", "}"])); | 2926 Source source = addSource(EngineTestCase.createSource(["class A {", " m([x
= 2 + 3]) {}", "}"])); |
| 2608 resolve(source); | 2927 resolve(source); |
| 2609 assertNoErrors(source); | 2928 assertNoErrors(source); |
| 2610 verify([source]); | 2929 verify([source]); |
| 2611 } | 2930 } |
| 2931 |
| 2612 void test_nonConstantValueInInitializer_namedArgument() { | 2932 void test_nonConstantValueInInitializer_namedArgument() { |
| 2613 Source source = addSource(EngineTestCase.createSource([ | 2933 Source source = addSource(EngineTestCase.createSource([ |
| 2614 "class A {", | 2934 "class A {", |
| 2615 " final a;", | 2935 " final a;", |
| 2616 " const A({this.a});", | 2936 " const A({this.a});", |
| 2617 "}", | 2937 "}", |
| 2618 "class B extends A {", | 2938 "class B extends A {", |
| 2619 " const B({b}) : super(a: b);", | 2939 " const B({b}) : super(a: b);", |
| 2620 "}"])); | 2940 "}"])); |
| 2621 resolve(source); | 2941 resolve(source); |
| 2622 assertNoErrors(source); | 2942 assertNoErrors(source); |
| 2623 verify([source]); | 2943 verify([source]); |
| 2624 } | 2944 } |
| 2945 |
| 2625 void test_nonConstCaseExpression() { | 2946 void test_nonConstCaseExpression() { |
| 2626 Source source = addSource(EngineTestCase.createSource([ | 2947 Source source = addSource(EngineTestCase.createSource([ |
| 2627 "f(Type t) {", | 2948 "f(Type t) {", |
| 2628 " switch (t) {", | 2949 " switch (t) {", |
| 2629 " case bool:", | 2950 " case bool:", |
| 2630 " case int:", | 2951 " case int:", |
| 2631 " return true;", | 2952 " return true;", |
| 2632 " default:", | 2953 " default:", |
| 2633 " return false;", | 2954 " return false;", |
| 2634 " }", | 2955 " }", |
| 2635 "}"])); | 2956 "}"])); |
| 2636 resolve(source); | 2957 resolve(source); |
| 2637 assertNoErrors(source); | 2958 assertNoErrors(source); |
| 2638 verify([source]); | 2959 verify([source]); |
| 2639 } | 2960 } |
| 2961 |
| 2640 void test_nonConstMapAsExpressionStatement_const() { | 2962 void test_nonConstMapAsExpressionStatement_const() { |
| 2641 Source source = addSource(EngineTestCase.createSource(["f() {", " const {'a
' : 0, 'b' : 1};", "}"])); | 2963 Source source = addSource(EngineTestCase.createSource(["f() {", " const {'a
' : 0, 'b' : 1};", "}"])); |
| 2642 resolve(source); | 2964 resolve(source); |
| 2643 assertNoErrors(source); | 2965 assertNoErrors(source); |
| 2644 verify([source]); | 2966 verify([source]); |
| 2645 } | 2967 } |
| 2968 |
| 2646 void test_nonConstMapAsExpressionStatement_notExpressionStatement() { | 2969 void test_nonConstMapAsExpressionStatement_notExpressionStatement() { |
| 2647 Source source = addSource(EngineTestCase.createSource(["f() {", " var m = {
'a' : 0, 'b' : 1};", "}"])); | 2970 Source source = addSource(EngineTestCase.createSource(["f() {", " var m = {
'a' : 0, 'b' : 1};", "}"])); |
| 2648 resolve(source); | 2971 resolve(source); |
| 2649 assertNoErrors(source); | 2972 assertNoErrors(source); |
| 2650 verify([source]); | 2973 verify([source]); |
| 2651 } | 2974 } |
| 2975 |
| 2652 void test_nonConstMapAsExpressionStatement_typeArguments() { | 2976 void test_nonConstMapAsExpressionStatement_typeArguments() { |
| 2653 Source source = addSource(EngineTestCase.createSource(["f() {", " <String,
int> {'a' : 0, 'b' : 1};", "}"])); | 2977 Source source = addSource(EngineTestCase.createSource(["f() {", " <String,
int> {'a' : 0, 'b' : 1};", "}"])); |
| 2654 resolve(source); | 2978 resolve(source); |
| 2655 assertNoErrors(source); | 2979 assertNoErrors(source); |
| 2656 verify([source]); | 2980 verify([source]); |
| 2657 } | 2981 } |
| 2982 |
| 2658 void test_nonConstValueInInitializer_binary_bool() { | 2983 void test_nonConstValueInInitializer_binary_bool() { |
| 2659 Source source = addSource(EngineTestCase.createSource([ | 2984 Source source = addSource(EngineTestCase.createSource([ |
| 2660 "class A {", | 2985 "class A {", |
| 2661 " final v;", | 2986 " final v;", |
| 2662 " const A.a1(bool p) : v = p && true;", | 2987 " const A.a1(bool p) : v = p && true;", |
| 2663 " const A.a2(bool p) : v = true && p;", | 2988 " const A.a2(bool p) : v = true && p;", |
| 2664 " const A.b1(bool p) : v = p || true;", | 2989 " const A.b1(bool p) : v = p || true;", |
| 2665 " const A.b2(bool p) : v = true || p;", | 2990 " const A.b2(bool p) : v = true || p;", |
| 2666 "}"])); | 2991 "}"])); |
| 2667 resolve(source); | 2992 resolve(source); |
| 2668 assertErrors(source, [HintCode.DEAD_CODE]); | 2993 assertErrors(source, [HintCode.DEAD_CODE]); |
| 2669 verify([source]); | 2994 verify([source]); |
| 2670 } | 2995 } |
| 2996 |
| 2671 void test_nonConstValueInInitializer_binary_dynamic() { | 2997 void test_nonConstValueInInitializer_binary_dynamic() { |
| 2672 Source source = addSource(EngineTestCase.createSource([ | 2998 Source source = addSource(EngineTestCase.createSource([ |
| 2673 "class A {", | 2999 "class A {", |
| 2674 " final v;", | 3000 " final v;", |
| 2675 " const A.a1(p) : v = p + 5;", | 3001 " const A.a1(p) : v = p + 5;", |
| 2676 " const A.a2(p) : v = 5 + p;", | 3002 " const A.a2(p) : v = 5 + p;", |
| 2677 " const A.b1(p) : v = p - 5;", | 3003 " const A.b1(p) : v = p - 5;", |
| 2678 " const A.b2(p) : v = 5 - p;", | 3004 " const A.b2(p) : v = 5 - p;", |
| 2679 " const A.c1(p) : v = p * 5;", | 3005 " const A.c1(p) : v = p * 5;", |
| 2680 " const A.c2(p) : v = 5 * p;", | 3006 " const A.c2(p) : v = 5 * p;", |
| 2681 " const A.d1(p) : v = p / 5;", | 3007 " const A.d1(p) : v = p / 5;", |
| 2682 " const A.d2(p) : v = 5 / p;", | 3008 " const A.d2(p) : v = 5 / p;", |
| 2683 " const A.e1(p) : v = p ~/ 5;", | 3009 " const A.e1(p) : v = p ~/ 5;", |
| 2684 " const A.e2(p) : v = 5 ~/ p;", | 3010 " const A.e2(p) : v = 5 ~/ p;", |
| 2685 " const A.f1(p) : v = p > 5;", | 3011 " const A.f1(p) : v = p > 5;", |
| 2686 " const A.f2(p) : v = 5 > p;", | 3012 " const A.f2(p) : v = 5 > p;", |
| 2687 " const A.g1(p) : v = p < 5;", | 3013 " const A.g1(p) : v = p < 5;", |
| 2688 " const A.g2(p) : v = 5 < p;", | 3014 " const A.g2(p) : v = 5 < p;", |
| 2689 " const A.h1(p) : v = p >= 5;", | 3015 " const A.h1(p) : v = p >= 5;", |
| 2690 " const A.h2(p) : v = 5 >= p;", | 3016 " const A.h2(p) : v = 5 >= p;", |
| 2691 " const A.i1(p) : v = p <= 5;", | 3017 " const A.i1(p) : v = p <= 5;", |
| 2692 " const A.i2(p) : v = 5 <= p;", | 3018 " const A.i2(p) : v = 5 <= p;", |
| 2693 " const A.j1(p) : v = p % 5;", | 3019 " const A.j1(p) : v = p % 5;", |
| 2694 " const A.j2(p) : v = 5 % p;", | 3020 " const A.j2(p) : v = 5 % p;", |
| 2695 "}"])); | 3021 "}"])); |
| 2696 resolve(source); | 3022 resolve(source); |
| 2697 assertNoErrors(source); | 3023 assertNoErrors(source); |
| 2698 } | 3024 } |
| 3025 |
| 2699 void test_nonConstValueInInitializer_binary_int() { | 3026 void test_nonConstValueInInitializer_binary_int() { |
| 2700 Source source = addSource(EngineTestCase.createSource([ | 3027 Source source = addSource(EngineTestCase.createSource([ |
| 2701 "class A {", | 3028 "class A {", |
| 2702 " final v;", | 3029 " final v;", |
| 2703 " const A.a1(int p) : v = p ^ 5;", | 3030 " const A.a1(int p) : v = p ^ 5;", |
| 2704 " const A.a2(int p) : v = 5 ^ p;", | 3031 " const A.a2(int p) : v = 5 ^ p;", |
| 2705 " const A.b1(int p) : v = p & 5;", | 3032 " const A.b1(int p) : v = p & 5;", |
| 2706 " const A.b2(int p) : v = 5 & p;", | 3033 " const A.b2(int p) : v = 5 & p;", |
| 2707 " const A.c1(int p) : v = p | 5;", | 3034 " const A.c1(int p) : v = p | 5;", |
| 2708 " const A.c2(int p) : v = 5 | p;", | 3035 " const A.c2(int p) : v = 5 | p;", |
| 2709 " const A.d1(int p) : v = p >> 5;", | 3036 " const A.d1(int p) : v = p >> 5;", |
| 2710 " const A.d2(int p) : v = 5 >> p;", | 3037 " const A.d2(int p) : v = 5 >> p;", |
| 2711 " const A.e1(int p) : v = p << 5;", | 3038 " const A.e1(int p) : v = p << 5;", |
| 2712 " const A.e2(int p) : v = 5 << p;", | 3039 " const A.e2(int p) : v = 5 << p;", |
| 2713 "}"])); | 3040 "}"])); |
| 2714 resolve(source); | 3041 resolve(source); |
| 2715 assertNoErrors(source); | 3042 assertNoErrors(source); |
| 2716 verify([source]); | 3043 verify([source]); |
| 2717 } | 3044 } |
| 3045 |
| 2718 void test_nonConstValueInInitializer_binary_num() { | 3046 void test_nonConstValueInInitializer_binary_num() { |
| 2719 Source source = addSource(EngineTestCase.createSource([ | 3047 Source source = addSource(EngineTestCase.createSource([ |
| 2720 "class A {", | 3048 "class A {", |
| 2721 " final v;", | 3049 " final v;", |
| 2722 " const A.a1(num p) : v = p + 5;", | 3050 " const A.a1(num p) : v = p + 5;", |
| 2723 " const A.a2(num p) : v = 5 + p;", | 3051 " const A.a2(num p) : v = 5 + p;", |
| 2724 " const A.b1(num p) : v = p - 5;", | 3052 " const A.b1(num p) : v = p - 5;", |
| 2725 " const A.b2(num p) : v = 5 - p;", | 3053 " const A.b2(num p) : v = 5 - p;", |
| 2726 " const A.c1(num p) : v = p * 5;", | 3054 " const A.c1(num p) : v = p * 5;", |
| 2727 " const A.c2(num p) : v = 5 * p;", | 3055 " const A.c2(num p) : v = 5 * p;", |
| 2728 " const A.d1(num p) : v = p / 5;", | 3056 " const A.d1(num p) : v = p / 5;", |
| 2729 " const A.d2(num p) : v = 5 / p;", | 3057 " const A.d2(num p) : v = 5 / p;", |
| 2730 " const A.e1(num p) : v = p ~/ 5;", | 3058 " const A.e1(num p) : v = p ~/ 5;", |
| 2731 " const A.e2(num p) : v = 5 ~/ p;", | 3059 " const A.e2(num p) : v = 5 ~/ p;", |
| 2732 " const A.f1(num p) : v = p > 5;", | 3060 " const A.f1(num p) : v = p > 5;", |
| 2733 " const A.f2(num p) : v = 5 > p;", | 3061 " const A.f2(num p) : v = 5 > p;", |
| 2734 " const A.g1(num p) : v = p < 5;", | 3062 " const A.g1(num p) : v = p < 5;", |
| 2735 " const A.g2(num p) : v = 5 < p;", | 3063 " const A.g2(num p) : v = 5 < p;", |
| 2736 " const A.h1(num p) : v = p >= 5;", | 3064 " const A.h1(num p) : v = p >= 5;", |
| 2737 " const A.h2(num p) : v = 5 >= p;", | 3065 " const A.h2(num p) : v = 5 >= p;", |
| 2738 " const A.i1(num p) : v = p <= 5;", | 3066 " const A.i1(num p) : v = p <= 5;", |
| 2739 " const A.i2(num p) : v = 5 <= p;", | 3067 " const A.i2(num p) : v = 5 <= p;", |
| 2740 " const A.j1(num p) : v = p % 5;", | 3068 " const A.j1(num p) : v = p % 5;", |
| 2741 " const A.j2(num p) : v = 5 % p;", | 3069 " const A.j2(num p) : v = 5 % p;", |
| 2742 "}"])); | 3070 "}"])); |
| 2743 resolve(source); | 3071 resolve(source); |
| 2744 assertNoErrors(source); | 3072 assertNoErrors(source); |
| 2745 verify([source]); | 3073 verify([source]); |
| 2746 } | 3074 } |
| 3075 |
| 2747 void test_nonConstValueInInitializer_field() { | 3076 void test_nonConstValueInInitializer_field() { |
| 2748 Source source = addSource(EngineTestCase.createSource([ | 3077 Source source = addSource(EngineTestCase.createSource([ |
| 2749 "class A {", | 3078 "class A {", |
| 2750 " final int a;", | 3079 " final int a;", |
| 2751 " const A() : a = 5;", | 3080 " const A() : a = 5;", |
| 2752 "}"])); | 3081 "}"])); |
| 2753 resolve(source); | 3082 resolve(source); |
| 2754 assertNoErrors(source); | 3083 assertNoErrors(source); |
| 2755 verify([source]); | 3084 verify([source]); |
| 2756 } | 3085 } |
| 3086 |
| 2757 void test_nonConstValueInInitializer_redirecting() { | 3087 void test_nonConstValueInInitializer_redirecting() { |
| 2758 Source source = addSource(EngineTestCase.createSource([ | 3088 Source source = addSource(EngineTestCase.createSource([ |
| 2759 "class A {", | 3089 "class A {", |
| 2760 " const A.named(p);", | 3090 " const A.named(p);", |
| 2761 " const A() : this.named(42);", | 3091 " const A() : this.named(42);", |
| 2762 "}"])); | 3092 "}"])); |
| 2763 resolve(source); | 3093 resolve(source); |
| 2764 assertNoErrors(source); | 3094 assertNoErrors(source); |
| 2765 verify([source]); | 3095 verify([source]); |
| 2766 } | 3096 } |
| 3097 |
| 2767 void test_nonConstValueInInitializer_super() { | 3098 void test_nonConstValueInInitializer_super() { |
| 2768 Source source = addSource(EngineTestCase.createSource([ | 3099 Source source = addSource(EngineTestCase.createSource([ |
| 2769 "class A {", | 3100 "class A {", |
| 2770 " const A(p);", | 3101 " const A(p);", |
| 2771 "}", | 3102 "}", |
| 2772 "class B extends A {", | 3103 "class B extends A {", |
| 2773 " const B() : super(42);", | 3104 " const B() : super(42);", |
| 2774 "}"])); | 3105 "}"])); |
| 2775 resolve(source); | 3106 resolve(source); |
| 2776 assertNoErrors(source); | 3107 assertNoErrors(source); |
| 2777 verify([source]); | 3108 verify([source]); |
| 2778 } | 3109 } |
| 3110 |
| 2779 void test_nonConstValueInInitializer_unary() { | 3111 void test_nonConstValueInInitializer_unary() { |
| 2780 Source source = addSource(EngineTestCase.createSource([ | 3112 Source source = addSource(EngineTestCase.createSource([ |
| 2781 "class A {", | 3113 "class A {", |
| 2782 " final v;", | 3114 " final v;", |
| 2783 " const A.a(bool p) : v = !p;", | 3115 " const A.a(bool p) : v = !p;", |
| 2784 " const A.b(int p) : v = ~p;", | 3116 " const A.b(int p) : v = ~p;", |
| 2785 " const A.c(num p) : v = -p;", | 3117 " const A.c(num p) : v = -p;", |
| 2786 "}"])); | 3118 "}"])); |
| 2787 resolve(source); | 3119 resolve(source); |
| 2788 assertNoErrors(source); | 3120 assertNoErrors(source); |
| 2789 verify([source]); | 3121 verify([source]); |
| 2790 } | 3122 } |
| 3123 |
| 2791 void test_nonGenerativeConstructor() { | 3124 void test_nonGenerativeConstructor() { |
| 2792 Source source = addSource(EngineTestCase.createSource([ | 3125 Source source = addSource(EngineTestCase.createSource([ |
| 2793 "class A {", | 3126 "class A {", |
| 2794 " A.named() {}", | 3127 " A.named() {}", |
| 2795 " factory A() {}", | 3128 " factory A() {}", |
| 2796 "}", | 3129 "}", |
| 2797 "class B extends A {", | 3130 "class B extends A {", |
| 2798 " B() : super.named();", | 3131 " B() : super.named();", |
| 2799 "}"])); | 3132 "}"])); |
| 2800 resolve(source); | 3133 resolve(source); |
| 2801 assertNoErrors(source); | 3134 assertNoErrors(source); |
| 2802 verify([source]); | 3135 verify([source]); |
| 2803 } | 3136 } |
| 3137 |
| 2804 void test_nonTypeInCatchClause_isClass() { | 3138 void test_nonTypeInCatchClause_isClass() { |
| 2805 Source source = addSource(EngineTestCase.createSource([ | 3139 Source source = addSource(EngineTestCase.createSource([ |
| 2806 "f() {", | 3140 "f() {", |
| 2807 " try {", | 3141 " try {", |
| 2808 " } on String catch (e) {", | 3142 " } on String catch (e) {", |
| 2809 " }", | 3143 " }", |
| 2810 "}"])); | 3144 "}"])); |
| 2811 resolve(source); | 3145 resolve(source); |
| 2812 assertNoErrors(source); | 3146 assertNoErrors(source); |
| 2813 verify([source]); | 3147 verify([source]); |
| 2814 } | 3148 } |
| 3149 |
| 2815 void test_nonTypeInCatchClause_isFunctionTypeAlias() { | 3150 void test_nonTypeInCatchClause_isFunctionTypeAlias() { |
| 2816 Source source = addSource(EngineTestCase.createSource([ | 3151 Source source = addSource(EngineTestCase.createSource([ |
| 2817 "typedef F();", | 3152 "typedef F();", |
| 2818 "f() {", | 3153 "f() {", |
| 2819 " try {", | 3154 " try {", |
| 2820 " } on F catch (e) {", | 3155 " } on F catch (e) {", |
| 2821 " }", | 3156 " }", |
| 2822 "}"])); | 3157 "}"])); |
| 2823 resolve(source); | 3158 resolve(source); |
| 2824 assertNoErrors(source); | 3159 assertNoErrors(source); |
| 2825 verify([source]); | 3160 verify([source]); |
| 2826 } | 3161 } |
| 3162 |
| 2827 void test_nonTypeInCatchClause_isTypeParameter() { | 3163 void test_nonTypeInCatchClause_isTypeParameter() { |
| 2828 Source source = addSource(EngineTestCase.createSource([ | 3164 Source source = addSource(EngineTestCase.createSource([ |
| 2829 "class A<T> {", | 3165 "class A<T> {", |
| 2830 " f() {", | 3166 " f() {", |
| 2831 " try {", | 3167 " try {", |
| 2832 " } on T catch (e) {", | 3168 " } on T catch (e) {", |
| 2833 " }", | 3169 " }", |
| 2834 " }", | 3170 " }", |
| 2835 "}"])); | 3171 "}"])); |
| 2836 resolve(source); | 3172 resolve(source); |
| 2837 assertNoErrors(source); | 3173 assertNoErrors(source); |
| 2838 verify([source]); | 3174 verify([source]); |
| 2839 } | 3175 } |
| 3176 |
| 2840 void test_nonTypeInCatchClause_noType() { | 3177 void test_nonTypeInCatchClause_noType() { |
| 2841 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", "
} catch (e) {", " }", "}"])); | 3178 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", "
} catch (e) {", " }", "}"])); |
| 2842 resolve(source); | 3179 resolve(source); |
| 2843 assertNoErrors(source); | 3180 assertNoErrors(source); |
| 2844 verify([source]); | 3181 verify([source]); |
| 2845 } | 3182 } |
| 3183 |
| 2846 void test_nonVoidReturnForOperator_no() { | 3184 void test_nonVoidReturnForOperator_no() { |
| 2847 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor []=(a, b) {}", "}"])); | 3185 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor []=(a, b) {}", "}"])); |
| 2848 resolve(source); | 3186 resolve(source); |
| 2849 assertNoErrors(source); | 3187 assertNoErrors(source); |
| 2850 verify([source]); | 3188 verify([source]); |
| 2851 } | 3189 } |
| 3190 |
| 2852 void test_nonVoidReturnForOperator_void() { | 3191 void test_nonVoidReturnForOperator_void() { |
| 2853 Source source = addSource(EngineTestCase.createSource(["class A {", " void
operator []=(a, b) {}", "}"])); | 3192 Source source = addSource(EngineTestCase.createSource(["class A {", " void
operator []=(a, b) {}", "}"])); |
| 2854 resolve(source); | 3193 resolve(source); |
| 2855 assertNoErrors(source); | 3194 assertNoErrors(source); |
| 2856 verify([source]); | 3195 verify([source]); |
| 2857 } | 3196 } |
| 3197 |
| 2858 void test_nonVoidReturnForSetter_function_no() { | 3198 void test_nonVoidReturnForSetter_function_no() { |
| 2859 Source source = addSource("set x(v) {}"); | 3199 Source source = addSource("set x(v) {}"); |
| 2860 resolve(source); | 3200 resolve(source); |
| 2861 assertNoErrors(source); | 3201 assertNoErrors(source); |
| 2862 verify([source]); | 3202 verify([source]); |
| 2863 } | 3203 } |
| 3204 |
| 2864 void test_nonVoidReturnForSetter_function_void() { | 3205 void test_nonVoidReturnForSetter_function_void() { |
| 2865 Source source = addSource("void set x(v) {}"); | 3206 Source source = addSource("void set x(v) {}"); |
| 2866 resolve(source); | 3207 resolve(source); |
| 2867 assertNoErrors(source); | 3208 assertNoErrors(source); |
| 2868 verify([source]); | 3209 verify([source]); |
| 2869 } | 3210 } |
| 3211 |
| 2870 void test_nonVoidReturnForSetter_method_no() { | 3212 void test_nonVoidReturnForSetter_method_no() { |
| 2871 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(v) {}", "}"])); | 3213 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(v) {}", "}"])); |
| 2872 resolve(source); | 3214 resolve(source); |
| 2873 assertNoErrors(source); | 3215 assertNoErrors(source); |
| 2874 verify([source]); | 3216 verify([source]); |
| 2875 } | 3217 } |
| 3218 |
| 2876 void test_nonVoidReturnForSetter_method_void() { | 3219 void test_nonVoidReturnForSetter_method_void() { |
| 2877 Source source = addSource(EngineTestCase.createSource(["class A {", " void
set x(v) {}", "}"])); | 3220 Source source = addSource(EngineTestCase.createSource(["class A {", " void
set x(v) {}", "}"])); |
| 2878 resolve(source); | 3221 resolve(source); |
| 2879 assertNoErrors(source); | 3222 assertNoErrors(source); |
| 2880 verify([source]); | 3223 verify([source]); |
| 2881 } | 3224 } |
| 3225 |
| 2882 void test_null_callMethod() { | 3226 void test_null_callMethod() { |
| 2883 Source source = addSource(EngineTestCase.createSource(["main() {", " null.m
();", "}"])); | 3227 Source source = addSource(EngineTestCase.createSource(["main() {", " null.m
();", "}"])); |
| 2884 resolve(source); | 3228 resolve(source); |
| 2885 assertNoErrors(source); | 3229 assertNoErrors(source); |
| 2886 } | 3230 } |
| 3231 |
| 2887 void test_null_callOperator() { | 3232 void test_null_callOperator() { |
| 2888 Source source = addSource(EngineTestCase.createSource([ | 3233 Source source = addSource(EngineTestCase.createSource([ |
| 2889 "main() {", | 3234 "main() {", |
| 2890 " null + 5;", | 3235 " null + 5;", |
| 2891 " null == 5;", | 3236 " null == 5;", |
| 2892 " null[0];", | 3237 " null[0];", |
| 2893 "}"])); | 3238 "}"])); |
| 2894 resolve(source); | 3239 resolve(source); |
| 2895 assertNoErrors(source); | 3240 assertNoErrors(source); |
| 2896 } | 3241 } |
| 3242 |
| 2897 void test_optionalParameterInOperator_required() { | 3243 void test_optionalParameterInOperator_required() { |
| 2898 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +(p) {}", "}"])); | 3244 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +(p) {}", "}"])); |
| 2899 resolve(source); | 3245 resolve(source); |
| 2900 assertNoErrors(source); | 3246 assertNoErrors(source); |
| 2901 verify([source]); | 3247 verify([source]); |
| 2902 } | 3248 } |
| 3249 |
| 2903 void test_prefixCollidesWithTopLevelMembers() { | 3250 void test_prefixCollidesWithTopLevelMembers() { |
| 2904 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {}"])); | 3251 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {}"])); |
| 2905 Source source = addSource(EngineTestCase.createSource([ | 3252 Source source = addSource(EngineTestCase.createSource([ |
| 2906 "import 'lib.dart' as p;", | 3253 "import 'lib.dart' as p;", |
| 2907 "typedef P();", | 3254 "typedef P();", |
| 2908 "p2() {}", | 3255 "p2() {}", |
| 2909 "var p3;", | 3256 "var p3;", |
| 2910 "class p4 {}", | 3257 "class p4 {}", |
| 2911 "p.A a;"])); | 3258 "p.A a;"])); |
| 2912 resolve(source); | 3259 resolve(source); |
| 2913 assertNoErrors(source); | 3260 assertNoErrors(source); |
| 2914 verify([source]); | 3261 verify([source]); |
| 2915 } | 3262 } |
| 3263 |
| 2916 void test_propagateTypeArgs_intoBounds() { | 3264 void test_propagateTypeArgs_intoBounds() { |
| 2917 Source source = addSource(EngineTestCase.createSource([ | 3265 Source source = addSource(EngineTestCase.createSource([ |
| 2918 "abstract class A<E> {}", | 3266 "abstract class A<E> {}", |
| 2919 "abstract class B<F> implements A<F>{}", | 3267 "abstract class B<F> implements A<F>{}", |
| 2920 "abstract class C<G, H extends A<G>> {}", | 3268 "abstract class C<G, H extends A<G>> {}", |
| 2921 "class D<I> extends C<I, B<I>> {}"])); | 3269 "class D<I> extends C<I, B<I>> {}"])); |
| 2922 resolve(source); | 3270 resolve(source); |
| 2923 assertNoErrors(source); | 3271 assertNoErrors(source); |
| 2924 verify([source]); | 3272 verify([source]); |
| 2925 } | 3273 } |
| 3274 |
| 2926 void test_propagateTypeArgs_intoSupertype() { | 3275 void test_propagateTypeArgs_intoSupertype() { |
| 2927 Source source = addSource(EngineTestCase.createSource([ | 3276 Source source = addSource(EngineTestCase.createSource([ |
| 2928 "class A<T> {", | 3277 "class A<T> {", |
| 2929 " A(T p);", | 3278 " A(T p);", |
| 2930 " A.named(T p);", | 3279 " A.named(T p);", |
| 2931 "}", | 3280 "}", |
| 2932 "class B<S> extends A<S> {", | 3281 "class B<S> extends A<S> {", |
| 2933 " B(S p) : super(p);", | 3282 " B(S p) : super(p);", |
| 2934 " B.named(S p) : super.named(p);", | 3283 " B.named(S p) : super.named(p);", |
| 2935 "}"])); | 3284 "}"])); |
| 2936 resolve(source); | 3285 resolve(source); |
| 2937 assertNoErrors(source); | 3286 assertNoErrors(source); |
| 2938 verify([source]); | 3287 verify([source]); |
| 2939 } | 3288 } |
| 3289 |
| 2940 void test_proxy_annotation_prefixed() { | 3290 void test_proxy_annotation_prefixed() { |
| 2941 Source source = addSource(EngineTestCase.createSource([ | 3291 Source source = addSource(EngineTestCase.createSource([ |
| 2942 "library L;", | 3292 "library L;", |
| 2943 "import 'meta.dart';", | |
| 2944 "@proxy", | 3293 "@proxy", |
| 2945 "class A {}", | 3294 "class A {}", |
| 2946 "f(A a) {", | 3295 "f(A a) {", |
| 2947 " a.m();", | 3296 " a.m();", |
| 2948 " var x = a.g;", | 3297 " var x = a.g;", |
| 2949 " a.s = 1;", | 3298 " a.s = 1;", |
| 2950 " var y = a + a;", | 3299 " var y = a + a;", |
| 2951 " a++;", | 3300 " a++;", |
| 2952 " ++a;", | 3301 " ++a;", |
| 2953 "}"])); | 3302 "}"])); |
| 2954 addSource2("/meta.dart", EngineTestCase.createSource([ | |
| 2955 "library meta;", | |
| 2956 "const proxy = const _Proxy();", | |
| 2957 "class _Proxy { const _Proxy(); }"])); | |
| 2958 resolve(source); | 3303 resolve(source); |
| 2959 assertNoErrors(source); | 3304 assertNoErrors(source); |
| 2960 } | 3305 } |
| 3306 |
| 2961 void test_proxy_annotation_prefixed2() { | 3307 void test_proxy_annotation_prefixed2() { |
| 2962 Source source = addSource(EngineTestCase.createSource([ | 3308 Source source = addSource(EngineTestCase.createSource([ |
| 2963 "library L;", | 3309 "library L;", |
| 2964 "import 'meta.dart';", | |
| 2965 "@proxy", | 3310 "@proxy", |
| 2966 "class A {}", | 3311 "class A {}", |
| 2967 "class B {", | 3312 "class B {", |
| 2968 " f(A a) {", | 3313 " f(A a) {", |
| 2969 " a.m();", | 3314 " a.m();", |
| 2970 " var x = a.g;", | 3315 " var x = a.g;", |
| 2971 " a.s = 1;", | 3316 " a.s = 1;", |
| 2972 " var y = a + a;", | 3317 " var y = a + a;", |
| 2973 " a++;", | 3318 " a++;", |
| 2974 " ++a;", | 3319 " ++a;", |
| 2975 " }", | 3320 " }", |
| 2976 "}"])); | 3321 "}"])); |
| 2977 addSource2("/meta.dart", EngineTestCase.createSource([ | |
| 2978 "library meta;", | |
| 2979 "const proxy = const _Proxy();", | |
| 2980 "class _Proxy { const _Proxy(); }"])); | |
| 2981 resolve(source); | 3322 resolve(source); |
| 2982 assertNoErrors(source); | 3323 assertNoErrors(source); |
| 2983 } | 3324 } |
| 3325 |
| 2984 void test_proxy_annotation_prefixed3() { | 3326 void test_proxy_annotation_prefixed3() { |
| 2985 Source source = addSource(EngineTestCase.createSource([ | 3327 Source source = addSource(EngineTestCase.createSource([ |
| 2986 "library L;", | 3328 "library L;", |
| 2987 "import 'meta.dart';", | |
| 2988 "class B {", | 3329 "class B {", |
| 2989 " f(A a) {", | 3330 " f(A a) {", |
| 2990 " a.m();", | 3331 " a.m();", |
| 2991 " var x = a.g;", | 3332 " var x = a.g;", |
| 2992 " a.s = 1;", | 3333 " a.s = 1;", |
| 2993 " var y = a + a;", | 3334 " var y = a + a;", |
| 2994 " a++;", | 3335 " a++;", |
| 2995 " ++a;", | 3336 " ++a;", |
| 2996 " }", | 3337 " }", |
| 2997 "}", | 3338 "}", |
| 2998 "@proxy", | 3339 "@proxy", |
| 2999 "class A {}"])); | 3340 "class A {}"])); |
| 3000 addSource2("/meta.dart", EngineTestCase.createSource([ | |
| 3001 "library meta;", | |
| 3002 "const proxy = const _Proxy();", | |
| 3003 "class _Proxy { const _Proxy(); }"])); | |
| 3004 resolve(source); | 3341 resolve(source); |
| 3005 assertNoErrors(source); | 3342 assertNoErrors(source); |
| 3006 } | 3343 } |
| 3344 |
| 3007 void test_proxy_annotation_simple() { | 3345 void test_proxy_annotation_simple() { |
| 3008 Source source = addSource(EngineTestCase.createSource([ | 3346 Source source = addSource(EngineTestCase.createSource([ |
| 3009 "library L;", | 3347 "library L;", |
| 3010 "import 'meta.dart';", | |
| 3011 "@proxy", | 3348 "@proxy", |
| 3012 "class B {", | 3349 "class B {", |
| 3013 " m() {", | 3350 " m() {", |
| 3014 " n();", | 3351 " n();", |
| 3015 " var x = g;", | 3352 " var x = g;", |
| 3016 " s = 1;", | 3353 " s = 1;", |
| 3017 " var y = this + this;", | 3354 " var y = this + this;", |
| 3018 " }", | 3355 " }", |
| 3019 "}"])); | 3356 "}"])); |
| 3020 addSource2("/meta.dart", EngineTestCase.createSource([ | |
| 3021 "library meta;", | |
| 3022 "const proxy = const _Proxy();", | |
| 3023 "class _Proxy { const _Proxy(); }"])); | |
| 3024 resolve(source); | 3357 resolve(source); |
| 3025 assertNoErrors(source); | 3358 assertNoErrors(source); |
| 3026 } | 3359 } |
| 3360 |
| 3027 void test_recursiveConstructorRedirect() { | 3361 void test_recursiveConstructorRedirect() { |
| 3028 Source source = addSource(EngineTestCase.createSource([ | 3362 Source source = addSource(EngineTestCase.createSource([ |
| 3029 "class A {", | 3363 "class A {", |
| 3030 " A.a() : this.b();", | 3364 " A.a() : this.b();", |
| 3031 " A.b() : this.c();", | 3365 " A.b() : this.c();", |
| 3032 " A.c() {}", | 3366 " A.c() {}", |
| 3033 "}"])); | 3367 "}"])); |
| 3034 resolve(source); | 3368 resolve(source); |
| 3035 assertNoErrors(source); | 3369 assertNoErrors(source); |
| 3036 verify([source]); | 3370 verify([source]); |
| 3037 } | 3371 } |
| 3372 |
| 3038 void test_recursiveFactoryRedirect() { | 3373 void test_recursiveFactoryRedirect() { |
| 3039 Source source = addSource(EngineTestCase.createSource([ | 3374 Source source = addSource(EngineTestCase.createSource([ |
| 3040 "class A {", | 3375 "class A {", |
| 3041 " factory A() = B;", | 3376 " factory A() = B;", |
| 3042 "}", | 3377 "}", |
| 3043 "class B implements A {", | 3378 "class B implements A {", |
| 3044 " factory B() = C;", | 3379 " factory B() = C;", |
| 3045 "}", | 3380 "}", |
| 3046 "class C implements B {", | 3381 "class C implements B {", |
| 3047 " factory C() {}", | 3382 " factory C() {}", |
| 3048 "}"])); | 3383 "}"])); |
| 3049 resolve(source); | 3384 resolve(source); |
| 3050 assertNoErrors(source); | 3385 assertNoErrors(source); |
| 3051 verify([source]); | 3386 verify([source]); |
| 3052 } | 3387 } |
| 3388 |
| 3053 void test_redirectToInvalidFunctionType() { | 3389 void test_redirectToInvalidFunctionType() { |
| 3054 Source source = addSource(EngineTestCase.createSource([ | 3390 Source source = addSource(EngineTestCase.createSource([ |
| 3055 "class A implements B {", | 3391 "class A implements B {", |
| 3056 " A(int p) {}", | 3392 " A(int p) {}", |
| 3057 "}", | 3393 "}", |
| 3058 "class B {", | 3394 "class B {", |
| 3059 " factory B(int p) = A;", | 3395 " factory B(int p) = A;", |
| 3060 "}"])); | 3396 "}"])); |
| 3061 resolve(source); | 3397 resolve(source); |
| 3062 assertNoErrors(source); | 3398 assertNoErrors(source); |
| 3063 verify([source]); | 3399 verify([source]); |
| 3064 } | 3400 } |
| 3401 |
| 3065 void test_redirectToInvalidReturnType() { | 3402 void test_redirectToInvalidReturnType() { |
| 3066 Source source = addSource(EngineTestCase.createSource([ | 3403 Source source = addSource(EngineTestCase.createSource([ |
| 3067 "class A {", | 3404 "class A {", |
| 3068 " A() {}", | 3405 " A() {}", |
| 3069 "}", | 3406 "}", |
| 3070 "class B extends A {", | 3407 "class B extends A {", |
| 3071 " factory B() = A;", | 3408 " factory B() = A;", |
| 3072 "}"])); | 3409 "}"])); |
| 3073 resolve(source); | 3410 resolve(source); |
| 3074 assertNoErrors(source); | 3411 assertNoErrors(source); |
| 3075 verify([source]); | 3412 verify([source]); |
| 3076 } | 3413 } |
| 3414 |
| 3077 void test_redirectToNonConstConstructor() { | 3415 void test_redirectToNonConstConstructor() { |
| 3078 Source source = addSource(EngineTestCase.createSource([ | 3416 Source source = addSource(EngineTestCase.createSource([ |
| 3079 "class A {", | 3417 "class A {", |
| 3080 " const A.a();", | 3418 " const A.a();", |
| 3081 " const factory A.b() = A.a;", | 3419 " const factory A.b() = A.a;", |
| 3082 "}"])); | 3420 "}"])); |
| 3083 resolve(source); | 3421 resolve(source); |
| 3084 assertNoErrors(source); | 3422 assertNoErrors(source); |
| 3085 verify([source]); | 3423 verify([source]); |
| 3086 } | 3424 } |
| 3425 |
| 3087 void test_referenceToDeclaredVariableInInitializer_constructorName() { | 3426 void test_referenceToDeclaredVariableInInitializer_constructorName() { |
| 3088 Source source = addSource(EngineTestCase.createSource([ | 3427 Source source = addSource(EngineTestCase.createSource([ |
| 3089 "class A {", | 3428 "class A {", |
| 3090 " A.x() {}", | 3429 " A.x() {}", |
| 3091 "}", | 3430 "}", |
| 3092 "f() {", | 3431 "f() {", |
| 3093 " var x = new A.x();", | 3432 " var x = new A.x();", |
| 3094 "}"])); | 3433 "}"])); |
| 3095 resolve(source); | 3434 resolve(source); |
| 3096 assertNoErrors(source); | 3435 assertNoErrors(source); |
| 3097 verify([source]); | 3436 verify([source]); |
| 3098 } | 3437 } |
| 3438 |
| 3099 void test_referenceToDeclaredVariableInInitializer_methodName() { | 3439 void test_referenceToDeclaredVariableInInitializer_methodName() { |
| 3100 Source source = addSource(EngineTestCase.createSource([ | 3440 Source source = addSource(EngineTestCase.createSource([ |
| 3101 "class A {", | 3441 "class A {", |
| 3102 " x() {}", | 3442 " x() {}", |
| 3103 "}", | 3443 "}", |
| 3104 "f(A a) {", | 3444 "f(A a) {", |
| 3105 " var x = a.x();", | 3445 " var x = a.x();", |
| 3106 "}"])); | 3446 "}"])); |
| 3107 resolve(source); | 3447 resolve(source); |
| 3108 assertNoErrors(source); | 3448 assertNoErrors(source); |
| 3109 verify([source]); | 3449 verify([source]); |
| 3110 } | 3450 } |
| 3451 |
| 3111 void test_referenceToDeclaredVariableInInitializer_propertyName() { | 3452 void test_referenceToDeclaredVariableInInitializer_propertyName() { |
| 3112 Source source = addSource(EngineTestCase.createSource([ | 3453 Source source = addSource(EngineTestCase.createSource([ |
| 3113 "class A {", | 3454 "class A {", |
| 3114 " var x;", | 3455 " var x;", |
| 3115 "}", | 3456 "}", |
| 3116 "f(A a) {", | 3457 "f(A a) {", |
| 3117 " var x = a.x;", | 3458 " var x = a.x;", |
| 3118 "}"])); | 3459 "}"])); |
| 3119 resolve(source); | 3460 resolve(source); |
| 3120 assertNoErrors(source); | 3461 assertNoErrors(source); |
| 3121 verify([source]); | 3462 verify([source]); |
| 3122 } | 3463 } |
| 3464 |
| 3123 void test_rethrowOutsideCatch() { | 3465 void test_rethrowOutsideCatch() { |
| 3124 Source source = addSource(EngineTestCase.createSource([ | 3466 Source source = addSource(EngineTestCase.createSource([ |
| 3125 "class A {", | 3467 "class A {", |
| 3126 " void m() {", | 3468 " void m() {", |
| 3127 " try {} catch (e) {rethrow;}", | 3469 " try {} catch (e) {rethrow;}", |
| 3128 " }", | 3470 " }", |
| 3129 "}"])); | 3471 "}"])); |
| 3130 resolve(source); | 3472 resolve(source); |
| 3131 assertNoErrors(source); | 3473 assertNoErrors(source); |
| 3132 verify([source]); | 3474 verify([source]); |
| 3133 } | 3475 } |
| 3476 |
| 3134 void test_returnInGenerativeConstructor() { | 3477 void test_returnInGenerativeConstructor() { |
| 3135 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
return; }", "}"])); | 3478 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
return; }", "}"])); |
| 3136 resolve(source); | 3479 resolve(source); |
| 3137 assertNoErrors(source); | 3480 assertNoErrors(source); |
| 3138 verify([source]); | 3481 verify([source]); |
| 3139 } | 3482 } |
| 3483 |
| 3140 void test_returnOfInvalidType_dynamic() { | 3484 void test_returnOfInvalidType_dynamic() { |
| 3141 Source source = addSource(EngineTestCase.createSource([ | 3485 Source source = addSource(EngineTestCase.createSource([ |
| 3142 "class TypeError {}", | 3486 "class TypeError {}", |
| 3143 "class A {", | 3487 "class A {", |
| 3144 " static void testLogicalOp() {", | 3488 " static void testLogicalOp() {", |
| 3145 " testOr(a, b, onTypeError) {", | 3489 " testOr(a, b, onTypeError) {", |
| 3146 " try {", | 3490 " try {", |
| 3147 " return a || b;", | 3491 " return a || b;", |
| 3148 " } on TypeError catch (t) {", | 3492 " } on TypeError catch (t) {", |
| 3149 " return onTypeError;", | 3493 " return onTypeError;", |
| 3150 " }", | 3494 " }", |
| 3151 " }", | 3495 " }", |
| 3152 " }", | 3496 " }", |
| 3153 "}"])); | 3497 "}"])); |
| 3154 resolve(source); | 3498 resolve(source); |
| 3155 assertNoErrors(source); | 3499 assertNoErrors(source); |
| 3156 verify([source]); | 3500 verify([source]); |
| 3157 } | 3501 } |
| 3502 |
| 3158 void test_returnOfInvalidType_dynamicAsTypeArgument() { | 3503 void test_returnOfInvalidType_dynamicAsTypeArgument() { |
| 3159 Source source = addSource(EngineTestCase.createSource([ | 3504 Source source = addSource(EngineTestCase.createSource([ |
| 3160 "class I<T> {", | 3505 "class I<T> {", |
| 3161 " factory I() => new A<T>();", | 3506 " factory I() => new A<T>();", |
| 3162 "}", | 3507 "}", |
| 3163 "class A<T> implements I {", | 3508 "class A<T> implements I {", |
| 3164 "}"])); | 3509 "}"])); |
| 3165 resolve(source); | 3510 resolve(source); |
| 3166 assertNoErrors(source); | 3511 assertNoErrors(source); |
| 3167 verify([source]); | 3512 verify([source]); |
| 3168 } | 3513 } |
| 3514 |
| 3169 void test_returnOfInvalidType_subtype() { | 3515 void test_returnOfInvalidType_subtype() { |
| 3170 Source source = addSource(EngineTestCase.createSource([ | 3516 Source source = addSource(EngineTestCase.createSource([ |
| 3171 "class A {}", | 3517 "class A {}", |
| 3172 "class B extends A {}", | 3518 "class B extends A {}", |
| 3173 "A f(B b) { return b; }"])); | 3519 "A f(B b) { return b; }"])); |
| 3174 resolve(source); | 3520 resolve(source); |
| 3175 assertNoErrors(source); | 3521 assertNoErrors(source); |
| 3176 verify([source]); | 3522 verify([source]); |
| 3177 } | 3523 } |
| 3524 |
| 3178 void test_returnOfInvalidType_supertype() { | 3525 void test_returnOfInvalidType_supertype() { |
| 3179 Source source = addSource(EngineTestCase.createSource([ | 3526 Source source = addSource(EngineTestCase.createSource([ |
| 3180 "class A {}", | 3527 "class A {}", |
| 3181 "class B extends A {}", | 3528 "class B extends A {}", |
| 3182 "B f(A a) { return a; }"])); | 3529 "B f(A a) { return a; }"])); |
| 3183 resolve(source); | 3530 resolve(source); |
| 3184 assertNoErrors(source); | 3531 assertNoErrors(source); |
| 3185 verify([source]); | 3532 verify([source]); |
| 3186 } | 3533 } |
| 3534 |
| 3187 void test_returnOfInvalidType_void() { | 3535 void test_returnOfInvalidType_void() { |
| 3188 Source source = addSource(EngineTestCase.createSource([ | 3536 Source source = addSource(EngineTestCase.createSource([ |
| 3189 "void f1() {}", | 3537 "void f1() {}", |
| 3190 "void f2() { return; }", | 3538 "void f2() { return; }", |
| 3191 "void f3() { return null; }", | 3539 "void f3() { return null; }", |
| 3192 "void f4() { return g1(); }", | 3540 "void f4() { return g1(); }", |
| 3193 "void f5() { return g2(); }", | 3541 "void f5() { return g2(); }", |
| 3194 "g1() {}", | 3542 "g1() {}", |
| 3195 "void g2() {}", | 3543 "void g2() {}", |
| 3196 ""])); | 3544 ""])); |
| 3197 resolve(source); | 3545 resolve(source); |
| 3198 assertNoErrors(source); | 3546 assertNoErrors(source); |
| 3199 verify([source]); | 3547 verify([source]); |
| 3200 } | 3548 } |
| 3549 |
| 3201 void test_returnWithoutValue_noReturnType() { | 3550 void test_returnWithoutValue_noReturnType() { |
| 3202 Source source = addSource(EngineTestCase.createSource(["f() { return; }"])); | 3551 Source source = addSource(EngineTestCase.createSource(["f() { return; }"])); |
| 3203 resolve(source); | 3552 resolve(source); |
| 3204 assertNoErrors(source); | 3553 assertNoErrors(source); |
| 3205 verify([source]); | 3554 verify([source]); |
| 3206 } | 3555 } |
| 3556 |
| 3207 void test_returnWithoutValue_void() { | 3557 void test_returnWithoutValue_void() { |
| 3208 Source source = addSource(EngineTestCase.createSource(["void f() { return; }
"])); | 3558 Source source = addSource(EngineTestCase.createSource(["void f() { return; }
"])); |
| 3209 resolve(source); | 3559 resolve(source); |
| 3210 assertNoErrors(source); | 3560 assertNoErrors(source); |
| 3211 verify([source]); | 3561 verify([source]); |
| 3212 } | 3562 } |
| 3563 |
| 3213 void test_reversedTypeArguments() { | 3564 void test_reversedTypeArguments() { |
| 3214 Source source = addSource(EngineTestCase.createSource([ | 3565 Source source = addSource(EngineTestCase.createSource([ |
| 3215 "class Codec<S1, T1> {", | 3566 "class Codec<S1, T1> {", |
| 3216 " Codec<T1, S1> get inverted => new _InvertedCodec<T1, S1>(this);", | 3567 " Codec<T1, S1> get inverted => new _InvertedCodec<T1, S1>(this);", |
| 3217 "}", | 3568 "}", |
| 3218 "class _InvertedCodec<T2, S2> extends Codec<T2, S2> {", | 3569 "class _InvertedCodec<T2, S2> extends Codec<T2, S2> {", |
| 3219 " _InvertedCodec(Codec<S2, T2> codec);", | 3570 " _InvertedCodec(Codec<S2, T2> codec);", |
| 3220 "}"])); | 3571 "}"])); |
| 3221 resolve(source); | 3572 resolve(source); |
| 3222 assertNoErrors(source); | 3573 assertNoErrors(source); |
| 3223 verify([source]); | 3574 verify([source]); |
| 3224 } | 3575 } |
| 3576 |
| 3225 void test_staticAccessToInstanceMember_annotation() { | 3577 void test_staticAccessToInstanceMember_annotation() { |
| 3226 Source source = addSource(EngineTestCase.createSource([ | 3578 Source source = addSource(EngineTestCase.createSource([ |
| 3227 "class A {", | 3579 "class A {", |
| 3228 " const A.name();", | 3580 " const A.name();", |
| 3229 "}", | 3581 "}", |
| 3230 "@A.name()", | 3582 "@A.name()", |
| 3231 "main() {", | 3583 "main() {", |
| 3232 "}"])); | 3584 "}"])); |
| 3233 resolve(source); | 3585 resolve(source); |
| 3234 assertNoErrors(source); | 3586 assertNoErrors(source); |
| 3235 verify([source]); | 3587 verify([source]); |
| 3236 } | 3588 } |
| 3589 |
| 3237 void test_staticAccessToInstanceMember_method() { | 3590 void test_staticAccessToInstanceMember_method() { |
| 3238 Source source = addSource(EngineTestCase.createSource([ | 3591 Source source = addSource(EngineTestCase.createSource([ |
| 3239 "class A {", | 3592 "class A {", |
| 3240 " static m() {}", | 3593 " static m() {}", |
| 3241 "}", | 3594 "}", |
| 3242 "main() {", | 3595 "main() {", |
| 3243 " A.m;", | 3596 " A.m;", |
| 3244 " A.m();", | 3597 " A.m();", |
| 3245 "}"])); | 3598 "}"])); |
| 3246 resolve(source); | 3599 resolve(source); |
| 3247 assertNoErrors(source); | 3600 assertNoErrors(source); |
| 3248 verify([source]); | 3601 verify([source]); |
| 3249 } | 3602 } |
| 3603 |
| 3250 void test_staticAccessToInstanceMember_propertyAccess_field() { | 3604 void test_staticAccessToInstanceMember_propertyAccess_field() { |
| 3251 Source source = addSource(EngineTestCase.createSource([ | 3605 Source source = addSource(EngineTestCase.createSource([ |
| 3252 "class A {", | 3606 "class A {", |
| 3253 " static var f;", | 3607 " static var f;", |
| 3254 "}", | 3608 "}", |
| 3255 "main() {", | 3609 "main() {", |
| 3256 " A.f;", | 3610 " A.f;", |
| 3257 " A.f = 1;", | 3611 " A.f = 1;", |
| 3258 "}"])); | 3612 "}"])); |
| 3259 resolve(source); | 3613 resolve(source); |
| 3260 assertNoErrors(source); | 3614 assertNoErrors(source); |
| 3261 verify([source]); | 3615 verify([source]); |
| 3262 } | 3616 } |
| 3617 |
| 3263 void test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() { | 3618 void test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() { |
| 3264 Source source = addSource(EngineTestCase.createSource([ | 3619 Source source = addSource(EngineTestCase.createSource([ |
| 3265 "class A {", | 3620 "class A {", |
| 3266 " static get f => 42;", | 3621 " static get f => 42;", |
| 3267 " static set f(x) {}", | 3622 " static set f(x) {}", |
| 3268 "}", | 3623 "}", |
| 3269 "main() {", | 3624 "main() {", |
| 3270 " A.f;", | 3625 " A.f;", |
| 3271 " A.f = 1;", | 3626 " A.f = 1;", |
| 3272 "}"])); | 3627 "}"])); |
| 3273 resolve(source); | 3628 resolve(source); |
| 3274 assertNoErrors(source); | 3629 assertNoErrors(source); |
| 3275 verify([source]); | 3630 verify([source]); |
| 3276 } | 3631 } |
| 3632 |
| 3277 void test_superInInvalidContext() { | 3633 void test_superInInvalidContext() { |
| 3278 Source source = addSource(EngineTestCase.createSource([ | 3634 Source source = addSource(EngineTestCase.createSource([ |
| 3279 "class A {", | 3635 "class A {", |
| 3280 " m() {}", | 3636 " m() {}", |
| 3281 "}", | 3637 "}", |
| 3282 "class B extends A {", | 3638 "class B extends A {", |
| 3283 " B() {", | 3639 " B() {", |
| 3284 " var v = super.m();", | 3640 " var v = super.m();", |
| 3285 " }", | 3641 " }", |
| 3286 " n() {", | 3642 " n() {", |
| 3287 " var v = super.m();", | 3643 " var v = super.m();", |
| 3288 " }", | 3644 " }", |
| 3289 "}"])); | 3645 "}"])); |
| 3290 resolve(source); | 3646 resolve(source); |
| 3291 assertNoErrors(source); | 3647 assertNoErrors(source); |
| 3292 verify([source]); | 3648 verify([source]); |
| 3293 } | 3649 } |
| 3650 |
| 3294 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { | 3651 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { |
| 3295 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "cl
ass B {", " A a;", "}"])); | 3652 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "cl
ass B {", " A a;", "}"])); |
| 3296 resolve(source); | 3653 resolve(source); |
| 3297 assertNoErrors(source); | 3654 assertNoErrors(source); |
| 3298 verify([source]); | 3655 verify([source]); |
| 3299 } | 3656 } |
| 3657 |
| 3300 void test_typeArgumentNotMatchingBounds_const() { | 3658 void test_typeArgumentNotMatchingBounds_const() { |
| 3301 Source source = addSource(EngineTestCase.createSource([ | 3659 Source source = addSource(EngineTestCase.createSource([ |
| 3302 "class A {}", | 3660 "class A {}", |
| 3303 "class B extends A {}", | 3661 "class B extends A {}", |
| 3304 "class G<E extends A> {", | 3662 "class G<E extends A> {", |
| 3305 " const G();", | 3663 " const G();", |
| 3306 "}", | 3664 "}", |
| 3307 "f() { return const G<B>(); }"])); | 3665 "f() { return const G<B>(); }"])); |
| 3308 resolve(source); | 3666 resolve(source); |
| 3309 assertNoErrors(source); | 3667 assertNoErrors(source); |
| 3310 verify([source]); | 3668 verify([source]); |
| 3311 } | 3669 } |
| 3670 |
| 3312 void test_typeArgumentNotMatchingBounds_new() { | 3671 void test_typeArgumentNotMatchingBounds_new() { |
| 3313 Source source = addSource(EngineTestCase.createSource([ | 3672 Source source = addSource(EngineTestCase.createSource([ |
| 3314 "class A {}", | 3673 "class A {}", |
| 3315 "class B extends A {}", | 3674 "class B extends A {}", |
| 3316 "class G<E extends A> {}", | 3675 "class G<E extends A> {}", |
| 3317 "f() { return new G<B>(); }"])); | 3676 "f() { return new G<B>(); }"])); |
| 3318 resolve(source); | 3677 resolve(source); |
| 3319 assertNoErrors(source); | 3678 assertNoErrors(source); |
| 3320 verify([source]); | 3679 verify([source]); |
| 3321 } | 3680 } |
| 3681 |
| 3322 void test_typeArgumentNotMatchingBounds_typeArgumentList_0() { | 3682 void test_typeArgumentNotMatchingBounds_typeArgumentList_0() { |
| 3323 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A>{}"])); | 3683 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A>{}"])); |
| 3324 resolve(source); | 3684 resolve(source); |
| 3325 assertNoErrors(source); | 3685 assertNoErrors(source); |
| 3326 verify([source]); | 3686 verify([source]); |
| 3327 } | 3687 } |
| 3688 |
| 3328 void test_typeArgumentNotMatchingBounds_typeArgumentList_1() { | 3689 void test_typeArgumentNotMatchingBounds_typeArgumentList_1() { |
| 3329 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A<A>>{}"])); | 3690 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A<A>>{}"])); |
| 3330 resolve(source); | 3691 resolve(source); |
| 3331 assertNoErrors(source); | 3692 assertNoErrors(source); |
| 3332 verify([source]); | 3693 verify([source]); |
| 3333 } | 3694 } |
| 3695 |
| 3334 void test_typeArgumentNotMatchingBounds_typeArgumentList_20() { | 3696 void test_typeArgumentNotMatchingBounds_typeArgumentList_20() { |
| 3335 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A>>>>>>>>>>>>>>>>>>>>>{}"])); | 3697 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A>>>>>>>>>>>>>>>>>>>>>{}"])); |
| 3336 resolve(source); | 3698 resolve(source); |
| 3337 assertNoErrors(source); | 3699 assertNoErrors(source); |
| 3338 verify([source]); | 3700 verify([source]); |
| 3339 } | 3701 } |
| 3702 |
| 3340 void test_typePromotion_booleanAnd_useInRight() { | 3703 void test_typePromotion_booleanAnd_useInRight() { |
| 3341 Source source = addSource(EngineTestCase.createSource([ | 3704 Source source = addSource(EngineTestCase.createSource([ |
| 3342 "main(Object p) {", | 3705 "main(Object p) {", |
| 3343 " p is String && p.length != 0;", | 3706 " p is String && p.length != 0;", |
| 3344 "}"])); | 3707 "}"])); |
| 3345 resolve(source); | 3708 resolve(source); |
| 3346 assertNoErrors(source); | 3709 assertNoErrors(source); |
| 3347 verify([source]); | 3710 verify([source]); |
| 3348 } | 3711 } |
| 3712 |
| 3349 void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignm
ent() { | 3713 void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignm
ent() { |
| 3350 Source source = addSource(EngineTestCase.createSource([ | 3714 Source source = addSource(EngineTestCase.createSource([ |
| 3351 "callMe(f()) { f(); }", | 3715 "callMe(f()) { f(); }", |
| 3352 "main(Object p) {", | 3716 "main(Object p) {", |
| 3353 " (p is String) && callMe(() { p.length; });", | 3717 " (p is String) && callMe(() { p.length; });", |
| 3354 "}"])); | 3718 "}"])); |
| 3355 resolve(source); | 3719 resolve(source); |
| 3356 assertNoErrors(source); | 3720 assertNoErrors(source); |
| 3357 verify([source]); | 3721 verify([source]); |
| 3358 } | 3722 } |
| 3723 |
| 3724 void test_typePromotion_conditional_issue14655() { |
| 3725 Source source = addSource(EngineTestCase.createSource([ |
| 3726 "class A {}", |
| 3727 "class B extends A {}", |
| 3728 "class C extends B {", |
| 3729 " mc() {}", |
| 3730 "}", |
| 3731 "print(_) {}", |
| 3732 "main(A p) {", |
| 3733 " (p is C) && (print(() => p) && (p is B)) ? p.mc() : p = null;", |
| 3734 "}"])); |
| 3735 resolve(source); |
| 3736 assertNoErrors(source); |
| 3737 verify([source]); |
| 3738 } |
| 3739 |
| 3359 void test_typePromotion_conditional_useInThen() { | 3740 void test_typePromotion_conditional_useInThen() { |
| 3360 Source source = addSource(EngineTestCase.createSource(["main(Object p) {", "
p is String ? p.length : 0;", "}"])); | 3741 Source source = addSource(EngineTestCase.createSource(["main(Object p) {", "
p is String ? p.length : 0;", "}"])); |
| 3361 resolve(source); | 3742 resolve(source); |
| 3362 assertNoErrors(source); | 3743 assertNoErrors(source); |
| 3363 verify([source]); | 3744 verify([source]); |
| 3364 } | 3745 } |
| 3746 |
| 3365 void test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment()
{ | 3747 void test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment()
{ |
| 3366 Source source = addSource(EngineTestCase.createSource([ | 3748 Source source = addSource(EngineTestCase.createSource([ |
| 3367 "callMe(f()) { f(); }", | 3749 "callMe(f()) { f(); }", |
| 3368 "main(Object p) {", | 3750 "main(Object p) {", |
| 3369 " p is String ? callMe(() { p.length; }) : 0;", | 3751 " p is String ? callMe(() { p.length; }) : 0;", |
| 3370 "}"])); | 3752 "}"])); |
| 3371 resolve(source); | 3753 resolve(source); |
| 3372 assertNoErrors(source); | 3754 assertNoErrors(source); |
| 3373 verify([source]); | 3755 verify([source]); |
| 3374 } | 3756 } |
| 3757 |
| 3375 void test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific() { | 3758 void test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific() { |
| 3376 Source source = addSource(EngineTestCase.createSource([ | 3759 Source source = addSource(EngineTestCase.createSource([ |
| 3377 "typedef FuncB(B b);", | 3760 "typedef FuncB(B b);", |
| 3378 "typedef FuncA(A a);", | 3761 "typedef FuncA(A a);", |
| 3379 "class A {}", | 3762 "class A {}", |
| 3380 "class B {}", | 3763 "class B {}", |
| 3381 "main(FuncA f) {", | 3764 "main(FuncA f) {", |
| 3382 " if (f is FuncB) {", | 3765 " if (f is FuncB) {", |
| 3383 " f(new A());", | 3766 " f(new A());", |
| 3384 " }", | 3767 " }", |
| 3385 "}"])); | 3768 "}"])); |
| 3386 resolve(source); | 3769 resolve(source); |
| 3387 assertNoErrors(source); | 3770 assertNoErrors(source); |
| 3388 verify([source]); | 3771 verify([source]); |
| 3389 } | 3772 } |
| 3773 |
| 3390 void test_typePromotion_functionType_return_ignoreIfNotMoreSpecific() { | 3774 void test_typePromotion_functionType_return_ignoreIfNotMoreSpecific() { |
| 3391 Source source = addSource(EngineTestCase.createSource([ | 3775 Source source = addSource(EngineTestCase.createSource([ |
| 3776 "class A {}", |
| 3777 "typedef FuncAtoDyn(A a);", |
| 3392 "typedef FuncDynToDyn(x);", | 3778 "typedef FuncDynToDyn(x);", |
| 3393 "typedef void FuncDynToVoid(x);", | 3779 "main(FuncAtoDyn f) {", |
| 3394 "class A {}", | 3780 " if (f is FuncDynToDyn) {", |
| 3395 "main(FuncDynToDyn f) {", | 3781 " A a = f(new A());", |
| 3396 " if (f is FuncDynToVoid) {", | |
| 3397 " A a = f(null);", | |
| 3398 " }", | 3782 " }", |
| 3399 "}"])); | 3783 "}"])); |
| 3400 resolve(source); | 3784 resolve(source); |
| 3401 assertNoErrors(source); | 3785 assertNoErrors(source); |
| 3402 verify([source]); | 3786 verify([source]); |
| 3403 } | 3787 } |
| 3788 |
| 3404 void test_typePromotion_functionType_return_voidToDynamic() { | 3789 void test_typePromotion_functionType_return_voidToDynamic() { |
| 3405 Source source = addSource(EngineTestCase.createSource([ | 3790 Source source = addSource(EngineTestCase.createSource([ |
| 3406 "typedef FuncDynToDyn(x);", | 3791 "typedef FuncDynToDyn(x);", |
| 3407 "typedef void FuncDynToVoid(x);", | 3792 "typedef void FuncDynToVoid(x);", |
| 3408 "class A {}", | 3793 "class A {}", |
| 3409 "main(FuncDynToVoid f) {", | 3794 "main(FuncDynToVoid f) {", |
| 3410 " if (f is FuncDynToDyn) {", | 3795 " if (f is FuncDynToDyn) {", |
| 3411 " A a = f(null);", | 3796 " A a = f(null);", |
| 3412 " }", | 3797 " }", |
| 3413 "}"])); | 3798 "}"])); |
| 3414 resolve(source); | 3799 resolve(source); |
| 3415 assertNoErrors(source); | 3800 assertNoErrors(source); |
| 3416 verify([source]); | 3801 verify([source]); |
| 3417 } | 3802 } |
| 3803 |
| 3418 void test_typePromotion_if_accessedInClosure_noAssignment() { | 3804 void test_typePromotion_if_accessedInClosure_noAssignment() { |
| 3419 Source source = addSource(EngineTestCase.createSource([ | 3805 Source source = addSource(EngineTestCase.createSource([ |
| 3420 "callMe(f()) { f(); }", | 3806 "callMe(f()) { f(); }", |
| 3421 "main(Object p) {", | 3807 "main(Object p) {", |
| 3422 " if (p is String) {", | 3808 " if (p is String) {", |
| 3423 " callMe(() {", | 3809 " callMe(() {", |
| 3424 " p.length;", | 3810 " p.length;", |
| 3425 " });", | 3811 " });", |
| 3426 " }", | 3812 " }", |
| 3427 "}"])); | 3813 "}"])); |
| 3428 resolve(source); | 3814 resolve(source); |
| 3429 assertNoErrors(source); | 3815 assertNoErrors(source); |
| 3430 verify([source]); | 3816 verify([source]); |
| 3431 } | 3817 } |
| 3818 |
| 3432 void test_typePromotion_if_extends_moreSpecific() { | 3819 void test_typePromotion_if_extends_moreSpecific() { |
| 3433 Source source = addSource(EngineTestCase.createSource([ | 3820 Source source = addSource(EngineTestCase.createSource([ |
| 3434 "class V {}", | 3821 "class V {}", |
| 3435 "class VP extends V {}", | 3822 "class VP extends V {}", |
| 3436 "class A<T> {}", | 3823 "class A<T> {}", |
| 3437 "class B<S> extends A<S> {", | 3824 "class B<S> extends A<S> {", |
| 3438 " var b;", | 3825 " var b;", |
| 3439 "}", | 3826 "}", |
| 3440 "", | 3827 "", |
| 3441 "main(A<V> p) {", | 3828 "main(A<V> p) {", |
| 3442 " if (p is B<VP>) {", | 3829 " if (p is B<VP>) {", |
| 3443 " p.b;", | 3830 " p.b;", |
| 3444 " }", | 3831 " }", |
| 3445 "}"])); | 3832 "}"])); |
| 3446 resolve(source); | 3833 resolve(source); |
| 3447 assertNoErrors(source); | 3834 assertNoErrors(source); |
| 3448 verify([source]); | 3835 verify([source]); |
| 3449 } | 3836 } |
| 3837 |
| 3450 void test_typePromotion_if_hasAssignment_outsideAfter() { | 3838 void test_typePromotion_if_hasAssignment_outsideAfter() { |
| 3451 Source source = addSource(EngineTestCase.createSource([ | 3839 Source source = addSource(EngineTestCase.createSource([ |
| 3452 "main(Object p) {", | 3840 "main(Object p) {", |
| 3453 " if (p is String) {", | 3841 " if (p is String) {", |
| 3454 " p.length;", | 3842 " p.length;", |
| 3455 " }", | 3843 " }", |
| 3456 " p = 0;", | 3844 " p = 0;", |
| 3457 "}"])); | 3845 "}"])); |
| 3458 resolve(source); | 3846 resolve(source); |
| 3459 assertNoErrors(source); | 3847 assertNoErrors(source); |
| 3460 verify([source]); | 3848 verify([source]); |
| 3461 } | 3849 } |
| 3850 |
| 3462 void test_typePromotion_if_hasAssignment_outsideBefore() { | 3851 void test_typePromotion_if_hasAssignment_outsideBefore() { |
| 3463 Source source = addSource(EngineTestCase.createSource([ | 3852 Source source = addSource(EngineTestCase.createSource([ |
| 3464 "main(Object p, Object p2) {", | 3853 "main(Object p, Object p2) {", |
| 3465 " p = p2;", | 3854 " p = p2;", |
| 3466 " if (p is String) {", | 3855 " if (p is String) {", |
| 3467 " p.length;", | 3856 " p.length;", |
| 3468 " }", | 3857 " }", |
| 3469 "}"])); | 3858 "}"])); |
| 3470 resolve(source); | 3859 resolve(source); |
| 3471 assertNoErrors(source); | 3860 assertNoErrors(source); |
| 3472 verify([source]); | 3861 verify([source]); |
| 3473 } | 3862 } |
| 3863 |
| 3474 void test_typePromotion_if_implements_moreSpecific() { | 3864 void test_typePromotion_if_implements_moreSpecific() { |
| 3475 Source source = addSource(EngineTestCase.createSource([ | 3865 Source source = addSource(EngineTestCase.createSource([ |
| 3476 "class V {}", | 3866 "class V {}", |
| 3477 "class VP extends V {}", | 3867 "class VP extends V {}", |
| 3478 "class A<T> {}", | 3868 "class A<T> {}", |
| 3479 "class B<S> implements A<S> {", | 3869 "class B<S> implements A<S> {", |
| 3480 " var b;", | 3870 " var b;", |
| 3481 "}", | 3871 "}", |
| 3482 "", | 3872 "", |
| 3483 "main(A<V> p) {", | 3873 "main(A<V> p) {", |
| 3484 " if (p is B<VP>) {", | 3874 " if (p is B<VP>) {", |
| 3485 " p.b;", | 3875 " p.b;", |
| 3486 " }", | 3876 " }", |
| 3487 "}"])); | 3877 "}"])); |
| 3488 resolve(source); | 3878 resolve(source); |
| 3489 assertNoErrors(source); | 3879 assertNoErrors(source); |
| 3490 verify([source]); | 3880 verify([source]); |
| 3491 } | 3881 } |
| 3882 |
| 3492 void test_typePromotion_if_inClosure_assignedAfter_inSameFunction() { | 3883 void test_typePromotion_if_inClosure_assignedAfter_inSameFunction() { |
| 3493 Source source = addSource(EngineTestCase.createSource([ | 3884 Source source = addSource(EngineTestCase.createSource([ |
| 3494 "main() {", | 3885 "main() {", |
| 3495 " f(Object p) {", | 3886 " f(Object p) {", |
| 3496 " if (p is String) {", | 3887 " if (p is String) {", |
| 3497 " p.length;", | 3888 " p.length;", |
| 3498 " }", | 3889 " }", |
| 3499 " p = 0;", | 3890 " p = 0;", |
| 3500 " };", | 3891 " };", |
| 3501 "}"])); | 3892 "}"])); |
| 3502 resolve(source); | 3893 resolve(source); |
| 3503 assertNoErrors(source); | 3894 assertNoErrors(source); |
| 3504 verify([source]); | 3895 verify([source]); |
| 3505 } | 3896 } |
| 3897 |
| 3506 void test_typePromotion_if_is_and_left() { | 3898 void test_typePromotion_if_is_and_left() { |
| 3507 Source source = addSource(EngineTestCase.createSource([ | 3899 Source source = addSource(EngineTestCase.createSource([ |
| 3508 "bool tt() => true;", | 3900 "bool tt() => true;", |
| 3509 "main(Object p) {", | 3901 "main(Object p) {", |
| 3510 " if (p is String && tt()) {", | 3902 " if (p is String && tt()) {", |
| 3511 " p.length;", | 3903 " p.length;", |
| 3512 " }", | 3904 " }", |
| 3513 "}"])); | 3905 "}"])); |
| 3514 resolve(source); | 3906 resolve(source); |
| 3515 assertNoErrors(source); | 3907 assertNoErrors(source); |
| 3516 verify([source]); | 3908 verify([source]); |
| 3517 } | 3909 } |
| 3910 |
| 3518 void test_typePromotion_if_is_and_right() { | 3911 void test_typePromotion_if_is_and_right() { |
| 3519 Source source = addSource(EngineTestCase.createSource([ | 3912 Source source = addSource(EngineTestCase.createSource([ |
| 3520 "bool tt() => true;", | 3913 "bool tt() => true;", |
| 3521 "main(Object p) {", | 3914 "main(Object p) {", |
| 3522 " if (tt() && p is String) {", | 3915 " if (tt() && p is String) {", |
| 3523 " p.length;", | 3916 " p.length;", |
| 3524 " }", | 3917 " }", |
| 3525 "}"])); | 3918 "}"])); |
| 3526 resolve(source); | 3919 resolve(source); |
| 3527 assertNoErrors(source); | 3920 assertNoErrors(source); |
| 3528 verify([source]); | 3921 verify([source]); |
| 3529 } | 3922 } |
| 3923 |
| 3530 void test_typePromotion_if_is_and_subThenSuper() { | 3924 void test_typePromotion_if_is_and_subThenSuper() { |
| 3531 Source source = addSource(EngineTestCase.createSource([ | 3925 Source source = addSource(EngineTestCase.createSource([ |
| 3532 "class A {", | 3926 "class A {", |
| 3533 " var a;", | 3927 " var a;", |
| 3534 "}", | 3928 "}", |
| 3535 "class B extends A {", | 3929 "class B extends A {", |
| 3536 " var b;", | 3930 " var b;", |
| 3537 "}", | 3931 "}", |
| 3538 "main(Object p) {", | 3932 "main(Object p) {", |
| 3539 " if (p is B && p is A) {", | 3933 " if (p is B && p is A) {", |
| 3540 " p.a;", | 3934 " p.a;", |
| 3541 " p.b;", | 3935 " p.b;", |
| 3542 " }", | 3936 " }", |
| 3543 "}"])); | 3937 "}"])); |
| 3544 resolve(source); | 3938 resolve(source); |
| 3545 assertNoErrors(source); | 3939 assertNoErrors(source); |
| 3546 verify([source]); | 3940 verify([source]); |
| 3547 } | 3941 } |
| 3942 |
| 3548 void test_typePromotion_if_is_parenthesized() { | 3943 void test_typePromotion_if_is_parenthesized() { |
| 3549 Source source = addSource(EngineTestCase.createSource([ | 3944 Source source = addSource(EngineTestCase.createSource([ |
| 3550 "main(Object p) {", | 3945 "main(Object p) {", |
| 3551 " if ((p is String)) {", | 3946 " if ((p is String)) {", |
| 3552 " p.length;", | 3947 " p.length;", |
| 3553 " }", | 3948 " }", |
| 3554 "}"])); | 3949 "}"])); |
| 3555 resolve(source); | 3950 resolve(source); |
| 3556 assertNoErrors(source); | 3951 assertNoErrors(source); |
| 3557 verify([source]); | 3952 verify([source]); |
| 3558 } | 3953 } |
| 3954 |
| 3559 void test_typePromotion_if_is_single() { | 3955 void test_typePromotion_if_is_single() { |
| 3560 Source source = addSource(EngineTestCase.createSource([ | 3956 Source source = addSource(EngineTestCase.createSource([ |
| 3561 "main(Object p) {", | 3957 "main(Object p) {", |
| 3562 " if (p is String) {", | 3958 " if (p is String) {", |
| 3563 " p.length;", | 3959 " p.length;", |
| 3564 " }", | 3960 " }", |
| 3565 "}"])); | 3961 "}"])); |
| 3566 resolve(source); | 3962 resolve(source); |
| 3567 assertNoErrors(source); | 3963 assertNoErrors(source); |
| 3568 verify([source]); | 3964 verify([source]); |
| 3569 } | 3965 } |
| 3966 |
| 3967 void test_typePromotion_parentheses() { |
| 3968 Source source = addSource(EngineTestCase.createSource([ |
| 3969 "main(Object p) {", |
| 3970 " (p is String) ? p.length : 0;", |
| 3971 " (p) is String ? p.length : 0;", |
| 3972 " ((p)) is String ? p.length : 0;", |
| 3973 " ((p) is String) ? p.length : 0;", |
| 3974 "}"])); |
| 3975 resolve(source); |
| 3976 assertNoErrors(source); |
| 3977 verify([source]); |
| 3978 } |
| 3979 |
| 3570 void test_typeType_class() { | 3980 void test_typeType_class() { |
| 3571 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(Type
t) {}", "main() {", " f(C);", "}"])); | 3981 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(Type
t) {}", "main() {", " f(C);", "}"])); |
| 3572 resolve(source); | 3982 resolve(source); |
| 3573 assertNoErrors(source); | 3983 assertNoErrors(source); |
| 3574 verify([source]); | 3984 verify([source]); |
| 3575 } | 3985 } |
| 3986 |
| 3576 void test_typeType_class_prefixed() { | 3987 void test_typeType_class_prefixed() { |
| 3577 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
C {}"])); | 3988 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
C {}"])); |
| 3578 Source source = addSource(EngineTestCase.createSource([ | 3989 Source source = addSource(EngineTestCase.createSource([ |
| 3579 "import 'lib.dart' as p;", | 3990 "import 'lib.dart' as p;", |
| 3580 "f(Type t) {}", | 3991 "f(Type t) {}", |
| 3581 "main() {", | 3992 "main() {", |
| 3582 " f(p.C);", | 3993 " f(p.C);", |
| 3583 "}"])); | 3994 "}"])); |
| 3584 resolve(source); | 3995 resolve(source); |
| 3585 assertNoErrors(source); | 3996 assertNoErrors(source); |
| 3586 verify([source]); | 3997 verify([source]); |
| 3587 } | 3998 } |
| 3999 |
| 3588 void test_typeType_functionTypeAlias() { | 4000 void test_typeType_functionTypeAlias() { |
| 3589 Source source = addSource(EngineTestCase.createSource([ | 4001 Source source = addSource(EngineTestCase.createSource([ |
| 3590 "typedef F();", | 4002 "typedef F();", |
| 3591 "f(Type t) {}", | 4003 "f(Type t) {}", |
| 3592 "main() {", | 4004 "main() {", |
| 3593 " f(F);", | 4005 " f(F);", |
| 3594 "}"])); | 4006 "}"])); |
| 3595 resolve(source); | 4007 resolve(source); |
| 3596 assertNoErrors(source); | 4008 assertNoErrors(source); |
| 3597 verify([source]); | 4009 verify([source]); |
| 3598 } | 4010 } |
| 4011 |
| 3599 void test_typeType_functionTypeAlias_prefixed() { | 4012 void test_typeType_functionTypeAlias_prefixed() { |
| 3600 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "typede
f F();"])); | 4013 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "typede
f F();"])); |
| 3601 Source source = addSource(EngineTestCase.createSource([ | 4014 Source source = addSource(EngineTestCase.createSource([ |
| 3602 "import 'lib.dart' as p;", | 4015 "import 'lib.dart' as p;", |
| 3603 "f(Type t) {}", | 4016 "f(Type t) {}", |
| 3604 "main() {", | 4017 "main() {", |
| 3605 " f(p.F);", | 4018 " f(p.F);", |
| 3606 "}"])); | 4019 "}"])); |
| 3607 resolve(source); | 4020 resolve(source); |
| 3608 assertNoErrors(source); | 4021 assertNoErrors(source); |
| 3609 verify([source]); | 4022 verify([source]); |
| 3610 } | 4023 } |
| 4024 |
| 3611 void test_undefinedConstructorInInitializer_explicit_named() { | 4025 void test_undefinedConstructorInInitializer_explicit_named() { |
| 3612 Source source = addSource(EngineTestCase.createSource([ | 4026 Source source = addSource(EngineTestCase.createSource([ |
| 3613 "class A {", | 4027 "class A {", |
| 3614 " A.named() {}", | 4028 " A.named() {}", |
| 3615 "}", | 4029 "}", |
| 3616 "class B extends A {", | 4030 "class B extends A {", |
| 3617 " B() : super.named();", | 4031 " B() : super.named();", |
| 3618 "}"])); | 4032 "}"])); |
| 3619 resolve(source); | 4033 resolve(source); |
| 3620 assertNoErrors(source); | 4034 assertNoErrors(source); |
| 3621 verify([source]); | 4035 verify([source]); |
| 3622 } | 4036 } |
| 4037 |
| 3623 void test_undefinedConstructorInInitializer_explicit_unnamed() { | 4038 void test_undefinedConstructorInInitializer_explicit_unnamed() { |
| 3624 Source source = addSource(EngineTestCase.createSource([ | 4039 Source source = addSource(EngineTestCase.createSource([ |
| 3625 "class A {", | 4040 "class A {", |
| 3626 " A() {}", | 4041 " A() {}", |
| 3627 "}", | 4042 "}", |
| 3628 "class B extends A {", | 4043 "class B extends A {", |
| 3629 " B() : super();", | 4044 " B() : super();", |
| 3630 "}"])); | 4045 "}"])); |
| 3631 resolve(source); | 4046 resolve(source); |
| 3632 assertNoErrors(source); | 4047 assertNoErrors(source); |
| 3633 verify([source]); | 4048 verify([source]); |
| 3634 } | 4049 } |
| 4050 |
| 3635 void test_undefinedConstructorInInitializer_hasOptionalParameters() { | 4051 void test_undefinedConstructorInInitializer_hasOptionalParameters() { |
| 3636 Source source = addSource(EngineTestCase.createSource([ | 4052 Source source = addSource(EngineTestCase.createSource([ |
| 3637 "class A {", | 4053 "class A {", |
| 3638 " A([p]) {}", | 4054 " A([p]) {}", |
| 3639 "}", | 4055 "}", |
| 3640 "class B extends A {", | 4056 "class B extends A {", |
| 3641 " B();", | 4057 " B();", |
| 3642 "}"])); | 4058 "}"])); |
| 3643 resolve(source); | 4059 resolve(source); |
| 3644 assertNoErrors(source); | 4060 assertNoErrors(source); |
| 3645 verify([source]); | 4061 verify([source]); |
| 3646 } | 4062 } |
| 4063 |
| 3647 void test_undefinedConstructorInInitializer_implicit() { | 4064 void test_undefinedConstructorInInitializer_implicit() { |
| 3648 Source source = addSource(EngineTestCase.createSource([ | 4065 Source source = addSource(EngineTestCase.createSource([ |
| 3649 "class A {", | 4066 "class A {", |
| 3650 " A() {}", | 4067 " A() {}", |
| 3651 "}", | 4068 "}", |
| 3652 "class B extends A {", | 4069 "class B extends A {", |
| 3653 " B();", | 4070 " B();", |
| 3654 "}"])); | 4071 "}"])); |
| 3655 resolve(source); | 4072 resolve(source); |
| 3656 assertNoErrors(source); | 4073 assertNoErrors(source); |
| 3657 verify([source]); | 4074 verify([source]); |
| 3658 } | 4075 } |
| 4076 |
| 3659 void test_undefinedConstructorInInitializer_implicit_typeAlias() { | 4077 void test_undefinedConstructorInInitializer_implicit_typeAlias() { |
| 3660 Source source = addSource(EngineTestCase.createSource([ | 4078 Source source = addSource(EngineTestCase.createSource([ |
| 3661 "class M {}", | 4079 "class M {}", |
| 3662 "class A = Object with M;", | 4080 "class A = Object with M;", |
| 3663 "class B extends A {", | 4081 "class B extends A {", |
| 3664 " B();", | 4082 " B();", |
| 3665 "}"])); | 4083 "}"])); |
| 3666 resolve(source); | 4084 resolve(source); |
| 3667 assertNoErrors(source); | 4085 assertNoErrors(source); |
| 3668 verify([source]); | 4086 verify([source]); |
| 3669 } | 4087 } |
| 4088 |
| 3670 void test_undefinedConstructorInInitializer_redirecting() { | 4089 void test_undefinedConstructorInInitializer_redirecting() { |
| 3671 Source source = addSource(EngineTestCase.createSource([ | 4090 Source source = addSource(EngineTestCase.createSource([ |
| 3672 "class Foo {", | 4091 "class Foo {", |
| 3673 " Foo.ctor();", | 4092 " Foo.ctor();", |
| 3674 "}", | 4093 "}", |
| 3675 "class Bar extends Foo {", | 4094 "class Bar extends Foo {", |
| 3676 " Bar() : this.ctor();", | 4095 " Bar() : this.ctor();", |
| 3677 " Bar.ctor() : super.ctor();", | 4096 " Bar.ctor() : super.ctor();", |
| 3678 "}"])); | 4097 "}"])); |
| 3679 resolve(source); | 4098 resolve(source); |
| 3680 assertNoErrors(source); | 4099 assertNoErrors(source); |
| 3681 verify([source]); | 4100 verify([source]); |
| 3682 } | 4101 } |
| 4102 |
| 3683 void test_undefinedGetter_typeSubstitution() { | 4103 void test_undefinedGetter_typeSubstitution() { |
| 3684 Source source = addSource(EngineTestCase.createSource([ | 4104 Source source = addSource(EngineTestCase.createSource([ |
| 3685 "class A<E> {", | 4105 "class A<E> {", |
| 3686 " E element;", | 4106 " E element;", |
| 3687 "}", | 4107 "}", |
| 3688 "class B extends A<List> {", | 4108 "class B extends A<List> {", |
| 3689 " m() {", | 4109 " m() {", |
| 3690 " element.last;", | 4110 " element.last;", |
| 3691 " }", | 4111 " }", |
| 3692 "}"])); | 4112 "}"])); |
| 3693 resolve(source); | 4113 resolve(source); |
| 3694 assertNoErrors(source); | 4114 assertNoErrors(source); |
| 3695 verify([source]); | 4115 verify([source]); |
| 3696 } | 4116 } |
| 4117 |
| 3697 void test_undefinedIdentifier_hide() { | 4118 void test_undefinedIdentifier_hide() { |
| 3698 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart' hide a;"])); | 4119 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart' hide a;"])); |
| 3699 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); | 4120 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); |
| 3700 resolve(source); | 4121 resolve(source); |
| 3701 assertNoErrors(source); | 4122 assertNoErrors(source); |
| 3702 verify([source]); | 4123 verify([source]); |
| 3703 } | 4124 } |
| 4125 |
| 3704 void test_undefinedIdentifier_show() { | 4126 void test_undefinedIdentifier_show() { |
| 3705 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart' show a;"])); | 4127 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart' show a;"])); |
| 3706 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); | 4128 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); |
| 3707 resolve(source); | 4129 resolve(source); |
| 3708 assertNoErrors(source); | 4130 assertNoErrors(source); |
| 3709 verify([source]); | 4131 verify([source]); |
| 3710 } | 4132 } |
| 4133 |
| 3711 void test_undefinedMethod_functionExpression_callMethod() { | 4134 void test_undefinedMethod_functionExpression_callMethod() { |
| 3712 Source source = addSource(EngineTestCase.createSource(["main() {", " (() =>
null).call();", "}"])); | 4135 Source source = addSource(EngineTestCase.createSource(["main() {", " (() =>
null).call();", "}"])); |
| 3713 resolve(source); | 4136 resolve(source); |
| 3714 assertNoErrors(source); | 4137 assertNoErrors(source); |
| 3715 } | 4138 } |
| 4139 |
| 3716 void test_undefinedMethod_functionExpression_directCall() { | 4140 void test_undefinedMethod_functionExpression_directCall() { |
| 3717 Source source = addSource(EngineTestCase.createSource(["main() {", " (() =>
null)();", "}"])); | 4141 Source source = addSource(EngineTestCase.createSource(["main() {", " (() =>
null)();", "}"])); |
| 3718 resolve(source); | 4142 resolve(source); |
| 3719 assertNoErrors(source); | 4143 assertNoErrors(source); |
| 3720 } | 4144 } |
| 4145 |
| 3721 void test_undefinedOperator_index() { | 4146 void test_undefinedOperator_index() { |
| 3722 Source source = addSource(EngineTestCase.createSource([ | 4147 Source source = addSource(EngineTestCase.createSource([ |
| 3723 "class A {", | 4148 "class A {", |
| 3724 " operator [](a) {}", | 4149 " operator [](a) {}", |
| 3725 " operator []=(a, b) {}", | 4150 " operator []=(a, b) {}", |
| 3726 "}", | 4151 "}", |
| 3727 "f(A a) {", | 4152 "f(A a) {", |
| 3728 " a[0];", | 4153 " a[0];", |
| 3729 " a[0] = 1;", | 4154 " a[0] = 1;", |
| 3730 "}"])); | 4155 "}"])); |
| 3731 resolve(source); | 4156 resolve(source); |
| 3732 assertNoErrors(source); | 4157 assertNoErrors(source); |
| 3733 verify([source]); | 4158 verify([source]); |
| 3734 } | 4159 } |
| 4160 |
| 3735 void test_undefinedOperator_tilde() { | 4161 void test_undefinedOperator_tilde() { |
| 3736 Source source = addSource(EngineTestCase.createSource(["const A = 3;", "cons
t B = ~((1 << A) - 1);"])); | 4162 Source source = addSource(EngineTestCase.createSource(["const A = 3;", "cons
t B = ~((1 << A) - 1);"])); |
| 3737 resolve(source); | 4163 resolve(source); |
| 3738 assertNoErrors(source); | 4164 assertNoErrors(source); |
| 3739 verify([source]); | 4165 verify([source]); |
| 3740 } | 4166 } |
| 4167 |
| 3741 void test_undefinedSetter_importWithPrefix() { | 4168 void test_undefinedSetter_importWithPrefix() { |
| 3742 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "set y(
int value) {}"])); | 4169 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "set y(
int value) {}"])); |
| 3743 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
x;", "main() {", " x.y = 0;", "}"])); | 4170 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
x;", "main() {", " x.y = 0;", "}"])); |
| 3744 resolve(source); | 4171 resolve(source); |
| 3745 assertNoErrors(source); | 4172 assertNoErrors(source); |
| 3746 verify([source]); | 4173 verify([source]); |
| 3747 } | 4174 } |
| 4175 |
| 3748 void test_undefinedSuperMethod_field() { | 4176 void test_undefinedSuperMethod_field() { |
| 3749 Source source = addSource(EngineTestCase.createSource([ | 4177 Source source = addSource(EngineTestCase.createSource([ |
| 3750 "class A {", | 4178 "class A {", |
| 3751 " var m;", | 4179 " var m;", |
| 3752 "}", | 4180 "}", |
| 3753 "class B extends A {", | 4181 "class B extends A {", |
| 3754 " f() {", | 4182 " f() {", |
| 3755 " super.m();", | 4183 " super.m();", |
| 3756 " }", | 4184 " }", |
| 3757 "}"])); | 4185 "}"])); |
| 3758 resolve(source); | 4186 resolve(source); |
| 3759 assertNoErrors(source); | 4187 assertNoErrors(source); |
| 3760 verify([source]); | 4188 verify([source]); |
| 3761 } | 4189 } |
| 4190 |
| 3762 void test_undefinedSuperMethod_method() { | 4191 void test_undefinedSuperMethod_method() { |
| 3763 Source source = addSource(EngineTestCase.createSource([ | 4192 Source source = addSource(EngineTestCase.createSource([ |
| 3764 "class A {", | 4193 "class A {", |
| 3765 " m() {}", | 4194 " m() {}", |
| 3766 "}", | 4195 "}", |
| 3767 "class B extends A {", | 4196 "class B extends A {", |
| 3768 " f() {", | 4197 " f() {", |
| 3769 " super.m();", | 4198 " super.m();", |
| 3770 " }", | 4199 " }", |
| 3771 "}"])); | 4200 "}"])); |
| 3772 resolve(source); | 4201 resolve(source); |
| 3773 assertNoErrors(source); | 4202 assertNoErrors(source); |
| 3774 verify([source]); | 4203 verify([source]); |
| 3775 } | 4204 } |
| 4205 |
| 3776 void test_unqualifiedReferenceToNonLocalStaticMember_fromComment_new() { | 4206 void test_unqualifiedReferenceToNonLocalStaticMember_fromComment_new() { |
| 3777 Source source = addSource(EngineTestCase.createSource([ | 4207 Source source = addSource(EngineTestCase.createSource([ |
| 3778 "class A {", | 4208 "class A {", |
| 3779 " A() {}", | 4209 " A() {}", |
| 3780 " A.named() {}", | 4210 " A.named() {}", |
| 3781 "}", | 4211 "}", |
| 3782 "/// [new A] or [new A.named]", | 4212 "/// [new A] or [new A.named]", |
| 3783 "main() {", | 4213 "main() {", |
| 3784 "}"])); | 4214 "}"])); |
| 3785 resolve(source); | 4215 resolve(source); |
| 3786 assertNoErrors(source); | 4216 assertNoErrors(source); |
| 3787 verify([source]); | 4217 verify([source]); |
| 3788 } | 4218 } |
| 4219 |
| 3789 void test_wrongNumberOfParametersForOperator_index() { | 4220 void test_wrongNumberOfParametersForOperator_index() { |
| 3790 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor []=(a, b) {}", "}"])); | 4221 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor []=(a, b) {}", "}"])); |
| 3791 resolve(source); | 4222 resolve(source); |
| 3792 assertNoErrors(source); | 4223 assertNoErrors(source); |
| 3793 verify([source]); | 4224 verify([source]); |
| 3794 } | 4225 } |
| 4226 |
| 3795 void test_wrongNumberOfParametersForOperator_minus() { | 4227 void test_wrongNumberOfParametersForOperator_minus() { |
| 3796 check_wrongNumberOfParametersForOperator("-", ""); | 4228 check_wrongNumberOfParametersForOperator("-", ""); |
| 3797 check_wrongNumberOfParametersForOperator("-", "a"); | 4229 check_wrongNumberOfParametersForOperator("-", "a"); |
| 3798 } | 4230 } |
| 4231 |
| 3799 void test_wrongNumberOfParametersForOperator1() { | 4232 void test_wrongNumberOfParametersForOperator1() { |
| 3800 check_wrongNumberOfParametersForOperator1("<"); | 4233 check_wrongNumberOfParametersForOperator1("<"); |
| 3801 check_wrongNumberOfParametersForOperator1(">"); | 4234 check_wrongNumberOfParametersForOperator1(">"); |
| 3802 check_wrongNumberOfParametersForOperator1("<="); | 4235 check_wrongNumberOfParametersForOperator1("<="); |
| 3803 check_wrongNumberOfParametersForOperator1(">="); | 4236 check_wrongNumberOfParametersForOperator1(">="); |
| 3804 check_wrongNumberOfParametersForOperator1("+"); | 4237 check_wrongNumberOfParametersForOperator1("+"); |
| 3805 check_wrongNumberOfParametersForOperator1("/"); | 4238 check_wrongNumberOfParametersForOperator1("/"); |
| 3806 check_wrongNumberOfParametersForOperator1("~/"); | 4239 check_wrongNumberOfParametersForOperator1("~/"); |
| 3807 check_wrongNumberOfParametersForOperator1("*"); | 4240 check_wrongNumberOfParametersForOperator1("*"); |
| 3808 check_wrongNumberOfParametersForOperator1("%"); | 4241 check_wrongNumberOfParametersForOperator1("%"); |
| 3809 check_wrongNumberOfParametersForOperator1("|"); | 4242 check_wrongNumberOfParametersForOperator1("|"); |
| 3810 check_wrongNumberOfParametersForOperator1("^"); | 4243 check_wrongNumberOfParametersForOperator1("^"); |
| 3811 check_wrongNumberOfParametersForOperator1("&"); | 4244 check_wrongNumberOfParametersForOperator1("&"); |
| 3812 check_wrongNumberOfParametersForOperator1("<<"); | 4245 check_wrongNumberOfParametersForOperator1("<<"); |
| 3813 check_wrongNumberOfParametersForOperator1(">>"); | 4246 check_wrongNumberOfParametersForOperator1(">>"); |
| 3814 check_wrongNumberOfParametersForOperator1("[]"); | 4247 check_wrongNumberOfParametersForOperator1("[]"); |
| 3815 } | 4248 } |
| 4249 |
| 3816 void test_wrongNumberOfParametersForSetter() { | 4250 void test_wrongNumberOfParametersForSetter() { |
| 3817 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(a) {}", "}"])); | 4251 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(a) {}", "}"])); |
| 3818 resolve(source); | 4252 resolve(source); |
| 3819 assertNoErrors(source); | 4253 assertNoErrors(source); |
| 3820 verify([source]); | 4254 verify([source]); |
| 3821 } | 4255 } |
| 4256 |
| 3822 void check_wrongNumberOfParametersForOperator(String name, String parameters)
{ | 4257 void check_wrongNumberOfParametersForOperator(String name, String parameters)
{ |
| 3823 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor ${name}(${parameters}) {}", "}"])); | 4258 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor ${name}(${parameters}) {}", "}"])); |
| 3824 resolve(source); | 4259 resolve(source); |
| 3825 assertNoErrors(source); | 4260 assertNoErrors(source); |
| 3826 verify([source]); | 4261 verify([source]); |
| 3827 reset(); | 4262 reset(); |
| 3828 } | 4263 } |
| 4264 |
| 3829 void check_wrongNumberOfParametersForOperator1(String name) { | 4265 void check_wrongNumberOfParametersForOperator1(String name) { |
| 3830 check_wrongNumberOfParametersForOperator(name, "a"); | 4266 check_wrongNumberOfParametersForOperator(name, "a"); |
| 3831 } | 4267 } |
| 4268 |
| 3832 static dartSuite() { | 4269 static dartSuite() { |
| 3833 _ut.group('NonErrorResolverTest', () { | 4270 _ut.group('NonErrorResolverTest', () { |
| 3834 _ut.test('test_ambiguousExport', () { | 4271 _ut.test('test_ambiguousExport', () { |
| 3835 final __test = new NonErrorResolverTest(); | 4272 final __test = new NonErrorResolverTest(); |
| 3836 runJUnitTest(__test, __test.test_ambiguousExport); | 4273 runJUnitTest(__test, __test.test_ambiguousExport); |
| 3837 }); | 4274 }); |
| 3838 _ut.test('test_ambiguousExport_combinators_hide', () { | 4275 _ut.test('test_ambiguousExport_combinators_hide', () { |
| 3839 final __test = new NonErrorResolverTest(); | 4276 final __test = new NonErrorResolverTest(); |
| 3840 runJUnitTest(__test, __test.test_ambiguousExport_combinators_hide); | 4277 runJUnitTest(__test, __test.test_ambiguousExport_combinators_hide); |
| 3841 }); | 4278 }); |
| 3842 _ut.test('test_ambiguousExport_combinators_show', () { | 4279 _ut.test('test_ambiguousExport_combinators_show', () { |
| 3843 final __test = new NonErrorResolverTest(); | 4280 final __test = new NonErrorResolverTest(); |
| 3844 runJUnitTest(__test, __test.test_ambiguousExport_combinators_show); | 4281 runJUnitTest(__test, __test.test_ambiguousExport_combinators_show); |
| 3845 }); | 4282 }); |
| 4283 _ut.test('test_ambiguousExport_sameDeclaration', () { |
| 4284 final __test = new NonErrorResolverTest(); |
| 4285 runJUnitTest(__test, __test.test_ambiguousExport_sameDeclaration); |
| 4286 }); |
| 3846 _ut.test('test_argumentDefinitionTestNonParameter_formalParameter', () { | 4287 _ut.test('test_argumentDefinitionTestNonParameter_formalParameter', () { |
| 3847 final __test = new NonErrorResolverTest(); | 4288 final __test = new NonErrorResolverTest(); |
| 3848 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_form
alParameter); | 4289 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_form
alParameter); |
| 3849 }); | 4290 }); |
| 3850 _ut.test('test_argumentDefinitionTestNonParameter_namedParameter', () { | 4291 _ut.test('test_argumentDefinitionTestNonParameter_namedParameter', () { |
| 3851 final __test = new NonErrorResolverTest(); | 4292 final __test = new NonErrorResolverTest(); |
| 3852 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_name
dParameter); | 4293 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_name
dParameter); |
| 3853 }); | 4294 }); |
| 3854 _ut.test('test_argumentDefinitionTestNonParameter_optionalParameter', () { | 4295 _ut.test('test_argumentDefinitionTestNonParameter_optionalParameter', () { |
| 3855 final __test = new NonErrorResolverTest(); | 4296 final __test = new NonErrorResolverTest(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3956 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth
eticField); | 4397 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth
eticField); |
| 3957 }); | 4398 }); |
| 3958 _ut.test('test_constEvalTypeBoolNumString_equal', () { | 4399 _ut.test('test_constEvalTypeBoolNumString_equal', () { |
| 3959 final __test = new NonErrorResolverTest(); | 4400 final __test = new NonErrorResolverTest(); |
| 3960 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_equal); | 4401 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_equal); |
| 3961 }); | 4402 }); |
| 3962 _ut.test('test_constEvalTypeBoolNumString_notEqual', () { | 4403 _ut.test('test_constEvalTypeBoolNumString_notEqual', () { |
| 3963 final __test = new NonErrorResolverTest(); | 4404 final __test = new NonErrorResolverTest(); |
| 3964 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual); | 4405 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual); |
| 3965 }); | 4406 }); |
| 4407 _ut.test('test_constEval_functionTypeLiteral', () { |
| 4408 final __test = new NonErrorResolverTest(); |
| 4409 runJUnitTest(__test, __test.test_constEval_functionTypeLiteral); |
| 4410 }); |
| 3966 _ut.test('test_constEval_propertyExtraction_fieldStatic_targetType', () { | 4411 _ut.test('test_constEval_propertyExtraction_fieldStatic_targetType', () { |
| 3967 final __test = new NonErrorResolverTest(); | 4412 final __test = new NonErrorResolverTest(); |
| 3968 runJUnitTest(__test, __test.test_constEval_propertyExtraction_fieldStati
c_targetType); | 4413 runJUnitTest(__test, __test.test_constEval_propertyExtraction_fieldStati
c_targetType); |
| 3969 }); | 4414 }); |
| 3970 _ut.test('test_constEval_propertyExtraction_methodStatic_targetType', () { | 4415 _ut.test('test_constEval_propertyExtraction_methodStatic_targetType', () { |
| 3971 final __test = new NonErrorResolverTest(); | 4416 final __test = new NonErrorResolverTest(); |
| 3972 runJUnitTest(__test, __test.test_constEval_propertyExtraction_methodStat
ic_targetType); | 4417 runJUnitTest(__test, __test.test_constEval_propertyExtraction_methodStat
ic_targetType); |
| 3973 }); | 4418 }); |
| 3974 _ut.test('test_constEval_symbol', () { | 4419 _ut.test('test_constEval_symbol', () { |
| 3975 final __test = new NonErrorResolverTest(); | 4420 final __test = new NonErrorResolverTest(); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4136 runJUnitTest(__test, __test.test_functionTypeAlias_scope_signature); | 4581 runJUnitTest(__test, __test.test_functionTypeAlias_scope_signature); |
| 4137 }); | 4582 }); |
| 4138 _ut.test('test_functionWithoutCall', () { | 4583 _ut.test('test_functionWithoutCall', () { |
| 4139 final __test = new NonErrorResolverTest(); | 4584 final __test = new NonErrorResolverTest(); |
| 4140 runJUnitTest(__test, __test.test_functionWithoutCall); | 4585 runJUnitTest(__test, __test.test_functionWithoutCall); |
| 4141 }); | 4586 }); |
| 4142 _ut.test('test_implicitThisReferenceInInitializer_constructorName', () { | 4587 _ut.test('test_implicitThisReferenceInInitializer_constructorName', () { |
| 4143 final __test = new NonErrorResolverTest(); | 4588 final __test = new NonErrorResolverTest(); |
| 4144 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_cons
tructorName); | 4589 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_cons
tructorName); |
| 4145 }); | 4590 }); |
| 4591 _ut.test('test_implicitThisReferenceInInitializer_importPrefix', () { |
| 4592 final __test = new NonErrorResolverTest(); |
| 4593 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_impo
rtPrefix); |
| 4594 }); |
| 4146 _ut.test('test_implicitThisReferenceInInitializer_prefixedIdentifier', ()
{ | 4595 _ut.test('test_implicitThisReferenceInInitializer_prefixedIdentifier', ()
{ |
| 4147 final __test = new NonErrorResolverTest(); | 4596 final __test = new NonErrorResolverTest(); |
| 4148 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_pref
ixedIdentifier); | 4597 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_pref
ixedIdentifier); |
| 4149 }); | 4598 }); |
| 4150 _ut.test('test_implicitThisReferenceInInitializer_qualifiedMethodInvocatio
n', () { | 4599 _ut.test('test_implicitThisReferenceInInitializer_qualifiedMethodInvocatio
n', () { |
| 4151 final __test = new NonErrorResolverTest(); | 4600 final __test = new NonErrorResolverTest(); |
| 4152 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_qual
ifiedMethodInvocation); | 4601 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_qual
ifiedMethodInvocation); |
| 4153 }); | 4602 }); |
| 4154 _ut.test('test_implicitThisReferenceInInitializer_qualifiedPropertyAccess'
, () { | 4603 _ut.test('test_implicitThisReferenceInInitializer_qualifiedPropertyAccess'
, () { |
| 4155 final __test = new NonErrorResolverTest(); | 4604 final __test = new NonErrorResolverTest(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4244 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_fromComm
ent); | 4693 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_fromComm
ent); |
| 4245 }); | 4694 }); |
| 4246 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_field', () { | 4695 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_field', () { |
| 4247 final __test = new NonErrorResolverTest(); | 4696 final __test = new NonErrorResolverTest(); |
| 4248 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas
sStatic_field); | 4697 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas
sStatic_field); |
| 4249 }); | 4698 }); |
| 4250 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_method', ()
{ | 4699 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_method', ()
{ |
| 4251 final __test = new NonErrorResolverTest(); | 4700 final __test = new NonErrorResolverTest(); |
| 4252 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas
sStatic_method); | 4701 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas
sStatic_method); |
| 4253 }); | 4702 }); |
| 4254 _ut.test('test_invalidAnnotation_constantVariable', () { | 4703 _ut.test('test_invalidAnnotation_constConstructor_importWithPrefix', () { |
| 4255 final __test = new NonErrorResolverTest(); | 4704 final __test = new NonErrorResolverTest(); |
| 4256 runJUnitTest(__test, __test.test_invalidAnnotation_constantVariable); | 4705 runJUnitTest(__test, __test.test_invalidAnnotation_constConstructor_impo
rtWithPrefix); |
| 4257 }); | 4706 }); |
| 4258 _ut.test('test_invalidAnnotation_importWithPrefix_constConstructor', () { | 4707 _ut.test('test_invalidAnnotation_constConstructor_named_importWithPrefix',
() { |
| 4259 final __test = new NonErrorResolverTest(); | 4708 final __test = new NonErrorResolverTest(); |
| 4260 runJUnitTest(__test, __test.test_invalidAnnotation_importWithPrefix_cons
tConstructor); | 4709 runJUnitTest(__test, __test.test_invalidAnnotation_constConstructor_name
d_importWithPrefix); |
| 4261 }); | 4710 }); |
| 4262 _ut.test('test_invalidAnnotation_importWithPrefix_constantVariable', () { | 4711 _ut.test('test_invalidAnnotation_constantVariable_field', () { |
| 4263 final __test = new NonErrorResolverTest(); | 4712 final __test = new NonErrorResolverTest(); |
| 4264 runJUnitTest(__test, __test.test_invalidAnnotation_importWithPrefix_cons
tantVariable); | 4713 runJUnitTest(__test, __test.test_invalidAnnotation_constantVariable_fiel
d); |
| 4714 }); |
| 4715 _ut.test('test_invalidAnnotation_constantVariable_field_importWithPrefix',
() { |
| 4716 final __test = new NonErrorResolverTest(); |
| 4717 runJUnitTest(__test, __test.test_invalidAnnotation_constantVariable_fiel
d_importWithPrefix); |
| 4718 }); |
| 4719 _ut.test('test_invalidAnnotation_constantVariable_topLevel', () { |
| 4720 final __test = new NonErrorResolverTest(); |
| 4721 runJUnitTest(__test, __test.test_invalidAnnotation_constantVariable_topL
evel); |
| 4722 }); |
| 4723 _ut.test('test_invalidAnnotation_constantVariable_topLevel_importWithPrefi
x', () { |
| 4724 final __test = new NonErrorResolverTest(); |
| 4725 runJUnitTest(__test, __test.test_invalidAnnotation_constantVariable_topL
evel_importWithPrefix); |
| 4265 }); | 4726 }); |
| 4266 _ut.test('test_invalidAssignment', () { | 4727 _ut.test('test_invalidAssignment', () { |
| 4267 final __test = new NonErrorResolverTest(); | 4728 final __test = new NonErrorResolverTest(); |
| 4268 runJUnitTest(__test, __test.test_invalidAssignment); | 4729 runJUnitTest(__test, __test.test_invalidAssignment); |
| 4269 }); | 4730 }); |
| 4270 _ut.test('test_invalidAssignment_compoundAssignment', () { | 4731 _ut.test('test_invalidAssignment_compoundAssignment', () { |
| 4271 final __test = new NonErrorResolverTest(); | 4732 final __test = new NonErrorResolverTest(); |
| 4272 runJUnitTest(__test, __test.test_invalidAssignment_compoundAssignment); | 4733 runJUnitTest(__test, __test.test_invalidAssignment_compoundAssignment); |
| 4273 }); | 4734 }); |
| 4274 _ut.test('test_invalidAssignment_defaultValue_named', () { | 4735 _ut.test('test_invalidAssignment_defaultValue_named', () { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4288 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass); | 4749 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass); |
| 4289 }); | 4750 }); |
| 4290 _ut.test('test_invalidMethodOverrideNamedParamType', () { | 4751 _ut.test('test_invalidMethodOverrideNamedParamType', () { |
| 4291 final __test = new NonErrorResolverTest(); | 4752 final __test = new NonErrorResolverTest(); |
| 4292 runJUnitTest(__test, __test.test_invalidMethodOverrideNamedParamType); | 4753 runJUnitTest(__test, __test.test_invalidMethodOverrideNamedParamType); |
| 4293 }); | 4754 }); |
| 4294 _ut.test('test_invalidOverrideDifferentDefaultValues_named', () { | 4755 _ut.test('test_invalidOverrideDifferentDefaultValues_named', () { |
| 4295 final __test = new NonErrorResolverTest(); | 4756 final __test = new NonErrorResolverTest(); |
| 4296 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_n
amed); | 4757 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_n
amed); |
| 4297 }); | 4758 }); |
| 4759 _ut.test('test_invalidOverrideDifferentDefaultValues_named_function', () { |
| 4760 final __test = new NonErrorResolverTest(); |
| 4761 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_n
amed_function); |
| 4762 }); |
| 4298 _ut.test('test_invalidOverrideDifferentDefaultValues_positional', () { | 4763 _ut.test('test_invalidOverrideDifferentDefaultValues_positional', () { |
| 4299 final __test = new NonErrorResolverTest(); | 4764 final __test = new NonErrorResolverTest(); |
| 4300 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p
ositional); | 4765 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p
ositional); |
| 4301 }); | 4766 }); |
| 4302 _ut.test('test_invalidOverrideDifferentDefaultValues_positional_changedOrd
er', () { | 4767 _ut.test('test_invalidOverrideDifferentDefaultValues_positional_changedOrd
er', () { |
| 4303 final __test = new NonErrorResolverTest(); | 4768 final __test = new NonErrorResolverTest(); |
| 4304 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p
ositional_changedOrder); | 4769 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p
ositional_changedOrder); |
| 4305 }); | 4770 }); |
| 4771 _ut.test('test_invalidOverrideDifferentDefaultValues_positional_function',
() { |
| 4772 final __test = new NonErrorResolverTest(); |
| 4773 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p
ositional_function); |
| 4774 }); |
| 4306 _ut.test('test_invalidOverrideNamed_unorderedNamedParameter', () { | 4775 _ut.test('test_invalidOverrideNamed_unorderedNamedParameter', () { |
| 4307 final __test = new NonErrorResolverTest(); | 4776 final __test = new NonErrorResolverTest(); |
| 4308 runJUnitTest(__test, __test.test_invalidOverrideNamed_unorderedNamedPara
meter); | 4777 runJUnitTest(__test, __test.test_invalidOverrideNamed_unorderedNamedPara
meter); |
| 4309 }); | 4778 }); |
| 4310 _ut.test('test_invalidOverrideRequired_less', () { | 4779 _ut.test('test_invalidOverrideRequired_less', () { |
| 4311 final __test = new NonErrorResolverTest(); | 4780 final __test = new NonErrorResolverTest(); |
| 4312 runJUnitTest(__test, __test.test_invalidOverrideRequired_less); | 4781 runJUnitTest(__test, __test.test_invalidOverrideRequired_less); |
| 4313 }); | 4782 }); |
| 4314 _ut.test('test_invalidOverrideRequired_same', () { | 4783 _ut.test('test_invalidOverrideRequired_same', () { |
| 4315 final __test = new NonErrorResolverTest(); | 4784 final __test = new NonErrorResolverTest(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4428 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_topLevel
_unspecifiedGetter); | 4897 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_topLevel
_unspecifiedGetter); |
| 4429 }); | 4898 }); |
| 4430 _ut.test('test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter',
() { | 4899 _ut.test('test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter',
() { |
| 4431 final __test = new NonErrorResolverTest(); | 4900 final __test = new NonErrorResolverTest(); |
| 4432 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_topLevel
_unspecifiedSetter); | 4901 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_topLevel
_unspecifiedSetter); |
| 4433 }); | 4902 }); |
| 4434 _ut.test('test_mixedReturnTypes_differentScopes', () { | 4903 _ut.test('test_mixedReturnTypes_differentScopes', () { |
| 4435 final __test = new NonErrorResolverTest(); | 4904 final __test = new NonErrorResolverTest(); |
| 4436 runJUnitTest(__test, __test.test_mixedReturnTypes_differentScopes); | 4905 runJUnitTest(__test, __test.test_mixedReturnTypes_differentScopes); |
| 4437 }); | 4906 }); |
| 4907 _ut.test('test_mixedReturnTypes_ignoreImplicit', () { |
| 4908 final __test = new NonErrorResolverTest(); |
| 4909 runJUnitTest(__test, __test.test_mixedReturnTypes_ignoreImplicit); |
| 4910 }); |
| 4911 _ut.test('test_mixedReturnTypes_ignoreImplicit2', () { |
| 4912 final __test = new NonErrorResolverTest(); |
| 4913 runJUnitTest(__test, __test.test_mixedReturnTypes_ignoreImplicit2); |
| 4914 }); |
| 4438 _ut.test('test_mixedReturnTypes_sameKind', () { | 4915 _ut.test('test_mixedReturnTypes_sameKind', () { |
| 4439 final __test = new NonErrorResolverTest(); | 4916 final __test = new NonErrorResolverTest(); |
| 4440 runJUnitTest(__test, __test.test_mixedReturnTypes_sameKind); | 4917 runJUnitTest(__test, __test.test_mixedReturnTypes_sameKind); |
| 4441 }); | 4918 }); |
| 4442 _ut.test('test_mixinDeclaresConstructor', () { | 4919 _ut.test('test_mixinDeclaresConstructor', () { |
| 4443 final __test = new NonErrorResolverTest(); | 4920 final __test = new NonErrorResolverTest(); |
| 4444 runJUnitTest(__test, __test.test_mixinDeclaresConstructor); | 4921 runJUnitTest(__test, __test.test_mixinDeclaresConstructor); |
| 4445 }); | 4922 }); |
| 4446 _ut.test('test_mixinDeclaresConstructor_factory', () { | 4923 _ut.test('test_mixinDeclaresConstructor_factory', () { |
| 4447 final __test = new NonErrorResolverTest(); | 4924 final __test = new NonErrorResolverTest(); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4780 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeArgum
entList_20); | 5257 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeArgum
entList_20); |
| 4781 }); | 5258 }); |
| 4782 _ut.test('test_typePromotion_booleanAnd_useInRight', () { | 5259 _ut.test('test_typePromotion_booleanAnd_useInRight', () { |
| 4783 final __test = new NonErrorResolverTest(); | 5260 final __test = new NonErrorResolverTest(); |
| 4784 runJUnitTest(__test, __test.test_typePromotion_booleanAnd_useInRight); | 5261 runJUnitTest(__test, __test.test_typePromotion_booleanAnd_useInRight); |
| 4785 }); | 5262 }); |
| 4786 _ut.test('test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_
noAssignment', () { | 5263 _ut.test('test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_
noAssignment', () { |
| 4787 final __test = new NonErrorResolverTest(); | 5264 final __test = new NonErrorResolverTest(); |
| 4788 runJUnitTest(__test, __test.test_typePromotion_booleanAnd_useInRight_acc
essedInClosureRight_noAssignment); | 5265 runJUnitTest(__test, __test.test_typePromotion_booleanAnd_useInRight_acc
essedInClosureRight_noAssignment); |
| 4789 }); | 5266 }); |
| 5267 _ut.test('test_typePromotion_conditional_issue14655', () { |
| 5268 final __test = new NonErrorResolverTest(); |
| 5269 runJUnitTest(__test, __test.test_typePromotion_conditional_issue14655); |
| 5270 }); |
| 4790 _ut.test('test_typePromotion_conditional_useInThen', () { | 5271 _ut.test('test_typePromotion_conditional_useInThen', () { |
| 4791 final __test = new NonErrorResolverTest(); | 5272 final __test = new NonErrorResolverTest(); |
| 4792 runJUnitTest(__test, __test.test_typePromotion_conditional_useInThen); | 5273 runJUnitTest(__test, __test.test_typePromotion_conditional_useInThen); |
| 4793 }); | 5274 }); |
| 4794 _ut.test('test_typePromotion_conditional_useInThen_accessedInClosure_noAss
ignment', () { | 5275 _ut.test('test_typePromotion_conditional_useInThen_accessedInClosure_noAss
ignment', () { |
| 4795 final __test = new NonErrorResolverTest(); | 5276 final __test = new NonErrorResolverTest(); |
| 4796 runJUnitTest(__test, __test.test_typePromotion_conditional_useInThen_acc
essedInClosure_noAssignment); | 5277 runJUnitTest(__test, __test.test_typePromotion_conditional_useInThen_acc
essedInClosure_noAssignment); |
| 4797 }); | 5278 }); |
| 4798 _ut.test('test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific', ()
{ | 5279 _ut.test('test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific', ()
{ |
| 4799 final __test = new NonErrorResolverTest(); | 5280 final __test = new NonErrorResolverTest(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4844 runJUnitTest(__test, __test.test_typePromotion_if_is_and_subThenSuper); | 5325 runJUnitTest(__test, __test.test_typePromotion_if_is_and_subThenSuper); |
| 4845 }); | 5326 }); |
| 4846 _ut.test('test_typePromotion_if_is_parenthesized', () { | 5327 _ut.test('test_typePromotion_if_is_parenthesized', () { |
| 4847 final __test = new NonErrorResolverTest(); | 5328 final __test = new NonErrorResolverTest(); |
| 4848 runJUnitTest(__test, __test.test_typePromotion_if_is_parenthesized); | 5329 runJUnitTest(__test, __test.test_typePromotion_if_is_parenthesized); |
| 4849 }); | 5330 }); |
| 4850 _ut.test('test_typePromotion_if_is_single', () { | 5331 _ut.test('test_typePromotion_if_is_single', () { |
| 4851 final __test = new NonErrorResolverTest(); | 5332 final __test = new NonErrorResolverTest(); |
| 4852 runJUnitTest(__test, __test.test_typePromotion_if_is_single); | 5333 runJUnitTest(__test, __test.test_typePromotion_if_is_single); |
| 4853 }); | 5334 }); |
| 5335 _ut.test('test_typePromotion_parentheses', () { |
| 5336 final __test = new NonErrorResolverTest(); |
| 5337 runJUnitTest(__test, __test.test_typePromotion_parentheses); |
| 5338 }); |
| 4854 _ut.test('test_typeType_class', () { | 5339 _ut.test('test_typeType_class', () { |
| 4855 final __test = new NonErrorResolverTest(); | 5340 final __test = new NonErrorResolverTest(); |
| 4856 runJUnitTest(__test, __test.test_typeType_class); | 5341 runJUnitTest(__test, __test.test_typeType_class); |
| 4857 }); | 5342 }); |
| 4858 _ut.test('test_typeType_class_prefixed', () { | 5343 _ut.test('test_typeType_class_prefixed', () { |
| 4859 final __test = new NonErrorResolverTest(); | 5344 final __test = new NonErrorResolverTest(); |
| 4860 runJUnitTest(__test, __test.test_typeType_class_prefixed); | 5345 runJUnitTest(__test, __test.test_typeType_class_prefixed); |
| 4861 }); | 5346 }); |
| 4862 _ut.test('test_typeType_functionTypeAlias', () { | 5347 _ut.test('test_typeType_functionTypeAlias', () { |
| 4863 final __test = new NonErrorResolverTest(); | 5348 final __test = new NonErrorResolverTest(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4947 final __test = new NonErrorResolverTest(); | 5432 final __test = new NonErrorResolverTest(); |
| 4948 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_minu
s); | 5433 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_minu
s); |
| 4949 }); | 5434 }); |
| 4950 _ut.test('test_wrongNumberOfParametersForSetter', () { | 5435 _ut.test('test_wrongNumberOfParametersForSetter', () { |
| 4951 final __test = new NonErrorResolverTest(); | 5436 final __test = new NonErrorResolverTest(); |
| 4952 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter); | 5437 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter); |
| 4953 }); | 5438 }); |
| 4954 }); | 5439 }); |
| 4955 } | 5440 } |
| 4956 } | 5441 } |
| 5442 |
| 4957 class LibraryTest extends EngineTestCase { | 5443 class LibraryTest extends EngineTestCase { |
| 4958 | |
| 4959 /** | 5444 /** |
| 4960 * The error listener to which all errors will be reported. | 5445 * The error listener to which all errors will be reported. |
| 4961 */ | 5446 */ |
| 4962 GatheringErrorListener _errorListener; | 5447 GatheringErrorListener _errorListener; |
| 4963 | 5448 |
| 4964 /** | 5449 /** |
| 4965 * The source factory used to create libraries. | 5450 * The source factory used to create libraries. |
| 4966 */ | 5451 */ |
| 4967 SourceFactory _sourceFactory; | 5452 SourceFactory _sourceFactory; |
| 4968 | 5453 |
| 4969 /** | 5454 /** |
| 4970 * The analysis context to pass in to all libraries created by the tests. | 5455 * The analysis context to pass in to all libraries created by the tests. |
| 4971 */ | 5456 */ |
| 4972 AnalysisContextImpl _analysisContext; | 5457 AnalysisContextImpl _analysisContext; |
| 4973 | 5458 |
| 4974 /** | 5459 /** |
| 4975 * The library used by the tests. | 5460 * The library used by the tests. |
| 4976 */ | 5461 */ |
| 4977 Library _library5; | 5462 Library _library5; |
| 5463 |
| 4978 void setUp() { | 5464 void setUp() { |
| 4979 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); | 5465 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); |
| 4980 _analysisContext = new AnalysisContextImpl(); | 5466 _analysisContext = new AnalysisContextImpl(); |
| 4981 _analysisContext.sourceFactory = _sourceFactory; | 5467 _analysisContext.sourceFactory = _sourceFactory; |
| 4982 _errorListener = new GatheringErrorListener(); | 5468 _errorListener = new GatheringErrorListener(); |
| 4983 _library5 = library("/lib.dart"); | 5469 _library5 = library("/lib.dart"); |
| 4984 } | 5470 } |
| 5471 |
| 4985 void test_getExplicitlyImportsCore() { | 5472 void test_getExplicitlyImportsCore() { |
| 4986 JUnitTestCase.assertFalse(_library5.explicitlyImportsCore); | 5473 JUnitTestCase.assertFalse(_library5.explicitlyImportsCore); |
| 4987 _errorListener.assertNoErrors(); | 5474 _errorListener.assertNoErrors(); |
| 4988 } | 5475 } |
| 5476 |
| 4989 void test_getExports() { | 5477 void test_getExports() { |
| 4990 EngineTestCase.assertLength(0, _library5.exports); | 5478 EngineTestCase.assertLength(0, _library5.exports); |
| 4991 _errorListener.assertNoErrors(); | 5479 _errorListener.assertNoErrors(); |
| 4992 } | 5480 } |
| 5481 |
| 4993 void test_getImports() { | 5482 void test_getImports() { |
| 4994 EngineTestCase.assertLength(0, _library5.imports); | 5483 EngineTestCase.assertLength(0, _library5.imports); |
| 4995 _errorListener.assertNoErrors(); | 5484 _errorListener.assertNoErrors(); |
| 4996 } | 5485 } |
| 5486 |
| 4997 void test_getImportsAndExports() { | 5487 void test_getImportsAndExports() { |
| 4998 _library5.importedLibraries = <Library> [library("/imported.dart")]; | 5488 _library5.importedLibraries = <Library> [library("/imported.dart")]; |
| 4999 _library5.exportedLibraries = <Library> [library("/exported.dart")]; | 5489 _library5.exportedLibraries = <Library> [library("/exported.dart")]; |
| 5000 EngineTestCase.assertLength(2, _library5.importsAndExports); | 5490 EngineTestCase.assertLength(2, _library5.importsAndExports); |
| 5001 _errorListener.assertNoErrors(); | 5491 _errorListener.assertNoErrors(); |
| 5002 } | 5492 } |
| 5493 |
| 5003 void test_getLibraryScope() { | 5494 void test_getLibraryScope() { |
| 5004 LibraryElementImpl element = new LibraryElementImpl(_analysisContext, ASTFac
tory.libraryIdentifier2(["lib"])); | 5495 LibraryElementImpl element = new LibraryElementImpl(_analysisContext, ASTFac
tory.libraryIdentifier2(["lib"])); |
| 5005 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart")
; | 5496 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart")
; |
| 5006 _library5.libraryElement = element; | 5497 _library5.libraryElement = element; |
| 5007 JUnitTestCase.assertNotNull(_library5.libraryScope); | 5498 JUnitTestCase.assertNotNull(_library5.libraryScope); |
| 5008 _errorListener.assertNoErrors(); | 5499 _errorListener.assertNoErrors(); |
| 5009 } | 5500 } |
| 5501 |
| 5010 void test_getLibrarySource() { | 5502 void test_getLibrarySource() { |
| 5011 JUnitTestCase.assertNotNull(_library5.librarySource); | 5503 JUnitTestCase.assertNotNull(_library5.librarySource); |
| 5012 } | 5504 } |
| 5505 |
| 5013 void test_setExplicitlyImportsCore() { | 5506 void test_setExplicitlyImportsCore() { |
| 5014 _library5.explicitlyImportsCore = true; | 5507 _library5.explicitlyImportsCore = true; |
| 5015 JUnitTestCase.assertTrue(_library5.explicitlyImportsCore); | 5508 JUnitTestCase.assertTrue(_library5.explicitlyImportsCore); |
| 5016 _errorListener.assertNoErrors(); | 5509 _errorListener.assertNoErrors(); |
| 5017 } | 5510 } |
| 5511 |
| 5018 void test_setExportedLibraries() { | 5512 void test_setExportedLibraries() { |
| 5019 Library exportLibrary = library("/exported.dart"); | 5513 Library exportLibrary = library("/exported.dart"); |
| 5020 _library5.exportedLibraries = <Library> [exportLibrary]; | 5514 _library5.exportedLibraries = <Library> [exportLibrary]; |
| 5021 List<Library> exports = _library5.exports; | 5515 List<Library> exports = _library5.exports; |
| 5022 EngineTestCase.assertLength(1, exports); | 5516 EngineTestCase.assertLength(1, exports); |
| 5023 JUnitTestCase.assertSame(exportLibrary, exports[0]); | 5517 JUnitTestCase.assertSame(exportLibrary, exports[0]); |
| 5024 _errorListener.assertNoErrors(); | 5518 _errorListener.assertNoErrors(); |
| 5025 } | 5519 } |
| 5520 |
| 5026 void test_setImportedLibraries() { | 5521 void test_setImportedLibraries() { |
| 5027 Library importLibrary = library("/imported.dart"); | 5522 Library importLibrary = library("/imported.dart"); |
| 5028 _library5.importedLibraries = <Library> [importLibrary]; | 5523 _library5.importedLibraries = <Library> [importLibrary]; |
| 5029 List<Library> imports = _library5.imports; | 5524 List<Library> imports = _library5.imports; |
| 5030 EngineTestCase.assertLength(1, imports); | 5525 EngineTestCase.assertLength(1, imports); |
| 5031 JUnitTestCase.assertSame(importLibrary, imports[0]); | 5526 JUnitTestCase.assertSame(importLibrary, imports[0]); |
| 5032 _errorListener.assertNoErrors(); | 5527 _errorListener.assertNoErrors(); |
| 5033 } | 5528 } |
| 5529 |
| 5034 void test_setLibraryElement() { | 5530 void test_setLibraryElement() { |
| 5035 LibraryElementImpl element = new LibraryElementImpl(_analysisContext, ASTFac
tory.libraryIdentifier2(["lib"])); | 5531 LibraryElementImpl element = new LibraryElementImpl(_analysisContext, ASTFac
tory.libraryIdentifier2(["lib"])); |
| 5036 _library5.libraryElement = element; | 5532 _library5.libraryElement = element; |
| 5037 JUnitTestCase.assertSame(element, _library5.libraryElement); | 5533 JUnitTestCase.assertSame(element, _library5.libraryElement); |
| 5038 } | 5534 } |
| 5535 |
| 5039 Library library(String definingCompilationUnitPath) => new Library(_analysisCo
ntext, _errorListener, new FileBasedSource.con1(_sourceFactory.contentCache, Fil
eUtilities2.createFile(definingCompilationUnitPath))); | 5536 Library library(String definingCompilationUnitPath) => new Library(_analysisCo
ntext, _errorListener, new FileBasedSource.con1(_sourceFactory.contentCache, Fil
eUtilities2.createFile(definingCompilationUnitPath))); |
| 5537 |
| 5040 static dartSuite() { | 5538 static dartSuite() { |
| 5041 _ut.group('LibraryTest', () { | 5539 _ut.group('LibraryTest', () { |
| 5042 _ut.test('test_getExplicitlyImportsCore', () { | 5540 _ut.test('test_getExplicitlyImportsCore', () { |
| 5043 final __test = new LibraryTest(); | 5541 final __test = new LibraryTest(); |
| 5044 runJUnitTest(__test, __test.test_getExplicitlyImportsCore); | 5542 runJUnitTest(__test, __test.test_getExplicitlyImportsCore); |
| 5045 }); | 5543 }); |
| 5046 _ut.test('test_getExports', () { | 5544 _ut.test('test_getExports', () { |
| 5047 final __test = new LibraryTest(); | 5545 final __test = new LibraryTest(); |
| 5048 runJUnitTest(__test, __test.test_getExports); | 5546 runJUnitTest(__test, __test.test_getExports); |
| 5049 }); | 5547 }); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5075 final __test = new LibraryTest(); | 5573 final __test = new LibraryTest(); |
| 5076 runJUnitTest(__test, __test.test_setImportedLibraries); | 5574 runJUnitTest(__test, __test.test_setImportedLibraries); |
| 5077 }); | 5575 }); |
| 5078 _ut.test('test_setLibraryElement', () { | 5576 _ut.test('test_setLibraryElement', () { |
| 5079 final __test = new LibraryTest(); | 5577 final __test = new LibraryTest(); |
| 5080 runJUnitTest(__test, __test.test_setLibraryElement); | 5578 runJUnitTest(__test, __test.test_setLibraryElement); |
| 5081 }); | 5579 }); |
| 5082 }); | 5580 }); |
| 5083 } | 5581 } |
| 5084 } | 5582 } |
| 5583 |
| 5584 class DeclarationMatcherTest extends ResolverTestCase { |
| 5585 void test_compilationUnitMatches_false_topLevelVariable() { |
| 5586 assertCompilationUnitMatches(false, EngineTestCase.createSource([ |
| 5587 "class C {", |
| 5588 " int m(int p) {", |
| 5589 " return p + p;", |
| 5590 " }", |
| 5591 "}"]), EngineTestCase.createSource([ |
| 5592 "const int ZERO = 0;", |
| 5593 "class C {", |
| 5594 " int m(int p) {", |
| 5595 " return (p * p) + (p * p) + ZERO;", |
| 5596 " }", |
| 5597 "}"])); |
| 5598 } |
| 5599 |
| 5600 void test_compilationUnitMatches_true_different() { |
| 5601 assertCompilationUnitMatches(true, EngineTestCase.createSource([ |
| 5602 "class C {", |
| 5603 " int m(int p) {", |
| 5604 " return p + p;", |
| 5605 " }", |
| 5606 "}"]), EngineTestCase.createSource([ |
| 5607 "class C {", |
| 5608 " int m(int p) {", |
| 5609 " return (p * p) + (p * p);", |
| 5610 " }", |
| 5611 "}"])); |
| 5612 } |
| 5613 |
| 5614 void test_compilationUnitMatches_true_same() { |
| 5615 String content = EngineTestCase.createSource([ |
| 5616 "class C {", |
| 5617 " int m(int p) {", |
| 5618 " return p + p;", |
| 5619 " }", |
| 5620 "}"]); |
| 5621 assertCompilationUnitMatches(true, content, content); |
| 5622 } |
| 5623 |
| 5624 void test_methodDeclarationMatches_false_localVariable() { |
| 5625 assertMethodMatches(false, EngineTestCase.createSource([ |
| 5626 "class C {", |
| 5627 " int m(int p) {", |
| 5628 " return p + p;", |
| 5629 " }", |
| 5630 "}"]), EngineTestCase.createSource([ |
| 5631 "class C {", |
| 5632 " int m(int p) {", |
| 5633 " int product = p * p;", |
| 5634 " return product + product;", |
| 5635 " }", |
| 5636 "}"])); |
| 5637 } |
| 5638 |
| 5639 void test_methodDeclarationMatches_false_parameter() { |
| 5640 assertMethodMatches(false, EngineTestCase.createSource([ |
| 5641 "class C {", |
| 5642 " int m(int p) {", |
| 5643 " return p + p;", |
| 5644 " }", |
| 5645 "}"]), EngineTestCase.createSource([ |
| 5646 "class C {", |
| 5647 " int m(int p, int q) {", |
| 5648 " return (p * q) + (q * p);", |
| 5649 " }", |
| 5650 "}"])); |
| 5651 } |
| 5652 |
| 5653 void test_methodDeclarationMatches_true_different() { |
| 5654 assertMethodMatches(true, EngineTestCase.createSource([ |
| 5655 "class C {", |
| 5656 " int m(int p) {", |
| 5657 " return p + p;", |
| 5658 " }", |
| 5659 "}"]), EngineTestCase.createSource([ |
| 5660 "class C {", |
| 5661 " int m(int p) {", |
| 5662 " return (p * p) + (p * p);", |
| 5663 " }", |
| 5664 "}"])); |
| 5665 } |
| 5666 |
| 5667 void test_methodDeclarationMatches_true_same() { |
| 5668 String content = EngineTestCase.createSource([ |
| 5669 "class C {", |
| 5670 " int m(int p) {", |
| 5671 " return p + p;", |
| 5672 " }", |
| 5673 "}"]); |
| 5674 assertMethodMatches(true, content, content); |
| 5675 } |
| 5676 |
| 5677 void assertCompilationUnitMatches(bool expectMatch, String oldContent, String
newContent) { |
| 5678 Source source = addSource(oldContent); |
| 5679 LibraryElement library = resolve(source); |
| 5680 CompilationUnit oldUnit = resolveCompilationUnit(source, library); |
| 5681 AnalysisContext context = analysisContext; |
| 5682 context.setContents(source, newContent); |
| 5683 CompilationUnit newUnit = context.parseCompilationUnit(source); |
| 5684 DeclarationMatcher matcher = new DeclarationMatcher(); |
| 5685 JUnitTestCase.assertEquals(expectMatch, matcher.matches(newUnit, oldUnit.ele
ment)); |
| 5686 } |
| 5687 |
| 5688 void assertMethodMatches(bool expectMatch, String oldContent, String newConten
t) { |
| 5689 Source source = addSource(oldContent); |
| 5690 LibraryElement library = resolve(source); |
| 5691 CompilationUnit oldUnit = resolveCompilationUnit(source, library); |
| 5692 MethodElement element = getMethod2(oldUnit).element as MethodElement; |
| 5693 AnalysisContext context = analysisContext; |
| 5694 context.setContents(source, newContent); |
| 5695 CompilationUnit newUnit = context.parseCompilationUnit(source); |
| 5696 MethodDeclaration newMethod = getMethod2(newUnit); |
| 5697 DeclarationMatcher matcher = new DeclarationMatcher(); |
| 5698 JUnitTestCase.assertEquals(expectMatch, matcher.matches(newMethod, element))
; |
| 5699 } |
| 5700 |
| 5701 MethodDeclaration getMethod2(CompilationUnit unit) { |
| 5702 ClassDeclaration classNode = unit.declarations[0] as ClassDeclaration; |
| 5703 return classNode.members[0] as MethodDeclaration; |
| 5704 } |
| 5705 |
| 5706 static dartSuite() { |
| 5707 _ut.group('DeclarationMatcherTest', () { |
| 5708 _ut.test('test_compilationUnitMatches_false_topLevelVariable', () { |
| 5709 final __test = new DeclarationMatcherTest(); |
| 5710 runJUnitTest(__test, __test.test_compilationUnitMatches_false_topLevelVa
riable); |
| 5711 }); |
| 5712 _ut.test('test_compilationUnitMatches_true_different', () { |
| 5713 final __test = new DeclarationMatcherTest(); |
| 5714 runJUnitTest(__test, __test.test_compilationUnitMatches_true_different); |
| 5715 }); |
| 5716 _ut.test('test_compilationUnitMatches_true_same', () { |
| 5717 final __test = new DeclarationMatcherTest(); |
| 5718 runJUnitTest(__test, __test.test_compilationUnitMatches_true_same); |
| 5719 }); |
| 5720 _ut.test('test_methodDeclarationMatches_false_localVariable', () { |
| 5721 final __test = new DeclarationMatcherTest(); |
| 5722 runJUnitTest(__test, __test.test_methodDeclarationMatches_false_localVar
iable); |
| 5723 }); |
| 5724 _ut.test('test_methodDeclarationMatches_false_parameter', () { |
| 5725 final __test = new DeclarationMatcherTest(); |
| 5726 runJUnitTest(__test, __test.test_methodDeclarationMatches_false_paramete
r); |
| 5727 }); |
| 5728 _ut.test('test_methodDeclarationMatches_true_different', () { |
| 5729 final __test = new DeclarationMatcherTest(); |
| 5730 runJUnitTest(__test, __test.test_methodDeclarationMatches_true_different
); |
| 5731 }); |
| 5732 _ut.test('test_methodDeclarationMatches_true_same', () { |
| 5733 final __test = new DeclarationMatcherTest(); |
| 5734 runJUnitTest(__test, __test.test_methodDeclarationMatches_true_same); |
| 5735 }); |
| 5736 }); |
| 5737 } |
| 5738 } |
| 5739 |
| 5085 class StaticTypeWarningCodeTest extends ResolverTestCase { | 5740 class StaticTypeWarningCodeTest extends ResolverTestCase { |
| 5086 void fail_inaccessibleSetter() { | 5741 void fail_inaccessibleSetter() { |
| 5087 Source source = addSource(EngineTestCase.createSource([])); | 5742 Source source = addSource(EngineTestCase.createSource([])); |
| 5088 resolve(source); | 5743 resolve(source); |
| 5089 assertErrors(source, [StaticTypeWarningCode.INACCESSIBLE_SETTER]); | 5744 assertErrors(source, [StaticTypeWarningCode.INACCESSIBLE_SETTER]); |
| 5090 verify([source]); | 5745 verify([source]); |
| 5091 } | 5746 } |
| 5747 |
| 5092 void test_expectedOneListTypeArgument() { | 5748 void test_expectedOneListTypeArgument() { |
| 5093 Source source = addSource(EngineTestCase.createSource(["main() {", " <int,
int> [];", "}"])); | 5749 Source source = addSource(EngineTestCase.createSource(["main() {", " <int,
int> [];", "}"])); |
| 5094 resolve(source); | 5750 resolve(source); |
| 5095 assertErrors(source, [StaticTypeWarningCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS
]); | 5751 assertErrors(source, [StaticTypeWarningCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS
]); |
| 5096 verify([source]); | 5752 verify([source]); |
| 5097 } | 5753 } |
| 5754 |
| 5098 void test_expectedTwoMapTypeArguments_one() { | 5755 void test_expectedTwoMapTypeArguments_one() { |
| 5099 Source source = addSource(EngineTestCase.createSource(["main() {", " <int>
{};", "}"])); | 5756 Source source = addSource(EngineTestCase.createSource(["main() {", " <int>
{};", "}"])); |
| 5100 resolve(source); | 5757 resolve(source); |
| 5101 assertErrors(source, [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]
); | 5758 assertErrors(source, [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]
); |
| 5102 verify([source]); | 5759 verify([source]); |
| 5103 } | 5760 } |
| 5761 |
| 5104 void test_expectedTwoMapTypeArguments_three() { | 5762 void test_expectedTwoMapTypeArguments_three() { |
| 5105 Source source = addSource(EngineTestCase.createSource(["main() {", " <int,
int, int> {};", "}"])); | 5763 Source source = addSource(EngineTestCase.createSource(["main() {", " <int,
int, int> {};", "}"])); |
| 5106 resolve(source); | 5764 resolve(source); |
| 5107 assertErrors(source, [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]
); | 5765 assertErrors(source, [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]
); |
| 5108 verify([source]); | 5766 verify([source]); |
| 5109 } | 5767 } |
| 5768 |
| 5110 void test_inconsistentMethodInheritance_paramCount() { | 5769 void test_inconsistentMethodInheritance_paramCount() { |
| 5111 Source source = addSource(EngineTestCase.createSource([ | 5770 Source source = addSource(EngineTestCase.createSource([ |
| 5112 "abstract class A {", | 5771 "abstract class A {", |
| 5113 " int x();", | 5772 " int x();", |
| 5114 "}", | 5773 "}", |
| 5115 "abstract class B {", | 5774 "abstract class B {", |
| 5116 " int x(int y);", | 5775 " int x(int y);", |
| 5117 "}", | 5776 "}", |
| 5118 "class C implements A, B {", | 5777 "class C implements A, B {", |
| 5119 "}"])); | 5778 "}"])); |
| 5120 resolve(source); | 5779 resolve(source); |
| 5121 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); | 5780 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); |
| 5122 verify([source]); | 5781 verify([source]); |
| 5123 } | 5782 } |
| 5783 |
| 5124 void test_inconsistentMethodInheritance_paramType() { | 5784 void test_inconsistentMethodInheritance_paramType() { |
| 5125 Source source = addSource(EngineTestCase.createSource([ | 5785 Source source = addSource(EngineTestCase.createSource([ |
| 5126 "abstract class A {", | 5786 "abstract class A {", |
| 5127 " x(int i);", | 5787 " x(int i);", |
| 5128 "}", | 5788 "}", |
| 5129 "abstract class B {", | 5789 "abstract class B {", |
| 5130 " x(String s);", | 5790 " x(String s);", |
| 5131 "}", | 5791 "}", |
| 5132 "abstract class C implements A, B {}"])); | 5792 "abstract class C implements A, B {}"])); |
| 5133 resolve(source); | 5793 resolve(source); |
| 5134 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); | 5794 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); |
| 5135 verify([source]); | 5795 verify([source]); |
| 5136 } | 5796 } |
| 5797 |
| 5137 void test_inconsistentMethodInheritance_returnType() { | 5798 void test_inconsistentMethodInheritance_returnType() { |
| 5138 Source source = addSource(EngineTestCase.createSource([ | 5799 Source source = addSource(EngineTestCase.createSource([ |
| 5139 "abstract class A {", | 5800 "abstract class A {", |
| 5140 " int x();", | 5801 " int x();", |
| 5141 "}", | 5802 "}", |
| 5142 "abstract class B {", | 5803 "abstract class B {", |
| 5143 " String x();", | 5804 " String x();", |
| 5144 "}", | 5805 "}", |
| 5145 "abstract class C implements A, B {}"])); | 5806 "abstract class C implements A, B {}"])); |
| 5146 resolve(source); | 5807 resolve(source); |
| 5147 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); | 5808 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); |
| 5148 verify([source]); | 5809 verify([source]); |
| 5149 } | 5810 } |
| 5811 |
| 5150 void test_instanceAccessToStaticMember_method_invocation() { | 5812 void test_instanceAccessToStaticMember_method_invocation() { |
| 5151 Source source = addSource(EngineTestCase.createSource([ | 5813 Source source = addSource(EngineTestCase.createSource([ |
| 5152 "class A {", | 5814 "class A {", |
| 5153 " static m() {}", | 5815 " static m() {}", |
| 5154 "}", | 5816 "}", |
| 5155 "main(A a) {", | 5817 "main(A a) {", |
| 5156 " a.m();", | 5818 " a.m();", |
| 5157 "}"])); | 5819 "}"])); |
| 5158 resolve(source); | 5820 resolve(source); |
| 5159 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); | 5821 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); |
| 5160 verify([source]); | 5822 verify([source]); |
| 5161 } | 5823 } |
| 5824 |
| 5162 void test_instanceAccessToStaticMember_method_reference() { | 5825 void test_instanceAccessToStaticMember_method_reference() { |
| 5163 Source source = addSource(EngineTestCase.createSource([ | 5826 Source source = addSource(EngineTestCase.createSource([ |
| 5164 "class A {", | 5827 "class A {", |
| 5165 " static m() {}", | 5828 " static m() {}", |
| 5166 "}", | 5829 "}", |
| 5167 "main(A a) {", | 5830 "main(A a) {", |
| 5168 " a.m;", | 5831 " a.m;", |
| 5169 "}"])); | 5832 "}"])); |
| 5170 resolve(source); | 5833 resolve(source); |
| 5171 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); | 5834 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); |
| 5172 verify([source]); | 5835 verify([source]); |
| 5173 } | 5836 } |
| 5837 |
| 5174 void test_instanceAccessToStaticMember_propertyAccess_field() { | 5838 void test_instanceAccessToStaticMember_propertyAccess_field() { |
| 5175 Source source = addSource(EngineTestCase.createSource([ | 5839 Source source = addSource(EngineTestCase.createSource([ |
| 5176 "class A {", | 5840 "class A {", |
| 5177 " static var f;", | 5841 " static var f;", |
| 5178 "}", | 5842 "}", |
| 5179 "main(A a) {", | 5843 "main(A a) {", |
| 5180 " a.f;", | 5844 " a.f;", |
| 5181 "}"])); | 5845 "}"])); |
| 5182 resolve(source); | 5846 resolve(source); |
| 5183 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); | 5847 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); |
| 5184 verify([source]); | 5848 verify([source]); |
| 5185 } | 5849 } |
| 5850 |
| 5186 void test_instanceAccessToStaticMember_propertyAccess_getter() { | 5851 void test_instanceAccessToStaticMember_propertyAccess_getter() { |
| 5187 Source source = addSource(EngineTestCase.createSource([ | 5852 Source source = addSource(EngineTestCase.createSource([ |
| 5188 "class A {", | 5853 "class A {", |
| 5189 " static get f => 42;", | 5854 " static get f => 42;", |
| 5190 "}", | 5855 "}", |
| 5191 "main(A a) {", | 5856 "main(A a) {", |
| 5192 " a.f;", | 5857 " a.f;", |
| 5193 "}"])); | 5858 "}"])); |
| 5194 resolve(source); | 5859 resolve(source); |
| 5195 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); | 5860 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); |
| 5196 verify([source]); | 5861 verify([source]); |
| 5197 } | 5862 } |
| 5863 |
| 5198 void test_instanceAccessToStaticMember_propertyAccess_setter() { | 5864 void test_instanceAccessToStaticMember_propertyAccess_setter() { |
| 5199 Source source = addSource(EngineTestCase.createSource([ | 5865 Source source = addSource(EngineTestCase.createSource([ |
| 5200 "class A {", | 5866 "class A {", |
| 5201 " static set f(x) {}", | 5867 " static set f(x) {}", |
| 5202 "}", | 5868 "}", |
| 5203 "main(A a) {", | 5869 "main(A a) {", |
| 5204 " a.f = 42;", | 5870 " a.f = 42;", |
| 5205 "}"])); | 5871 "}"])); |
| 5206 resolve(source); | 5872 resolve(source); |
| 5207 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); | 5873 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); |
| 5208 verify([source]); | 5874 verify([source]); |
| 5209 } | 5875 } |
| 5876 |
| 5210 void test_invalidAssignment_compoundAssignment() { | 5877 void test_invalidAssignment_compoundAssignment() { |
| 5211 Source source = addSource(EngineTestCase.createSource([ | 5878 Source source = addSource(EngineTestCase.createSource([ |
| 5212 "class byte {", | 5879 "class byte {", |
| 5213 " int _value;", | 5880 " int _value;", |
| 5214 " byte(this._value);", | 5881 " byte(this._value);", |
| 5215 " int operator +(int val) {}", | 5882 " int operator +(int val) {}", |
| 5216 "}", | 5883 "}", |
| 5217 "", | 5884 "", |
| 5218 "void main() {", | 5885 "void main() {", |
| 5219 " byte b = new byte(52);", | 5886 " byte b = new byte(52);", |
| 5220 " b += 3;", | 5887 " b += 3;", |
| 5221 "}"])); | 5888 "}"])); |
| 5222 resolve(source); | 5889 resolve(source); |
| 5223 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 5890 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 5224 verify([source]); | 5891 verify([source]); |
| 5225 } | 5892 } |
| 5893 |
| 5226 void test_invalidAssignment_defaultValue_named() { | 5894 void test_invalidAssignment_defaultValue_named() { |
| 5227 Source source = addSource(EngineTestCase.createSource(["f({String x: 0}) {",
"}"])); | 5895 Source source = addSource(EngineTestCase.createSource(["f({String x: 0}) {",
"}"])); |
| 5228 resolve(source); | 5896 resolve(source); |
| 5229 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 5897 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 5230 verify([source]); | 5898 verify([source]); |
| 5231 } | 5899 } |
| 5900 |
| 5232 void test_invalidAssignment_defaultValue_optional() { | 5901 void test_invalidAssignment_defaultValue_optional() { |
| 5233 Source source = addSource(EngineTestCase.createSource(["f([String x = 0]) {"
, "}"])); | 5902 Source source = addSource(EngineTestCase.createSource(["f([String x = 0]) {"
, "}"])); |
| 5234 resolve(source); | 5903 resolve(source); |
| 5235 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 5904 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 5236 verify([source]); | 5905 verify([source]); |
| 5237 } | 5906 } |
| 5907 |
| 5238 void test_invalidAssignment_instanceVariable() { | 5908 void test_invalidAssignment_instanceVariable() { |
| 5239 Source source = addSource(EngineTestCase.createSource([ | 5909 Source source = addSource(EngineTestCase.createSource([ |
| 5240 "class A {", | 5910 "class A {", |
| 5241 " int x;", | 5911 " int x;", |
| 5242 "}", | 5912 "}", |
| 5243 "f() {", | 5913 "f() {", |
| 5244 " A a;", | 5914 " A a;", |
| 5245 " a.x = '0';", | 5915 " a.x = '0';", |
| 5246 "}"])); | 5916 "}"])); |
| 5247 resolve(source); | 5917 resolve(source); |
| 5248 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 5918 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 5249 verify([source]); | 5919 verify([source]); |
| 5250 } | 5920 } |
| 5921 |
| 5251 void test_invalidAssignment_localVariable() { | 5922 void test_invalidAssignment_localVariable() { |
| 5252 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;",
" x = '0';", "}"])); | 5923 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;",
" x = '0';", "}"])); |
| 5253 resolve(source); | 5924 resolve(source); |
| 5254 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 5925 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 5255 verify([source]); | 5926 verify([source]); |
| 5256 } | 5927 } |
| 5928 |
| 5257 void test_invalidAssignment_staticVariable() { | 5929 void test_invalidAssignment_staticVariable() { |
| 5258 Source source = addSource(EngineTestCase.createSource([ | 5930 Source source = addSource(EngineTestCase.createSource([ |
| 5259 "class A {", | 5931 "class A {", |
| 5260 " static int x;", | 5932 " static int x;", |
| 5261 "}", | 5933 "}", |
| 5262 "f() {", | 5934 "f() {", |
| 5263 " A.x = '0';", | 5935 " A.x = '0';", |
| 5264 "}"])); | 5936 "}"])); |
| 5265 resolve(source); | 5937 resolve(source); |
| 5266 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 5938 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 5267 verify([source]); | 5939 verify([source]); |
| 5268 } | 5940 } |
| 5941 |
| 5269 void test_invalidAssignment_topLevelVariableDeclaration() { | 5942 void test_invalidAssignment_topLevelVariableDeclaration() { |
| 5270 Source source = addSource(EngineTestCase.createSource(["int x = 'string';"])
); | 5943 Source source = addSource(EngineTestCase.createSource(["int x = 'string';"])
); |
| 5271 resolve(source); | 5944 resolve(source); |
| 5272 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 5945 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 5273 verify([source]); | 5946 verify([source]); |
| 5274 } | 5947 } |
| 5948 |
| 5275 void test_invalidAssignment_variableDeclaration() { | 5949 void test_invalidAssignment_variableDeclaration() { |
| 5276 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
= 'string';", "}"])); | 5950 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
= 'string';", "}"])); |
| 5277 resolve(source); | 5951 resolve(source); |
| 5278 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 5952 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 5279 verify([source]); | 5953 verify([source]); |
| 5280 } | 5954 } |
| 5955 |
| 5281 void test_invocationOfNonFunction_class() { | 5956 void test_invocationOfNonFunction_class() { |
| 5282 Source source = addSource(EngineTestCase.createSource(["class A {", " void
m() {", " A();", " }", "}"])); | 5957 Source source = addSource(EngineTestCase.createSource(["class A {", " void
m() {", " A();", " }", "}"])); |
| 5283 resolve(source); | 5958 resolve(source); |
| 5284 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); | 5959 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); |
| 5285 } | 5960 } |
| 5961 |
| 5286 void test_invocationOfNonFunction_localVariable() { | 5962 void test_invocationOfNonFunction_localVariable() { |
| 5287 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;",
" return x();", "}"])); | 5963 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;",
" return x();", "}"])); |
| 5288 resolve(source); | 5964 resolve(source); |
| 5289 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); | 5965 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); |
| 5290 verify([source]); | 5966 verify([source]); |
| 5291 } | 5967 } |
| 5968 |
| 5292 void test_invocationOfNonFunction_ordinaryInvocation() { | 5969 void test_invocationOfNonFunction_ordinaryInvocation() { |
| 5293 Source source = addSource(EngineTestCase.createSource([ | 5970 Source source = addSource(EngineTestCase.createSource([ |
| 5294 "class A {", | 5971 "class A {", |
| 5295 " static int x;", | 5972 " static int x;", |
| 5296 "}", | 5973 "}", |
| 5297 "class B {", | 5974 "class B {", |
| 5298 " m() {", | 5975 " m() {", |
| 5299 " A.x();", | 5976 " A.x();", |
| 5300 " }", | 5977 " }", |
| 5301 "}"])); | 5978 "}"])); |
| 5302 resolve(source); | 5979 resolve(source); |
| 5303 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); | 5980 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); |
| 5304 } | 5981 } |
| 5982 |
| 5305 void test_invocationOfNonFunction_staticInvocation() { | 5983 void test_invocationOfNonFunction_staticInvocation() { |
| 5306 Source source = addSource(EngineTestCase.createSource([ | 5984 Source source = addSource(EngineTestCase.createSource([ |
| 5307 "class A {", | 5985 "class A {", |
| 5308 " static int get g => 0;", | 5986 " static int get g => 0;", |
| 5309 " f() {", | 5987 " f() {", |
| 5310 " A.g();", | 5988 " A.g();", |
| 5311 " }", | 5989 " }", |
| 5312 "}"])); | 5990 "}"])); |
| 5313 resolve(source); | 5991 resolve(source); |
| 5314 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); | 5992 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); |
| 5315 } | 5993 } |
| 5994 |
| 5316 void test_invocationOfNonFunction_superExpression() { | 5995 void test_invocationOfNonFunction_superExpression() { |
| 5317 Source source = addSource(EngineTestCase.createSource([ | 5996 Source source = addSource(EngineTestCase.createSource([ |
| 5318 "class A {", | 5997 "class A {", |
| 5319 " int get g => 0;", | 5998 " int get g => 0;", |
| 5320 "}", | 5999 "}", |
| 5321 "class B extends A {", | 6000 "class B extends A {", |
| 5322 " m() {", | 6001 " m() {", |
| 5323 " var v = super.g();", | 6002 " var v = super.g();", |
| 5324 " }", | 6003 " }", |
| 5325 "}"])); | 6004 "}"])); |
| 5326 resolve(source); | 6005 resolve(source); |
| 5327 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); | 6006 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); |
| 5328 verify([source]); | 6007 verify([source]); |
| 5329 } | 6008 } |
| 6009 |
| 5330 void test_invocationOfNonFunctionExpression_literal() { | 6010 void test_invocationOfNonFunctionExpression_literal() { |
| 5331 Source source = addSource(EngineTestCase.createSource(["f() {", " 3(5);", "
}"])); | 6011 Source source = addSource(EngineTestCase.createSource(["f() {", " 3(5);", "
}"])); |
| 5332 resolve(source); | 6012 resolve(source); |
| 5333 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRE
SSION]); | 6013 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRE
SSION]); |
| 5334 verify([source]); | 6014 verify([source]); |
| 5335 } | 6015 } |
| 6016 |
| 5336 void test_nonBoolCondition_conditional() { | 6017 void test_nonBoolCondition_conditional() { |
| 5337 Source source = addSource(EngineTestCase.createSource(["f() { return 3 ? 2 :
1; }"])); | 6018 Source source = addSource(EngineTestCase.createSource(["f() { return 3 ? 2 :
1; }"])); |
| 5338 resolve(source); | 6019 resolve(source); |
| 5339 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); | 6020 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); |
| 5340 verify([source]); | 6021 verify([source]); |
| 5341 } | 6022 } |
| 6023 |
| 5342 void test_nonBoolCondition_do() { | 6024 void test_nonBoolCondition_do() { |
| 5343 Source source = addSource(EngineTestCase.createSource(["f() {", " do {} whi
le (3);", "}"])); | 6025 Source source = addSource(EngineTestCase.createSource(["f() {", " do {} whi
le (3);", "}"])); |
| 5344 resolve(source); | 6026 resolve(source); |
| 5345 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); | 6027 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); |
| 5346 verify([source]); | 6028 verify([source]); |
| 5347 } | 6029 } |
| 6030 |
| 5348 void test_nonBoolCondition_if() { | 6031 void test_nonBoolCondition_if() { |
| 5349 Source source = addSource(EngineTestCase.createSource(["f() {", " if (3) re
turn 2; else return 1;", "}"])); | 6032 Source source = addSource(EngineTestCase.createSource(["f() {", " if (3) re
turn 2; else return 1;", "}"])); |
| 5350 resolve(source); | 6033 resolve(source); |
| 5351 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); | 6034 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); |
| 5352 verify([source]); | 6035 verify([source]); |
| 5353 } | 6036 } |
| 6037 |
| 5354 void test_nonBoolCondition_while() { | 6038 void test_nonBoolCondition_while() { |
| 5355 Source source = addSource(EngineTestCase.createSource(["f() {", " while (3)
{}", "}"])); | 6039 Source source = addSource(EngineTestCase.createSource(["f() {", " while (3)
{}", "}"])); |
| 5356 resolve(source); | 6040 resolve(source); |
| 5357 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); | 6041 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); |
| 5358 verify([source]); | 6042 verify([source]); |
| 5359 } | 6043 } |
| 6044 |
| 5360 void test_nonBoolExpression_functionType() { | 6045 void test_nonBoolExpression_functionType() { |
| 5361 Source source = addSource(EngineTestCase.createSource([ | 6046 Source source = addSource(EngineTestCase.createSource([ |
| 5362 "int makeAssertion() => 1;", | 6047 "int makeAssertion() => 1;", |
| 5363 "f() {", | 6048 "f() {", |
| 5364 " assert(makeAssertion);", | 6049 " assert(makeAssertion);", |
| 5365 "}"])); | 6050 "}"])); |
| 5366 resolve(source); | 6051 resolve(source); |
| 5367 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); | 6052 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); |
| 5368 verify([source]); | 6053 verify([source]); |
| 5369 } | 6054 } |
| 6055 |
| 5370 void test_nonBoolExpression_interfaceType() { | 6056 void test_nonBoolExpression_interfaceType() { |
| 5371 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0)
;", "}"])); | 6057 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0)
;", "}"])); |
| 5372 resolve(source); | 6058 resolve(source); |
| 5373 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); | 6059 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); |
| 5374 verify([source]); | 6060 verify([source]); |
| 5375 } | 6061 } |
| 6062 |
| 5376 void test_nonBoolNegationExpression() { | 6063 void test_nonBoolNegationExpression() { |
| 5377 Source source = addSource(EngineTestCase.createSource(["f() {", " !42;", "}
"])); | 6064 Source source = addSource(EngineTestCase.createSource(["f() {", " !42;", "}
"])); |
| 5378 resolve(source); | 6065 resolve(source); |
| 5379 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_NEGATION_EXPRESSION]); | 6066 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_NEGATION_EXPRESSION]); |
| 5380 verify([source]); | 6067 verify([source]); |
| 5381 } | 6068 } |
| 6069 |
| 5382 void test_nonTypeAsTypeArgument_notAType() { | 6070 void test_nonTypeAsTypeArgument_notAType() { |
| 5383 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E>
{}", "f(B<A> b) {}"])); | 6071 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E>
{}", "f(B<A> b) {}"])); |
| 5384 resolve(source); | 6072 resolve(source); |
| 5385 assertErrors(source, [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); | 6073 assertErrors(source, [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); |
| 5386 verify([source]); | 6074 verify([source]); |
| 5387 } | 6075 } |
| 6076 |
| 5388 void test_nonTypeAsTypeArgument_undefinedIdentifier() { | 6077 void test_nonTypeAsTypeArgument_undefinedIdentifier() { |
| 5389 Source source = addSource(EngineTestCase.createSource(["class B<E> {}", "f(B
<A> b) {}"])); | 6078 Source source = addSource(EngineTestCase.createSource(["class B<E> {}", "f(B
<A> b) {}"])); |
| 5390 resolve(source); | 6079 resolve(source); |
| 5391 assertErrors(source, [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); | 6080 assertErrors(source, [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); |
| 5392 verify([source]); | 6081 verify([source]); |
| 5393 } | 6082 } |
| 6083 |
| 5394 void test_returnOfInvalidType_expressionFunctionBody_function() { | 6084 void test_returnOfInvalidType_expressionFunctionBody_function() { |
| 5395 Source source = addSource(EngineTestCase.createSource(["int f() => '0';"])); | 6085 Source source = addSource(EngineTestCase.createSource(["int f() => '0';"])); |
| 5396 resolve(source); | 6086 resolve(source); |
| 5397 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 6087 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 5398 verify([source]); | 6088 verify([source]); |
| 5399 } | 6089 } |
| 6090 |
| 5400 void test_returnOfInvalidType_expressionFunctionBody_getter() { | 6091 void test_returnOfInvalidType_expressionFunctionBody_getter() { |
| 5401 Source source = addSource(EngineTestCase.createSource(["int get g => '0';"])
); | 6092 Source source = addSource(EngineTestCase.createSource(["int get g => '0';"])
); |
| 5402 resolve(source); | 6093 resolve(source); |
| 5403 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 6094 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 5404 verify([source]); | 6095 verify([source]); |
| 5405 } | 6096 } |
| 6097 |
| 5406 void test_returnOfInvalidType_expressionFunctionBody_localFunction() { | 6098 void test_returnOfInvalidType_expressionFunctionBody_localFunction() { |
| 5407 Source source = addSource(EngineTestCase.createSource([ | 6099 Source source = addSource(EngineTestCase.createSource([ |
| 5408 "class A {", | 6100 "class A {", |
| 5409 " String m() {", | 6101 " String m() {", |
| 5410 " int f() => '0';", | 6102 " int f() => '0';", |
| 5411 " }", | 6103 " }", |
| 5412 "}"])); | 6104 "}"])); |
| 5413 resolve(source); | 6105 resolve(source); |
| 5414 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 6106 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 5415 verify([source]); | 6107 verify([source]); |
| 5416 } | 6108 } |
| 6109 |
| 5417 void test_returnOfInvalidType_expressionFunctionBody_method() { | 6110 void test_returnOfInvalidType_expressionFunctionBody_method() { |
| 5418 Source source = addSource(EngineTestCase.createSource(["class A {", " int f
() => '0';", "}"])); | 6111 Source source = addSource(EngineTestCase.createSource(["class A {", " int f
() => '0';", "}"])); |
| 5419 resolve(source); | 6112 resolve(source); |
| 5420 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 6113 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 5421 verify([source]); | 6114 verify([source]); |
| 5422 } | 6115 } |
| 6116 |
| 5423 void test_returnOfInvalidType_expressionFunctionBody_void() { | 6117 void test_returnOfInvalidType_expressionFunctionBody_void() { |
| 5424 Source source = addSource(EngineTestCase.createSource(["void f() => 42;"])); | 6118 Source source = addSource(EngineTestCase.createSource(["void f() => 42;"])); |
| 5425 resolve(source); | 6119 resolve(source); |
| 5426 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 6120 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 5427 verify([source]); | 6121 verify([source]); |
| 5428 } | 6122 } |
| 6123 |
| 5429 void test_returnOfInvalidType_function() { | 6124 void test_returnOfInvalidType_function() { |
| 5430 Source source = addSource(EngineTestCase.createSource(["int f() { return '0'
; }"])); | 6125 Source source = addSource(EngineTestCase.createSource(["int f() { return '0'
; }"])); |
| 5431 resolve(source); | 6126 resolve(source); |
| 5432 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 6127 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 5433 verify([source]); | 6128 verify([source]); |
| 5434 } | 6129 } |
| 6130 |
| 5435 void test_returnOfInvalidType_getter() { | 6131 void test_returnOfInvalidType_getter() { |
| 5436 Source source = addSource(EngineTestCase.createSource(["int get g { return '
0'; }"])); | 6132 Source source = addSource(EngineTestCase.createSource(["int get g { return '
0'; }"])); |
| 5437 resolve(source); | 6133 resolve(source); |
| 5438 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 6134 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 5439 verify([source]); | 6135 verify([source]); |
| 5440 } | 6136 } |
| 6137 |
| 5441 void test_returnOfInvalidType_localFunction() { | 6138 void test_returnOfInvalidType_localFunction() { |
| 5442 Source source = addSource(EngineTestCase.createSource([ | 6139 Source source = addSource(EngineTestCase.createSource([ |
| 5443 "class A {", | 6140 "class A {", |
| 5444 " String m() {", | 6141 " String m() {", |
| 5445 " int f() { return '0'; }", | 6142 " int f() { return '0'; }", |
| 5446 " }", | 6143 " }", |
| 5447 "}"])); | 6144 "}"])); |
| 5448 resolve(source); | 6145 resolve(source); |
| 5449 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 6146 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 5450 verify([source]); | 6147 verify([source]); |
| 5451 } | 6148 } |
| 6149 |
| 5452 void test_returnOfInvalidType_method() { | 6150 void test_returnOfInvalidType_method() { |
| 5453 Source source = addSource(EngineTestCase.createSource(["class A {", " int f
() { return '0'; }", "}"])); | 6151 Source source = addSource(EngineTestCase.createSource(["class A {", " int f
() { return '0'; }", "}"])); |
| 5454 resolve(source); | 6152 resolve(source); |
| 5455 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 6153 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 5456 verify([source]); | 6154 verify([source]); |
| 5457 } | 6155 } |
| 6156 |
| 5458 void test_returnOfInvalidType_void() { | 6157 void test_returnOfInvalidType_void() { |
| 5459 Source source = addSource(EngineTestCase.createSource(["void f() { return 42
; }"])); | 6158 Source source = addSource(EngineTestCase.createSource(["void f() { return 42
; }"])); |
| 5460 resolve(source); | 6159 resolve(source); |
| 5461 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 6160 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 5462 verify([source]); | 6161 verify([source]); |
| 5463 } | 6162 } |
| 6163 |
| 5464 void test_typeArgumentNotMatchingBounds_classTypeAlias() { | 6164 void test_typeArgumentNotMatchingBounds_classTypeAlias() { |
| 5465 Source source = addSource(EngineTestCase.createSource([ | 6165 Source source = addSource(EngineTestCase.createSource([ |
| 5466 "class A {}", | 6166 "class A {}", |
| 5467 "class B {}", | 6167 "class B {}", |
| 5468 "class C {}", | 6168 "class C {}", |
| 5469 "class G<E extends A> {}", | 6169 "class G<E extends A> {}", |
| 5470 "class D = G<B> with C;"])); | 6170 "class D = G<B> with C;"])); |
| 5471 resolve(source); | 6171 resolve(source); |
| 5472 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6172 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5473 verify([source]); | 6173 verify([source]); |
| 5474 } | 6174 } |
| 6175 |
| 5475 void test_typeArgumentNotMatchingBounds_extends() { | 6176 void test_typeArgumentNotMatchingBounds_extends() { |
| 5476 Source source = addSource(EngineTestCase.createSource([ | 6177 Source source = addSource(EngineTestCase.createSource([ |
| 5477 "class A {}", | 6178 "class A {}", |
| 5478 "class B {}", | 6179 "class B {}", |
| 5479 "class G<E extends A> {}", | 6180 "class G<E extends A> {}", |
| 5480 "class C extends G<B>{}"])); | 6181 "class C extends G<B>{}"])); |
| 5481 resolve(source); | 6182 resolve(source); |
| 5482 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6183 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5483 verify([source]); | 6184 verify([source]); |
| 5484 } | 6185 } |
| 6186 |
| 5485 void test_typeArgumentNotMatchingBounds_fieldFormalParameter() { | 6187 void test_typeArgumentNotMatchingBounds_fieldFormalParameter() { |
| 5486 Source source = addSource(EngineTestCase.createSource([ | 6188 Source source = addSource(EngineTestCase.createSource([ |
| 5487 "class A {}", | 6189 "class A {}", |
| 5488 "class B {}", | 6190 "class B {}", |
| 5489 "class G<E extends A> {}", | 6191 "class G<E extends A> {}", |
| 5490 "class C {", | 6192 "class C {", |
| 5491 " var f;", | 6193 " var f;", |
| 5492 " C(G<B> this.f) {}", | 6194 " C(G<B> this.f) {}", |
| 5493 "}"])); | 6195 "}"])); |
| 5494 resolve(source); | 6196 resolve(source); |
| 5495 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6197 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5496 verify([source]); | 6198 verify([source]); |
| 5497 } | 6199 } |
| 6200 |
| 5498 void test_typeArgumentNotMatchingBounds_functionReturnType() { | 6201 void test_typeArgumentNotMatchingBounds_functionReturnType() { |
| 5499 Source source = addSource(EngineTestCase.createSource([ | 6202 Source source = addSource(EngineTestCase.createSource([ |
| 5500 "class A {}", | 6203 "class A {}", |
| 5501 "class B {}", | 6204 "class B {}", |
| 5502 "class G<E extends A> {}", | 6205 "class G<E extends A> {}", |
| 5503 "G<B> f() {}"])); | 6206 "G<B> f() {}"])); |
| 5504 resolve(source); | 6207 resolve(source); |
| 5505 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6208 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5506 verify([source]); | 6209 verify([source]); |
| 5507 } | 6210 } |
| 6211 |
| 5508 void test_typeArgumentNotMatchingBounds_functionTypeAlias() { | 6212 void test_typeArgumentNotMatchingBounds_functionTypeAlias() { |
| 5509 Source source = addSource(EngineTestCase.createSource([ | 6213 Source source = addSource(EngineTestCase.createSource([ |
| 5510 "class A {}", | 6214 "class A {}", |
| 5511 "class B {}", | 6215 "class B {}", |
| 5512 "class G<E extends A> {}", | 6216 "class G<E extends A> {}", |
| 5513 "typedef G<B> f();"])); | 6217 "typedef G<B> f();"])); |
| 5514 resolve(source); | 6218 resolve(source); |
| 5515 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6219 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5516 verify([source]); | 6220 verify([source]); |
| 5517 } | 6221 } |
| 6222 |
| 5518 void test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() { | 6223 void test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() { |
| 5519 Source source = addSource(EngineTestCase.createSource([ | 6224 Source source = addSource(EngineTestCase.createSource([ |
| 5520 "class A {}", | 6225 "class A {}", |
| 5521 "class B {}", | 6226 "class B {}", |
| 5522 "class G<E extends A> {}", | 6227 "class G<E extends A> {}", |
| 5523 "f(G<B> h()) {}"])); | 6228 "f(G<B> h()) {}"])); |
| 5524 resolve(source); | 6229 resolve(source); |
| 5525 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6230 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5526 verify([source]); | 6231 verify([source]); |
| 5527 } | 6232 } |
| 6233 |
| 5528 void test_typeArgumentNotMatchingBounds_implements() { | 6234 void test_typeArgumentNotMatchingBounds_implements() { |
| 5529 Source source = addSource(EngineTestCase.createSource([ | 6235 Source source = addSource(EngineTestCase.createSource([ |
| 5530 "class A {}", | 6236 "class A {}", |
| 5531 "class B {}", | 6237 "class B {}", |
| 5532 "class G<E extends A> {}", | 6238 "class G<E extends A> {}", |
| 5533 "class C implements G<B>{}"])); | 6239 "class C implements G<B>{}"])); |
| 5534 resolve(source); | 6240 resolve(source); |
| 5535 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6241 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5536 verify([source]); | 6242 verify([source]); |
| 5537 } | 6243 } |
| 6244 |
| 5538 void test_typeArgumentNotMatchingBounds_is() { | 6245 void test_typeArgumentNotMatchingBounds_is() { |
| 5539 Source source = addSource(EngineTestCase.createSource([ | 6246 Source source = addSource(EngineTestCase.createSource([ |
| 5540 "class A {}", | 6247 "class A {}", |
| 5541 "class B {}", | 6248 "class B {}", |
| 5542 "class G<E extends A> {}", | 6249 "class G<E extends A> {}", |
| 5543 "var b = 1 is G<B>;"])); | 6250 "var b = 1 is G<B>;"])); |
| 5544 resolve(source); | 6251 resolve(source); |
| 5545 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6252 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5546 verify([source]); | 6253 verify([source]); |
| 5547 } | 6254 } |
| 6255 |
| 5548 void test_typeArgumentNotMatchingBounds_methodReturnType() { | 6256 void test_typeArgumentNotMatchingBounds_methodReturnType() { |
| 5549 Source source = addSource(EngineTestCase.createSource([ | 6257 Source source = addSource(EngineTestCase.createSource([ |
| 5550 "class A {}", | 6258 "class A {}", |
| 5551 "class B {}", | 6259 "class B {}", |
| 5552 "class G<E extends A> {}", | 6260 "class G<E extends A> {}", |
| 5553 "class C {", | 6261 "class C {", |
| 5554 " G<B> m() {}", | 6262 " G<B> m() {}", |
| 5555 "}"])); | 6263 "}"])); |
| 5556 resolve(source); | 6264 resolve(source); |
| 5557 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6265 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5558 verify([source]); | 6266 verify([source]); |
| 5559 } | 6267 } |
| 6268 |
| 5560 void test_typeArgumentNotMatchingBounds_new() { | 6269 void test_typeArgumentNotMatchingBounds_new() { |
| 5561 Source source = addSource(EngineTestCase.createSource([ | 6270 Source source = addSource(EngineTestCase.createSource([ |
| 5562 "class A {}", | 6271 "class A {}", |
| 5563 "class B {}", | 6272 "class B {}", |
| 5564 "class G<E extends A> {}", | 6273 "class G<E extends A> {}", |
| 5565 "f() { return new G<B>(); }"])); | 6274 "f() { return new G<B>(); }"])); |
| 5566 resolve(source); | 6275 resolve(source); |
| 5567 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6276 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5568 verify([source]); | 6277 verify([source]); |
| 5569 } | 6278 } |
| 6279 |
| 5570 void test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() { | 6280 void test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() { |
| 5571 Source source = addSource(EngineTestCase.createSource([ | 6281 Source source = addSource(EngineTestCase.createSource([ |
| 5572 "class A {}", | 6282 "class A {}", |
| 5573 "class B extends A {}", | 6283 "class B extends A {}", |
| 5574 "class C extends B {}", | 6284 "class C extends B {}", |
| 5575 "class G<E extends B> {}", | 6285 "class G<E extends B> {}", |
| 5576 "f() { return new G<A>(); }"])); | 6286 "f() { return new G<A>(); }"])); |
| 5577 resolve(source); | 6287 resolve(source); |
| 5578 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6288 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5579 verify([source]); | 6289 verify([source]); |
| 5580 } | 6290 } |
| 6291 |
| 5581 void test_typeArgumentNotMatchingBounds_parameter() { | 6292 void test_typeArgumentNotMatchingBounds_parameter() { |
| 5582 Source source = addSource(EngineTestCase.createSource([ | 6293 Source source = addSource(EngineTestCase.createSource([ |
| 5583 "class A {}", | 6294 "class A {}", |
| 5584 "class B {}", | 6295 "class B {}", |
| 5585 "class G<E extends A> {}", | 6296 "class G<E extends A> {}", |
| 5586 "f(G<B> g) {}"])); | 6297 "f(G<B> g) {}"])); |
| 5587 resolve(source); | 6298 resolve(source); |
| 5588 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6299 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5589 verify([source]); | 6300 verify([source]); |
| 5590 } | 6301 } |
| 6302 |
| 5591 void test_typeArgumentNotMatchingBounds_redirectingConstructor() { | 6303 void test_typeArgumentNotMatchingBounds_redirectingConstructor() { |
| 5592 Source source = addSource(EngineTestCase.createSource([ | 6304 Source source = addSource(EngineTestCase.createSource([ |
| 5593 "class A {}", | 6305 "class A {}", |
| 5594 "class B {}", | 6306 "class B {}", |
| 5595 "class X<T extends A> {", | 6307 "class X<T extends A> {", |
| 5596 " X(int x, int y) {}", | 6308 " X(int x, int y) {}", |
| 5597 " factory X.name(int x, int y) = X<B>;", | 6309 " factory X.name(int x, int y) = X<B>;", |
| 5598 "}"])); | 6310 "}"])); |
| 5599 resolve(source); | 6311 resolve(source); |
| 5600 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6312 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5601 verify([source]); | 6313 verify([source]); |
| 5602 } | 6314 } |
| 6315 |
| 5603 void test_typeArgumentNotMatchingBounds_typeArgumentList() { | 6316 void test_typeArgumentNotMatchingBounds_typeArgumentList() { |
| 5604 Source source = addSource(EngineTestCase.createSource([ | 6317 Source source = addSource(EngineTestCase.createSource([ |
| 5605 "class A {}", | 6318 "class A {}", |
| 5606 "class B {}", | 6319 "class B {}", |
| 5607 "class C<E> {}", | 6320 "class C<E> {}", |
| 5608 "class D<E extends A> {}", | 6321 "class D<E extends A> {}", |
| 5609 "C<D<B>> Var;"])); | 6322 "C<D<B>> Var;"])); |
| 5610 resolve(source); | 6323 resolve(source); |
| 5611 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6324 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5612 verify([source]); | 6325 verify([source]); |
| 5613 } | 6326 } |
| 6327 |
| 5614 void test_typeArgumentNotMatchingBounds_typeParameter() { | 6328 void test_typeArgumentNotMatchingBounds_typeParameter() { |
| 5615 Source source = addSource(EngineTestCase.createSource([ | 6329 Source source = addSource(EngineTestCase.createSource([ |
| 5616 "class A {}", | 6330 "class A {}", |
| 5617 "class B {}", | 6331 "class B {}", |
| 5618 "class C {}", | 6332 "class C {}", |
| 5619 "class G<E extends A> {}", | 6333 "class G<E extends A> {}", |
| 5620 "class D<F extends G<B>> {}"])); | 6334 "class D<F extends G<B>> {}"])); |
| 5621 resolve(source); | 6335 resolve(source); |
| 5622 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6336 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5623 verify([source]); | 6337 verify([source]); |
| 5624 } | 6338 } |
| 6339 |
| 5625 void test_typeArgumentNotMatchingBounds_variableDeclaration() { | 6340 void test_typeArgumentNotMatchingBounds_variableDeclaration() { |
| 5626 Source source = addSource(EngineTestCase.createSource([ | 6341 Source source = addSource(EngineTestCase.createSource([ |
| 5627 "class A {}", | 6342 "class A {}", |
| 5628 "class B {}", | 6343 "class B {}", |
| 5629 "class G<E extends A> {}", | 6344 "class G<E extends A> {}", |
| 5630 "G<B> g;"])); | 6345 "G<B> g;"])); |
| 5631 resolve(source); | 6346 resolve(source); |
| 5632 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6347 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5633 verify([source]); | 6348 verify([source]); |
| 5634 } | 6349 } |
| 6350 |
| 5635 void test_typeArgumentNotMatchingBounds_with() { | 6351 void test_typeArgumentNotMatchingBounds_with() { |
| 5636 Source source = addSource(EngineTestCase.createSource([ | 6352 Source source = addSource(EngineTestCase.createSource([ |
| 5637 "class A {}", | 6353 "class A {}", |
| 5638 "class B {}", | 6354 "class B {}", |
| 5639 "class G<E extends A> {}", | 6355 "class G<E extends A> {}", |
| 5640 "class C extends Object with G<B>{}"])); | 6356 "class C extends Object with G<B>{}"])); |
| 5641 resolve(source); | 6357 resolve(source); |
| 5642 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); | 6358 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 5643 verify([source]); | 6359 verify([source]); |
| 5644 } | 6360 } |
| 6361 |
| 5645 void test_typeParameterSupertypeOfItsBound() { | 6362 void test_typeParameterSupertypeOfItsBound() { |
| 5646 Source source = addSource(EngineTestCase.createSource(["class A<T extends T>
{", "}"])); | 6363 Source source = addSource(EngineTestCase.createSource(["class A<T extends T>
{", "}"])); |
| 5647 resolve(source); | 6364 resolve(source); |
| 5648 assertErrors(source, [StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_
BOUND]); | 6365 assertErrors(source, [StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_
BOUND]); |
| 5649 verify([source]); | 6366 verify([source]); |
| 5650 } | 6367 } |
| 6368 |
| 5651 void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_mutated()
{ | 6369 void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_mutated()
{ |
| 5652 Source source = addSource(EngineTestCase.createSource([ | 6370 Source source = addSource(EngineTestCase.createSource([ |
| 5653 "callMe(f()) { f(); }", | 6371 "callMe(f()) { f(); }", |
| 5654 "main(Object p) {", | 6372 "main(Object p) {", |
| 5655 " (p is String) && callMe(() { p.length; });", | 6373 " (p is String) && callMe(() { p.length; });", |
| 5656 " p = 0;", | 6374 " p = 0;", |
| 5657 "}"])); | 6375 "}"])); |
| 5658 resolve(source); | 6376 resolve(source); |
| 5659 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6377 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5660 } | 6378 } |
| 6379 |
| 5661 void test_typePromotion_booleanAnd_useInRight_mutatedInLeft() { | 6380 void test_typePromotion_booleanAnd_useInRight_mutatedInLeft() { |
| 5662 Source source = addSource(EngineTestCase.createSource([ | 6381 Source source = addSource(EngineTestCase.createSource([ |
| 5663 "main(Object p) {", | 6382 "main(Object p) {", |
| 5664 " ((p is String) && ((p = 42) == 42)) && p.length != 0;", | 6383 " ((p is String) && ((p = 42) == 42)) && p.length != 0;", |
| 5665 "}"])); | 6384 "}"])); |
| 5666 resolve(source); | 6385 resolve(source); |
| 5667 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6386 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5668 } | 6387 } |
| 6388 |
| 5669 void test_typePromotion_booleanAnd_useInRight_mutatedInRight() { | 6389 void test_typePromotion_booleanAnd_useInRight_mutatedInRight() { |
| 5670 Source source = addSource(EngineTestCase.createSource([ | 6390 Source source = addSource(EngineTestCase.createSource([ |
| 5671 "main(Object p) {", | 6391 "main(Object p) {", |
| 5672 " (p is String) && (((p = 42) == 42) && p.length != 0);", | 6392 " (p is String) && (((p = 42) == 42) && p.length != 0);", |
| 5673 "}"])); | 6393 "}"])); |
| 5674 resolve(source); | 6394 resolve(source); |
| 5675 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6395 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5676 } | 6396 } |
| 6397 |
| 5677 void test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_
after() { | 6398 void test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_
after() { |
| 5678 Source source = addSource(EngineTestCase.createSource([ | 6399 Source source = addSource(EngineTestCase.createSource([ |
| 5679 "callMe(f()) { f(); }", | 6400 "callMe(f()) { f(); }", |
| 5680 "main(Object p) {", | 6401 "main(Object p) {", |
| 5681 " p is String ? callMe(() { p.length; }) : 0;", | 6402 " p is String ? callMe(() { p.length; }) : 0;", |
| 5682 " p = 42;", | 6403 " p = 42;", |
| 5683 "}"])); | 6404 "}"])); |
| 5684 resolve(source); | 6405 resolve(source); |
| 5685 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6406 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5686 } | 6407 } |
| 6408 |
| 5687 void test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_
before() { | 6409 void test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_
before() { |
| 5688 Source source = addSource(EngineTestCase.createSource([ | 6410 Source source = addSource(EngineTestCase.createSource([ |
| 5689 "callMe(f()) { f(); }", | 6411 "callMe(f()) { f(); }", |
| 5690 "main(Object p) {", | 6412 "main(Object p) {", |
| 5691 " p = 42;", | 6413 " p = 42;", |
| 5692 " p is String ? callMe(() { p.length; }) : 0;", | 6414 " p is String ? callMe(() { p.length; }) : 0;", |
| 5693 "}"])); | 6415 "}"])); |
| 5694 resolve(source); | 6416 resolve(source); |
| 5695 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6417 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5696 } | 6418 } |
| 6419 |
| 5697 void test_typePromotion_conditional_useInThen_hasAssignment() { | 6420 void test_typePromotion_conditional_useInThen_hasAssignment() { |
| 5698 Source source = addSource(EngineTestCase.createSource([ | 6421 Source source = addSource(EngineTestCase.createSource([ |
| 5699 "main(Object p) {", | 6422 "main(Object p) {", |
| 5700 " p is String ? (p.length + (p = 42)) : 0;", | 6423 " p is String ? (p.length + (p = 42)) : 0;", |
| 5701 "}"])); | 6424 "}"])); |
| 5702 resolve(source); | 6425 resolve(source); |
| 5703 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6426 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5704 } | 6427 } |
| 6428 |
| 5705 void test_typePromotion_if_accessedInClosure_hasAssignment() { | 6429 void test_typePromotion_if_accessedInClosure_hasAssignment() { |
| 5706 Source source = addSource(EngineTestCase.createSource([ | 6430 Source source = addSource(EngineTestCase.createSource([ |
| 5707 "callMe(f()) { f(); }", | 6431 "callMe(f()) { f(); }", |
| 5708 "main(Object p) {", | 6432 "main(Object p) {", |
| 5709 " if (p is String) {", | 6433 " if (p is String) {", |
| 5710 " callMe(() {", | 6434 " callMe(() {", |
| 5711 " p.length;", | 6435 " p.length;", |
| 5712 " });", | 6436 " });", |
| 5713 " }", | 6437 " }", |
| 5714 " p = 0;", | 6438 " p = 0;", |
| 5715 "}"])); | 6439 "}"])); |
| 5716 resolve(source); | 6440 resolve(source); |
| 5717 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6441 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5718 } | 6442 } |
| 6443 |
| 5719 void test_typePromotion_if_and_right_hasAssignment() { | 6444 void test_typePromotion_if_and_right_hasAssignment() { |
| 5720 Source source = addSource(EngineTestCase.createSource([ | 6445 Source source = addSource(EngineTestCase.createSource([ |
| 5721 "main(Object p) {", | 6446 "main(Object p) {", |
| 5722 " if (p is String && (p = null) == null) {", | 6447 " if (p is String && (p = null) == null) {", |
| 5723 " p.length;", | 6448 " p.length;", |
| 5724 " }", | 6449 " }", |
| 5725 "}"])); | 6450 "}"])); |
| 5726 resolve(source); | 6451 resolve(source); |
| 5727 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6452 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5728 } | 6453 } |
| 6454 |
| 5729 void test_typePromotion_if_extends_notMoreSpecific_dynamic() { | 6455 void test_typePromotion_if_extends_notMoreSpecific_dynamic() { |
| 5730 Source source = addSource(EngineTestCase.createSource([ | 6456 Source source = addSource(EngineTestCase.createSource([ |
| 5731 "class V {}", | 6457 "class V {}", |
| 5732 "class A<T> {}", | 6458 "class A<T> {}", |
| 5733 "class B<S> extends A<S> {", | 6459 "class B<S> extends A<S> {", |
| 5734 " var b;", | 6460 " var b;", |
| 5735 "}", | 6461 "}", |
| 5736 "", | 6462 "", |
| 5737 "main(A<V> p) {", | 6463 "main(A<V> p) {", |
| 5738 " if (p is B) {", | 6464 " if (p is B) {", |
| 5739 " p.b;", | 6465 " p.b;", |
| 5740 " }", | 6466 " }", |
| 5741 "}"])); | 6467 "}"])); |
| 5742 resolve(source); | 6468 resolve(source); |
| 5743 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6469 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5744 } | 6470 } |
| 6471 |
| 5745 void test_typePromotion_if_extends_notMoreSpecific_notMoreSpecificTypeArg() { | 6472 void test_typePromotion_if_extends_notMoreSpecific_notMoreSpecificTypeArg() { |
| 5746 Source source = addSource(EngineTestCase.createSource([ | 6473 Source source = addSource(EngineTestCase.createSource([ |
| 5747 "class V {}", | 6474 "class V {}", |
| 5748 "class A<T> {}", | 6475 "class A<T> {}", |
| 5749 "class B<S> extends A<S> {", | 6476 "class B<S> extends A<S> {", |
| 5750 " var b;", | 6477 " var b;", |
| 5751 "}", | 6478 "}", |
| 5752 "", | 6479 "", |
| 5753 "main(A<V> p) {", | 6480 "main(A<V> p) {", |
| 5754 " if (p is B<int>) {", | 6481 " if (p is B<int>) {", |
| 5755 " p.b;", | 6482 " p.b;", |
| 5756 " }", | 6483 " }", |
| 5757 "}"])); | 6484 "}"])); |
| 5758 resolve(source); | 6485 resolve(source); |
| 5759 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6486 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5760 } | 6487 } |
| 6488 |
| 5761 void test_typePromotion_if_hasAssignment_after() { | 6489 void test_typePromotion_if_hasAssignment_after() { |
| 5762 Source source = addSource(EngineTestCase.createSource([ | 6490 Source source = addSource(EngineTestCase.createSource([ |
| 5763 "main(Object p) {", | 6491 "main(Object p) {", |
| 5764 " if (p is String) {", | 6492 " if (p is String) {", |
| 5765 " p.length;", | 6493 " p.length;", |
| 5766 " p = 0;", | 6494 " p = 0;", |
| 5767 " }", | 6495 " }", |
| 5768 "}"])); | 6496 "}"])); |
| 5769 resolve(source); | 6497 resolve(source); |
| 5770 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6498 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5771 } | 6499 } |
| 6500 |
| 5772 void test_typePromotion_if_hasAssignment_before() { | 6501 void test_typePromotion_if_hasAssignment_before() { |
| 5773 Source source = addSource(EngineTestCase.createSource([ | 6502 Source source = addSource(EngineTestCase.createSource([ |
| 5774 "main(Object p) {", | 6503 "main(Object p) {", |
| 5775 " if (p is String) {", | 6504 " if (p is String) {", |
| 5776 " p = 0;", | 6505 " p = 0;", |
| 5777 " p.length;", | 6506 " p.length;", |
| 5778 " }", | 6507 " }", |
| 5779 "}"])); | 6508 "}"])); |
| 5780 resolve(source); | 6509 resolve(source); |
| 5781 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6510 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5782 } | 6511 } |
| 6512 |
| 5783 void test_typePromotion_if_hasAssignment_inClosure_anonymous_after() { | 6513 void test_typePromotion_if_hasAssignment_inClosure_anonymous_after() { |
| 5784 Source source = addSource(EngineTestCase.createSource([ | 6514 Source source = addSource(EngineTestCase.createSource([ |
| 5785 "main(Object p) {", | 6515 "main(Object p) {", |
| 5786 " if (p is String) {", | 6516 " if (p is String) {", |
| 5787 " p.length;", | 6517 " p.length;", |
| 5788 " }", | 6518 " }", |
| 5789 " () {p = 0;};", | 6519 " () {p = 0;};", |
| 5790 "}"])); | 6520 "}"])); |
| 5791 resolve(source); | 6521 resolve(source); |
| 5792 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6522 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5793 } | 6523 } |
| 6524 |
| 5794 void test_typePromotion_if_hasAssignment_inClosure_anonymous_before() { | 6525 void test_typePromotion_if_hasAssignment_inClosure_anonymous_before() { |
| 5795 Source source = addSource(EngineTestCase.createSource([ | 6526 Source source = addSource(EngineTestCase.createSource([ |
| 5796 "main(Object p) {", | 6527 "main(Object p) {", |
| 5797 " () {p = 0;};", | 6528 " () {p = 0;};", |
| 5798 " if (p is String) {", | 6529 " if (p is String) {", |
| 5799 " p.length;", | 6530 " p.length;", |
| 5800 " }", | 6531 " }", |
| 5801 "}"])); | 6532 "}"])); |
| 5802 resolve(source); | 6533 resolve(source); |
| 5803 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6534 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5804 } | 6535 } |
| 6536 |
| 5805 void test_typePromotion_if_hasAssignment_inClosure_function_after() { | 6537 void test_typePromotion_if_hasAssignment_inClosure_function_after() { |
| 5806 Source source = addSource(EngineTestCase.createSource([ | 6538 Source source = addSource(EngineTestCase.createSource([ |
| 5807 "main(Object p) {", | 6539 "main(Object p) {", |
| 5808 " if (p is String) {", | 6540 " if (p is String) {", |
| 5809 " p.length;", | 6541 " p.length;", |
| 5810 " }", | 6542 " }", |
| 5811 " f() {p = 0;};", | 6543 " f() {p = 0;};", |
| 5812 "}"])); | 6544 "}"])); |
| 5813 resolve(source); | 6545 resolve(source); |
| 5814 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6546 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5815 } | 6547 } |
| 6548 |
| 5816 void test_typePromotion_if_hasAssignment_inClosure_function_before() { | 6549 void test_typePromotion_if_hasAssignment_inClosure_function_before() { |
| 5817 Source source = addSource(EngineTestCase.createSource([ | 6550 Source source = addSource(EngineTestCase.createSource([ |
| 5818 "main(Object p) {", | 6551 "main(Object p) {", |
| 5819 " f() {p = 0;};", | 6552 " f() {p = 0;};", |
| 5820 " if (p is String) {", | 6553 " if (p is String) {", |
| 5821 " p.length;", | 6554 " p.length;", |
| 5822 " }", | 6555 " }", |
| 5823 "}"])); | 6556 "}"])); |
| 5824 resolve(source); | 6557 resolve(source); |
| 5825 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6558 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5826 } | 6559 } |
| 6560 |
| 5827 void test_typePromotion_if_implements_notMoreSpecific_dynamic() { | 6561 void test_typePromotion_if_implements_notMoreSpecific_dynamic() { |
| 5828 Source source = addSource(EngineTestCase.createSource([ | 6562 Source source = addSource(EngineTestCase.createSource([ |
| 5829 "class V {}", | 6563 "class V {}", |
| 5830 "class A<T> {}", | 6564 "class A<T> {}", |
| 5831 "class B<S> implements A<S> {", | 6565 "class B<S> implements A<S> {", |
| 5832 " var b;", | 6566 " var b;", |
| 5833 "}", | 6567 "}", |
| 5834 "", | 6568 "", |
| 5835 "main(A<V> p) {", | 6569 "main(A<V> p) {", |
| 5836 " if (p is B) {", | 6570 " if (p is B) {", |
| 5837 " p.b;", | 6571 " p.b;", |
| 5838 " }", | 6572 " }", |
| 5839 "}"])); | 6573 "}"])); |
| 5840 resolve(source); | 6574 resolve(source); |
| 5841 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6575 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5842 } | 6576 } |
| 6577 |
| 5843 void test_typePromotion_if_with_notMoreSpecific_dynamic() { | 6578 void test_typePromotion_if_with_notMoreSpecific_dynamic() { |
| 5844 Source source = addSource(EngineTestCase.createSource([ | 6579 Source source = addSource(EngineTestCase.createSource([ |
| 5845 "class V {}", | 6580 "class V {}", |
| 5846 "class A<T> {}", | 6581 "class A<T> {}", |
| 5847 "class B<S> extends Object with A<S> {", | 6582 "class B<S> extends Object with A<S> {", |
| 5848 " var b;", | 6583 " var b;", |
| 5849 "}", | 6584 "}", |
| 5850 "", | 6585 "", |
| 5851 "main(A<V> p) {", | 6586 "main(A<V> p) {", |
| 5852 " if (p is B) {", | 6587 " if (p is B) {", |
| 5853 " p.b;", | 6588 " p.b;", |
| 5854 " }", | 6589 " }", |
| 5855 "}"])); | 6590 "}"])); |
| 5856 resolve(source); | 6591 resolve(source); |
| 5857 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6592 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5858 } | 6593 } |
| 6594 |
| 5859 void test_undefinedGetter() { | 6595 void test_undefinedGetter() { |
| 5860 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e)
{ return e.m; }"])); | 6596 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e)
{ return e.m; }"])); |
| 5861 resolve(source); | 6597 resolve(source); |
| 5862 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6598 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5863 } | 6599 } |
| 6600 |
| 5864 void test_undefinedGetter_static() { | 6601 void test_undefinedGetter_static() { |
| 5865 Source source = addSource(EngineTestCase.createSource(["class A {}", "var a
= A.B;"])); | 6602 Source source = addSource(EngineTestCase.createSource(["class A {}", "var a
= A.B;"])); |
| 5866 resolve(source); | 6603 resolve(source); |
| 5867 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); | 6604 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 5868 } | 6605 } |
| 6606 |
| 5869 void test_undefinedMethod() { | 6607 void test_undefinedMethod() { |
| 5870 Source source = addSource(EngineTestCase.createSource(["class A {", " void
m() {", " n();", " }", "}"])); | 6608 Source source = addSource(EngineTestCase.createSource(["class A {", " void
m() {", " n();", " }", "}"])); |
| 5871 resolve(source); | 6609 resolve(source); |
| 5872 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); | 6610 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); |
| 5873 } | 6611 } |
| 6612 |
| 5874 void test_undefinedMethod_assignmentExpression() { | 6613 void test_undefinedMethod_assignmentExpression() { |
| 5875 Source source = addSource(EngineTestCase.createSource([ | 6614 Source source = addSource(EngineTestCase.createSource([ |
| 5876 "class A {}", | 6615 "class A {}", |
| 5877 "class B {", | 6616 "class B {", |
| 5878 " f(A a) {", | 6617 " f(A a) {", |
| 5879 " A a2 = new A();", | 6618 " A a2 = new A();", |
| 5880 " a += a2;", | 6619 " a += a2;", |
| 5881 " }", | 6620 " }", |
| 5882 "}"])); | 6621 "}"])); |
| 5883 resolve(source); | 6622 resolve(source); |
| 5884 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); | 6623 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); |
| 5885 } | 6624 } |
| 6625 |
| 5886 void test_undefinedMethod_ignoreTypePropagation() { | 6626 void test_undefinedMethod_ignoreTypePropagation() { |
| 5887 Source source = addSource(EngineTestCase.createSource([ | 6627 Source source = addSource(EngineTestCase.createSource([ |
| 5888 "class A {}", | 6628 "class A {}", |
| 5889 "class B extends A {", | 6629 "class B extends A {", |
| 5890 " m() {}", | 6630 " m() {}", |
| 5891 "}", | 6631 "}", |
| 5892 "class C {", | 6632 "class C {", |
| 5893 " f() {", | 6633 " f() {", |
| 5894 " A a = new B();", | 6634 " A a = new B();", |
| 5895 " a.m();", | 6635 " a.m();", |
| 5896 " }", | 6636 " }", |
| 5897 "}"])); | 6637 "}"])); |
| 5898 resolve(source); | 6638 resolve(source); |
| 5899 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); | 6639 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); |
| 5900 } | 6640 } |
| 6641 |
| 5901 void test_undefinedMethod_private() { | 6642 void test_undefinedMethod_private() { |
| 5902 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {", " _foo() {}", "}"])); | 6643 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {", " _foo() {}", "}"])); |
| 5903 Source source = addSource(EngineTestCase.createSource([ | 6644 Source source = addSource(EngineTestCase.createSource([ |
| 5904 "import 'lib.dart';", | 6645 "import 'lib.dart';", |
| 5905 "class B extends A {", | 6646 "class B extends A {", |
| 5906 " test() {", | 6647 " test() {", |
| 5907 " _foo();", | 6648 " _foo();", |
| 5908 " }", | 6649 " }", |
| 5909 "}"])); | 6650 "}"])); |
| 5910 resolve(source); | 6651 resolve(source); |
| 5911 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); | 6652 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); |
| 5912 } | 6653 } |
| 6654 |
| 5913 void test_undefinedOperator_indexBoth() { | 6655 void test_undefinedOperator_indexBoth() { |
| 5914 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0]++;", "}"])); | 6656 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0]++;", "}"])); |
| 5915 resolve(source); | 6657 resolve(source); |
| 5916 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 6658 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 5917 } | 6659 } |
| 6660 |
| 5918 void test_undefinedOperator_indexGetter() { | 6661 void test_undefinedOperator_indexGetter() { |
| 5919 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0];", "}"])); | 6662 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0];", "}"])); |
| 5920 resolve(source); | 6663 resolve(source); |
| 5921 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 6664 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 5922 } | 6665 } |
| 6666 |
| 5923 void test_undefinedOperator_indexSetter() { | 6667 void test_undefinedOperator_indexSetter() { |
| 5924 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0] = 1;", "}"])); | 6668 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0] = 1;", "}"])); |
| 5925 resolve(source); | 6669 resolve(source); |
| 5926 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 6670 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 5927 } | 6671 } |
| 6672 |
| 5928 void test_undefinedOperator_plus() { | 6673 void test_undefinedOperator_plus() { |
| 5929 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a + 1;", "}"])); | 6674 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a + 1;", "}"])); |
| 5930 resolve(source); | 6675 resolve(source); |
| 5931 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 6676 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 5932 } | 6677 } |
| 6678 |
| 5933 void test_undefinedOperator_postfixExpression() { | 6679 void test_undefinedOperator_postfixExpression() { |
| 5934 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a++;", "}"])); | 6680 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a++;", "}"])); |
| 5935 resolve(source); | 6681 resolve(source); |
| 5936 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 6682 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 5937 } | 6683 } |
| 6684 |
| 5938 void test_undefinedOperator_prefixExpression() { | 6685 void test_undefinedOperator_prefixExpression() { |
| 5939 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " ++a;", "}"])); | 6686 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " ++a;", "}"])); |
| 5940 resolve(source); | 6687 resolve(source); |
| 5941 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 6688 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 5942 } | 6689 } |
| 6690 |
| 5943 void test_undefinedSetter() { | 6691 void test_undefinedSetter() { |
| 5944 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e1
) { e1.m = 0; }"])); | 6692 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e1
) { e1.m = 0; }"])); |
| 5945 resolve(source); | 6693 resolve(source); |
| 5946 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]); | 6694 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]); |
| 5947 } | 6695 } |
| 6696 |
| 5948 void test_undefinedSetter_static() { | 6697 void test_undefinedSetter_static() { |
| 5949 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() {
A.B = 0;}"])); | 6698 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() {
A.B = 0;}"])); |
| 5950 resolve(source); | 6699 resolve(source); |
| 5951 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]); | 6700 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]); |
| 5952 } | 6701 } |
| 6702 |
| 5953 void test_undefinedSuperMethod() { | 6703 void test_undefinedSuperMethod() { |
| 5954 Source source = addSource(EngineTestCase.createSource([ | 6704 Source source = addSource(EngineTestCase.createSource([ |
| 5955 "class A {}", | 6705 "class A {}", |
| 5956 "class B extends A {", | 6706 "class B extends A {", |
| 5957 " m() { return super.m(); }", | 6707 " m() { return super.m(); }", |
| 5958 "}"])); | 6708 "}"])); |
| 5959 resolve(source); | 6709 resolve(source); |
| 5960 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]); | 6710 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]); |
| 5961 } | 6711 } |
| 6712 |
| 5962 void test_unqualifiedReferenceToNonLocalStaticMember_getter() { | 6713 void test_unqualifiedReferenceToNonLocalStaticMember_getter() { |
| 5963 Source source = addSource(EngineTestCase.createSource([ | 6714 Source source = addSource(EngineTestCase.createSource([ |
| 5964 "class A {", | 6715 "class A {", |
| 5965 " static int get a => 0;", | 6716 " static int get a => 0;", |
| 5966 "}", | 6717 "}", |
| 5967 "class B extends A {", | 6718 "class B extends A {", |
| 5968 " int b() {", | 6719 " int b() {", |
| 5969 " return a;", | 6720 " return a;", |
| 5970 " }", | 6721 " }", |
| 5971 "}"])); | 6722 "}"])); |
| 5972 resolve(source); | 6723 resolve(source); |
| 5973 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC
AL_STATIC_MEMBER]); | 6724 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC
AL_STATIC_MEMBER]); |
| 5974 verify([source]); | 6725 verify([source]); |
| 5975 } | 6726 } |
| 6727 |
| 5976 void test_unqualifiedReferenceToNonLocalStaticMember_method() { | 6728 void test_unqualifiedReferenceToNonLocalStaticMember_method() { |
| 5977 Source source = addSource(EngineTestCase.createSource([ | 6729 Source source = addSource(EngineTestCase.createSource([ |
| 5978 "class A {", | 6730 "class A {", |
| 5979 " static void a() {}", | 6731 " static void a() {}", |
| 5980 "}", | 6732 "}", |
| 5981 "class B extends A {", | 6733 "class B extends A {", |
| 5982 " void b() {", | 6734 " void b() {", |
| 5983 " a();", | 6735 " a();", |
| 5984 " }", | 6736 " }", |
| 5985 "}"])); | 6737 "}"])); |
| 5986 resolve(source); | 6738 resolve(source); |
| 5987 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC
AL_STATIC_MEMBER]); | 6739 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC
AL_STATIC_MEMBER]); |
| 5988 verify([source]); | 6740 verify([source]); |
| 5989 } | 6741 } |
| 6742 |
| 5990 void test_unqualifiedReferenceToNonLocalStaticMember_setter() { | 6743 void test_unqualifiedReferenceToNonLocalStaticMember_setter() { |
| 5991 Source source = addSource(EngineTestCase.createSource([ | 6744 Source source = addSource(EngineTestCase.createSource([ |
| 5992 "class A {", | 6745 "class A {", |
| 5993 " static set a(x) {}", | 6746 " static set a(x) {}", |
| 5994 "}", | 6747 "}", |
| 5995 "class B extends A {", | 6748 "class B extends A {", |
| 5996 " b(y) {", | 6749 " b(y) {", |
| 5997 " a = y;", | 6750 " a = y;", |
| 5998 " }", | 6751 " }", |
| 5999 "}"])); | 6752 "}"])); |
| 6000 resolve(source); | 6753 resolve(source); |
| 6001 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC
AL_STATIC_MEMBER]); | 6754 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC
AL_STATIC_MEMBER]); |
| 6002 verify([source]); | 6755 verify([source]); |
| 6003 } | 6756 } |
| 6757 |
| 6004 void test_wrongNumberOfTypeArguments_tooFew() { | 6758 void test_wrongNumberOfTypeArguments_tooFew() { |
| 6005 Source source = addSource(EngineTestCase.createSource(["class A<E, F> {}", "
A<A> a = null;"])); | 6759 Source source = addSource(EngineTestCase.createSource(["class A<E, F> {}", "
A<A> a = null;"])); |
| 6006 resolve(source); | 6760 resolve(source); |
| 6007 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; | 6761 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; |
| 6008 verify([source]); | 6762 verify([source]); |
| 6009 } | 6763 } |
| 6764 |
| 6010 void test_wrongNumberOfTypeArguments_tooMany() { | 6765 void test_wrongNumberOfTypeArguments_tooMany() { |
| 6011 Source source = addSource(EngineTestCase.createSource(["class A<E> {}", "A<A
, A> a = null;"])); | 6766 Source source = addSource(EngineTestCase.createSource(["class A<E> {}", "A<A
, A> a = null;"])); |
| 6012 resolve(source); | 6767 resolve(source); |
| 6013 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; | 6768 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; |
| 6014 verify([source]); | 6769 verify([source]); |
| 6015 } | 6770 } |
| 6771 |
| 6016 void test_wrongNumberOfTypeArguments_typeTest_tooFew() { | 6772 void test_wrongNumberOfTypeArguments_typeTest_tooFew() { |
| 6017 Source source = addSource(EngineTestCase.createSource([ | 6773 Source source = addSource(EngineTestCase.createSource([ |
| 6018 "class A {}", | 6774 "class A {}", |
| 6019 "class C<K, V> {}", | 6775 "class C<K, V> {}", |
| 6020 "f(p) {", | 6776 "f(p) {", |
| 6021 " return p is C<A>;", | 6777 " return p is C<A>;", |
| 6022 "}"])); | 6778 "}"])); |
| 6023 resolve(source); | 6779 resolve(source); |
| 6024 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; | 6780 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; |
| 6025 verify([source]); | 6781 verify([source]); |
| 6026 } | 6782 } |
| 6783 |
| 6027 void test_wrongNumberOfTypeArguments_typeTest_tooMany() { | 6784 void test_wrongNumberOfTypeArguments_typeTest_tooMany() { |
| 6028 Source source = addSource(EngineTestCase.createSource([ | 6785 Source source = addSource(EngineTestCase.createSource([ |
| 6029 "class A {}", | 6786 "class A {}", |
| 6030 "class C<E> {}", | 6787 "class C<E> {}", |
| 6031 "f(p) {", | 6788 "f(p) {", |
| 6032 " return p is C<A, A>;", | 6789 " return p is C<A, A>;", |
| 6033 "}"])); | 6790 "}"])); |
| 6034 resolve(source); | 6791 resolve(source); |
| 6035 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; | 6792 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; |
| 6036 verify([source]); | 6793 verify([source]); |
| 6037 } | 6794 } |
| 6795 |
| 6038 static dartSuite() { | 6796 static dartSuite() { |
| 6039 _ut.group('StaticTypeWarningCodeTest', () { | 6797 _ut.group('StaticTypeWarningCodeTest', () { |
| 6040 _ut.test('test_expectedOneListTypeArgument', () { | 6798 _ut.test('test_expectedOneListTypeArgument', () { |
| 6041 final __test = new StaticTypeWarningCodeTest(); | 6799 final __test = new StaticTypeWarningCodeTest(); |
| 6042 runJUnitTest(__test, __test.test_expectedOneListTypeArgument); | 6800 runJUnitTest(__test, __test.test_expectedOneListTypeArgument); |
| 6043 }); | 6801 }); |
| 6044 _ut.test('test_expectedTwoMapTypeArguments_one', () { | 6802 _ut.test('test_expectedTwoMapTypeArguments_one', () { |
| 6045 final __test = new StaticTypeWarningCodeTest(); | 6803 final __test = new StaticTypeWarningCodeTest(); |
| 6046 runJUnitTest(__test, __test.test_expectedTwoMapTypeArguments_one); | 6804 runJUnitTest(__test, __test.test_expectedTwoMapTypeArguments_one); |
| 6047 }); | 6805 }); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6441 final __test = new StaticTypeWarningCodeTest(); | 7199 final __test = new StaticTypeWarningCodeTest(); |
| 6442 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too
Few); | 7200 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too
Few); |
| 6443 }); | 7201 }); |
| 6444 _ut.test('test_wrongNumberOfTypeArguments_typeTest_tooMany', () { | 7202 _ut.test('test_wrongNumberOfTypeArguments_typeTest_tooMany', () { |
| 6445 final __test = new StaticTypeWarningCodeTest(); | 7203 final __test = new StaticTypeWarningCodeTest(); |
| 6446 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too
Many); | 7204 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too
Many); |
| 6447 }); | 7205 }); |
| 6448 }); | 7206 }); |
| 6449 } | 7207 } |
| 6450 } | 7208 } |
| 7209 |
| 6451 class HintCodeTest extends ResolverTestCase { | 7210 class HintCodeTest extends ResolverTestCase { |
| 6452 void fail_isInt() { | 7211 void fail_isInt() { |
| 6453 Source source = addSource(EngineTestCase.createSource(["var v = 1 is int;"])
); | 7212 Source source = addSource(EngineTestCase.createSource(["var v = 1 is int;"])
); |
| 6454 resolve(source); | 7213 resolve(source); |
| 6455 assertErrors(source, [HintCode.IS_INT]); | 7214 assertErrors(source, [HintCode.IS_INT]); |
| 6456 verify([source]); | 7215 verify([source]); |
| 6457 } | 7216 } |
| 7217 |
| 6458 void fail_isNotInt() { | 7218 void fail_isNotInt() { |
| 6459 Source source = addSource(EngineTestCase.createSource(["var v = 1 is! int;"]
)); | 7219 Source source = addSource(EngineTestCase.createSource(["var v = 1 is! int;"]
)); |
| 6460 resolve(source); | 7220 resolve(source); |
| 6461 assertErrors(source, [HintCode.IS_NOT_INT]); | 7221 assertErrors(source, [HintCode.IS_NOT_INT]); |
| 6462 verify([source]); | 7222 verify([source]); |
| 6463 } | 7223 } |
| 7224 |
| 6464 void fail_overrideEqualsButNotHashCode() { | 7225 void fail_overrideEqualsButNotHashCode() { |
| 6465 Source source = addSource(EngineTestCase.createSource(["class A {", " bool
operator ==(x) {}", "}"])); | 7226 Source source = addSource(EngineTestCase.createSource(["class A {", " bool
operator ==(x) {}", "}"])); |
| 6466 resolve(source); | 7227 resolve(source); |
| 6467 assertErrors(source, [HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE]); | 7228 assertErrors(source, [HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE]); |
| 6468 verify([source]); | 7229 verify([source]); |
| 6469 } | 7230 } |
| 7231 |
| 6470 void test_deadCode_deadBlock_conditionalElse() { | 7232 void test_deadCode_deadBlock_conditionalElse() { |
| 6471 Source source = addSource(EngineTestCase.createSource(["f() {", " true ? 1
: 2;", "}"])); | 7233 Source source = addSource(EngineTestCase.createSource(["f() {", " true ? 1
: 2;", "}"])); |
| 6472 resolve(source); | 7234 resolve(source); |
| 6473 assertErrors(source, [HintCode.DEAD_CODE]); | 7235 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6474 verify([source]); | 7236 verify([source]); |
| 6475 } | 7237 } |
| 7238 |
| 6476 void test_deadCode_deadBlock_conditionalElse_nested() { | 7239 void test_deadCode_deadBlock_conditionalElse_nested() { |
| 6477 Source source = addSource(EngineTestCase.createSource(["f() {", " true ? tr
ue : false && false;", "}"])); | 7240 Source source = addSource(EngineTestCase.createSource(["f() {", " true ? tr
ue : false && false;", "}"])); |
| 6478 resolve(source); | 7241 resolve(source); |
| 6479 assertErrors(source, [HintCode.DEAD_CODE]); | 7242 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6480 verify([source]); | 7243 verify([source]); |
| 6481 } | 7244 } |
| 7245 |
| 6482 void test_deadCode_deadBlock_conditionalIf() { | 7246 void test_deadCode_deadBlock_conditionalIf() { |
| 6483 Source source = addSource(EngineTestCase.createSource(["f() {", " false ? 1
: 2;", "}"])); | 7247 Source source = addSource(EngineTestCase.createSource(["f() {", " false ? 1
: 2;", "}"])); |
| 6484 resolve(source); | 7248 resolve(source); |
| 6485 assertErrors(source, [HintCode.DEAD_CODE]); | 7249 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6486 verify([source]); | 7250 verify([source]); |
| 6487 } | 7251 } |
| 7252 |
| 6488 void test_deadCode_deadBlock_conditionalIf_nested() { | 7253 void test_deadCode_deadBlock_conditionalIf_nested() { |
| 6489 Source source = addSource(EngineTestCase.createSource(["f() {", " false ? f
alse && false : true;", "}"])); | 7254 Source source = addSource(EngineTestCase.createSource(["f() {", " false ? f
alse && false : true;", "}"])); |
| 6490 resolve(source); | 7255 resolve(source); |
| 6491 assertErrors(source, [HintCode.DEAD_CODE]); | 7256 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6492 verify([source]); | 7257 verify([source]); |
| 6493 } | 7258 } |
| 7259 |
| 6494 void test_deadCode_deadBlock_else() { | 7260 void test_deadCode_deadBlock_else() { |
| 6495 Source source = addSource(EngineTestCase.createSource(["f() {", " if(true)
{} else {}", "}"])); | 7261 Source source = addSource(EngineTestCase.createSource(["f() {", " if(true)
{} else {}", "}"])); |
| 6496 resolve(source); | 7262 resolve(source); |
| 6497 assertErrors(source, [HintCode.DEAD_CODE]); | 7263 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6498 verify([source]); | 7264 verify([source]); |
| 6499 } | 7265 } |
| 7266 |
| 6500 void test_deadCode_deadBlock_else_nested() { | 7267 void test_deadCode_deadBlock_else_nested() { |
| 6501 Source source = addSource(EngineTestCase.createSource(["f() {", " if(true)
{} else {if (false) {}}", "}"])); | 7268 Source source = addSource(EngineTestCase.createSource(["f() {", " if(true)
{} else {if (false) {}}", "}"])); |
| 6502 resolve(source); | 7269 resolve(source); |
| 6503 assertErrors(source, [HintCode.DEAD_CODE]); | 7270 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6504 verify([source]); | 7271 verify([source]); |
| 6505 } | 7272 } |
| 7273 |
| 6506 void test_deadCode_deadBlock_if() { | 7274 void test_deadCode_deadBlock_if() { |
| 6507 Source source = addSource(EngineTestCase.createSource(["f() {", " if(false)
{}", "}"])); | 7275 Source source = addSource(EngineTestCase.createSource(["f() {", " if(false)
{}", "}"])); |
| 6508 resolve(source); | 7276 resolve(source); |
| 6509 assertErrors(source, [HintCode.DEAD_CODE]); | 7277 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6510 verify([source]); | 7278 verify([source]); |
| 6511 } | 7279 } |
| 7280 |
| 6512 void test_deadCode_deadBlock_if_nested() { | 7281 void test_deadCode_deadBlock_if_nested() { |
| 6513 Source source = addSource(EngineTestCase.createSource(["f() {", " if(false)
{if(false) {}}", "}"])); | 7282 Source source = addSource(EngineTestCase.createSource(["f() {", " if(false)
{if(false) {}}", "}"])); |
| 6514 resolve(source); | 7283 resolve(source); |
| 6515 assertErrors(source, [HintCode.DEAD_CODE]); | 7284 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6516 verify([source]); | 7285 verify([source]); |
| 6517 } | 7286 } |
| 7287 |
| 6518 void test_deadCode_deadBlock_while() { | 7288 void test_deadCode_deadBlock_while() { |
| 6519 Source source = addSource(EngineTestCase.createSource(["f() {", " while(fal
se) {}", "}"])); | 7289 Source source = addSource(EngineTestCase.createSource(["f() {", " while(fal
se) {}", "}"])); |
| 6520 resolve(source); | 7290 resolve(source); |
| 6521 assertErrors(source, [HintCode.DEAD_CODE]); | 7291 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6522 verify([source]); | 7292 verify([source]); |
| 6523 } | 7293 } |
| 7294 |
| 6524 void test_deadCode_deadBlock_while_nested() { | 7295 void test_deadCode_deadBlock_while_nested() { |
| 6525 Source source = addSource(EngineTestCase.createSource(["f() {", " while(fal
se) {if(false) {}}", "}"])); | 7296 Source source = addSource(EngineTestCase.createSource(["f() {", " while(fal
se) {if(false) {}}", "}"])); |
| 6526 resolve(source); | 7297 resolve(source); |
| 6527 assertErrors(source, [HintCode.DEAD_CODE]); | 7298 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6528 verify([source]); | 7299 verify([source]); |
| 6529 } | 7300 } |
| 7301 |
| 6530 void test_deadCode_deadCatch_catchFollowingCatch() { | 7302 void test_deadCode_deadCatch_catchFollowingCatch() { |
| 6531 Source source = addSource(EngineTestCase.createSource([ | 7303 Source source = addSource(EngineTestCase.createSource([ |
| 6532 "class A {}", | 7304 "class A {}", |
| 6533 "f() {", | 7305 "f() {", |
| 6534 " try {} catch (e) {} catch (e) {}", | 7306 " try {} catch (e) {} catch (e) {}", |
| 6535 "}"])); | 7307 "}"])); |
| 6536 resolve(source); | 7308 resolve(source); |
| 6537 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); | 7309 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); |
| 6538 verify([source]); | 7310 verify([source]); |
| 6539 } | 7311 } |
| 7312 |
| 6540 void test_deadCode_deadCatch_catchFollowingCatch_nested() { | 7313 void test_deadCode_deadCatch_catchFollowingCatch_nested() { |
| 6541 Source source = addSource(EngineTestCase.createSource([ | 7314 Source source = addSource(EngineTestCase.createSource([ |
| 6542 "class A {}", | 7315 "class A {}", |
| 6543 "f() {", | 7316 "f() {", |
| 6544 " try {} catch (e) {} catch (e) {if(false) {}}", | 7317 " try {} catch (e) {} catch (e) {if(false) {}}", |
| 6545 "}"])); | 7318 "}"])); |
| 6546 resolve(source); | 7319 resolve(source); |
| 6547 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); | 7320 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); |
| 6548 verify([source]); | 7321 verify([source]); |
| 6549 } | 7322 } |
| 7323 |
| 6550 void test_deadCode_deadCatch_catchFollowingCatch_object() { | 7324 void test_deadCode_deadCatch_catchFollowingCatch_object() { |
| 6551 Source source = addSource(EngineTestCase.createSource([ | 7325 Source source = addSource(EngineTestCase.createSource([ |
| 6552 "f() {", | 7326 "f() {", |
| 6553 " try {} on Object catch (e) {} catch (e) {}", | 7327 " try {} on Object catch (e) {} catch (e) {}", |
| 6554 "}"])); | 7328 "}"])); |
| 6555 resolve(source); | 7329 resolve(source); |
| 6556 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); | 7330 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); |
| 6557 verify([source]); | 7331 verify([source]); |
| 6558 } | 7332 } |
| 7333 |
| 6559 void test_deadCode_deadCatch_catchFollowingCatch_object_nested() { | 7334 void test_deadCode_deadCatch_catchFollowingCatch_object_nested() { |
| 6560 Source source = addSource(EngineTestCase.createSource([ | 7335 Source source = addSource(EngineTestCase.createSource([ |
| 6561 "f() {", | 7336 "f() {", |
| 6562 " try {} on Object catch (e) {} catch (e) {if(false) {}}", | 7337 " try {} on Object catch (e) {} catch (e) {if(false) {}}", |
| 6563 "}"])); | 7338 "}"])); |
| 6564 resolve(source); | 7339 resolve(source); |
| 6565 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); | 7340 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); |
| 6566 verify([source]); | 7341 verify([source]); |
| 6567 } | 7342 } |
| 7343 |
| 6568 void test_deadCode_deadCatch_onCatchSubtype() { | 7344 void test_deadCode_deadCatch_onCatchSubtype() { |
| 6569 Source source = addSource(EngineTestCase.createSource([ | 7345 Source source = addSource(EngineTestCase.createSource([ |
| 6570 "class A {}", | 7346 "class A {}", |
| 6571 "class B extends A {}", | 7347 "class B extends A {}", |
| 6572 "f() {", | 7348 "f() {", |
| 6573 " try {} on A catch (e) {} on B catch (e) {}", | 7349 " try {} on A catch (e) {} on B catch (e) {}", |
| 6574 "}"])); | 7350 "}"])); |
| 6575 resolve(source); | 7351 resolve(source); |
| 6576 assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]); | 7352 assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]); |
| 6577 verify([source]); | 7353 verify([source]); |
| 6578 } | 7354 } |
| 7355 |
| 6579 void test_deadCode_deadCatch_onCatchSubtype_nested() { | 7356 void test_deadCode_deadCatch_onCatchSubtype_nested() { |
| 6580 Source source = addSource(EngineTestCase.createSource([ | 7357 Source source = addSource(EngineTestCase.createSource([ |
| 6581 "class A {}", | 7358 "class A {}", |
| 6582 "class B extends A {}", | 7359 "class B extends A {}", |
| 6583 "f() {", | 7360 "f() {", |
| 6584 " try {} on A catch (e) {} on B catch (e) {if(false) {}}", | 7361 " try {} on A catch (e) {} on B catch (e) {if(false) {}}", |
| 6585 "}"])); | 7362 "}"])); |
| 6586 resolve(source); | 7363 resolve(source); |
| 6587 assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]); | 7364 assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]); |
| 6588 verify([source]); | 7365 verify([source]); |
| 6589 } | 7366 } |
| 7367 |
| 6590 void test_deadCode_deadOperandLHS_and() { | 7368 void test_deadCode_deadOperandLHS_and() { |
| 6591 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
false && false;", "}"])); | 7369 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
false && false;", "}"])); |
| 6592 resolve(source); | 7370 resolve(source); |
| 6593 assertErrors(source, [HintCode.DEAD_CODE]); | 7371 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6594 verify([source]); | 7372 verify([source]); |
| 6595 } | 7373 } |
| 7374 |
| 6596 void test_deadCode_deadOperandLHS_and_nested() { | 7375 void test_deadCode_deadOperandLHS_and_nested() { |
| 6597 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
false && (false && false);", "}"])); | 7376 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
false && (false && false);", "}"])); |
| 6598 resolve(source); | 7377 resolve(source); |
| 6599 assertErrors(source, [HintCode.DEAD_CODE]); | 7378 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6600 verify([source]); | 7379 verify([source]); |
| 6601 } | 7380 } |
| 7381 |
| 6602 void test_deadCode_deadOperandLHS_or() { | 7382 void test_deadCode_deadOperandLHS_or() { |
| 6603 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
true || true;", "}"])); | 7383 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
true || true;", "}"])); |
| 6604 resolve(source); | 7384 resolve(source); |
| 6605 assertErrors(source, [HintCode.DEAD_CODE]); | 7385 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6606 verify([source]); | 7386 verify([source]); |
| 6607 } | 7387 } |
| 7388 |
| 6608 void test_deadCode_deadOperandLHS_or_nested() { | 7389 void test_deadCode_deadOperandLHS_or_nested() { |
| 6609 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
true || (false && false);", "}"])); | 7390 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
true || (false && false);", "}"])); |
| 6610 resolve(source); | 7391 resolve(source); |
| 6611 assertErrors(source, [HintCode.DEAD_CODE]); | 7392 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6612 verify([source]); | 7393 verify([source]); |
| 6613 } | 7394 } |
| 7395 |
| 6614 void test_deadCode_statementAfterReturn_function() { | 7396 void test_deadCode_statementAfterReturn_function() { |
| 6615 Source source = addSource(EngineTestCase.createSource([ | 7397 Source source = addSource(EngineTestCase.createSource([ |
| 6616 "f() {", | 7398 "f() {", |
| 6617 " var one = 1;", | 7399 " var one = 1;", |
| 6618 " return;", | 7400 " return;", |
| 6619 " var two = 2;", | 7401 " var two = 2;", |
| 6620 "}"])); | 7402 "}"])); |
| 6621 resolve(source); | 7403 resolve(source); |
| 6622 assertErrors(source, [HintCode.DEAD_CODE]); | 7404 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6623 verify([source]); | 7405 verify([source]); |
| 6624 } | 7406 } |
| 7407 |
| 6625 void test_deadCode_statementAfterReturn_ifStatement() { | 7408 void test_deadCode_statementAfterReturn_ifStatement() { |
| 6626 Source source = addSource(EngineTestCase.createSource([ | 7409 Source source = addSource(EngineTestCase.createSource([ |
| 6627 "f(bool b) {", | 7410 "f(bool b) {", |
| 6628 " if(b) {", | 7411 " if(b) {", |
| 6629 " var one = 1;", | 7412 " var one = 1;", |
| 6630 " return;", | 7413 " return;", |
| 6631 " var two = 2;", | 7414 " var two = 2;", |
| 6632 " }", | 7415 " }", |
| 6633 "}"])); | 7416 "}"])); |
| 6634 resolve(source); | 7417 resolve(source); |
| 6635 assertErrors(source, [HintCode.DEAD_CODE]); | 7418 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6636 verify([source]); | 7419 verify([source]); |
| 6637 } | 7420 } |
| 7421 |
| 6638 void test_deadCode_statementAfterReturn_method() { | 7422 void test_deadCode_statementAfterReturn_method() { |
| 6639 Source source = addSource(EngineTestCase.createSource([ | 7423 Source source = addSource(EngineTestCase.createSource([ |
| 6640 "class A {", | 7424 "class A {", |
| 6641 " m() {", | 7425 " m() {", |
| 6642 " var one = 1;", | 7426 " var one = 1;", |
| 6643 " return;", | 7427 " return;", |
| 6644 " var two = 2;", | 7428 " var two = 2;", |
| 6645 " }", | 7429 " }", |
| 6646 "}"])); | 7430 "}"])); |
| 6647 resolve(source); | 7431 resolve(source); |
| 6648 assertErrors(source, [HintCode.DEAD_CODE]); | 7432 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6649 verify([source]); | 7433 verify([source]); |
| 6650 } | 7434 } |
| 7435 |
| 6651 void test_deadCode_statementAfterReturn_nested() { | 7436 void test_deadCode_statementAfterReturn_nested() { |
| 6652 Source source = addSource(EngineTestCase.createSource([ | 7437 Source source = addSource(EngineTestCase.createSource([ |
| 6653 "f() {", | 7438 "f() {", |
| 6654 " var one = 1;", | 7439 " var one = 1;", |
| 6655 " return;", | 7440 " return;", |
| 6656 " if(false) {}", | 7441 " if(false) {}", |
| 6657 "}"])); | 7442 "}"])); |
| 6658 resolve(source); | 7443 resolve(source); |
| 6659 assertErrors(source, [HintCode.DEAD_CODE]); | 7444 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6660 verify([source]); | 7445 verify([source]); |
| 6661 } | 7446 } |
| 7447 |
| 6662 void test_deadCode_statementAfterReturn_twoReturns() { | 7448 void test_deadCode_statementAfterReturn_twoReturns() { |
| 6663 Source source = addSource(EngineTestCase.createSource([ | 7449 Source source = addSource(EngineTestCase.createSource([ |
| 6664 "f() {", | 7450 "f() {", |
| 6665 " var one = 1;", | 7451 " var one = 1;", |
| 6666 " return;", | 7452 " return;", |
| 6667 " var two = 2;", | 7453 " var two = 2;", |
| 6668 " return;", | 7454 " return;", |
| 6669 " var three = 3;", | 7455 " var three = 3;", |
| 6670 "}"])); | 7456 "}"])); |
| 6671 resolve(source); | 7457 resolve(source); |
| 6672 assertErrors(source, [HintCode.DEAD_CODE]); | 7458 assertErrors(source, [HintCode.DEAD_CODE]); |
| 6673 verify([source]); | 7459 verify([source]); |
| 6674 } | 7460 } |
| 7461 |
| 7462 void test_deprecatedAnnotationUse_assignment() { |
| 7463 Source source = addSource(EngineTestCase.createSource([ |
| 7464 "class A {", |
| 7465 " @deprecated", |
| 7466 " A operator+(A a) {}", |
| 7467 "}", |
| 7468 "f(A a) {", |
| 7469 " A b;", |
| 7470 " a += b;", |
| 7471 "}"])); |
| 7472 resolve(source); |
| 7473 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7474 verify([source]); |
| 7475 } |
| 7476 |
| 7477 void test_deprecatedAnnotationUse_deprecated() { |
| 7478 Source source = addSource(EngineTestCase.createSource([ |
| 7479 "class A {", |
| 7480 " @deprecated", |
| 7481 " m() {}", |
| 7482 " n() {m();}", |
| 7483 "}"])); |
| 7484 resolve(source); |
| 7485 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7486 verify([source]); |
| 7487 } |
| 7488 |
| 7489 void test_deprecatedAnnotationUse_Deprecated() { |
| 7490 Source source = addSource(EngineTestCase.createSource([ |
| 7491 "class A {", |
| 7492 " @Deprecated('0.9')", |
| 7493 " m() {}", |
| 7494 " n() {m();}", |
| 7495 "}"])); |
| 7496 resolve(source); |
| 7497 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7498 verify([source]); |
| 7499 } |
| 7500 |
| 7501 void test_deprecatedAnnotationUse_export() { |
| 7502 Source source = addSource(EngineTestCase.createSource(["export 'deprecated_l
ibrary.dart';"])); |
| 7503 addSource2("/deprecated_library.dart", EngineTestCase.createSource([ |
| 7504 "@deprecated", |
| 7505 "library deprecated_library;", |
| 7506 "class A {}"])); |
| 7507 resolve(source); |
| 7508 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7509 verify([source]); |
| 7510 } |
| 7511 |
| 7512 void test_deprecatedAnnotationUse_getter() { |
| 7513 Source source = addSource(EngineTestCase.createSource([ |
| 7514 "class A {", |
| 7515 " @deprecated", |
| 7516 " get m => 1;", |
| 7517 "}", |
| 7518 "f(A a) {", |
| 7519 " return a.m;", |
| 7520 "}"])); |
| 7521 resolve(source); |
| 7522 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7523 verify([source]); |
| 7524 } |
| 7525 |
| 7526 void test_deprecatedAnnotationUse_import() { |
| 7527 Source source = addSource(EngineTestCase.createSource(["import 'deprecated_l
ibrary.dart';", "f(A a) {}"])); |
| 7528 addSource2("/deprecated_library.dart", EngineTestCase.createSource([ |
| 7529 "@deprecated", |
| 7530 "library deprecated_library;", |
| 7531 "class A {}"])); |
| 7532 resolve(source); |
| 7533 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7534 verify([source]); |
| 7535 } |
| 7536 |
| 7537 void test_deprecatedAnnotationUse_indexExpression() { |
| 7538 Source source = addSource(EngineTestCase.createSource([ |
| 7539 "class A {", |
| 7540 " @deprecated", |
| 7541 " operator[](int i) {}", |
| 7542 "}", |
| 7543 "f(A a) {", |
| 7544 " return a[1];", |
| 7545 "}"])); |
| 7546 resolve(source); |
| 7547 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7548 verify([source]); |
| 7549 } |
| 7550 |
| 7551 void test_deprecatedAnnotationUse_instanceCreation() { |
| 7552 Source source = addSource(EngineTestCase.createSource([ |
| 7553 "class A {", |
| 7554 " @deprecated", |
| 7555 " A(int i) {}", |
| 7556 "}", |
| 7557 "f() {", |
| 7558 " A a = new A(1);", |
| 7559 "}"])); |
| 7560 resolve(source); |
| 7561 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7562 verify([source]); |
| 7563 } |
| 7564 |
| 7565 void test_deprecatedAnnotationUse_instanceCreation_namedConstructor() { |
| 7566 Source source = addSource(EngineTestCase.createSource([ |
| 7567 "class A {", |
| 7568 " @deprecated", |
| 7569 " A.named(int i) {}", |
| 7570 "}", |
| 7571 "f() {", |
| 7572 " A a = new A.named(1);", |
| 7573 "}"])); |
| 7574 resolve(source); |
| 7575 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7576 verify([source]); |
| 7577 } |
| 7578 |
| 7579 void test_deprecatedAnnotationUse_operator() { |
| 7580 Source source = addSource(EngineTestCase.createSource([ |
| 7581 "class A {", |
| 7582 " @deprecated", |
| 7583 " operator+(A a) {}", |
| 7584 "}", |
| 7585 "f(A a) {", |
| 7586 " A b;", |
| 7587 " return a + b;", |
| 7588 "}"])); |
| 7589 resolve(source); |
| 7590 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7591 verify([source]); |
| 7592 } |
| 7593 |
| 7594 void test_deprecatedAnnotationUse_setter() { |
| 7595 Source source = addSource(EngineTestCase.createSource([ |
| 7596 "class A {", |
| 7597 " @deprecated", |
| 7598 " set s(v) {}", |
| 7599 "}", |
| 7600 "f(A a) {", |
| 7601 " return a.s = 1;", |
| 7602 "}"])); |
| 7603 resolve(source); |
| 7604 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7605 verify([source]); |
| 7606 } |
| 7607 |
| 7608 void test_deprecatedAnnotationUse_superConstructor() { |
| 7609 Source source = addSource(EngineTestCase.createSource([ |
| 7610 "class A {", |
| 7611 " @deprecated", |
| 7612 " A() {}", |
| 7613 "}", |
| 7614 "class B extends A {", |
| 7615 " B() : super() {}", |
| 7616 "}"])); |
| 7617 resolve(source); |
| 7618 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7619 verify([source]); |
| 7620 } |
| 7621 |
| 7622 void test_deprecatedAnnotationUse_superConstructor_namedConstructor() { |
| 7623 Source source = addSource(EngineTestCase.createSource([ |
| 7624 "class A {", |
| 7625 " @deprecated", |
| 7626 " A.named() {}", |
| 7627 "}", |
| 7628 "class B extends A {", |
| 7629 " B() : super.named() {}", |
| 7630 "}"])); |
| 7631 resolve(source); |
| 7632 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 7633 verify([source]); |
| 7634 } |
| 7635 |
| 6675 void test_divisionOptimization_double() { | 7636 void test_divisionOptimization_double() { |
| 6676 Source source = addSource(EngineTestCase.createSource([ | 7637 Source source = addSource(EngineTestCase.createSource([ |
| 6677 "f(double x, double y) {", | 7638 "f(double x, double y) {", |
| 6678 " var v = (x / y).toInt();", | 7639 " var v = (x / y).toInt();", |
| 6679 "}"])); | 7640 "}"])); |
| 6680 resolve(source); | 7641 resolve(source); |
| 6681 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); | 7642 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); |
| 6682 verify([source]); | 7643 verify([source]); |
| 6683 } | 7644 } |
| 7645 |
| 6684 void test_divisionOptimization_int() { | 7646 void test_divisionOptimization_int() { |
| 6685 Source source = addSource(EngineTestCase.createSource(["f(int x, int y) {",
" var v = (x / y).toInt();", "}"])); | 7647 Source source = addSource(EngineTestCase.createSource(["f(int x, int y) {",
" var v = (x / y).toInt();", "}"])); |
| 6686 resolve(source); | 7648 resolve(source); |
| 6687 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); | 7649 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); |
| 6688 verify([source]); | 7650 verify([source]); |
| 6689 } | 7651 } |
| 7652 |
| 6690 void test_divisionOptimization_propagatedType() { | 7653 void test_divisionOptimization_propagatedType() { |
| 6691 Source source = addSource(EngineTestCase.createSource([ | 7654 Source source = addSource(EngineTestCase.createSource([ |
| 6692 "f(x, y) {", | 7655 "f(x, y) {", |
| 6693 " x = 1;", | 7656 " x = 1;", |
| 6694 " y = 1;", | 7657 " y = 1;", |
| 6695 " var v = (x / y).toInt();", | 7658 " var v = (x / y).toInt();", |
| 6696 "}"])); | 7659 "}"])); |
| 6697 resolve(source); | 7660 resolve(source); |
| 6698 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); | 7661 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); |
| 6699 verify([source]); | 7662 verify([source]); |
| 6700 } | 7663 } |
| 7664 |
| 6701 void test_divisionOptimization_wrappedBinaryExpression() { | 7665 void test_divisionOptimization_wrappedBinaryExpression() { |
| 6702 Source source = addSource(EngineTestCase.createSource([ | 7666 Source source = addSource(EngineTestCase.createSource([ |
| 6703 "f(int x, int y) {", | 7667 "f(int x, int y) {", |
| 6704 " var v = (((x / y))).toInt();", | 7668 " var v = (((x / y))).toInt();", |
| 6705 "}"])); | 7669 "}"])); |
| 6706 resolve(source); | 7670 resolve(source); |
| 6707 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); | 7671 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); |
| 6708 verify([source]); | 7672 verify([source]); |
| 6709 } | 7673 } |
| 7674 |
| 6710 void test_duplicateImport() { | 7675 void test_duplicateImport() { |
| 6711 Source source = addSource(EngineTestCase.createSource([ | 7676 Source source = addSource(EngineTestCase.createSource([ |
| 6712 "library L;", | 7677 "library L;", |
| 6713 "import 'lib1.dart';", | 7678 "import 'lib1.dart';", |
| 6714 "import 'lib1.dart';", | 7679 "import 'lib1.dart';", |
| 6715 "A a;"])); | 7680 "A a;"])); |
| 6716 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); | 7681 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); |
| 6717 resolve(source); | 7682 resolve(source); |
| 6718 assertErrors(source, [HintCode.DUPLICATE_IMPORT]); | 7683 assertErrors(source, [HintCode.DUPLICATE_IMPORT]); |
| 6719 verify([source]); | 7684 verify([source]); |
| 6720 } | 7685 } |
| 7686 |
| 6721 void test_duplicateImport2() { | 7687 void test_duplicateImport2() { |
| 6722 Source source = addSource(EngineTestCase.createSource([ | 7688 Source source = addSource(EngineTestCase.createSource([ |
| 6723 "library L;", | 7689 "library L;", |
| 6724 "import 'lib1.dart';", | 7690 "import 'lib1.dart';", |
| 6725 "import 'lib1.dart';", | 7691 "import 'lib1.dart';", |
| 6726 "import 'lib1.dart';", | 7692 "import 'lib1.dart';", |
| 6727 "A a;"])); | 7693 "A a;"])); |
| 6728 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); | 7694 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); |
| 6729 resolve(source); | 7695 resolve(source); |
| 6730 assertErrors(source, [HintCode.DUPLICATE_IMPORT, HintCode.DUPLICATE_IMPORT])
; | 7696 assertErrors(source, [HintCode.DUPLICATE_IMPORT, HintCode.DUPLICATE_IMPORT])
; |
| 6731 verify([source]); | 7697 verify([source]); |
| 6732 } | 7698 } |
| 7699 |
| 6733 void test_duplicateImport3() { | 7700 void test_duplicateImport3() { |
| 6734 Source source = addSource(EngineTestCase.createSource([ | 7701 Source source = addSource(EngineTestCase.createSource([ |
| 6735 "library L;", | 7702 "library L;", |
| 6736 "import 'lib1.dart' as M show A hide B;", | 7703 "import 'lib1.dart' as M show A hide B;", |
| 6737 "import 'lib1.dart' as M show A hide B;", | 7704 "import 'lib1.dart' as M show A hide B;", |
| 6738 "M.A a;"])); | 7705 "M.A a;"])); |
| 6739 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}", "class B {}"])); | 7706 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}", "class B {}"])); |
| 6740 resolve(source); | 7707 resolve(source); |
| 6741 assertErrors(source, [HintCode.DUPLICATE_IMPORT, HintCode.UNUSED_IMPORT]); | 7708 assertErrors(source, [HintCode.DUPLICATE_IMPORT, HintCode.UNUSED_IMPORT]); |
| 6742 verify([source]); | 7709 verify([source]); |
| 6743 } | 7710 } |
| 7711 |
| 6744 void test_isDouble() { | 7712 void test_isDouble() { |
| 6745 Source source = addSource(EngineTestCase.createSource(["var v = 1 is double;
"])); | 7713 Source source = addSource(EngineTestCase.createSource(["var v = 1 is double;
"])); |
| 6746 resolve(source); | 7714 resolve(source); |
| 6747 assertErrors(source, [HintCode.IS_DOUBLE]); | 7715 assertErrors(source, [HintCode.IS_DOUBLE]); |
| 6748 verify([source]); | 7716 verify([source]); |
| 6749 } | 7717 } |
| 7718 |
| 6750 void test_isNotDouble() { | 7719 void test_isNotDouble() { |
| 6751 Source source = addSource(EngineTestCase.createSource(["var v = 1 is! double
;"])); | 7720 Source source = addSource(EngineTestCase.createSource(["var v = 1 is! double
;"])); |
| 6752 resolve(source); | 7721 resolve(source); |
| 6753 assertErrors(source, [HintCode.IS_NOT_DOUBLE]); | 7722 assertErrors(source, [HintCode.IS_NOT_DOUBLE]); |
| 6754 verify([source]); | 7723 verify([source]); |
| 6755 } | 7724 } |
| 7725 |
| 6756 void test_overriddingPrivateMember_getter() { | 7726 void test_overriddingPrivateMember_getter() { |
| 6757 Source source = addSource(EngineTestCase.createSource([ | 7727 Source source = addSource(EngineTestCase.createSource([ |
| 6758 "import 'lib1.dart';", | 7728 "import 'lib1.dart';", |
| 6759 "class B extends A {", | 7729 "class B extends A {", |
| 6760 " get _g => 0;", | 7730 " get _g => 0;", |
| 6761 "}"])); | 7731 "}"])); |
| 6762 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " get _g => 0;", "}"])); | 7732 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " get _g => 0;", "}"])); |
| 6763 resolve(source); | 7733 resolve(source); |
| 6764 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); | 7734 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); |
| 6765 verify([source, source2]); | 7735 verify([source, source2]); |
| 6766 } | 7736 } |
| 7737 |
| 6767 void test_overriddingPrivateMember_method() { | 7738 void test_overriddingPrivateMember_method() { |
| 6768 Source source = addSource(EngineTestCase.createSource([ | 7739 Source source = addSource(EngineTestCase.createSource([ |
| 6769 "import 'lib1.dart';", | 7740 "import 'lib1.dart';", |
| 6770 "class B extends A {", | 7741 "class B extends A {", |
| 6771 " _m(int x) => 0;", | 7742 " _m(int x) => 0;", |
| 6772 "}"])); | 7743 "}"])); |
| 6773 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " _m(int x) => 0;", "}"])); | 7744 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " _m(int x) => 0;", "}"])); |
| 6774 resolve(source); | 7745 resolve(source); |
| 6775 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); | 7746 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); |
| 6776 verify([source, source2]); | 7747 verify([source, source2]); |
| 6777 } | 7748 } |
| 7749 |
| 6778 void test_overriddingPrivateMember_method2() { | 7750 void test_overriddingPrivateMember_method2() { |
| 6779 Source source = addSource(EngineTestCase.createSource([ | 7751 Source source = addSource(EngineTestCase.createSource([ |
| 6780 "import 'lib1.dart';", | 7752 "import 'lib1.dart';", |
| 6781 "class B extends A {}", | 7753 "class B extends A {}", |
| 6782 "class C extends B {", | 7754 "class C extends B {", |
| 6783 " _m(int x) => 0;", | 7755 " _m(int x) => 0;", |
| 6784 "}"])); | 7756 "}"])); |
| 6785 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " _m(int x) => 0;", "}"])); | 7757 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " _m(int x) => 0;", "}"])); |
| 6786 resolve(source); | 7758 resolve(source); |
| 6787 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); | 7759 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); |
| 6788 verify([source, source2]); | 7760 verify([source, source2]); |
| 6789 } | 7761 } |
| 7762 |
| 6790 void test_overriddingPrivateMember_setter() { | 7763 void test_overriddingPrivateMember_setter() { |
| 6791 Source source = addSource(EngineTestCase.createSource([ | 7764 Source source = addSource(EngineTestCase.createSource([ |
| 6792 "import 'lib1.dart';", | 7765 "import 'lib1.dart';", |
| 6793 "class B extends A {", | 7766 "class B extends A {", |
| 6794 " set _s(int x) {}", | 7767 " set _s(int x) {}", |
| 6795 "}"])); | 7768 "}"])); |
| 6796 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " set _s(int x) {}", "}"])); | 7769 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " set _s(int x) {}", "}"])); |
| 6797 resolve(source); | 7770 resolve(source); |
| 6798 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); | 7771 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); |
| 6799 verify([source, source2]); | 7772 verify([source, source2]); |
| 6800 } | 7773 } |
| 7774 |
| 6801 void test_typeCheck_type_is_Null() { | 7775 void test_typeCheck_type_is_Null() { |
| 6802 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is Null;", "}"])); | 7776 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is Null;", "}"])); |
| 6803 resolve(source); | 7777 resolve(source); |
| 6804 assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]); | 7778 assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]); |
| 6805 verify([source]); | 7779 verify([source]); |
| 6806 } | 7780 } |
| 7781 |
| 6807 void test_typeCheck_type_not_Null() { | 7782 void test_typeCheck_type_not_Null() { |
| 6808 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is! Null;", "}"])); | 7783 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is! Null;", "}"])); |
| 6809 resolve(source); | 7784 resolve(source); |
| 6810 assertErrors(source, [HintCode.TYPE_CHECK_IS_NOT_NULL]); | 7785 assertErrors(source, [HintCode.TYPE_CHECK_IS_NOT_NULL]); |
| 6811 verify([source]); | 7786 verify([source]); |
| 6812 } | 7787 } |
| 7788 |
| 6813 void test_undefinedGetter() { | 7789 void test_undefinedGetter() { |
| 6814 Source source = addSource(EngineTestCase.createSource([ | 7790 Source source = addSource(EngineTestCase.createSource([ |
| 6815 "class A {}", | 7791 "class A {}", |
| 6816 "f(var a) {", | 7792 "f(var a) {", |
| 6817 " if(a is A) {", | 7793 " if(a is A) {", |
| 6818 " return a.m;", | 7794 " return a.m;", |
| 6819 " }", | 7795 " }", |
| 6820 "}"])); | 7796 "}"])); |
| 6821 resolve(source); | 7797 resolve(source); |
| 6822 assertErrors(source, [HintCode.UNDEFINED_GETTER]); | 7798 assertErrors(source, [HintCode.UNDEFINED_GETTER]); |
| 6823 } | 7799 } |
| 7800 |
| 6824 void test_undefinedGetter_message() { | 7801 void test_undefinedGetter_message() { |
| 6825 JUnitTestCase.assertEquals(StaticTypeWarningCode.UNDEFINED_GETTER.message, S
taticWarningCode.UNDEFINED_GETTER.message); | 7802 JUnitTestCase.assertEquals(StaticTypeWarningCode.UNDEFINED_GETTER.message, S
taticWarningCode.UNDEFINED_GETTER.message); |
| 6826 } | 7803 } |
| 7804 |
| 6827 void test_undefinedMethod() { | 7805 void test_undefinedMethod() { |
| 6828 Source source = addSource(EngineTestCase.createSource([ | 7806 Source source = addSource(EngineTestCase.createSource([ |
| 6829 "f() {", | 7807 "f() {", |
| 6830 " var a = 'str';", | 7808 " var a = 'str';", |
| 6831 " a.notAMethodOnString();", | 7809 " a.notAMethodOnString();", |
| 6832 "}"])); | 7810 "}"])); |
| 6833 resolve(source); | 7811 resolve(source); |
| 6834 assertErrors(source, [HintCode.UNDEFINED_METHOD]); | 7812 assertErrors(source, [HintCode.UNDEFINED_METHOD]); |
| 6835 } | 7813 } |
| 7814 |
| 6836 void test_undefinedMethod_assignmentExpression() { | 7815 void test_undefinedMethod_assignmentExpression() { |
| 6837 Source source = addSource(EngineTestCase.createSource([ | 7816 Source source = addSource(EngineTestCase.createSource([ |
| 6838 "class A {}", | 7817 "class A {}", |
| 6839 "class B {", | 7818 "class B {", |
| 6840 " f(var a, var a2) {", | 7819 " f(var a, var a2) {", |
| 6841 " a = new A();", | 7820 " a = new A();", |
| 6842 " a2 = new A();", | 7821 " a2 = new A();", |
| 6843 " a += a2;", | 7822 " a += a2;", |
| 6844 " }", | 7823 " }", |
| 6845 "}"])); | 7824 "}"])); |
| 6846 resolve(source); | 7825 resolve(source); |
| 6847 assertErrors(source, [HintCode.UNDEFINED_METHOD]); | 7826 assertErrors(source, [HintCode.UNDEFINED_METHOD]); |
| 6848 } | 7827 } |
| 7828 |
| 6849 void test_undefinedOperator_binaryExpression() { | 7829 void test_undefinedOperator_binaryExpression() { |
| 6850 Source source = addSource(EngineTestCase.createSource([ | 7830 Source source = addSource(EngineTestCase.createSource([ |
| 6851 "class A {}", | 7831 "class A {}", |
| 6852 "f(var a) {", | 7832 "f(var a) {", |
| 6853 " if(a is A) {", | 7833 " if(a is A) {", |
| 6854 " a + 1;", | 7834 " a + 1;", |
| 6855 " }", | 7835 " }", |
| 6856 "}"])); | 7836 "}"])); |
| 6857 resolve(source); | 7837 resolve(source); |
| 6858 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); | 7838 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); |
| 6859 } | 7839 } |
| 7840 |
| 6860 void test_undefinedOperator_indexBoth() { | 7841 void test_undefinedOperator_indexBoth() { |
| 6861 Source source = addSource(EngineTestCase.createSource([ | 7842 Source source = addSource(EngineTestCase.createSource([ |
| 6862 "class A {}", | 7843 "class A {}", |
| 6863 "f(var a) {", | 7844 "f(var a) {", |
| 6864 " if(a is A) {", | 7845 " if(a is A) {", |
| 6865 " a[0]++;", | 7846 " a[0]++;", |
| 6866 " }", | 7847 " }", |
| 6867 "}"])); | 7848 "}"])); |
| 6868 resolve(source); | 7849 resolve(source); |
| 6869 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); | 7850 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); |
| 6870 } | 7851 } |
| 7852 |
| 6871 void test_undefinedOperator_indexGetter() { | 7853 void test_undefinedOperator_indexGetter() { |
| 6872 Source source = addSource(EngineTestCase.createSource([ | 7854 Source source = addSource(EngineTestCase.createSource([ |
| 6873 "class A {}", | 7855 "class A {}", |
| 6874 "f(var a) {", | 7856 "f(var a) {", |
| 6875 " if(a is A) {", | 7857 " if(a is A) {", |
| 6876 " a[0];", | 7858 " a[0];", |
| 6877 " }", | 7859 " }", |
| 6878 "}"])); | 7860 "}"])); |
| 6879 resolve(source); | 7861 resolve(source); |
| 6880 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); | 7862 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); |
| 6881 } | 7863 } |
| 7864 |
| 6882 void test_undefinedOperator_indexSetter() { | 7865 void test_undefinedOperator_indexSetter() { |
| 6883 Source source = addSource(EngineTestCase.createSource([ | 7866 Source source = addSource(EngineTestCase.createSource([ |
| 6884 "class A {}", | 7867 "class A {}", |
| 6885 "f(var a) {", | 7868 "f(var a) {", |
| 6886 " if(a is A) {", | 7869 " if(a is A) {", |
| 6887 " a[0] = 1;", | 7870 " a[0] = 1;", |
| 6888 " }", | 7871 " }", |
| 6889 "}"])); | 7872 "}"])); |
| 6890 resolve(source); | 7873 resolve(source); |
| 6891 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); | 7874 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); |
| 6892 } | 7875 } |
| 7876 |
| 6893 void test_undefinedOperator_postfixExpression() { | 7877 void test_undefinedOperator_postfixExpression() { |
| 6894 Source source = addSource(EngineTestCase.createSource([ | 7878 Source source = addSource(EngineTestCase.createSource([ |
| 6895 "class A {}", | 7879 "class A {}", |
| 6896 "f(var a) {", | 7880 "f(var a) {", |
| 6897 " if(a is A) {", | 7881 " if(a is A) {", |
| 6898 " a++;", | 7882 " a++;", |
| 6899 " }", | 7883 " }", |
| 6900 "}"])); | 7884 "}"])); |
| 6901 resolve(source); | 7885 resolve(source); |
| 6902 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); | 7886 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); |
| 6903 } | 7887 } |
| 7888 |
| 6904 void test_undefinedOperator_prefixExpression() { | 7889 void test_undefinedOperator_prefixExpression() { |
| 6905 Source source = addSource(EngineTestCase.createSource([ | 7890 Source source = addSource(EngineTestCase.createSource([ |
| 6906 "class A {}", | 7891 "class A {}", |
| 6907 "f(var a) {", | 7892 "f(var a) {", |
| 6908 " if(a is A) {", | 7893 " if(a is A) {", |
| 6909 " ++a;", | 7894 " ++a;", |
| 6910 " }", | 7895 " }", |
| 6911 "}"])); | 7896 "}"])); |
| 6912 resolve(source); | 7897 resolve(source); |
| 6913 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); | 7898 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]); |
| 6914 } | 7899 } |
| 7900 |
| 6915 void test_undefinedSetter() { | 7901 void test_undefinedSetter() { |
| 6916 Source source = addSource(EngineTestCase.createSource([ | 7902 Source source = addSource(EngineTestCase.createSource([ |
| 6917 "class A {}", | 7903 "class A {}", |
| 6918 "f(var a) {", | 7904 "f(var a) {", |
| 6919 " if(a is A) {", | 7905 " if(a is A) {", |
| 6920 " a.m = 0;", | 7906 " a.m = 0;", |
| 6921 " }", | 7907 " }", |
| 6922 "}"])); | 7908 "}"])); |
| 6923 resolve(source); | 7909 resolve(source); |
| 6924 assertErrors(source, [HintCode.UNDEFINED_SETTER]); | 7910 assertErrors(source, [HintCode.UNDEFINED_SETTER]); |
| 6925 } | 7911 } |
| 7912 |
| 6926 void test_undefinedSetter_message() { | 7913 void test_undefinedSetter_message() { |
| 6927 JUnitTestCase.assertEquals(StaticTypeWarningCode.UNDEFINED_SETTER.message, S
taticWarningCode.UNDEFINED_SETTER.message); | 7914 JUnitTestCase.assertEquals(StaticTypeWarningCode.UNDEFINED_SETTER.message, S
taticWarningCode.UNDEFINED_SETTER.message); |
| 6928 } | 7915 } |
| 7916 |
| 6929 void test_unnecessaryCast_type_supertype() { | 7917 void test_unnecessaryCast_type_supertype() { |
| 6930 Source source = addSource(EngineTestCase.createSource(["m(int i) {", " var
b = i as Object;", "}"])); | 7918 Source source = addSource(EngineTestCase.createSource(["m(int i) {", " var
b = i as Object;", "}"])); |
| 6931 resolve(source); | 7919 resolve(source); |
| 6932 assertErrors(source, [HintCode.UNNECESSARY_CAST]); | 7920 assertErrors(source, [HintCode.UNNECESSARY_CAST]); |
| 6933 verify([source]); | 7921 verify([source]); |
| 6934 } | 7922 } |
| 7923 |
| 6935 void test_unnecessaryCast_type_type() { | 7924 void test_unnecessaryCast_type_type() { |
| 6936 Source source = addSource(EngineTestCase.createSource(["m(num i) {", " var
b = i as num;", "}"])); | 7925 Source source = addSource(EngineTestCase.createSource(["m(num i) {", " var
b = i as num;", "}"])); |
| 6937 resolve(source); | 7926 resolve(source); |
| 6938 assertErrors(source, [HintCode.UNNECESSARY_CAST]); | 7927 assertErrors(source, [HintCode.UNNECESSARY_CAST]); |
| 6939 verify([source]); | 7928 verify([source]); |
| 6940 } | 7929 } |
| 7930 |
| 6941 void test_unnecessaryTypeCheck_null_is_Null() { | 7931 void test_unnecessaryTypeCheck_null_is_Null() { |
| 6942 Source source = addSource(EngineTestCase.createSource(["bool b = null is Nul
l;"])); | 7932 Source source = addSource(EngineTestCase.createSource(["bool b = null is Nul
l;"])); |
| 6943 resolve(source); | 7933 resolve(source); |
| 6944 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]); | 7934 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]); |
| 6945 verify([source]); | 7935 verify([source]); |
| 6946 } | 7936 } |
| 7937 |
| 6947 void test_unnecessaryTypeCheck_null_not_Null() { | 7938 void test_unnecessaryTypeCheck_null_not_Null() { |
| 6948 Source source = addSource(EngineTestCase.createSource(["bool b = null is! Nu
ll;"])); | 7939 Source source = addSource(EngineTestCase.createSource(["bool b = null is! Nu
ll;"])); |
| 6949 resolve(source); | 7940 resolve(source); |
| 6950 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]); | 7941 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]); |
| 6951 verify([source]); | 7942 verify([source]); |
| 6952 } | 7943 } |
| 7944 |
| 6953 void test_unnecessaryTypeCheck_type_is_dynamic() { | 7945 void test_unnecessaryTypeCheck_type_is_dynamic() { |
| 6954 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is dynamic;", "}"])); | 7946 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is dynamic;", "}"])); |
| 6955 resolve(source); | 7947 resolve(source); |
| 6956 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]); | 7948 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]); |
| 6957 verify([source]); | 7949 verify([source]); |
| 6958 } | 7950 } |
| 7951 |
| 6959 void test_unnecessaryTypeCheck_type_is_object() { | 7952 void test_unnecessaryTypeCheck_type_is_object() { |
| 6960 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is Object;", "}"])); | 7953 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is Object;", "}"])); |
| 6961 resolve(source); | 7954 resolve(source); |
| 6962 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]); | 7955 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]); |
| 6963 verify([source]); | 7956 verify([source]); |
| 6964 } | 7957 } |
| 7958 |
| 6965 void test_unnecessaryTypeCheck_type_not_dynamic() { | 7959 void test_unnecessaryTypeCheck_type_not_dynamic() { |
| 6966 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is! dynamic;", "}"])); | 7960 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is! dynamic;", "}"])); |
| 6967 resolve(source); | 7961 resolve(source); |
| 6968 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]); | 7962 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]); |
| 6969 verify([source]); | 7963 verify([source]); |
| 6970 } | 7964 } |
| 7965 |
| 6971 void test_unnecessaryTypeCheck_type_not_object() { | 7966 void test_unnecessaryTypeCheck_type_not_object() { |
| 6972 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is! Object;", "}"])); | 7967 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is! Object;", "}"])); |
| 6973 resolve(source); | 7968 resolve(source); |
| 6974 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]); | 7969 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]); |
| 6975 verify([source]); | 7970 verify([source]); |
| 6976 } | 7971 } |
| 7972 |
| 6977 void test_unusedImport() { | 7973 void test_unusedImport() { |
| 6978 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';"])); | 7974 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';"])); |
| 6979 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;"])); | 7975 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;"])); |
| 6980 resolve(source); | 7976 resolve(source); |
| 6981 assertErrors(source, [HintCode.UNUSED_IMPORT]); | 7977 assertErrors(source, [HintCode.UNUSED_IMPORT]); |
| 6982 assertNoErrors(source2); | 7978 assertNoErrors(source2); |
| 6983 verify([source, source2]); | 7979 verify([source, source2]); |
| 6984 } | 7980 } |
| 7981 |
| 6985 void test_unusedImport_as() { | 7982 void test_unusedImport_as() { |
| 6986 Source source = addSource(EngineTestCase.createSource([ | 7983 Source source = addSource(EngineTestCase.createSource([ |
| 6987 "library L;", | 7984 "library L;", |
| 6988 "import 'lib1.dart';", | 7985 "import 'lib1.dart';", |
| 6989 "import 'lib1.dart' as one;", | 7986 "import 'lib1.dart' as one;", |
| 6990 "one.A a;"])); | 7987 "one.A a;"])); |
| 6991 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {}"])); | 7988 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {}"])); |
| 6992 resolve(source); | 7989 resolve(source); |
| 6993 assertErrors(source, [HintCode.UNUSED_IMPORT]); | 7990 assertErrors(source, [HintCode.UNUSED_IMPORT]); |
| 6994 assertNoErrors(source2); | 7991 assertNoErrors(source2); |
| 6995 verify([source, source2]); | 7992 verify([source, source2]); |
| 6996 } | 7993 } |
| 7994 |
| 6997 void test_unusedImport_hide() { | 7995 void test_unusedImport_hide() { |
| 6998 Source source = addSource(EngineTestCase.createSource([ | 7996 Source source = addSource(EngineTestCase.createSource([ |
| 6999 "library L;", | 7997 "library L;", |
| 7000 "import 'lib1.dart';", | 7998 "import 'lib1.dart';", |
| 7001 "import 'lib1.dart' hide A;", | 7999 "import 'lib1.dart' hide A;", |
| 7002 "A a;"])); | 8000 "A a;"])); |
| 7003 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {}"])); | 8001 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {}"])); |
| 7004 resolve(source); | 8002 resolve(source); |
| 7005 assertErrors(source, [HintCode.UNUSED_IMPORT]); | 8003 assertErrors(source, [HintCode.UNUSED_IMPORT]); |
| 7006 assertNoErrors(source2); | 8004 assertNoErrors(source2); |
| 7007 verify([source, source2]); | 8005 verify([source, source2]); |
| 7008 } | 8006 } |
| 8007 |
| 7009 void test_unusedImport_show() { | 8008 void test_unusedImport_show() { |
| 7010 Source source = addSource(EngineTestCase.createSource([ | 8009 Source source = addSource(EngineTestCase.createSource([ |
| 7011 "library L;", | 8010 "library L;", |
| 7012 "import 'lib1.dart' show A;", | 8011 "import 'lib1.dart' show A;", |
| 7013 "import 'lib1.dart' show B;", | 8012 "import 'lib1.dart' show B;", |
| 7014 "A a;"])); | 8013 "A a;"])); |
| 7015 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {}", "class B {}"])); | 8014 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {}", "class B {}"])); |
| 7016 resolve(source); | 8015 resolve(source); |
| 7017 assertErrors(source, [HintCode.UNUSED_IMPORT]); | 8016 assertErrors(source, [HintCode.UNUSED_IMPORT]); |
| 7018 assertNoErrors(source2); | 8017 assertNoErrors(source2); |
| 7019 verify([source, source2]); | 8018 verify([source, source2]); |
| 7020 } | 8019 } |
| 8020 |
| 7021 static dartSuite() { | 8021 static dartSuite() { |
| 7022 _ut.group('HintCodeTest', () { | 8022 _ut.group('HintCodeTest', () { |
| 7023 _ut.test('test_deadCode_deadBlock_conditionalElse', () { | 8023 _ut.test('test_deadCode_deadBlock_conditionalElse', () { |
| 7024 final __test = new HintCodeTest(); | 8024 final __test = new HintCodeTest(); |
| 7025 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse); | 8025 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse); |
| 7026 }); | 8026 }); |
| 7027 _ut.test('test_deadCode_deadBlock_conditionalElse_nested', () { | 8027 _ut.test('test_deadCode_deadBlock_conditionalElse_nested', () { |
| 7028 final __test = new HintCodeTest(); | 8028 final __test = new HintCodeTest(); |
| 7029 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse_nest
ed); | 8029 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse_nest
ed); |
| 7030 }); | 8030 }); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7113 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_method); | 8113 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_method); |
| 7114 }); | 8114 }); |
| 7115 _ut.test('test_deadCode_statementAfterReturn_nested', () { | 8115 _ut.test('test_deadCode_statementAfterReturn_nested', () { |
| 7116 final __test = new HintCodeTest(); | 8116 final __test = new HintCodeTest(); |
| 7117 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_nested); | 8117 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_nested); |
| 7118 }); | 8118 }); |
| 7119 _ut.test('test_deadCode_statementAfterReturn_twoReturns', () { | 8119 _ut.test('test_deadCode_statementAfterReturn_twoReturns', () { |
| 7120 final __test = new HintCodeTest(); | 8120 final __test = new HintCodeTest(); |
| 7121 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_twoReturn
s); | 8121 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_twoReturn
s); |
| 7122 }); | 8122 }); |
| 8123 _ut.test('test_deprecatedAnnotationUse_Deprecated', () { |
| 8124 final __test = new HintCodeTest(); |
| 8125 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_Deprecated); |
| 8126 }); |
| 8127 _ut.test('test_deprecatedAnnotationUse_assignment', () { |
| 8128 final __test = new HintCodeTest(); |
| 8129 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_assignment); |
| 8130 }); |
| 8131 _ut.test('test_deprecatedAnnotationUse_deprecated', () { |
| 8132 final __test = new HintCodeTest(); |
| 8133 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_deprecated); |
| 8134 }); |
| 8135 _ut.test('test_deprecatedAnnotationUse_export', () { |
| 8136 final __test = new HintCodeTest(); |
| 8137 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_export); |
| 8138 }); |
| 8139 _ut.test('test_deprecatedAnnotationUse_getter', () { |
| 8140 final __test = new HintCodeTest(); |
| 8141 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_getter); |
| 8142 }); |
| 8143 _ut.test('test_deprecatedAnnotationUse_import', () { |
| 8144 final __test = new HintCodeTest(); |
| 8145 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_import); |
| 8146 }); |
| 8147 _ut.test('test_deprecatedAnnotationUse_indexExpression', () { |
| 8148 final __test = new HintCodeTest(); |
| 8149 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_indexExpression
); |
| 8150 }); |
| 8151 _ut.test('test_deprecatedAnnotationUse_instanceCreation', () { |
| 8152 final __test = new HintCodeTest(); |
| 8153 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_instanceCreatio
n); |
| 8154 }); |
| 8155 _ut.test('test_deprecatedAnnotationUse_instanceCreation_namedConstructor',
() { |
| 8156 final __test = new HintCodeTest(); |
| 8157 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_instanceCreatio
n_namedConstructor); |
| 8158 }); |
| 8159 _ut.test('test_deprecatedAnnotationUse_operator', () { |
| 8160 final __test = new HintCodeTest(); |
| 8161 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_operator); |
| 8162 }); |
| 8163 _ut.test('test_deprecatedAnnotationUse_setter', () { |
| 8164 final __test = new HintCodeTest(); |
| 8165 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_setter); |
| 8166 }); |
| 8167 _ut.test('test_deprecatedAnnotationUse_superConstructor', () { |
| 8168 final __test = new HintCodeTest(); |
| 8169 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_superConstructo
r); |
| 8170 }); |
| 8171 _ut.test('test_deprecatedAnnotationUse_superConstructor_namedConstructor',
() { |
| 8172 final __test = new HintCodeTest(); |
| 8173 runJUnitTest(__test, __test.test_deprecatedAnnotationUse_superConstructo
r_namedConstructor); |
| 8174 }); |
| 7123 _ut.test('test_divisionOptimization_double', () { | 8175 _ut.test('test_divisionOptimization_double', () { |
| 7124 final __test = new HintCodeTest(); | 8176 final __test = new HintCodeTest(); |
| 7125 runJUnitTest(__test, __test.test_divisionOptimization_double); | 8177 runJUnitTest(__test, __test.test_divisionOptimization_double); |
| 7126 }); | 8178 }); |
| 7127 _ut.test('test_divisionOptimization_int', () { | 8179 _ut.test('test_divisionOptimization_int', () { |
| 7128 final __test = new HintCodeTest(); | 8180 final __test = new HintCodeTest(); |
| 7129 runJUnitTest(__test, __test.test_divisionOptimization_int); | 8181 runJUnitTest(__test, __test.test_divisionOptimization_int); |
| 7130 }); | 8182 }); |
| 7131 _ut.test('test_divisionOptimization_propagatedType', () { | 8183 _ut.test('test_divisionOptimization_propagatedType', () { |
| 7132 final __test = new HintCodeTest(); | 8184 final __test = new HintCodeTest(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7272 final __test = new HintCodeTest(); | 8324 final __test = new HintCodeTest(); |
| 7273 runJUnitTest(__test, __test.test_unusedImport_hide); | 8325 runJUnitTest(__test, __test.test_unusedImport_hide); |
| 7274 }); | 8326 }); |
| 7275 _ut.test('test_unusedImport_show', () { | 8327 _ut.test('test_unusedImport_show', () { |
| 7276 final __test = new HintCodeTest(); | 8328 final __test = new HintCodeTest(); |
| 7277 runJUnitTest(__test, __test.test_unusedImport_show); | 8329 runJUnitTest(__test, __test.test_unusedImport_show); |
| 7278 }); | 8330 }); |
| 7279 }); | 8331 }); |
| 7280 } | 8332 } |
| 7281 } | 8333 } |
| 8334 |
| 7282 class TypeResolverVisitorTest extends EngineTestCase { | 8335 class TypeResolverVisitorTest extends EngineTestCase { |
| 7283 | |
| 7284 /** | 8336 /** |
| 7285 * The error listener to which errors will be reported. | 8337 * The error listener to which errors will be reported. |
| 7286 */ | 8338 */ |
| 7287 GatheringErrorListener _listener; | 8339 GatheringErrorListener _listener; |
| 7288 | 8340 |
| 7289 /** | 8341 /** |
| 7290 * The object representing the information about the library in which the type
s are being | 8342 * The object representing the information about the library in which the type
s are being |
| 7291 * resolved. | 8343 * resolved. |
| 7292 */ | 8344 */ |
| 7293 Library _library; | 8345 Library _library; |
| 7294 | 8346 |
| 7295 /** | 8347 /** |
| 7296 * The type provider used to access the types. | 8348 * The type provider used to access the types. |
| 7297 */ | 8349 */ |
| 7298 TestTypeProvider _typeProvider; | 8350 TestTypeProvider _typeProvider; |
| 7299 | 8351 |
| 7300 /** | 8352 /** |
| 7301 * The visitor used to resolve types needed to form the type hierarchy. | 8353 * The visitor used to resolve types needed to form the type hierarchy. |
| 7302 */ | 8354 */ |
| 7303 TypeResolverVisitor _visitor; | 8355 TypeResolverVisitor _visitor; |
| 8356 |
| 7304 void fail_visitConstructorDeclaration() { | 8357 void fail_visitConstructorDeclaration() { |
| 7305 JUnitTestCase.fail("Not yet tested"); | 8358 JUnitTestCase.fail("Not yet tested"); |
| 7306 _listener.assertNoErrors(); | 8359 _listener.assertNoErrors(); |
| 7307 } | 8360 } |
| 8361 |
| 7308 void fail_visitFunctionDeclaration() { | 8362 void fail_visitFunctionDeclaration() { |
| 7309 JUnitTestCase.fail("Not yet tested"); | 8363 JUnitTestCase.fail("Not yet tested"); |
| 7310 _listener.assertNoErrors(); | 8364 _listener.assertNoErrors(); |
| 7311 } | 8365 } |
| 8366 |
| 7312 void fail_visitFunctionTypeAlias() { | 8367 void fail_visitFunctionTypeAlias() { |
| 7313 JUnitTestCase.fail("Not yet tested"); | 8368 JUnitTestCase.fail("Not yet tested"); |
| 7314 _listener.assertNoErrors(); | 8369 _listener.assertNoErrors(); |
| 7315 } | 8370 } |
| 8371 |
| 7316 void fail_visitFunctionTypedFormalParameter() { | 8372 void fail_visitFunctionTypedFormalParameter() { |
| 7317 JUnitTestCase.fail("Not yet tested"); | 8373 JUnitTestCase.fail("Not yet tested"); |
| 7318 _listener.assertNoErrors(); | 8374 _listener.assertNoErrors(); |
| 7319 } | 8375 } |
| 8376 |
| 7320 void fail_visitMethodDeclaration() { | 8377 void fail_visitMethodDeclaration() { |
| 7321 JUnitTestCase.fail("Not yet tested"); | 8378 JUnitTestCase.fail("Not yet tested"); |
| 7322 _listener.assertNoErrors(); | 8379 _listener.assertNoErrors(); |
| 7323 } | 8380 } |
| 8381 |
| 7324 void fail_visitVariableDeclaration() { | 8382 void fail_visitVariableDeclaration() { |
| 7325 JUnitTestCase.fail("Not yet tested"); | 8383 JUnitTestCase.fail("Not yet tested"); |
| 7326 ClassElement type = ElementFactory.classElement2("A", []); | 8384 ClassElement type = ElementFactory.classElement2("A", []); |
| 7327 VariableDeclaration node = ASTFactory.variableDeclaration("a"); | 8385 VariableDeclaration node = ASTFactory.variableDeclaration("a"); |
| 7328 ASTFactory.variableDeclarationList(null, ASTFactory.typeName(type, []), [nod
e]); | 8386 ASTFactory.variableDeclarationList(null, ASTFactory.typeName(type, []), [nod
e]); |
| 7329 JUnitTestCase.assertSame(type.type, node.name.staticType); | 8387 JUnitTestCase.assertSame(type.type, node.name.staticType); |
| 7330 _listener.assertNoErrors(); | 8388 _listener.assertNoErrors(); |
| 7331 } | 8389 } |
| 8390 |
| 7332 void setUp() { | 8391 void setUp() { |
| 7333 _listener = new GatheringErrorListener(); | 8392 _listener = new GatheringErrorListener(); |
| 7334 SourceFactory factory = new SourceFactory.con2([new FileUriResolver()]); | 8393 SourceFactory factory = new SourceFactory.con2([new FileUriResolver()]); |
| 7335 AnalysisContextImpl context = new AnalysisContextImpl(); | 8394 AnalysisContextImpl context = new AnalysisContextImpl(); |
| 7336 context.sourceFactory = factory; | 8395 context.sourceFactory = factory; |
| 7337 Source librarySource = new FileBasedSource.con1(factory.contentCache, FileUt
ilities2.createFile("/lib.dart")); | 8396 Source librarySource = new FileBasedSource.con1(factory.contentCache, FileUt
ilities2.createFile("/lib.dart")); |
| 7338 _library = new Library(context, _listener, librarySource); | 8397 _library = new Library(context, _listener, librarySource); |
| 7339 LibraryElementImpl element = new LibraryElementImpl(context, ASTFactory.libr
aryIdentifier2(["lib"])); | 8398 LibraryElementImpl element = new LibraryElementImpl(context, ASTFactory.libr
aryIdentifier2(["lib"])); |
| 7340 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart")
; | 8399 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart")
; |
| 7341 _library.libraryElement = element; | 8400 _library.libraryElement = element; |
| 7342 _typeProvider = new TestTypeProvider(); | 8401 _typeProvider = new TestTypeProvider(); |
| 7343 _visitor = new TypeResolverVisitor.con1(_library, librarySource, _typeProvid
er); | 8402 _visitor = new TypeResolverVisitor.con1(_library, librarySource, _typeProvid
er); |
| 7344 } | 8403 } |
| 8404 |
| 7345 void test_visitCatchClause_exception() { | 8405 void test_visitCatchClause_exception() { |
| 7346 CatchClause clause = ASTFactory.catchClause("e", []); | 8406 CatchClause clause = ASTFactory.catchClause("e", []); |
| 7347 SimpleIdentifier exceptionParameter = clause.exceptionParameter; | 8407 SimpleIdentifier exceptionParameter = clause.exceptionParameter; |
| 7348 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar
ameter); | 8408 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar
ameter); |
| 7349 resolve(clause, _typeProvider.dynamicType, null, []); | 8409 resolve(clause, _typeProvider.dynamicType, null, []); |
| 7350 _listener.assertNoErrors(); | 8410 _listener.assertNoErrors(); |
| 7351 } | 8411 } |
| 8412 |
| 7352 void test_visitCatchClause_exception_stackTrace() { | 8413 void test_visitCatchClause_exception_stackTrace() { |
| 7353 CatchClause clause = ASTFactory.catchClause2("e", "s", []); | 8414 CatchClause clause = ASTFactory.catchClause2("e", "s", []); |
| 7354 SimpleIdentifier exceptionParameter = clause.exceptionParameter; | 8415 SimpleIdentifier exceptionParameter = clause.exceptionParameter; |
| 7355 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar
ameter); | 8416 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar
ameter); |
| 7356 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter; | 8417 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter; |
| 7357 stackTraceParameter.staticElement = new LocalVariableElementImpl(stackTraceP
arameter); | 8418 stackTraceParameter.staticElement = new LocalVariableElementImpl(stackTraceP
arameter); |
| 7358 resolve(clause, _typeProvider.dynamicType, _typeProvider.stackTraceType, [])
; | 8419 resolve(clause, _typeProvider.dynamicType, _typeProvider.stackTraceType, [])
; |
| 7359 _listener.assertNoErrors(); | 8420 _listener.assertNoErrors(); |
| 7360 } | 8421 } |
| 8422 |
| 7361 void test_visitCatchClause_on_exception() { | 8423 void test_visitCatchClause_on_exception() { |
| 7362 ClassElement exceptionElement = ElementFactory.classElement2("E", []); | 8424 ClassElement exceptionElement = ElementFactory.classElement2("E", []); |
| 7363 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []); | 8425 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []); |
| 7364 CatchClause clause = ASTFactory.catchClause4(exceptionType, "e", []); | 8426 CatchClause clause = ASTFactory.catchClause4(exceptionType, "e", []); |
| 7365 SimpleIdentifier exceptionParameter = clause.exceptionParameter; | 8427 SimpleIdentifier exceptionParameter = clause.exceptionParameter; |
| 7366 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar
ameter); | 8428 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar
ameter); |
| 7367 resolve(clause, exceptionElement.type, null, [exceptionElement]); | 8429 resolve(clause, exceptionElement.type, null, [exceptionElement]); |
| 7368 _listener.assertNoErrors(); | 8430 _listener.assertNoErrors(); |
| 7369 } | 8431 } |
| 8432 |
| 7370 void test_visitCatchClause_on_exception_stackTrace() { | 8433 void test_visitCatchClause_on_exception_stackTrace() { |
| 7371 ClassElement exceptionElement = ElementFactory.classElement2("E", []); | 8434 ClassElement exceptionElement = ElementFactory.classElement2("E", []); |
| 7372 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []); | 8435 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []); |
| 7373 ((exceptionType.name as SimpleIdentifier)).staticElement = exceptionElement; | 8436 (exceptionType.name as SimpleIdentifier).staticElement = exceptionElement; |
| 7374 CatchClause clause = ASTFactory.catchClause5(exceptionType, "e", "s", []); | 8437 CatchClause clause = ASTFactory.catchClause5(exceptionType, "e", "s", []); |
| 7375 SimpleIdentifier exceptionParameter = clause.exceptionParameter; | 8438 SimpleIdentifier exceptionParameter = clause.exceptionParameter; |
| 7376 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar
ameter); | 8439 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar
ameter); |
| 7377 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter; | 8440 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter; |
| 7378 stackTraceParameter.staticElement = new LocalVariableElementImpl(stackTraceP
arameter); | 8441 stackTraceParameter.staticElement = new LocalVariableElementImpl(stackTraceP
arameter); |
| 7379 resolve(clause, exceptionElement.type, _typeProvider.stackTraceType, [except
ionElement]); | 8442 resolve(clause, exceptionElement.type, _typeProvider.stackTraceType, [except
ionElement]); |
| 7380 _listener.assertNoErrors(); | 8443 _listener.assertNoErrors(); |
| 7381 } | 8444 } |
| 8445 |
| 7382 void test_visitClassDeclaration() { | 8446 void test_visitClassDeclaration() { |
| 7383 ClassElement elementA = ElementFactory.classElement2("A", []); | 8447 ClassElement elementA = ElementFactory.classElement2("A", []); |
| 7384 ClassElement elementB = ElementFactory.classElement2("B", []); | 8448 ClassElement elementB = ElementFactory.classElement2("B", []); |
| 7385 ClassElement elementC = ElementFactory.classElement2("C", []); | 8449 ClassElement elementC = ElementFactory.classElement2("C", []); |
| 7386 ClassElement elementD = ElementFactory.classElement2("D", []); | 8450 ClassElement elementD = ElementFactory.classElement2("D", []); |
| 7387 ExtendsClause extendsClause = ASTFactory.extendsClause(ASTFactory.typeName(e
lementB, [])); | 8451 ExtendsClause extendsClause = ASTFactory.extendsClause(ASTFactory.typeName(e
lementB, [])); |
| 7388 WithClause withClause = ASTFactory.withClause([ASTFactory.typeName(elementC,
[])]); | 8452 WithClause withClause = ASTFactory.withClause([ASTFactory.typeName(elementC,
[])]); |
| 7389 ImplementsClause implementsClause = ASTFactory.implementsClause([ASTFactory.
typeName(elementD, [])]); | 8453 ImplementsClause implementsClause = ASTFactory.implementsClause([ASTFactory.
typeName(elementD, [])]); |
| 7390 ClassDeclaration declaration = ASTFactory.classDeclaration(null, "A", null,
extendsClause, withClause, implementsClause, []); | 8454 ClassDeclaration declaration = ASTFactory.classDeclaration(null, "A", null,
extendsClause, withClause, implementsClause, []); |
| 7391 declaration.name.staticElement = elementA; | 8455 declaration.name.staticElement = elementA; |
| 7392 resolveNode(declaration, [elementA, elementB, elementC, elementD]); | 8456 resolveNode(declaration, [elementA, elementB, elementC, elementD]); |
| 7393 JUnitTestCase.assertSame(elementB.type, elementA.supertype); | 8457 JUnitTestCase.assertSame(elementB.type, elementA.supertype); |
| 7394 List<InterfaceType> mixins = elementA.mixins; | 8458 List<InterfaceType> mixins = elementA.mixins; |
| 7395 EngineTestCase.assertLength(1, mixins); | 8459 EngineTestCase.assertLength(1, mixins); |
| 7396 JUnitTestCase.assertSame(elementC.type, mixins[0]); | 8460 JUnitTestCase.assertSame(elementC.type, mixins[0]); |
| 7397 List<InterfaceType> interfaces = elementA.interfaces; | 8461 List<InterfaceType> interfaces = elementA.interfaces; |
| 7398 EngineTestCase.assertLength(1, interfaces); | 8462 EngineTestCase.assertLength(1, interfaces); |
| 7399 JUnitTestCase.assertSame(elementD.type, interfaces[0]); | 8463 JUnitTestCase.assertSame(elementD.type, interfaces[0]); |
| 7400 _listener.assertNoErrors(); | 8464 _listener.assertNoErrors(); |
| 7401 } | 8465 } |
| 8466 |
| 7402 void test_visitClassTypeAlias() { | 8467 void test_visitClassTypeAlias() { |
| 7403 ClassElement elementA = ElementFactory.classElement2("A", []); | 8468 ClassElement elementA = ElementFactory.classElement2("A", []); |
| 7404 ClassElement elementB = ElementFactory.classElement2("B", []); | 8469 ClassElement elementB = ElementFactory.classElement2("B", []); |
| 7405 ClassElement elementC = ElementFactory.classElement2("C", []); | 8470 ClassElement elementC = ElementFactory.classElement2("C", []); |
| 7406 ClassElement elementD = ElementFactory.classElement2("D", []); | 8471 ClassElement elementD = ElementFactory.classElement2("D", []); |
| 7407 WithClause withClause = ASTFactory.withClause([ASTFactory.typeName(elementC,
[])]); | 8472 WithClause withClause = ASTFactory.withClause([ASTFactory.typeName(elementC,
[])]); |
| 7408 ImplementsClause implementsClause = ASTFactory.implementsClause([ASTFactory.
typeName(elementD, [])]); | 8473 ImplementsClause implementsClause = ASTFactory.implementsClause([ASTFactory.
typeName(elementD, [])]); |
| 7409 ClassTypeAlias alias = ASTFactory.classTypeAlias("A", null, null, ASTFactory
.typeName(elementB, []), withClause, implementsClause); | 8474 ClassTypeAlias alias = ASTFactory.classTypeAlias("A", null, null, ASTFactory
.typeName(elementB, []), withClause, implementsClause); |
| 7410 alias.name.staticElement = elementA; | 8475 alias.name.staticElement = elementA; |
| 7411 resolveNode(alias, [elementA, elementB, elementC, elementD]); | 8476 resolveNode(alias, [elementA, elementB, elementC, elementD]); |
| 7412 JUnitTestCase.assertSame(elementB.type, elementA.supertype); | 8477 JUnitTestCase.assertSame(elementB.type, elementA.supertype); |
| 7413 List<InterfaceType> mixins = elementA.mixins; | 8478 List<InterfaceType> mixins = elementA.mixins; |
| 7414 EngineTestCase.assertLength(1, mixins); | 8479 EngineTestCase.assertLength(1, mixins); |
| 7415 JUnitTestCase.assertSame(elementC.type, mixins[0]); | 8480 JUnitTestCase.assertSame(elementC.type, mixins[0]); |
| 7416 List<InterfaceType> interfaces = elementA.interfaces; | 8481 List<InterfaceType> interfaces = elementA.interfaces; |
| 7417 EngineTestCase.assertLength(1, interfaces); | 8482 EngineTestCase.assertLength(1, interfaces); |
| 7418 JUnitTestCase.assertSame(elementD.type, interfaces[0]); | 8483 JUnitTestCase.assertSame(elementD.type, interfaces[0]); |
| 7419 _listener.assertNoErrors(); | 8484 _listener.assertNoErrors(); |
| 7420 } | 8485 } |
| 8486 |
| 7421 void test_visitFieldFormalParameter_functionType() { | 8487 void test_visitFieldFormalParameter_functionType() { |
| 7422 InterfaceType intType = _typeProvider.intType; | 8488 InterfaceType intType = _typeProvider.intType; |
| 7423 TypeName intTypeName = ASTFactory.typeName4("int", []); | 8489 TypeName intTypeName = ASTFactory.typeName4("int", []); |
| 7424 String innerParameterName = "a"; | 8490 String innerParameterName = "a"; |
| 7425 SimpleFormalParameter parameter = ASTFactory.simpleFormalParameter3(innerPar
ameterName); | 8491 SimpleFormalParameter parameter = ASTFactory.simpleFormalParameter3(innerPar
ameterName); |
| 7426 parameter.identifier.staticElement = ElementFactory.requiredParameter(innerP
arameterName); | 8492 parameter.identifier.staticElement = ElementFactory.requiredParameter(innerP
arameterName); |
| 7427 String outerParameterName = "p"; | 8493 String outerParameterName = "p"; |
| 7428 FormalParameter node = ASTFactory.fieldFormalParameter2(null, intTypeName, o
uterParameterName, ASTFactory.formalParameterList([parameter])); | 8494 FormalParameter node = ASTFactory.fieldFormalParameter2(null, intTypeName, o
uterParameterName, ASTFactory.formalParameterList([parameter])); |
| 7429 node.identifier.staticElement = ElementFactory.requiredParameter(outerParame
terName); | 8495 node.identifier.staticElement = ElementFactory.requiredParameter(outerParame
terName); |
| 7430 Type2 parameterType = resolve6(node, [intType.element]); | 8496 Type2 parameterType = resolve6(node, [intType.element]); |
| 7431 EngineTestCase.assertInstanceOf(FunctionType, parameterType); | 8497 EngineTestCase.assertInstanceOf(FunctionType, parameterType); |
| 7432 FunctionType functionType = parameterType as FunctionType; | 8498 FunctionType functionType = parameterType as FunctionType; |
| 7433 JUnitTestCase.assertSame(intType, functionType.returnType); | 8499 JUnitTestCase.assertSame(intType, functionType.returnType); |
| 7434 EngineTestCase.assertLength(1, functionType.parameters); | 8500 EngineTestCase.assertLength(1, functionType.parameters); |
| 7435 _listener.assertNoErrors(); | 8501 _listener.assertNoErrors(); |
| 7436 } | 8502 } |
| 8503 |
| 7437 void test_visitFieldFormalParameter_noType() { | 8504 void test_visitFieldFormalParameter_noType() { |
| 7438 String parameterName = "p"; | 8505 String parameterName = "p"; |
| 7439 FormalParameter node = ASTFactory.fieldFormalParameter(Keyword.VAR, null, pa
rameterName); | 8506 FormalParameter node = ASTFactory.fieldFormalParameter(Keyword.VAR, null, pa
rameterName); |
| 7440 node.identifier.staticElement = ElementFactory.requiredParameter(parameterNa
me); | 8507 node.identifier.staticElement = ElementFactory.requiredParameter(parameterNa
me); |
| 7441 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve6(node, [])); | 8508 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve6(node, [])); |
| 7442 _listener.assertNoErrors(); | 8509 _listener.assertNoErrors(); |
| 7443 } | 8510 } |
| 8511 |
| 7444 void test_visitFieldFormalParameter_type() { | 8512 void test_visitFieldFormalParameter_type() { |
| 7445 InterfaceType intType = _typeProvider.intType; | 8513 InterfaceType intType = _typeProvider.intType; |
| 7446 TypeName intTypeName = ASTFactory.typeName4("int", []); | 8514 TypeName intTypeName = ASTFactory.typeName4("int", []); |
| 7447 String parameterName = "p"; | 8515 String parameterName = "p"; |
| 7448 FormalParameter node = ASTFactory.fieldFormalParameter(null, intTypeName, pa
rameterName); | 8516 FormalParameter node = ASTFactory.fieldFormalParameter(null, intTypeName, pa
rameterName); |
| 7449 node.identifier.staticElement = ElementFactory.requiredParameter(parameterNa
me); | 8517 node.identifier.staticElement = ElementFactory.requiredParameter(parameterNa
me); |
| 7450 JUnitTestCase.assertSame(intType, resolve6(node, [intType.element])); | 8518 JUnitTestCase.assertSame(intType, resolve6(node, [intType.element])); |
| 7451 _listener.assertNoErrors(); | 8519 _listener.assertNoErrors(); |
| 7452 } | 8520 } |
| 8521 |
| 7453 void test_visitSimpleFormalParameter_noType() { | 8522 void test_visitSimpleFormalParameter_noType() { |
| 7454 FormalParameter node = ASTFactory.simpleFormalParameter3("p"); | 8523 FormalParameter node = ASTFactory.simpleFormalParameter3("p"); |
| 7455 node.identifier.staticElement = new ParameterElementImpl.con1(ASTFactory.ide
ntifier3("p")); | 8524 node.identifier.staticElement = new ParameterElementImpl.con1(ASTFactory.ide
ntifier3("p")); |
| 7456 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve6(node, [])); | 8525 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve6(node, [])); |
| 7457 _listener.assertNoErrors(); | 8526 _listener.assertNoErrors(); |
| 7458 } | 8527 } |
| 8528 |
| 7459 void test_visitSimpleFormalParameter_type() { | 8529 void test_visitSimpleFormalParameter_type() { |
| 7460 InterfaceType intType = _typeProvider.intType; | 8530 InterfaceType intType = _typeProvider.intType; |
| 7461 ClassElement intElement = intType.element; | 8531 ClassElement intElement = intType.element; |
| 7462 FormalParameter node = ASTFactory.simpleFormalParameter4(ASTFactory.typeName
(intElement, []), "p"); | 8532 FormalParameter node = ASTFactory.simpleFormalParameter4(ASTFactory.typeName
(intElement, []), "p"); |
| 7463 SimpleIdentifier identifier = node.identifier; | 8533 SimpleIdentifier identifier = node.identifier; |
| 7464 ParameterElementImpl element = new ParameterElementImpl.con1(identifier); | 8534 ParameterElementImpl element = new ParameterElementImpl.con1(identifier); |
| 7465 identifier.staticElement = element; | 8535 identifier.staticElement = element; |
| 7466 JUnitTestCase.assertSame(intType, resolve6(node, [intElement])); | 8536 JUnitTestCase.assertSame(intType, resolve6(node, [intElement])); |
| 7467 _listener.assertNoErrors(); | 8537 _listener.assertNoErrors(); |
| 7468 } | 8538 } |
| 8539 |
| 7469 void test_visitTypeName_noParameters_noArguments() { | 8540 void test_visitTypeName_noParameters_noArguments() { |
| 7470 ClassElement classA = ElementFactory.classElement2("A", []); | 8541 ClassElement classA = ElementFactory.classElement2("A", []); |
| 7471 TypeName typeName = ASTFactory.typeName(classA, []); | 8542 TypeName typeName = ASTFactory.typeName(classA, []); |
| 7472 typeName.type = null; | 8543 typeName.type = null; |
| 7473 resolveNode(typeName, [classA]); | 8544 resolveNode(typeName, [classA]); |
| 7474 JUnitTestCase.assertSame(classA.type, typeName.type); | 8545 JUnitTestCase.assertSame(classA.type, typeName.type); |
| 7475 _listener.assertNoErrors(); | 8546 _listener.assertNoErrors(); |
| 7476 } | 8547 } |
| 8548 |
| 7477 void test_visitTypeName_parameters_arguments() { | 8549 void test_visitTypeName_parameters_arguments() { |
| 7478 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 8550 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 7479 ClassElement classB = ElementFactory.classElement2("B", []); | 8551 ClassElement classB = ElementFactory.classElement2("B", []); |
| 7480 TypeName typeName = ASTFactory.typeName(classA, [ASTFactory.typeName(classB,
[])]); | 8552 TypeName typeName = ASTFactory.typeName(classA, [ASTFactory.typeName(classB,
[])]); |
| 7481 typeName.type = null; | 8553 typeName.type = null; |
| 7482 resolveNode(typeName, [classA, classB]); | 8554 resolveNode(typeName, [classA, classB]); |
| 7483 InterfaceType resultType = typeName.type as InterfaceType; | 8555 InterfaceType resultType = typeName.type as InterfaceType; |
| 7484 JUnitTestCase.assertSame(classA, resultType.element); | 8556 JUnitTestCase.assertSame(classA, resultType.element); |
| 7485 List<Type2> resultArguments = resultType.typeArguments; | 8557 List<Type2> resultArguments = resultType.typeArguments; |
| 7486 EngineTestCase.assertLength(1, resultArguments); | 8558 EngineTestCase.assertLength(1, resultArguments); |
| 7487 JUnitTestCase.assertSame(classB.type, resultArguments[0]); | 8559 JUnitTestCase.assertSame(classB.type, resultArguments[0]); |
| 7488 _listener.assertNoErrors(); | 8560 _listener.assertNoErrors(); |
| 7489 } | 8561 } |
| 8562 |
| 7490 void test_visitTypeName_parameters_noArguments() { | 8563 void test_visitTypeName_parameters_noArguments() { |
| 7491 ClassElement classA = ElementFactory.classElement2("A", ["E"]); | 8564 ClassElement classA = ElementFactory.classElement2("A", ["E"]); |
| 7492 TypeName typeName = ASTFactory.typeName(classA, []); | 8565 TypeName typeName = ASTFactory.typeName(classA, []); |
| 7493 typeName.type = null; | 8566 typeName.type = null; |
| 7494 resolveNode(typeName, [classA]); | 8567 resolveNode(typeName, [classA]); |
| 7495 InterfaceType resultType = typeName.type as InterfaceType; | 8568 InterfaceType resultType = typeName.type as InterfaceType; |
| 7496 JUnitTestCase.assertSame(classA, resultType.element); | 8569 JUnitTestCase.assertSame(classA, resultType.element); |
| 7497 List<Type2> resultArguments = resultType.typeArguments; | 8570 List<Type2> resultArguments = resultType.typeArguments; |
| 7498 EngineTestCase.assertLength(1, resultArguments); | 8571 EngineTestCase.assertLength(1, resultArguments); |
| 7499 JUnitTestCase.assertSame(DynamicTypeImpl.instance, resultArguments[0]); | 8572 JUnitTestCase.assertSame(DynamicTypeImpl.instance, resultArguments[0]); |
| 7500 _listener.assertNoErrors(); | 8573 _listener.assertNoErrors(); |
| 7501 } | 8574 } |
| 8575 |
| 7502 void test_visitTypeName_void() { | 8576 void test_visitTypeName_void() { |
| 7503 ClassElement classA = ElementFactory.classElement2("A", []); | 8577 ClassElement classA = ElementFactory.classElement2("A", []); |
| 7504 TypeName typeName = ASTFactory.typeName4("void", []); | 8578 TypeName typeName = ASTFactory.typeName4("void", []); |
| 7505 resolveNode(typeName, [classA]); | 8579 resolveNode(typeName, [classA]); |
| 7506 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type); | 8580 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type); |
| 7507 _listener.assertNoErrors(); | 8581 _listener.assertNoErrors(); |
| 7508 } | 8582 } |
| 7509 | 8583 |
| 7510 /** | 8584 /** |
| 7511 * Analyze the given catch clause and assert that the types of the parameters
have been set to the | 8585 * Analyze the given catch clause and assert that the types of the parameters
have been set to the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 7534 * Return the type associated with the given parameter after the static type a
nalyzer has computed | 8608 * Return the type associated with the given parameter after the static type a
nalyzer has computed |
| 7535 * a type for it. | 8609 * a type for it. |
| 7536 * | 8610 * |
| 7537 * @param node the parameter with which the type is associated | 8611 * @param node the parameter with which the type is associated |
| 7538 * @param definedElements the elements that are to be defined in the scope in
which the element is | 8612 * @param definedElements the elements that are to be defined in the scope in
which the element is |
| 7539 * being resolved | 8613 * being resolved |
| 7540 * @return the type associated with the parameter | 8614 * @return the type associated with the parameter |
| 7541 */ | 8615 */ |
| 7542 Type2 resolve6(FormalParameter node, List<Element> definedElements) { | 8616 Type2 resolve6(FormalParameter node, List<Element> definedElements) { |
| 7543 resolveNode(node, definedElements); | 8617 resolveNode(node, definedElements); |
| 7544 return ((node.identifier.staticElement as ParameterElement)).type; | 8618 return (node.identifier.staticElement as ParameterElement).type; |
| 7545 } | 8619 } |
| 7546 | 8620 |
| 7547 /** | 8621 /** |
| 7548 * Return the element associated with the given identifier after the resolver
has resolved the | 8622 * Return the element associated with the given identifier after the resolver
has resolved the |
| 7549 * identifier. | 8623 * identifier. |
| 7550 * | 8624 * |
| 7551 * @param node the expression to be resolved | 8625 * @param node the expression to be resolved |
| 7552 * @param definedElements the elements that are to be defined in the scope in
which the element is | 8626 * @param definedElements the elements that are to be defined in the scope in
which the element is |
| 7553 * being resolved | 8627 * being resolved |
| 7554 * @return the element to which the expression was resolved | 8628 * @return the element to which the expression was resolved |
| 7555 */ | 8629 */ |
| 7556 void resolveNode(ASTNode node, List<Element> definedElements) { | 8630 void resolveNode(ASTNode node, List<Element> definedElements) { |
| 7557 for (Element element in definedElements) { | 8631 for (Element element in definedElements) { |
| 7558 _library.libraryScope.define(element); | 8632 _library.libraryScope.define(element); |
| 7559 } | 8633 } |
| 7560 node.accept(_visitor); | 8634 node.accept(_visitor); |
| 7561 } | 8635 } |
| 8636 |
| 7562 static dartSuite() { | 8637 static dartSuite() { |
| 7563 _ut.group('TypeResolverVisitorTest', () { | 8638 _ut.group('TypeResolverVisitorTest', () { |
| 7564 _ut.test('test_visitCatchClause_exception', () { | 8639 _ut.test('test_visitCatchClause_exception', () { |
| 7565 final __test = new TypeResolverVisitorTest(); | 8640 final __test = new TypeResolverVisitorTest(); |
| 7566 runJUnitTest(__test, __test.test_visitCatchClause_exception); | 8641 runJUnitTest(__test, __test.test_visitCatchClause_exception); |
| 7567 }); | 8642 }); |
| 7568 _ut.test('test_visitCatchClause_exception_stackTrace', () { | 8643 _ut.test('test_visitCatchClause_exception_stackTrace', () { |
| 7569 final __test = new TypeResolverVisitorTest(); | 8644 final __test = new TypeResolverVisitorTest(); |
| 7570 runJUnitTest(__test, __test.test_visitCatchClause_exception_stackTrace); | 8645 runJUnitTest(__test, __test.test_visitCatchClause_exception_stackTrace); |
| 7571 }); | 8646 }); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7617 final __test = new TypeResolverVisitorTest(); | 8692 final __test = new TypeResolverVisitorTest(); |
| 7618 runJUnitTest(__test, __test.test_visitTypeName_parameters_noArguments); | 8693 runJUnitTest(__test, __test.test_visitTypeName_parameters_noArguments); |
| 7619 }); | 8694 }); |
| 7620 _ut.test('test_visitTypeName_void', () { | 8695 _ut.test('test_visitTypeName_void', () { |
| 7621 final __test = new TypeResolverVisitorTest(); | 8696 final __test = new TypeResolverVisitorTest(); |
| 7622 runJUnitTest(__test, __test.test_visitTypeName_void); | 8697 runJUnitTest(__test, __test.test_visitTypeName_void); |
| 7623 }); | 8698 }); |
| 7624 }); | 8699 }); |
| 7625 } | 8700 } |
| 7626 } | 8701 } |
| 8702 |
| 7627 class ResolverTestCase extends EngineTestCase { | 8703 class ResolverTestCase extends EngineTestCase { |
| 7628 | |
| 7629 /** | 8704 /** |
| 7630 * The source factory used to create [Source]. | 8705 * The source factory used to create [Source]. |
| 7631 */ | 8706 */ |
| 7632 SourceFactory sourceFactory; | 8707 SourceFactory sourceFactory; |
| 7633 | 8708 |
| 7634 /** | 8709 /** |
| 7635 * The analysis context used to parse the compilation units being resolved. | 8710 * The analysis context used to parse the compilation units being resolved. |
| 7636 */ | 8711 */ |
| 7637 AnalysisContextImpl analysisContext; | 8712 AnalysisContextImpl analysisContext; |
| 8713 |
| 7638 void setUp() { | 8714 void setUp() { |
| 7639 reset(); | 8715 reset(); |
| 7640 } | 8716 } |
| 7641 | 8717 |
| 7642 /** | 8718 /** |
| 7643 * Add a source file to the content provider. | 8719 * Add a source file to the content provider. |
| 7644 * | 8720 * |
| 7645 * @param contents the contents to be returned by the content provider for the
specified file | 8721 * @param contents the contents to be returned by the content provider for the
specified file |
| 7646 * @return the source object representing the added file | 8722 * @return the source object representing the added file |
| 7647 */ | 8723 */ |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7804 * Create a source object representing a file with the given name and give it
an empty content. | 8880 * Create a source object representing a file with the given name and give it
an empty content. |
| 7805 * | 8881 * |
| 7806 * @param fileName the name of the file for which a source is to be created | 8882 * @param fileName the name of the file for which a source is to be created |
| 7807 * @return the source that was created | 8883 * @return the source that was created |
| 7808 */ | 8884 */ |
| 7809 FileBasedSource createSource2(String fileName) { | 8885 FileBasedSource createSource2(String fileName) { |
| 7810 FileBasedSource source = new FileBasedSource.con1(sourceFactory.contentCache
, FileUtilities2.createFile(fileName)); | 8886 FileBasedSource source = new FileBasedSource.con1(sourceFactory.contentCache
, FileUtilities2.createFile(fileName)); |
| 7811 sourceFactory.setContents(source, ""); | 8887 sourceFactory.setContents(source, ""); |
| 7812 return source; | 8888 return source; |
| 7813 } | 8889 } |
| 8890 |
| 7814 static dartSuite() { | 8891 static dartSuite() { |
| 7815 _ut.group('ResolverTestCase', () { | 8892 _ut.group('ResolverTestCase', () { |
| 7816 }); | 8893 }); |
| 7817 } | 8894 } |
| 7818 } | 8895 } |
| 8896 |
| 7819 class TypeProviderImplTest extends EngineTestCase { | 8897 class TypeProviderImplTest extends EngineTestCase { |
| 7820 void test_creation() { | 8898 void test_creation() { |
| 7821 InterfaceType objectType = classElement("Object", null, []).type; | 8899 InterfaceType objectType = classElement("Object", null, []).type; |
| 7822 InterfaceType boolType = classElement("bool", objectType, []).type; | 8900 InterfaceType boolType = classElement("bool", objectType, []).type; |
| 7823 InterfaceType numType = classElement("num", objectType, []).type; | 8901 InterfaceType numType = classElement("num", objectType, []).type; |
| 7824 InterfaceType doubleType = classElement("double", numType, []).type; | 8902 InterfaceType doubleType = classElement("double", numType, []).type; |
| 7825 InterfaceType functionType = classElement("Function", objectType, []).type; | 8903 InterfaceType functionType = classElement("Function", objectType, []).type; |
| 7826 InterfaceType intType = classElement("int", numType, []).type; | 8904 InterfaceType intType = classElement("int", numType, []).type; |
| 7827 InterfaceType listType = classElement("List", objectType, ["E"]).type; | 8905 InterfaceType listType = classElement("List", objectType, ["E"]).type; |
| 7828 InterfaceType mapType = classElement("Map", objectType, ["K", "V"]).type; | 8906 InterfaceType mapType = classElement("Map", objectType, ["K", "V"]).type; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 7853 JUnitTestCase.assertSame(functionType, provider.functionType); | 8931 JUnitTestCase.assertSame(functionType, provider.functionType); |
| 7854 JUnitTestCase.assertSame(intType, provider.intType); | 8932 JUnitTestCase.assertSame(intType, provider.intType); |
| 7855 JUnitTestCase.assertSame(listType, provider.listType); | 8933 JUnitTestCase.assertSame(listType, provider.listType); |
| 7856 JUnitTestCase.assertSame(mapType, provider.mapType); | 8934 JUnitTestCase.assertSame(mapType, provider.mapType); |
| 7857 JUnitTestCase.assertSame(objectType, provider.objectType); | 8935 JUnitTestCase.assertSame(objectType, provider.objectType); |
| 7858 JUnitTestCase.assertSame(stackTraceType, provider.stackTraceType); | 8936 JUnitTestCase.assertSame(stackTraceType, provider.stackTraceType); |
| 7859 JUnitTestCase.assertSame(stringType, provider.stringType); | 8937 JUnitTestCase.assertSame(stringType, provider.stringType); |
| 7860 JUnitTestCase.assertSame(symbolType, provider.symbolType); | 8938 JUnitTestCase.assertSame(symbolType, provider.symbolType); |
| 7861 JUnitTestCase.assertSame(typeType, provider.typeType); | 8939 JUnitTestCase.assertSame(typeType, provider.typeType); |
| 7862 } | 8940 } |
| 8941 |
| 7863 ClassElement classElement(String typeName, InterfaceType superclassType, List<
String> parameterNames) { | 8942 ClassElement classElement(String typeName, InterfaceType superclassType, List<
String> parameterNames) { |
| 7864 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier3(typeN
ame)); | 8943 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier3(typeN
ame)); |
| 7865 element.supertype = superclassType; | 8944 element.supertype = superclassType; |
| 7866 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element); | 8945 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element); |
| 7867 element.type = type; | 8946 element.type = type; |
| 7868 int count = parameterNames.length; | 8947 int count = parameterNames.length; |
| 7869 if (count > 0) { | 8948 if (count > 0) { |
| 7870 List<TypeParameterElementImpl> typeParameters = new List<TypeParameterElem
entImpl>(count); | 8949 List<TypeParameterElementImpl> typeParameters = new List<TypeParameterElem
entImpl>(count); |
| 7871 List<TypeParameterTypeImpl> typeArguments = new List<TypeParameterTypeImpl
>(count); | 8950 List<TypeParameterTypeImpl> typeArguments = new List<TypeParameterTypeImpl
>(count); |
| 7872 for (int i = 0; i < count; i++) { | 8951 for (int i = 0; i < count; i++) { |
| 7873 TypeParameterElementImpl typeParameter = new TypeParameterElementImpl(AS
TFactory.identifier3(parameterNames[i])); | 8952 TypeParameterElementImpl typeParameter = new TypeParameterElementImpl(AS
TFactory.identifier3(parameterNames[i])); |
| 7874 typeParameters[i] = typeParameter; | 8953 typeParameters[i] = typeParameter; |
| 7875 typeArguments[i] = new TypeParameterTypeImpl(typeParameter); | 8954 typeArguments[i] = new TypeParameterTypeImpl(typeParameter); |
| 7876 typeParameter.type = typeArguments[i]; | 8955 typeParameter.type = typeArguments[i]; |
| 7877 } | 8956 } |
| 7878 element.typeParameters = typeParameters; | 8957 element.typeParameters = typeParameters; |
| 7879 type.typeArguments = typeArguments; | 8958 type.typeArguments = typeArguments; |
| 7880 } | 8959 } |
| 7881 return element; | 8960 return element; |
| 7882 } | 8961 } |
| 8962 |
| 7883 static dartSuite() { | 8963 static dartSuite() { |
| 7884 _ut.group('TypeProviderImplTest', () { | 8964 _ut.group('TypeProviderImplTest', () { |
| 7885 _ut.test('test_creation', () { | 8965 _ut.test('test_creation', () { |
| 7886 final __test = new TypeProviderImplTest(); | 8966 final __test = new TypeProviderImplTest(); |
| 7887 runJUnitTest(__test, __test.test_creation); | 8967 runJUnitTest(__test, __test.test_creation); |
| 7888 }); | 8968 }); |
| 7889 }); | 8969 }); |
| 7890 } | 8970 } |
| 7891 } | 8971 } |
| 8972 |
| 7892 class InheritanceManagerTest extends EngineTestCase { | 8973 class InheritanceManagerTest extends EngineTestCase { |
| 7893 | |
| 7894 /** | 8974 /** |
| 7895 * The type provider used to access the types. | 8975 * The type provider used to access the types. |
| 7896 */ | 8976 */ |
| 7897 TestTypeProvider _typeProvider; | 8977 TestTypeProvider _typeProvider; |
| 7898 | 8978 |
| 7899 /** | 8979 /** |
| 7900 * The library containing the code being resolved. | 8980 * The library containing the code being resolved. |
| 7901 */ | 8981 */ |
| 7902 LibraryElementImpl _definingLibrary; | 8982 LibraryElementImpl _definingLibrary; |
| 7903 | 8983 |
| 7904 /** | 8984 /** |
| 7905 * The inheritance manager being tested. | 8985 * The inheritance manager being tested. |
| 7906 */ | 8986 */ |
| 7907 InheritanceManager _inheritanceManager; | 8987 InheritanceManager _inheritanceManager; |
| 7908 | 8988 |
| 7909 /** | 8989 /** |
| 7910 * The number of members that Object implements (as determined by [TestTypePro
vider]). | 8990 * The number of members that Object implements (as determined by [TestTypePro
vider]). |
| 7911 */ | 8991 */ |
| 7912 int _numOfMembersInObject = 0; | 8992 int _numOfMembersInObject = 0; |
| 8993 |
| 7913 void setUp() { | 8994 void setUp() { |
| 7914 _typeProvider = new TestTypeProvider(); | 8995 _typeProvider = new TestTypeProvider(); |
| 7915 _inheritanceManager = createInheritanceManager(); | 8996 _inheritanceManager = createInheritanceManager(); |
| 7916 InterfaceType objectType = _typeProvider.objectType; | 8997 InterfaceType objectType = _typeProvider.objectType; |
| 7917 _numOfMembersInObject = objectType.methods.length + objectType.accessors.len
gth; | 8998 _numOfMembersInObject = objectType.methods.length + objectType.accessors.len
gth; |
| 7918 } | 8999 } |
| 9000 |
| 7919 void test_getMapOfMembersInheritedFromClasses_accessor_extends() { | 9001 void test_getMapOfMembersInheritedFromClasses_accessor_extends() { |
| 7920 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9002 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 7921 String getterName = "g"; | 9003 String getterName = "g"; |
| 7922 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); | 9004 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); |
| 7923 classA.accessors = <PropertyAccessorElement> [getterG]; | 9005 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 7924 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 9006 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 7925 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); | 9007 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); |
| 7926 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); | 9008 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); |
| 7927 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9009 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 7928 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); | 9010 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); |
| 7929 JUnitTestCase.assertSame(getterG, mapB.get(getterName)); | 9011 JUnitTestCase.assertSame(getterG, mapB.get(getterName)); |
| 7930 assertNoErrors(classA); | 9012 assertNoErrors(classA); |
| 7931 assertNoErrors(classB); | 9013 assertNoErrors(classB); |
| 7932 } | 9014 } |
| 9015 |
| 7933 void test_getMapOfMembersInheritedFromClasses_accessor_implements() { | 9016 void test_getMapOfMembersInheritedFromClasses_accessor_implements() { |
| 7934 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9017 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 7935 String getterName = "g"; | 9018 String getterName = "g"; |
| 7936 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); | 9019 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); |
| 7937 classA.accessors = <PropertyAccessorElement> [getterG]; | 9020 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 7938 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9021 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 7939 classB.interfaces = <InterfaceType> [classA.type]; | 9022 classB.interfaces = <InterfaceType> [classA.type]; |
| 7940 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); | 9023 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); |
| 7941 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); | 9024 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); |
| 7942 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9025 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 7943 JUnitTestCase.assertEquals(_numOfMembersInObject, mapB.size); | 9026 JUnitTestCase.assertEquals(_numOfMembersInObject, mapB.size); |
| 7944 JUnitTestCase.assertNull(mapB.get(getterName)); | 9027 JUnitTestCase.assertNull(mapB.get(getterName)); |
| 7945 assertNoErrors(classA); | 9028 assertNoErrors(classA); |
| 7946 assertNoErrors(classB); | 9029 assertNoErrors(classB); |
| 7947 } | 9030 } |
| 9031 |
| 7948 void test_getMapOfMembersInheritedFromClasses_accessor_with() { | 9032 void test_getMapOfMembersInheritedFromClasses_accessor_with() { |
| 7949 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9033 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 7950 String getterName = "g"; | 9034 String getterName = "g"; |
| 7951 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); | 9035 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); |
| 7952 classA.accessors = <PropertyAccessorElement> [getterG]; | 9036 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 7953 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9037 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 7954 classB.mixins = <InterfaceType> [classA.type]; | 9038 classB.mixins = <InterfaceType> [classA.type]; |
| 7955 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); | 9039 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); |
| 7956 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); | 9040 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); |
| 7957 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9041 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 7958 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); | 9042 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); |
| 7959 JUnitTestCase.assertSame(getterG, mapB.get(getterName)); | 9043 JUnitTestCase.assertSame(getterG, mapB.get(getterName)); |
| 7960 assertNoErrors(classA); | 9044 assertNoErrors(classA); |
| 7961 assertNoErrors(classB); | 9045 assertNoErrors(classB); |
| 7962 } | 9046 } |
| 9047 |
| 7963 void test_getMapOfMembersInheritedFromClasses_method_extends() { | 9048 void test_getMapOfMembersInheritedFromClasses_method_extends() { |
| 7964 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9049 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 7965 String methodName = "m"; | 9050 String methodName = "m"; |
| 7966 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9051 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 7967 classA.methods = <MethodElement> [methodM]; | 9052 classA.methods = <MethodElement> [methodM]; |
| 7968 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9053 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 7969 classB.supertype = classA.type; | 9054 classB.supertype = classA.type; |
| 7970 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); | 9055 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); |
| 7971 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); | 9056 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); |
| 7972 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9057 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 7973 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); | 9058 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); |
| 7974 JUnitTestCase.assertSame(methodM, mapB.get(methodName)); | 9059 JUnitTestCase.assertSame(methodM, mapB.get(methodName)); |
| 7975 assertNoErrors(classA); | 9060 assertNoErrors(classA); |
| 7976 assertNoErrors(classB); | 9061 assertNoErrors(classB); |
| 7977 } | 9062 } |
| 9063 |
| 7978 void test_getMapOfMembersInheritedFromClasses_method_implements() { | 9064 void test_getMapOfMembersInheritedFromClasses_method_implements() { |
| 7979 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9065 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 7980 String methodName = "m"; | 9066 String methodName = "m"; |
| 7981 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9067 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 7982 classA.methods = <MethodElement> [methodM]; | 9068 classA.methods = <MethodElement> [methodM]; |
| 7983 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9069 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 7984 classB.interfaces = <InterfaceType> [classA.type]; | 9070 classB.interfaces = <InterfaceType> [classA.type]; |
| 7985 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); | 9071 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); |
| 7986 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); | 9072 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); |
| 7987 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9073 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 7988 JUnitTestCase.assertEquals(_numOfMembersInObject, mapB.size); | 9074 JUnitTestCase.assertEquals(_numOfMembersInObject, mapB.size); |
| 7989 JUnitTestCase.assertNull(mapB.get(methodName)); | 9075 JUnitTestCase.assertNull(mapB.get(methodName)); |
| 7990 assertNoErrors(classA); | 9076 assertNoErrors(classA); |
| 7991 assertNoErrors(classB); | 9077 assertNoErrors(classB); |
| 7992 } | 9078 } |
| 9079 |
| 7993 void test_getMapOfMembersInheritedFromClasses_method_with() { | 9080 void test_getMapOfMembersInheritedFromClasses_method_with() { |
| 7994 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9081 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 7995 String methodName = "m"; | 9082 String methodName = "m"; |
| 7996 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9083 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 7997 classA.methods = <MethodElement> [methodM]; | 9084 classA.methods = <MethodElement> [methodM]; |
| 7998 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9085 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 7999 classB.mixins = <InterfaceType> [classA.type]; | 9086 classB.mixins = <InterfaceType> [classA.type]; |
| 8000 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); | 9087 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssB); |
| 8001 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); | 9088 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla
ssA); |
| 8002 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9089 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 8003 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); | 9090 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); |
| 8004 JUnitTestCase.assertSame(methodM, mapB.get(methodName)); | 9091 JUnitTestCase.assertSame(methodM, mapB.get(methodName)); |
| 8005 assertNoErrors(classA); | 9092 assertNoErrors(classA); |
| 8006 assertNoErrors(classB); | 9093 assertNoErrors(classB); |
| 8007 } | 9094 } |
| 9095 |
| 8008 void test_getMapOfMembersInheritedFromInterfaces_accessor_extends() { | 9096 void test_getMapOfMembersInheritedFromInterfaces_accessor_extends() { |
| 8009 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9097 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8010 String getterName = "g"; | 9098 String getterName = "g"; |
| 8011 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); | 9099 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); |
| 8012 classA.accessors = <PropertyAccessorElement> [getterG]; | 9100 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 8013 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 9101 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 8014 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); | 9102 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); |
| 8015 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); | 9103 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); |
| 8016 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9104 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 8017 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); | 9105 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); |
| 8018 JUnitTestCase.assertSame(getterG, mapB.get(getterName)); | 9106 JUnitTestCase.assertSame(getterG, mapB.get(getterName)); |
| 8019 assertNoErrors(classA); | 9107 assertNoErrors(classA); |
| 8020 assertNoErrors(classB); | 9108 assertNoErrors(classB); |
| 8021 } | 9109 } |
| 9110 |
| 8022 void test_getMapOfMembersInheritedFromInterfaces_accessor_implements() { | 9111 void test_getMapOfMembersInheritedFromInterfaces_accessor_implements() { |
| 8023 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9112 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8024 String getterName = "g"; | 9113 String getterName = "g"; |
| 8025 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); | 9114 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); |
| 8026 classA.accessors = <PropertyAccessorElement> [getterG]; | 9115 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 8027 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9116 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8028 classB.interfaces = <InterfaceType> [classA.type]; | 9117 classB.interfaces = <InterfaceType> [classA.type]; |
| 8029 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); | 9118 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); |
| 8030 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); | 9119 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); |
| 8031 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9120 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 8032 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); | 9121 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); |
| 8033 JUnitTestCase.assertSame(getterG, mapB.get(getterName)); | 9122 JUnitTestCase.assertSame(getterG, mapB.get(getterName)); |
| 8034 assertNoErrors(classA); | 9123 assertNoErrors(classA); |
| 8035 assertNoErrors(classB); | 9124 assertNoErrors(classB); |
| 8036 } | 9125 } |
| 9126 |
| 8037 void test_getMapOfMembersInheritedFromInterfaces_accessor_with() { | 9127 void test_getMapOfMembersInheritedFromInterfaces_accessor_with() { |
| 8038 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9128 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8039 String getterName = "g"; | 9129 String getterName = "g"; |
| 8040 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); | 9130 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); |
| 8041 classA.accessors = <PropertyAccessorElement> [getterG]; | 9131 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 8042 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9132 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8043 classB.mixins = <InterfaceType> [classA.type]; | 9133 classB.mixins = <InterfaceType> [classA.type]; |
| 8044 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); | 9134 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); |
| 8045 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); | 9135 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); |
| 8046 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9136 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 8047 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); | 9137 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); |
| 8048 JUnitTestCase.assertSame(getterG, mapB.get(getterName)); | 9138 JUnitTestCase.assertSame(getterG, mapB.get(getterName)); |
| 8049 assertNoErrors(classA); | 9139 assertNoErrors(classA); |
| 8050 assertNoErrors(classB); | 9140 assertNoErrors(classB); |
| 8051 } | 9141 } |
| 9142 |
| 8052 void test_getMapOfMembersInheritedFromInterfaces_method_extends() { | 9143 void test_getMapOfMembersInheritedFromInterfaces_method_extends() { |
| 8053 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9144 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8054 String methodName = "m"; | 9145 String methodName = "m"; |
| 8055 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9146 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8056 classA.methods = <MethodElement> [methodM]; | 9147 classA.methods = <MethodElement> [methodM]; |
| 8057 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 9148 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 8058 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); | 9149 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); |
| 8059 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); | 9150 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); |
| 8060 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9151 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 8061 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); | 9152 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); |
| 8062 JUnitTestCase.assertSame(methodM, mapB.get(methodName)); | 9153 JUnitTestCase.assertSame(methodM, mapB.get(methodName)); |
| 8063 assertNoErrors(classA); | 9154 assertNoErrors(classA); |
| 8064 assertNoErrors(classB); | 9155 assertNoErrors(classB); |
| 8065 } | 9156 } |
| 9157 |
| 8066 void test_getMapOfMembersInheritedFromInterfaces_method_implements() { | 9158 void test_getMapOfMembersInheritedFromInterfaces_method_implements() { |
| 8067 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9159 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8068 String methodName = "m"; | 9160 String methodName = "m"; |
| 8069 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9161 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8070 classA.methods = <MethodElement> [methodM]; | 9162 classA.methods = <MethodElement> [methodM]; |
| 8071 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9163 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8072 classB.interfaces = <InterfaceType> [classA.type]; | 9164 classB.interfaces = <InterfaceType> [classA.type]; |
| 8073 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); | 9165 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); |
| 8074 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); | 9166 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); |
| 8075 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9167 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 8076 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); | 9168 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); |
| 8077 JUnitTestCase.assertSame(methodM, mapB.get(methodName)); | 9169 JUnitTestCase.assertSame(methodM, mapB.get(methodName)); |
| 8078 assertNoErrors(classA); | 9170 assertNoErrors(classA); |
| 8079 assertNoErrors(classB); | 9171 assertNoErrors(classB); |
| 8080 } | 9172 } |
| 9173 |
| 8081 void test_getMapOfMembersInheritedFromInterfaces_method_with() { | 9174 void test_getMapOfMembersInheritedFromInterfaces_method_with() { |
| 8082 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9175 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8083 String methodName = "m"; | 9176 String methodName = "m"; |
| 8084 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9177 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8085 classA.methods = <MethodElement> [methodM]; | 9178 classA.methods = <MethodElement> [methodM]; |
| 8086 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9179 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8087 classB.mixins = <InterfaceType> [classA.type]; | 9180 classB.mixins = <InterfaceType> [classA.type]; |
| 8088 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); | 9181 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classB); |
| 8089 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); | 9182 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces(
classA); |
| 8090 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); | 9183 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size); |
| 8091 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); | 9184 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size); |
| 8092 JUnitTestCase.assertSame(methodM, mapB.get(methodName)); | 9185 JUnitTestCase.assertSame(methodM, mapB.get(methodName)); |
| 8093 assertNoErrors(classA); | 9186 assertNoErrors(classA); |
| 8094 assertNoErrors(classB); | 9187 assertNoErrors(classB); |
| 8095 } | 9188 } |
| 9189 |
| 8096 void test_lookupInheritance_interface_getter() { | 9190 void test_lookupInheritance_interface_getter() { |
| 8097 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9191 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8098 String getterName = "g"; | 9192 String getterName = "g"; |
| 8099 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); | 9193 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); |
| 8100 classA.accessors = <PropertyAccessorElement> [getterG]; | 9194 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 8101 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9195 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8102 classB.interfaces = <InterfaceType> [classA.type]; | 9196 classB.interfaces = <InterfaceType> [classA.type]; |
| 8103 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas
sB, getterName)); | 9197 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas
sB, getterName)); |
| 8104 assertNoErrors(classA); | 9198 assertNoErrors(classA); |
| 8105 assertNoErrors(classB); | 9199 assertNoErrors(classB); |
| 8106 } | 9200 } |
| 9201 |
| 8107 void test_lookupInheritance_interface_method() { | 9202 void test_lookupInheritance_interface_method() { |
| 8108 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9203 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8109 String methodName = "m"; | 9204 String methodName = "m"; |
| 8110 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9205 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8111 classA.methods = <MethodElement> [methodM]; | 9206 classA.methods = <MethodElement> [methodM]; |
| 8112 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9207 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8113 classB.interfaces = <InterfaceType> [classA.type]; | 9208 classB.interfaces = <InterfaceType> [classA.type]; |
| 8114 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas
sB, methodName)); | 9209 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas
sB, methodName)); |
| 8115 assertNoErrors(classA); | 9210 assertNoErrors(classA); |
| 8116 assertNoErrors(classB); | 9211 assertNoErrors(classB); |
| 8117 } | 9212 } |
| 9213 |
| 8118 void test_lookupInheritance_interface_setter() { | 9214 void test_lookupInheritance_interface_setter() { |
| 8119 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9215 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8120 String setterName = "s"; | 9216 String setterName = "s"; |
| 8121 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, _typeProvider.intType); | 9217 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, _typeProvider.intType); |
| 8122 classA.accessors = <PropertyAccessorElement> [setterS]; | 9218 classA.accessors = <PropertyAccessorElement> [setterS]; |
| 8123 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9219 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8124 classB.interfaces = <InterfaceType> [classA.type]; | 9220 classB.interfaces = <InterfaceType> [classA.type]; |
| 8125 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas
sB, "${setterName}=")); | 9221 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas
sB, "${setterName}=")); |
| 8126 assertNoErrors(classA); | 9222 assertNoErrors(classA); |
| 8127 assertNoErrors(classB); | 9223 assertNoErrors(classB); |
| 8128 } | 9224 } |
| 9225 |
| 8129 void test_lookupInheritance_interface_staticMember() { | 9226 void test_lookupInheritance_interface_staticMember() { |
| 8130 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9227 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8131 String methodName = "m"; | 9228 String methodName = "m"; |
| 8132 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9229 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8133 ((methodM as MethodElementImpl)).static = true; | 9230 (methodM as MethodElementImpl).static = true; |
| 8134 classA.methods = <MethodElement> [methodM]; | 9231 classA.methods = <MethodElement> [methodM]; |
| 8135 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9232 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8136 classB.interfaces = <InterfaceType> [classA.type]; | 9233 classB.interfaces = <InterfaceType> [classA.type]; |
| 8137 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho
dName)); | 9234 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho
dName)); |
| 8138 assertNoErrors(classA); | 9235 assertNoErrors(classA); |
| 8139 assertNoErrors(classB); | 9236 assertNoErrors(classB); |
| 8140 } | 9237 } |
| 9238 |
| 8141 void test_lookupInheritance_interfaces_infiniteLoop() { | 9239 void test_lookupInheritance_interfaces_infiniteLoop() { |
| 8142 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9240 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8143 classA.interfaces = <InterfaceType> [classA.type]; | 9241 classA.interfaces = <InterfaceType> [classA.type]; |
| 8144 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name
")); | 9242 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name
")); |
| 8145 assertNoErrors(classA); | 9243 assertNoErrors(classA); |
| 8146 } | 9244 } |
| 9245 |
| 8147 void test_lookupInheritance_interfaces_infiniteLoop2() { | 9246 void test_lookupInheritance_interfaces_infiniteLoop2() { |
| 8148 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9247 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8149 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9248 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8150 classA.interfaces = <InterfaceType> [classB.type]; | 9249 classA.interfaces = <InterfaceType> [classB.type]; |
| 8151 classB.interfaces = <InterfaceType> [classA.type]; | 9250 classB.interfaces = <InterfaceType> [classA.type]; |
| 8152 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name
")); | 9251 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name
")); |
| 8153 assertNoErrors(classA); | 9252 assertNoErrors(classA); |
| 8154 assertNoErrors(classB); | 9253 assertNoErrors(classB); |
| 8155 } | 9254 } |
| 9255 |
| 8156 void test_lookupInheritance_interfaces_STWC_inconsistentMethodInheritance() { | 9256 void test_lookupInheritance_interfaces_STWC_inconsistentMethodInheritance() { |
| 8157 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []); | 9257 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []); |
| 8158 String methodName = "m"; | 9258 String methodName = "m"; |
| 8159 MethodElement methodM1 = ElementFactory.methodElement(methodName, null, [_ty
peProvider.intType]); | 9259 MethodElement methodM1 = ElementFactory.methodElement(methodName, null, [_ty
peProvider.intType]); |
| 8160 classI1.methods = <MethodElement> [methodM1]; | 9260 classI1.methods = <MethodElement> [methodM1]; |
| 8161 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []); | 9261 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []); |
| 8162 MethodElement methodM2 = ElementFactory.methodElement(methodName, null, [_ty
peProvider.stringType]); | 9262 MethodElement methodM2 = ElementFactory.methodElement(methodName, null, [_ty
peProvider.stringType]); |
| 8163 classI2.methods = <MethodElement> [methodM2]; | 9263 classI2.methods = <MethodElement> [methodM2]; |
| 8164 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9264 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8165 classA.interfaces = <InterfaceType> [classI1.type, classI2.type]; | 9265 classA.interfaces = <InterfaceType> [classI1.type, classI2.type]; |
| 8166 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, metho
dName)); | 9266 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, metho
dName)); |
| 8167 assertNoErrors(classI1); | 9267 assertNoErrors(classI1); |
| 8168 assertNoErrors(classI2); | 9268 assertNoErrors(classI2); |
| 8169 assertErrors(classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); | 9269 assertErrors(classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); |
| 8170 } | 9270 } |
| 9271 |
| 8171 void test_lookupInheritance_interfaces_SWC_inconsistentMethodInheritance() { | 9272 void test_lookupInheritance_interfaces_SWC_inconsistentMethodInheritance() { |
| 8172 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []); | 9273 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []); |
| 8173 String methodName = "m"; | 9274 String methodName = "m"; |
| 8174 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9275 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8175 classI1.methods = <MethodElement> [methodM]; | 9276 classI1.methods = <MethodElement> [methodM]; |
| 8176 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []); | 9277 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []); |
| 8177 PropertyAccessorElement getter = ElementFactory.getterElement(methodName, fa
lse, _typeProvider.intType); | 9278 PropertyAccessorElement getter = ElementFactory.getterElement(methodName, fa
lse, _typeProvider.intType); |
| 8178 classI2.accessors = <PropertyAccessorElement> [getter]; | 9279 classI2.accessors = <PropertyAccessorElement> [getter]; |
| 8179 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9280 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8180 classA.interfaces = <InterfaceType> [classI1.type, classI2.type]; | 9281 classA.interfaces = <InterfaceType> [classI1.type, classI2.type]; |
| 8181 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, metho
dName)); | 9282 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, metho
dName)); |
| 8182 assertNoErrors(classI1); | 9283 assertNoErrors(classI1); |
| 8183 assertNoErrors(classI2); | 9284 assertNoErrors(classI2); |
| 8184 assertErrors(classA, [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETT
ER_AND_METHOD]); | 9285 assertErrors(classA, [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETT
ER_AND_METHOD]); |
| 8185 } | 9286 } |
| 9287 |
| 8186 void test_lookupInheritance_interfaces_union1() { | 9288 void test_lookupInheritance_interfaces_union1() { |
| 8187 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []); | 9289 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []); |
| 8188 String methodName1 = "m1"; | 9290 String methodName1 = "m1"; |
| 8189 MethodElement methodM1 = ElementFactory.methodElement(methodName1, _typeProv
ider.intType, []); | 9291 MethodElement methodM1 = ElementFactory.methodElement(methodName1, _typeProv
ider.intType, []); |
| 8190 classI1.methods = <MethodElement> [methodM1]; | 9292 classI1.methods = <MethodElement> [methodM1]; |
| 8191 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []); | 9293 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []); |
| 8192 String methodName2 = "m2"; | 9294 String methodName2 = "m2"; |
| 8193 MethodElement methodM2 = ElementFactory.methodElement(methodName2, _typeProv
ider.intType, []); | 9295 MethodElement methodM2 = ElementFactory.methodElement(methodName2, _typeProv
ider.intType, []); |
| 8194 classI2.methods = <MethodElement> [methodM2]; | 9296 classI2.methods = <MethodElement> [methodM2]; |
| 8195 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9297 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8196 classA.interfaces = <InterfaceType> [classI1.type, classI2.type]; | 9298 classA.interfaces = <InterfaceType> [classI1.type, classI2.type]; |
| 8197 JUnitTestCase.assertSame(methodM1, _inheritanceManager.lookupInheritance(cla
ssA, methodName1)); | 9299 JUnitTestCase.assertSame(methodM1, _inheritanceManager.lookupInheritance(cla
ssA, methodName1)); |
| 8198 JUnitTestCase.assertSame(methodM2, _inheritanceManager.lookupInheritance(cla
ssA, methodName2)); | 9300 JUnitTestCase.assertSame(methodM2, _inheritanceManager.lookupInheritance(cla
ssA, methodName2)); |
| 8199 assertNoErrors(classI1); | 9301 assertNoErrors(classI1); |
| 8200 assertNoErrors(classI2); | 9302 assertNoErrors(classI2); |
| 8201 assertNoErrors(classA); | 9303 assertNoErrors(classA); |
| 8202 } | 9304 } |
| 9305 |
| 8203 void test_lookupInheritance_interfaces_union2() { | 9306 void test_lookupInheritance_interfaces_union2() { |
| 8204 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []); | 9307 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []); |
| 8205 String methodName1 = "m1"; | 9308 String methodName1 = "m1"; |
| 8206 MethodElement methodM1 = ElementFactory.methodElement(methodName1, _typeProv
ider.intType, []); | 9309 MethodElement methodM1 = ElementFactory.methodElement(methodName1, _typeProv
ider.intType, []); |
| 8207 classI1.methods = <MethodElement> [methodM1]; | 9310 classI1.methods = <MethodElement> [methodM1]; |
| 8208 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []); | 9311 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []); |
| 8209 String methodName2 = "m2"; | 9312 String methodName2 = "m2"; |
| 8210 MethodElement methodM2 = ElementFactory.methodElement(methodName2, _typeProv
ider.intType, []); | 9313 MethodElement methodM2 = ElementFactory.methodElement(methodName2, _typeProv
ider.intType, []); |
| 8211 classI2.methods = <MethodElement> [methodM2]; | 9314 classI2.methods = <MethodElement> [methodM2]; |
| 8212 classI2.interfaces = <InterfaceType> [classI1.type]; | 9315 classI2.interfaces = <InterfaceType> [classI1.type]; |
| 8213 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9316 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8214 classA.interfaces = <InterfaceType> [classI2.type]; | 9317 classA.interfaces = <InterfaceType> [classI2.type]; |
| 8215 JUnitTestCase.assertSame(methodM1, _inheritanceManager.lookupInheritance(cla
ssA, methodName1)); | 9318 JUnitTestCase.assertSame(methodM1, _inheritanceManager.lookupInheritance(cla
ssA, methodName1)); |
| 8216 JUnitTestCase.assertSame(methodM2, _inheritanceManager.lookupInheritance(cla
ssA, methodName2)); | 9319 JUnitTestCase.assertSame(methodM2, _inheritanceManager.lookupInheritance(cla
ssA, methodName2)); |
| 8217 assertNoErrors(classI1); | 9320 assertNoErrors(classI1); |
| 8218 assertNoErrors(classI2); | 9321 assertNoErrors(classI2); |
| 8219 assertNoErrors(classA); | 9322 assertNoErrors(classA); |
| 8220 } | 9323 } |
| 9324 |
| 8221 void test_lookupInheritance_mixin_getter() { | 9325 void test_lookupInheritance_mixin_getter() { |
| 8222 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9326 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8223 String getterName = "g"; | 9327 String getterName = "g"; |
| 8224 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); | 9328 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); |
| 8225 classA.accessors = <PropertyAccessorElement> [getterG]; | 9329 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 8226 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9330 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8227 classB.mixins = <InterfaceType> [classA.type]; | 9331 classB.mixins = <InterfaceType> [classA.type]; |
| 8228 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas
sB, getterName)); | 9332 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas
sB, getterName)); |
| 8229 assertNoErrors(classA); | 9333 assertNoErrors(classA); |
| 8230 assertNoErrors(classB); | 9334 assertNoErrors(classB); |
| 8231 } | 9335 } |
| 9336 |
| 8232 void test_lookupInheritance_mixin_method() { | 9337 void test_lookupInheritance_mixin_method() { |
| 8233 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9338 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8234 String methodName = "m"; | 9339 String methodName = "m"; |
| 8235 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9340 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8236 classA.methods = <MethodElement> [methodM]; | 9341 classA.methods = <MethodElement> [methodM]; |
| 8237 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9342 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8238 classB.mixins = <InterfaceType> [classA.type]; | 9343 classB.mixins = <InterfaceType> [classA.type]; |
| 8239 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas
sB, methodName)); | 9344 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas
sB, methodName)); |
| 8240 assertNoErrors(classA); | 9345 assertNoErrors(classA); |
| 8241 assertNoErrors(classB); | 9346 assertNoErrors(classB); |
| 8242 } | 9347 } |
| 9348 |
| 8243 void test_lookupInheritance_mixin_setter() { | 9349 void test_lookupInheritance_mixin_setter() { |
| 8244 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9350 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8245 String setterName = "s"; | 9351 String setterName = "s"; |
| 8246 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, _typeProvider.intType); | 9352 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, _typeProvider.intType); |
| 8247 classA.accessors = <PropertyAccessorElement> [setterS]; | 9353 classA.accessors = <PropertyAccessorElement> [setterS]; |
| 8248 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9354 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8249 classB.mixins = <InterfaceType> [classA.type]; | 9355 classB.mixins = <InterfaceType> [classA.type]; |
| 8250 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas
sB, "${setterName}=")); | 9356 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas
sB, "${setterName}=")); |
| 8251 assertNoErrors(classA); | 9357 assertNoErrors(classA); |
| 8252 assertNoErrors(classB); | 9358 assertNoErrors(classB); |
| 8253 } | 9359 } |
| 9360 |
| 8254 void test_lookupInheritance_mixin_staticMember() { | 9361 void test_lookupInheritance_mixin_staticMember() { |
| 8255 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9362 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8256 String methodName = "m"; | 9363 String methodName = "m"; |
| 8257 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9364 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8258 ((methodM as MethodElementImpl)).static = true; | 9365 (methodM as MethodElementImpl).static = true; |
| 8259 classA.methods = <MethodElement> [methodM]; | 9366 classA.methods = <MethodElement> [methodM]; |
| 8260 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9367 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8261 classB.mixins = <InterfaceType> [classA.type]; | 9368 classB.mixins = <InterfaceType> [classA.type]; |
| 8262 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho
dName)); | 9369 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho
dName)); |
| 8263 assertNoErrors(classA); | 9370 assertNoErrors(classA); |
| 8264 assertNoErrors(classB); | 9371 assertNoErrors(classB); |
| 8265 } | 9372 } |
| 9373 |
| 8266 void test_lookupInheritance_noMember() { | 9374 void test_lookupInheritance_noMember() { |
| 8267 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9375 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8268 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "a"))
; | 9376 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "a"))
; |
| 8269 assertNoErrors(classA); | 9377 assertNoErrors(classA); |
| 8270 } | 9378 } |
| 9379 |
| 8271 void test_lookupInheritance_superclass_getter() { | 9380 void test_lookupInheritance_superclass_getter() { |
| 8272 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9381 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8273 String getterName = "g"; | 9382 String getterName = "g"; |
| 8274 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); | 9383 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); |
| 8275 classA.accessors = <PropertyAccessorElement> [getterG]; | 9384 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 8276 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 9385 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 8277 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas
sB, getterName)); | 9386 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas
sB, getterName)); |
| 8278 assertNoErrors(classA); | 9387 assertNoErrors(classA); |
| 8279 assertNoErrors(classB); | 9388 assertNoErrors(classB); |
| 8280 } | 9389 } |
| 9390 |
| 8281 void test_lookupInheritance_superclass_infiniteLoop() { | 9391 void test_lookupInheritance_superclass_infiniteLoop() { |
| 8282 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9392 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8283 classA.supertype = classA.type; | 9393 classA.supertype = classA.type; |
| 8284 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name
")); | 9394 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name
")); |
| 8285 assertNoErrors(classA); | 9395 assertNoErrors(classA); |
| 8286 } | 9396 } |
| 9397 |
| 8287 void test_lookupInheritance_superclass_infiniteLoop2() { | 9398 void test_lookupInheritance_superclass_infiniteLoop2() { |
| 8288 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9399 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8289 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 9400 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 8290 classA.supertype = classB.type; | 9401 classA.supertype = classB.type; |
| 8291 classB.supertype = classA.type; | 9402 classB.supertype = classA.type; |
| 8292 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name
")); | 9403 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name
")); |
| 8293 assertNoErrors(classA); | 9404 assertNoErrors(classA); |
| 8294 assertNoErrors(classB); | 9405 assertNoErrors(classB); |
| 8295 } | 9406 } |
| 9407 |
| 8296 void test_lookupInheritance_superclass_method() { | 9408 void test_lookupInheritance_superclass_method() { |
| 8297 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9409 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8298 String methodName = "m"; | 9410 String methodName = "m"; |
| 8299 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9411 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8300 classA.methods = <MethodElement> [methodM]; | 9412 classA.methods = <MethodElement> [methodM]; |
| 8301 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 9413 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 8302 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas
sB, methodName)); | 9414 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas
sB, methodName)); |
| 8303 assertNoErrors(classA); | 9415 assertNoErrors(classA); |
| 8304 assertNoErrors(classB); | 9416 assertNoErrors(classB); |
| 8305 } | 9417 } |
| 9418 |
| 8306 void test_lookupInheritance_superclass_setter() { | 9419 void test_lookupInheritance_superclass_setter() { |
| 8307 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9420 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8308 String setterName = "s"; | 9421 String setterName = "s"; |
| 8309 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, _typeProvider.intType); | 9422 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, _typeProvider.intType); |
| 8310 classA.accessors = <PropertyAccessorElement> [setterS]; | 9423 classA.accessors = <PropertyAccessorElement> [setterS]; |
| 8311 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 9424 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 8312 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas
sB, "${setterName}=")); | 9425 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas
sB, "${setterName}=")); |
| 8313 assertNoErrors(classA); | 9426 assertNoErrors(classA); |
| 8314 assertNoErrors(classB); | 9427 assertNoErrors(classB); |
| 8315 } | 9428 } |
| 9429 |
| 8316 void test_lookupInheritance_superclass_staticMember() { | 9430 void test_lookupInheritance_superclass_staticMember() { |
| 8317 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9431 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8318 String methodName = "m"; | 9432 String methodName = "m"; |
| 8319 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9433 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8320 ((methodM as MethodElementImpl)).static = true; | 9434 (methodM as MethodElementImpl).static = true; |
| 8321 classA.methods = <MethodElement> [methodM]; | 9435 classA.methods = <MethodElement> [methodM]; |
| 8322 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 9436 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 8323 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho
dName)); | 9437 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho
dName)); |
| 8324 assertNoErrors(classA); | 9438 assertNoErrors(classA); |
| 8325 assertNoErrors(classB); | 9439 assertNoErrors(classB); |
| 8326 } | 9440 } |
| 9441 |
| 8327 void test_lookupMember_getter() { | 9442 void test_lookupMember_getter() { |
| 8328 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9443 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8329 String getterName = "g"; | 9444 String getterName = "g"; |
| 8330 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); | 9445 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f
alse, _typeProvider.intType); |
| 8331 classA.accessors = <PropertyAccessorElement> [getterG]; | 9446 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 8332 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupMember(classA, g
etterName)); | 9447 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupMember(classA, g
etterName)); |
| 8333 assertNoErrors(classA); | 9448 assertNoErrors(classA); |
| 8334 } | 9449 } |
| 9450 |
| 8335 void test_lookupMember_getter_static() { | 9451 void test_lookupMember_getter_static() { |
| 8336 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9452 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8337 String getterName = "g"; | 9453 String getterName = "g"; |
| 8338 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, t
rue, _typeProvider.intType); | 9454 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, t
rue, _typeProvider.intType); |
| 8339 classA.accessors = <PropertyAccessorElement> [getterG]; | 9455 classA.accessors = <PropertyAccessorElement> [getterG]; |
| 8340 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, getterName
)); | 9456 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, getterName
)); |
| 8341 assertNoErrors(classA); | 9457 assertNoErrors(classA); |
| 8342 } | 9458 } |
| 9459 |
| 8343 void test_lookupMember_method() { | 9460 void test_lookupMember_method() { |
| 8344 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9461 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8345 String methodName = "m"; | 9462 String methodName = "m"; |
| 8346 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9463 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8347 classA.methods = <MethodElement> [methodM]; | 9464 classA.methods = <MethodElement> [methodM]; |
| 8348 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupMember(classA, m
ethodName)); | 9465 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupMember(classA, m
ethodName)); |
| 8349 assertNoErrors(classA); | 9466 assertNoErrors(classA); |
| 8350 } | 9467 } |
| 9468 |
| 8351 void test_lookupMember_method_static() { | 9469 void test_lookupMember_method_static() { |
| 8352 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9470 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8353 String methodName = "m"; | 9471 String methodName = "m"; |
| 8354 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); | 9472 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid
er.intType, []); |
| 8355 ((methodM as MethodElementImpl)).static = true; | 9473 (methodM as MethodElementImpl).static = true; |
| 8356 classA.methods = <MethodElement> [methodM]; | 9474 classA.methods = <MethodElement> [methodM]; |
| 8357 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, methodName
)); | 9475 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, methodName
)); |
| 8358 assertNoErrors(classA); | 9476 assertNoErrors(classA); |
| 8359 } | 9477 } |
| 9478 |
| 8360 void test_lookupMember_noMember() { | 9479 void test_lookupMember_noMember() { |
| 8361 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9480 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8362 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, "a")); | 9481 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, "a")); |
| 8363 assertNoErrors(classA); | 9482 assertNoErrors(classA); |
| 8364 } | 9483 } |
| 9484 |
| 8365 void test_lookupMember_setter() { | 9485 void test_lookupMember_setter() { |
| 8366 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9486 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8367 String setterName = "s"; | 9487 String setterName = "s"; |
| 8368 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, _typeProvider.intType); | 9488 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f
alse, _typeProvider.intType); |
| 8369 classA.accessors = <PropertyAccessorElement> [setterS]; | 9489 classA.accessors = <PropertyAccessorElement> [setterS]; |
| 8370 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupMember(classA, "
${setterName}=")); | 9490 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupMember(classA, "
${setterName}=")); |
| 8371 assertNoErrors(classA); | 9491 assertNoErrors(classA); |
| 8372 } | 9492 } |
| 9493 |
| 8373 void test_lookupMember_setter_static() { | 9494 void test_lookupMember_setter_static() { |
| 8374 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 9495 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 8375 String setterName = "s"; | 9496 String setterName = "s"; |
| 8376 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, t
rue, _typeProvider.intType); | 9497 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, t
rue, _typeProvider.intType); |
| 8377 classA.accessors = <PropertyAccessorElement> [setterS]; | 9498 classA.accessors = <PropertyAccessorElement> [setterS]; |
| 8378 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, setterName
)); | 9499 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, setterName
)); |
| 8379 assertNoErrors(classA); | 9500 assertNoErrors(classA); |
| 8380 } | 9501 } |
| 9502 |
| 8381 void assertErrors(ClassElement classElt, List<ErrorCode> expectedErrorCodes) { | 9503 void assertErrors(ClassElement classElt, List<ErrorCode> expectedErrorCodes) { |
| 8382 GatheringErrorListener errorListener = new GatheringErrorListener(); | 9504 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 8383 Set<AnalysisError> actualErrors = _inheritanceManager.getErrors(classElt); | 9505 Set<AnalysisError> actualErrors = _inheritanceManager.getErrors(classElt); |
| 8384 if (actualErrors != null) { | 9506 if (actualErrors != null) { |
| 8385 for (AnalysisError error in actualErrors) { | 9507 for (AnalysisError error in actualErrors) { |
| 8386 errorListener.onError(error); | 9508 errorListener.onError(error); |
| 8387 } | 9509 } |
| 8388 } | 9510 } |
| 8389 errorListener.assertErrors2(expectedErrorCodes); | 9511 errorListener.assertErrors2(expectedErrorCodes); |
| 8390 } | 9512 } |
| 9513 |
| 8391 void assertNoErrors(ClassElement classElt) { | 9514 void assertNoErrors(ClassElement classElt) { |
| 8392 assertErrors(classElt, []); | 9515 assertErrors(classElt, []); |
| 8393 } | 9516 } |
| 8394 | 9517 |
| 8395 /** | 9518 /** |
| 8396 * Create the inheritance manager used by the tests. | 9519 * Create the inheritance manager used by the tests. |
| 8397 * | 9520 * |
| 8398 * @return the inheritance manager that was created | 9521 * @return the inheritance manager that was created |
| 8399 */ | 9522 */ |
| 8400 InheritanceManager createInheritanceManager() { | 9523 InheritanceManager createInheritanceManager() { |
| 8401 AnalysisContextImpl context = AnalysisContextFactory.contextWithCore(); | 9524 AnalysisContextImpl context = AnalysisContextFactory.contextWithCore(); |
| 8402 FileBasedSource source = new FileBasedSource.con1(new ContentCache(), FileUt
ilities2.createFile("/test.dart")); | 9525 FileBasedSource source = new FileBasedSource.con1(new ContentCache(), FileUt
ilities2.createFile("/test.dart")); |
| 8403 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem
entImpl("test.dart"); | 9526 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem
entImpl("test.dart"); |
| 8404 definingCompilationUnit.source = source; | 9527 definingCompilationUnit.source = source; |
| 8405 _definingLibrary = ElementFactory.library(context, "test"); | 9528 _definingLibrary = ElementFactory.library(context, "test"); |
| 8406 _definingLibrary.definingCompilationUnit = definingCompilationUnit; | 9529 _definingLibrary.definingCompilationUnit = definingCompilationUnit; |
| 8407 return new InheritanceManager(_definingLibrary); | 9530 return new InheritanceManager(_definingLibrary); |
| 8408 } | 9531 } |
| 9532 |
| 8409 static dartSuite() { | 9533 static dartSuite() { |
| 8410 _ut.group('InheritanceManagerTest', () { | 9534 _ut.group('InheritanceManagerTest', () { |
| 8411 _ut.test('test_getMapOfMembersInheritedFromClasses_accessor_extends', () { | 9535 _ut.test('test_getMapOfMembersInheritedFromClasses_accessor_extends', () { |
| 8412 final __test = new InheritanceManagerTest(); | 9536 final __test = new InheritanceManagerTest(); |
| 8413 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromClasses_acc
essor_extends); | 9537 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromClasses_acc
essor_extends); |
| 8414 }); | 9538 }); |
| 8415 _ut.test('test_getMapOfMembersInheritedFromClasses_accessor_implements', (
) { | 9539 _ut.test('test_getMapOfMembersInheritedFromClasses_accessor_implements', (
) { |
| 8416 final __test = new InheritanceManagerTest(); | 9540 final __test = new InheritanceManagerTest(); |
| 8417 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromClasses_acc
essor_implements); | 9541 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromClasses_acc
essor_implements); |
| 8418 }); | 9542 }); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8564 final __test = new InheritanceManagerTest(); | 9688 final __test = new InheritanceManagerTest(); |
| 8565 runJUnitTest(__test, __test.test_lookupMember_setter); | 9689 runJUnitTest(__test, __test.test_lookupMember_setter); |
| 8566 }); | 9690 }); |
| 8567 _ut.test('test_lookupMember_setter_static', () { | 9691 _ut.test('test_lookupMember_setter_static', () { |
| 8568 final __test = new InheritanceManagerTest(); | 9692 final __test = new InheritanceManagerTest(); |
| 8569 runJUnitTest(__test, __test.test_lookupMember_setter_static); | 9693 runJUnitTest(__test, __test.test_lookupMember_setter_static); |
| 8570 }); | 9694 }); |
| 8571 }); | 9695 }); |
| 8572 } | 9696 } |
| 8573 } | 9697 } |
| 9698 |
| 8574 class CompileTimeErrorCodeTest extends ResolverTestCase { | 9699 class CompileTimeErrorCodeTest extends ResolverTestCase { |
| 8575 void fail_compileTimeConstantRaisesException() { | 9700 void fail_compileTimeConstantRaisesException() { |
| 8576 Source source = addSource(EngineTestCase.createSource([])); | 9701 Source source = addSource(EngineTestCase.createSource([])); |
| 8577 resolve(source); | 9702 resolve(source); |
| 8578 assertErrors(source, [CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCE
PTION]); | 9703 assertErrors(source, [CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCE
PTION]); |
| 8579 verify([source]); | 9704 verify([source]); |
| 8580 } | 9705 } |
| 9706 |
| 8581 void fail_constEvalThrowsException() { | 9707 void fail_constEvalThrowsException() { |
| 8582 Source source = addSource(EngineTestCase.createSource([ | 9708 Source source = addSource(EngineTestCase.createSource([ |
| 8583 "class C {", | 9709 "class C {", |
| 8584 " const C();", | 9710 " const C();", |
| 8585 "}", | 9711 "}", |
| 8586 "f() { return const C(); }"])); | 9712 "f() { return const C(); }"])); |
| 8587 resolve(source); | 9713 resolve(source); |
| 8588 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTIO
N]); | 9714 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTIO
N]); |
| 8589 verify([source]); | 9715 verify([source]); |
| 8590 } | 9716 } |
| 9717 |
| 8591 void fail_mixinDeclaresConstructor() { | 9718 void fail_mixinDeclaresConstructor() { |
| 8592 Source source = addSource(EngineTestCase.createSource([ | 9719 Source source = addSource(EngineTestCase.createSource([ |
| 8593 "class A {", | 9720 "class A {", |
| 8594 " A() {}", | 9721 " A() {}", |
| 8595 "}", | 9722 "}", |
| 8596 "class B extends Object mixin A {}"])); | 9723 "class B extends Object mixin A {}"])); |
| 8597 resolve(source); | 9724 resolve(source); |
| 8598 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); | 9725 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); |
| 8599 verify([source]); | 9726 verify([source]); |
| 8600 } | 9727 } |
| 9728 |
| 8601 void fail_mixinOfNonClass() { | 9729 void fail_mixinOfNonClass() { |
| 8602 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex
tends Object mixin A {}"])); | 9730 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex
tends Object mixin A {}"])); |
| 8603 resolve(source); | 9731 resolve(source); |
| 8604 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); | 9732 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); |
| 8605 verify([source]); | 9733 verify([source]); |
| 8606 } | 9734 } |
| 9735 |
| 8607 void fail_objectCannotExtendAnotherClass() { | 9736 void fail_objectCannotExtendAnotherClass() { |
| 8608 Source source = addSource(EngineTestCase.createSource([])); | 9737 Source source = addSource(EngineTestCase.createSource([])); |
| 8609 resolve(source); | 9738 resolve(source); |
| 8610 assertErrors(source, [CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLAS
S]); | 9739 assertErrors(source, [CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLAS
S]); |
| 8611 verify([source]); | 9740 verify([source]); |
| 8612 } | 9741 } |
| 9742 |
| 8613 void fail_recursiveCompileTimeConstant() { | 9743 void fail_recursiveCompileTimeConstant() { |
| 8614 Source source = addSource(EngineTestCase.createSource([ | 9744 Source source = addSource(EngineTestCase.createSource([ |
| 8615 "class A {", | 9745 "class A {", |
| 8616 " const A();", | 9746 " const A();", |
| 8617 " final m = const A();", | 9747 " final m = const A();", |
| 8618 "}"])); | 9748 "}"])); |
| 8619 resolve(source); | 9749 resolve(source); |
| 8620 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT])
; | 9750 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT])
; |
| 8621 verify([source]); | 9751 verify([source]); |
| 8622 } | 9752 } |
| 9753 |
| 8623 void fail_recursiveCompileTimeConstant_cycle() { | 9754 void fail_recursiveCompileTimeConstant_cycle() { |
| 8624 Source source = addSource(EngineTestCase.createSource(["const x = y + 1;", "
const y = x + 1;"])); | 9755 Source source = addSource(EngineTestCase.createSource(["const x = y + 1;", "
const y = x + 1;"])); |
| 8625 resolve(source); | 9756 resolve(source); |
| 8626 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT])
; | 9757 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT])
; |
| 8627 verify([source]); | 9758 verify([source]); |
| 8628 } | 9759 } |
| 9760 |
| 8629 void fail_superInitializerInObject() { | 9761 void fail_superInitializerInObject() { |
| 8630 Source source = addSource(EngineTestCase.createSource([])); | 9762 Source source = addSource(EngineTestCase.createSource([])); |
| 8631 resolve(source); | 9763 resolve(source); |
| 8632 assertErrors(source, [CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]); | 9764 assertErrors(source, [CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]); |
| 8633 verify([source]); | 9765 verify([source]); |
| 8634 } | 9766 } |
| 9767 |
| 8635 void test_ambiguousExport() { | 9768 void test_ambiguousExport() { |
| 8636 Source source = addSource(EngineTestCase.createSource([ | 9769 Source source = addSource(EngineTestCase.createSource([ |
| 8637 "library L;", | 9770 "library L;", |
| 8638 "export 'lib1.dart';", | 9771 "export 'lib1.dart';", |
| 8639 "export 'lib2.dart';"])); | 9772 "export 'lib2.dart';"])); |
| 8640 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 9773 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 8641 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 9774 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 8642 resolve(source); | 9775 resolve(source); |
| 8643 assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]); | 9776 assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]); |
| 8644 verify([source]); | 9777 verify([source]); |
| 8645 } | 9778 } |
| 9779 |
| 8646 void test_ambiguousImport_function() { | 9780 void test_ambiguousImport_function() { |
| 8647 Source source = addSource(EngineTestCase.createSource([ | 9781 Source source = addSource(EngineTestCase.createSource([ |
| 8648 "import 'lib1.dart';", | 9782 "import 'lib1.dart';", |
| 8649 "import 'lib2.dart';", | 9783 "import 'lib2.dart';", |
| 8650 "g() { return f(); }"])); | 9784 "g() { return f(); }"])); |
| 8651 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "f()
{}"])); | 9785 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "f()
{}"])); |
| 8652 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "f()
{}"])); | 9786 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "f()
{}"])); |
| 8653 resolve(source); | 9787 resolve(source); |
| 8654 assertErrors(source, [ | 9788 assertErrors(source, [ |
| 8655 StaticWarningCode.AMBIGUOUS_IMPORT, | 9789 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 8656 CompileTimeErrorCode.UNDEFINED_FUNCTION]); | 9790 CompileTimeErrorCode.UNDEFINED_FUNCTION]); |
| 8657 } | 9791 } |
| 9792 |
| 8658 void test_argumentDefinitionTestNonParameter() { | 9793 void test_argumentDefinitionTestNonParameter() { |
| 8659 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0;
", " return ?v;", "}"])); | 9794 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0;
", " return ?v;", "}"])); |
| 8660 resolve(source); | 9795 resolve(source); |
| 8661 assertErrors(source, [ | 9796 assertErrors(source, [ |
| 8662 ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST, | 9797 ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST, |
| 8663 CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER]); | 9798 CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER]); |
| 8664 verify([source]); | 9799 verify([source]); |
| 8665 } | 9800 } |
| 9801 |
| 8666 void test_builtInIdentifierAsMixinName_classTypeAlias() { | 9802 void test_builtInIdentifierAsMixinName_classTypeAlias() { |
| 8667 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B {}", "class as = A with B;"])); | 9803 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B {}", "class as = A with B;"])); |
| 8668 resolve(source); | 9804 resolve(source); |
| 8669 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NA
ME]); | 9805 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NA
ME]); |
| 8670 verify([source]); | 9806 verify([source]); |
| 8671 } | 9807 } |
| 9808 |
| 8672 void test_builtInIdentifierAsType_formalParameter_field() { | 9809 void test_builtInIdentifierAsType_formalParameter_field() { |
| 8673 Source source = addSource(EngineTestCase.createSource(["class A {", " var x
;", " A(static this.x);", "}"])); | 9810 Source source = addSource(EngineTestCase.createSource(["class A {", " var x
;", " A(static this.x);", "}"])); |
| 8674 resolve(source); | 9811 resolve(source); |
| 8675 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]); | 9812 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]); |
| 8676 verify([source]); | 9813 verify([source]); |
| 8677 } | 9814 } |
| 9815 |
| 8678 void test_builtInIdentifierAsType_formalParameter_simple() { | 9816 void test_builtInIdentifierAsType_formalParameter_simple() { |
| 8679 Source source = addSource(EngineTestCase.createSource(["f(static x) {", "}"]
)); | 9817 Source source = addSource(EngineTestCase.createSource(["f(static x) {", "}"]
)); |
| 8680 resolve(source); | 9818 resolve(source); |
| 8681 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]); | 9819 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]); |
| 8682 verify([source]); | 9820 verify([source]); |
| 8683 } | 9821 } |
| 9822 |
| 8684 void test_builtInIdentifierAsType_variableDeclaration() { | 9823 void test_builtInIdentifierAsType_variableDeclaration() { |
| 8685 Source source = addSource(EngineTestCase.createSource(["f() {", " typedef x
;", "}"])); | 9824 Source source = addSource(EngineTestCase.createSource(["f() {", " typedef x
;", "}"])); |
| 8686 resolve(source); | 9825 resolve(source); |
| 8687 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]); | 9826 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]); |
| 8688 verify([source]); | 9827 verify([source]); |
| 8689 } | 9828 } |
| 9829 |
| 8690 void test_builtInIdentifierAsTypedefName_functionTypeAlias() { | 9830 void test_builtInIdentifierAsTypedefName_functionTypeAlias() { |
| 8691 Source source = addSource(EngineTestCase.createSource(["typedef bool as();"]
)); | 9831 Source source = addSource(EngineTestCase.createSource(["typedef bool as();"]
)); |
| 8692 resolve(source); | 9832 resolve(source); |
| 8693 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NA
ME]); | 9833 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NA
ME]); |
| 8694 verify([source]); | 9834 verify([source]); |
| 8695 } | 9835 } |
| 9836 |
| 8696 void test_builtInIdentifierAsTypeName() { | 9837 void test_builtInIdentifierAsTypeName() { |
| 8697 Source source = addSource(EngineTestCase.createSource(["class as {}"])); | 9838 Source source = addSource(EngineTestCase.createSource(["class as {}"])); |
| 8698 resolve(source); | 9839 resolve(source); |
| 8699 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]
); | 9840 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]
); |
| 8700 verify([source]); | 9841 verify([source]); |
| 8701 } | 9842 } |
| 9843 |
| 8702 void test_builtInIdentifierAsTypeParameterName() { | 9844 void test_builtInIdentifierAsTypeParameterName() { |
| 8703 Source source = addSource(EngineTestCase.createSource(["class A<as> {}"])); | 9845 Source source = addSource(EngineTestCase.createSource(["class A<as> {}"])); |
| 8704 resolve(source); | 9846 resolve(source); |
| 8705 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAM
ETER_NAME]); | 9847 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAM
ETER_NAME]); |
| 8706 verify([source]); | 9848 verify([source]); |
| 8707 } | 9849 } |
| 9850 |
| 8708 void test_caseExpressionTypeImplementsEquals() { | 9851 void test_caseExpressionTypeImplementsEquals() { |
| 8709 Source source = addSource(EngineTestCase.createSource([ | 9852 Source source = addSource(EngineTestCase.createSource([ |
| 8710 "class IntWrapper {", | 9853 "class IntWrapper {", |
| 8711 " final int value;", | 9854 " final int value;", |
| 8712 " const IntWrapper(this.value);", | 9855 " const IntWrapper(this.value);", |
| 8713 " bool operator ==(IntWrapper x) {", | 9856 " bool operator ==(IntWrapper x) {", |
| 8714 " return value == x.value;", | 9857 " return value == x.value;", |
| 8715 " }", | 9858 " }", |
| 8716 " get hashCode => value;", | 9859 " get hashCode => value;", |
| 8717 "}", | 9860 "}", |
| 8718 "", | 9861 "", |
| 8719 "f(var a) {", | 9862 "f(var a) {", |
| 8720 " switch(a) {", | 9863 " switch(a) {", |
| 8721 " case(const IntWrapper(1)) : return 1;", | 9864 " case(const IntWrapper(1)) : return 1;", |
| 8722 " default: return 0;", | 9865 " default: return 0;", |
| 8723 " }", | 9866 " }", |
| 8724 "}"])); | 9867 "}"])); |
| 8725 resolve(source); | 9868 resolve(source); |
| 8726 assertErrors(source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_E
QUALS]); | 9869 assertErrors(source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_E
QUALS]); |
| 8727 verify([source]); | 9870 verify([source]); |
| 8728 } | 9871 } |
| 9872 |
| 8729 void test_conflictingConstructorNameAndMember_field() { | 9873 void test_conflictingConstructorNameAndMember_field() { |
| 8730 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A.x() {}", "}"])); | 9874 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A.x() {}", "}"])); |
| 8731 resolve(source); | 9875 resolve(source); |
| 8732 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_
FIELD]); | 9876 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_
FIELD]); |
| 8733 verify([source]); | 9877 verify([source]); |
| 8734 } | 9878 } |
| 9879 |
| 8735 void test_conflictingConstructorNameAndMember_method() { | 9880 void test_conflictingConstructorNameAndMember_method() { |
| 8736 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A.x();", " void x() {}", "}"])); | 9881 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A.x();", " void x() {}", "}"])); |
| 8737 resolve(source); | 9882 resolve(source); |
| 8738 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_
METHOD]); | 9883 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_
METHOD]); |
| 8739 verify([source]); | 9884 verify([source]); |
| 8740 } | 9885 } |
| 9886 |
| 8741 void test_conflictingGetterAndMethod_field_method() { | 9887 void test_conflictingGetterAndMethod_field_method() { |
| 8742 Source source = addSource(EngineTestCase.createSource([ | 9888 Source source = addSource(EngineTestCase.createSource([ |
| 8743 "class A {", | 9889 "class A {", |
| 8744 " int m;", | 9890 " final int m = 0;", |
| 8745 "}", | 9891 "}", |
| 8746 "class B extends A {", | 9892 "class B extends A {", |
| 8747 " m() {}", | 9893 " m() {}", |
| 8748 "}"])); | 9894 "}"])); |
| 8749 resolve(source); | 9895 resolve(source); |
| 8750 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]); | 9896 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]); |
| 8751 verify([source]); | 9897 verify([source]); |
| 8752 } | 9898 } |
| 9899 |
| 8753 void test_conflictingGetterAndMethod_getter_method() { | 9900 void test_conflictingGetterAndMethod_getter_method() { |
| 8754 Source source = addSource(EngineTestCase.createSource([ | 9901 Source source = addSource(EngineTestCase.createSource([ |
| 8755 "class A {", | 9902 "class A {", |
| 8756 " get m => 0;", | 9903 " get m => 0;", |
| 8757 "}", | 9904 "}", |
| 8758 "class B extends A {", | 9905 "class B extends A {", |
| 8759 " m() {}", | 9906 " m() {}", |
| 8760 "}"])); | 9907 "}"])); |
| 8761 resolve(source); | 9908 resolve(source); |
| 8762 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]); | 9909 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]); |
| 8763 verify([source]); | 9910 verify([source]); |
| 8764 } | 9911 } |
| 9912 |
| 8765 void test_conflictingGetterAndMethod_method_field() { | 9913 void test_conflictingGetterAndMethod_method_field() { |
| 8766 Source source = addSource(EngineTestCase.createSource([ | 9914 Source source = addSource(EngineTestCase.createSource([ |
| 8767 "class A {", | 9915 "class A {", |
| 8768 " m() {}", | 9916 " m() {}", |
| 8769 "}", | 9917 "}", |
| 8770 "class B extends A {", | 9918 "class B extends A {", |
| 8771 " int m;", | 9919 " int m;", |
| 8772 "}"])); | 9920 "}"])); |
| 8773 resolve(source); | 9921 resolve(source); |
| 8774 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]); | 9922 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]); |
| 8775 verify([source]); | 9923 verify([source]); |
| 8776 } | 9924 } |
| 9925 |
| 8777 void test_conflictingGetterAndMethod_method_getter() { | 9926 void test_conflictingGetterAndMethod_method_getter() { |
| 8778 Source source = addSource(EngineTestCase.createSource([ | 9927 Source source = addSource(EngineTestCase.createSource([ |
| 8779 "class A {", | 9928 "class A {", |
| 8780 " m() {}", | 9929 " m() {}", |
| 8781 "}", | 9930 "}", |
| 8782 "class B extends A {", | 9931 "class B extends A {", |
| 8783 " get m => 0;", | 9932 " get m => 0;", |
| 8784 "}"])); | 9933 "}"])); |
| 8785 resolve(source); | 9934 resolve(source); |
| 8786 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]); | 9935 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]); |
| 8787 verify([source]); | 9936 verify([source]); |
| 8788 } | 9937 } |
| 9938 |
| 8789 void test_conflictingTypeVariableAndClass() { | 9939 void test_conflictingTypeVariableAndClass() { |
| 8790 Source source = addSource(EngineTestCase.createSource(["class T<T> {", "}"])
); | 9940 Source source = addSource(EngineTestCase.createSource(["class T<T> {", "}"])
); |
| 8791 resolve(source); | 9941 resolve(source); |
| 8792 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_CLA
SS]); | 9942 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_CLA
SS]); |
| 8793 verify([source]); | 9943 verify([source]); |
| 8794 } | 9944 } |
| 9945 |
| 8795 void test_conflictingTypeVariableAndMember_field() { | 9946 void test_conflictingTypeVariableAndMember_field() { |
| 8796 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " va
r T;", "}"])); | 9947 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " va
r T;", "}"])); |
| 8797 resolve(source); | 9948 resolve(source); |
| 8798 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM
BER]); | 9949 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM
BER]); |
| 8799 verify([source]); | 9950 verify([source]); |
| 8800 } | 9951 } |
| 9952 |
| 8801 void test_conflictingTypeVariableAndMember_getter() { | 9953 void test_conflictingTypeVariableAndMember_getter() { |
| 8802 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " ge
t T => null;", "}"])); | 9954 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " ge
t T => null;", "}"])); |
| 8803 resolve(source); | 9955 resolve(source); |
| 8804 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM
BER]); | 9956 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM
BER]); |
| 8805 verify([source]); | 9957 verify([source]); |
| 8806 } | 9958 } |
| 9959 |
| 8807 void test_conflictingTypeVariableAndMember_method() { | 9960 void test_conflictingTypeVariableAndMember_method() { |
| 8808 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " T(
) {}", "}"])); | 9961 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " T(
) {}", "}"])); |
| 8809 resolve(source); | 9962 resolve(source); |
| 8810 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM
BER]); | 9963 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM
BER]); |
| 8811 verify([source]); | 9964 verify([source]); |
| 8812 } | 9965 } |
| 9966 |
| 8813 void test_conflictingTypeVariableAndMember_method_static() { | 9967 void test_conflictingTypeVariableAndMember_method_static() { |
| 8814 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " st
atic T() {}", "}"])); | 9968 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " st
atic T() {}", "}"])); |
| 8815 resolve(source); | 9969 resolve(source); |
| 8816 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM
BER]); | 9970 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM
BER]); |
| 8817 verify([source]); | 9971 verify([source]); |
| 8818 } | 9972 } |
| 9973 |
| 8819 void test_conflictingTypeVariableAndMember_setter() { | 9974 void test_conflictingTypeVariableAndMember_setter() { |
| 8820 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " se
t T(x) {}", "}"])); | 9975 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " se
t T(x) {}", "}"])); |
| 8821 resolve(source); | 9976 resolve(source); |
| 8822 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM
BER]); | 9977 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM
BER]); |
| 8823 verify([source]); | 9978 verify([source]); |
| 8824 } | 9979 } |
| 9980 |
| 8825 void test_constConstructorWithNonConstSuper_explicit() { | 9981 void test_constConstructorWithNonConstSuper_explicit() { |
| 8826 Source source = addSource(EngineTestCase.createSource([ | 9982 Source source = addSource(EngineTestCase.createSource([ |
| 8827 "class A {", | 9983 "class A {", |
| 8828 " A();", | 9984 " A();", |
| 8829 "}", | 9985 "}", |
| 8830 "class B extends A {", | 9986 "class B extends A {", |
| 8831 " const B(): super();", | 9987 " const B(): super();", |
| 8832 "}"])); | 9988 "}"])); |
| 8833 resolve(source); | 9989 resolve(source); |
| 8834 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_
SUPER]); | 9990 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_
SUPER]); |
| 8835 verify([source]); | 9991 verify([source]); |
| 8836 } | 9992 } |
| 9993 |
| 8837 void test_constConstructorWithNonConstSuper_implicit() { | 9994 void test_constConstructorWithNonConstSuper_implicit() { |
| 8838 Source source = addSource(EngineTestCase.createSource([ | 9995 Source source = addSource(EngineTestCase.createSource([ |
| 8839 "class A {", | 9996 "class A {", |
| 8840 " A();", | 9997 " A();", |
| 8841 "}", | 9998 "}", |
| 8842 "class B extends A {", | 9999 "class B extends A {", |
| 8843 " const B();", | 10000 " const B();", |
| 8844 "}"])); | 10001 "}"])); |
| 8845 resolve(source); | 10002 resolve(source); |
| 8846 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_
SUPER]); | 10003 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_
SUPER]); |
| 8847 verify([source]); | 10004 verify([source]); |
| 8848 } | 10005 } |
| 10006 |
| 8849 void test_constConstructorWithNonFinalField_mixin() { | 10007 void test_constConstructorWithNonFinalField_mixin() { |
| 8850 Source source = addSource(EngineTestCase.createSource([ | 10008 Source source = addSource(EngineTestCase.createSource([ |
| 8851 "class A {", | 10009 "class A {", |
| 8852 " var a;", | 10010 " var a;", |
| 8853 "}", | 10011 "}", |
| 8854 "class B extends Object with A {", | 10012 "class B extends Object with A {", |
| 8855 " const B();", | 10013 " const B();", |
| 8856 "}"])); | 10014 "}"])); |
| 8857 resolve(source); | 10015 resolve(source); |
| 8858 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_
FIELD]); | 10016 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_
FIELD]); |
| 8859 verify([source]); | 10017 verify([source]); |
| 8860 } | 10018 } |
| 10019 |
| 8861 void test_constConstructorWithNonFinalField_super() { | 10020 void test_constConstructorWithNonFinalField_super() { |
| 8862 Source source = addSource(EngineTestCase.createSource([ | 10021 Source source = addSource(EngineTestCase.createSource([ |
| 8863 "class A {", | 10022 "class A {", |
| 8864 " var a;", | 10023 " var a;", |
| 8865 "}", | 10024 "}", |
| 8866 "class B extends A {", | 10025 "class B extends A {", |
| 8867 " const B();", | 10026 " const B();", |
| 8868 "}"])); | 10027 "}"])); |
| 8869 resolve(source); | 10028 resolve(source); |
| 8870 assertErrors(source, [ | 10029 assertErrors(source, [ |
| 8871 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD, | 10030 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD, |
| 8872 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]); | 10031 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]); |
| 8873 verify([source]); | 10032 verify([source]); |
| 8874 } | 10033 } |
| 10034 |
| 8875 void test_constConstructorWithNonFinalField_this() { | 10035 void test_constConstructorWithNonFinalField_this() { |
| 8876 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " const A();", "}"])); | 10036 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " const A();", "}"])); |
| 8877 resolve(source); | 10037 resolve(source); |
| 8878 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_
FIELD]); | 10038 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_
FIELD]); |
| 8879 verify([source]); | 10039 verify([source]); |
| 8880 } | 10040 } |
| 10041 |
| 8881 void test_constEval_newInstance_constConstructor() { | 10042 void test_constEval_newInstance_constConstructor() { |
| 8882 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A();", "}", "const a = new A();"])); | 10043 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A();", "}", "const a = new A();"])); |
| 8883 resolve(source); | 10044 resolve(source); |
| 8884 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); | 10045 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); |
| 8885 verify([source]); | 10046 verify([source]); |
| 8886 } | 10047 } |
| 10048 |
| 8887 void test_constEval_propertyExtraction_targetNotConst() { | 10049 void test_constEval_propertyExtraction_targetNotConst() { |
| 8888 Source source = addSource(EngineTestCase.createSource([ | 10050 Source source = addSource(EngineTestCase.createSource([ |
| 8889 "class A {", | 10051 "class A {", |
| 8890 " const A();", | 10052 " const A();", |
| 8891 " m() {}", | 10053 " m() {}", |
| 8892 "}", | 10054 "}", |
| 8893 "final a = const A();", | 10055 "final a = const A();", |
| 8894 "const C = a.m;"])); | 10056 "const C = a.m;"])); |
| 8895 resolve(source); | 10057 resolve(source); |
| 8896 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); | 10058 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); |
| 8897 verify([source]); | 10059 verify([source]); |
| 8898 } | 10060 } |
| 10061 |
| 8899 void test_constEvalThrowsException_binaryMinus_null() { | 10062 void test_constEvalThrowsException_binaryMinus_null() { |
| 8900 check_constEvalThrowsException_binary_null("null - 5", false); | 10063 check_constEvalThrowsException_binary_null("null - 5", false); |
| 8901 check_constEvalThrowsException_binary_null("5 - null", true); | 10064 check_constEvalThrowsException_binary_null("5 - null", true); |
| 8902 } | 10065 } |
| 10066 |
| 8903 void test_constEvalThrowsException_binaryPlus_null() { | 10067 void test_constEvalThrowsException_binaryPlus_null() { |
| 8904 check_constEvalThrowsException_binary_null("null + 5", false); | 10068 check_constEvalThrowsException_binary_null("null + 5", false); |
| 8905 check_constEvalThrowsException_binary_null("5 + null", true); | 10069 check_constEvalThrowsException_binary_null("5 + null", true); |
| 8906 } | 10070 } |
| 10071 |
| 8907 void test_constEvalThrowsException_divisionByZero() { | 10072 void test_constEvalThrowsException_divisionByZero() { |
| 8908 Source source = addSource("const C = 1 ~/ 0;"); | 10073 Source source = addSource("const C = 1 ~/ 0;"); |
| 8909 resolve(source); | 10074 resolve(source); |
| 8910 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE]); | 10075 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE]); |
| 8911 verify([source]); | 10076 verify([source]); |
| 8912 } | 10077 } |
| 10078 |
| 8913 void test_constEvalThrowsException_unaryBitNot_null() { | 10079 void test_constEvalThrowsException_unaryBitNot_null() { |
| 8914 Source source = addSource("const C = ~null;"); | 10080 Source source = addSource("const C = ~null;"); |
| 8915 resolve(source); | 10081 resolve(source); |
| 8916 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); | 10082 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); |
| 8917 } | 10083 } |
| 10084 |
| 8918 void test_constEvalThrowsException_unaryNegated_null() { | 10085 void test_constEvalThrowsException_unaryNegated_null() { |
| 8919 Source source = addSource("const C = -null;"); | 10086 Source source = addSource("const C = -null;"); |
| 8920 resolve(source); | 10087 resolve(source); |
| 8921 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); | 10088 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); |
| 8922 } | 10089 } |
| 10090 |
| 8923 void test_constEvalThrowsException_unaryNot_null() { | 10091 void test_constEvalThrowsException_unaryNot_null() { |
| 8924 Source source = addSource("const C = !null;"); | 10092 Source source = addSource("const C = !null;"); |
| 8925 resolve(source); | 10093 resolve(source); |
| 8926 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); | 10094 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); |
| 8927 verify([source]); | 10095 verify([source]); |
| 8928 } | 10096 } |
| 10097 |
| 8929 void test_constEvalTypeBool_binary() { | 10098 void test_constEvalTypeBool_binary() { |
| 8930 check_constEvalTypeBool_withParameter_binary("p && ''"); | 10099 check_constEvalTypeBool_withParameter_binary("p && ''"); |
| 8931 check_constEvalTypeBool_withParameter_binary("p || ''"); | 10100 check_constEvalTypeBool_withParameter_binary("p || ''"); |
| 8932 } | 10101 } |
| 10102 |
| 8933 void test_constEvalTypeBool_binary_leftTrue() { | 10103 void test_constEvalTypeBool_binary_leftTrue() { |
| 8934 Source source = addSource("const C = (true || 0);"); | 10104 Source source = addSource("const C = (true || 0);"); |
| 8935 resolve(source); | 10105 resolve(source); |
| 8936 assertErrors(source, [ | 10106 assertErrors(source, [ |
| 8937 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, | 10107 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, |
| 8938 HintCode.DEAD_CODE]); | 10108 HintCode.DEAD_CODE]); |
| 8939 verify([source]); | 10109 verify([source]); |
| 8940 } | 10110 } |
| 10111 |
| 8941 void test_constEvalTypeBoolNumString_equal() { | 10112 void test_constEvalTypeBoolNumString_equal() { |
| 8942 Source source = addSource(EngineTestCase.createSource([ | 10113 Source source = addSource(EngineTestCase.createSource([ |
| 8943 "class A {", | 10114 "class A {", |
| 8944 " const A();", | 10115 " const A();", |
| 8945 "}", | 10116 "}", |
| 8946 "class B {", | 10117 "class B {", |
| 8947 " final a;", | 10118 " final a;", |
| 8948 " const B(num p) : a = p == const A();", | 10119 " const B(num p) : a = p == const A();", |
| 8949 "}"])); | 10120 "}"])); |
| 8950 resolve(source); | 10121 resolve(source); |
| 8951 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING])
; | 10122 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING])
; |
| 8952 verify([source]); | 10123 verify([source]); |
| 8953 } | 10124 } |
| 10125 |
| 8954 void test_constEvalTypeBoolNumString_notEqual() { | 10126 void test_constEvalTypeBoolNumString_notEqual() { |
| 8955 Source source = addSource(EngineTestCase.createSource([ | 10127 Source source = addSource(EngineTestCase.createSource([ |
| 8956 "class A {", | 10128 "class A {", |
| 8957 " const A();", | 10129 " const A();", |
| 8958 "}", | 10130 "}", |
| 8959 "class B {", | 10131 "class B {", |
| 8960 " final a;", | 10132 " final a;", |
| 8961 " const B(String p) : a = p != const A();", | 10133 " const B(String p) : a = p != const A();", |
| 8962 "}"])); | 10134 "}"])); |
| 8963 resolve(source); | 10135 resolve(source); |
| 8964 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING])
; | 10136 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING])
; |
| 8965 verify([source]); | 10137 verify([source]); |
| 8966 } | 10138 } |
| 10139 |
| 8967 void test_constEvalTypeInt_binary() { | 10140 void test_constEvalTypeInt_binary() { |
| 8968 check_constEvalTypeInt_withParameter_binary("p ^ ''"); | 10141 check_constEvalTypeInt_withParameter_binary("p ^ ''"); |
| 8969 check_constEvalTypeInt_withParameter_binary("p & ''"); | 10142 check_constEvalTypeInt_withParameter_binary("p & ''"); |
| 8970 check_constEvalTypeInt_withParameter_binary("p | ''"); | 10143 check_constEvalTypeInt_withParameter_binary("p | ''"); |
| 8971 check_constEvalTypeInt_withParameter_binary("p >> ''"); | 10144 check_constEvalTypeInt_withParameter_binary("p >> ''"); |
| 8972 check_constEvalTypeInt_withParameter_binary("p << ''"); | 10145 check_constEvalTypeInt_withParameter_binary("p << ''"); |
| 8973 } | 10146 } |
| 10147 |
| 8974 void test_constEvalTypeNum_binary() { | 10148 void test_constEvalTypeNum_binary() { |
| 8975 check_constEvalTypeNum_withParameter_binary("p + ''"); | 10149 check_constEvalTypeNum_withParameter_binary("p + ''"); |
| 8976 check_constEvalTypeNum_withParameter_binary("p - ''"); | 10150 check_constEvalTypeNum_withParameter_binary("p - ''"); |
| 8977 check_constEvalTypeNum_withParameter_binary("p * ''"); | 10151 check_constEvalTypeNum_withParameter_binary("p * ''"); |
| 8978 check_constEvalTypeNum_withParameter_binary("p / ''"); | 10152 check_constEvalTypeNum_withParameter_binary("p / ''"); |
| 8979 check_constEvalTypeNum_withParameter_binary("p ~/ ''"); | 10153 check_constEvalTypeNum_withParameter_binary("p ~/ ''"); |
| 8980 check_constEvalTypeNum_withParameter_binary("p > ''"); | 10154 check_constEvalTypeNum_withParameter_binary("p > ''"); |
| 8981 check_constEvalTypeNum_withParameter_binary("p < ''"); | 10155 check_constEvalTypeNum_withParameter_binary("p < ''"); |
| 8982 check_constEvalTypeNum_withParameter_binary("p >= ''"); | 10156 check_constEvalTypeNum_withParameter_binary("p >= ''"); |
| 8983 check_constEvalTypeNum_withParameter_binary("p <= ''"); | 10157 check_constEvalTypeNum_withParameter_binary("p <= ''"); |
| 8984 check_constEvalTypeNum_withParameter_binary("p % ''"); | 10158 check_constEvalTypeNum_withParameter_binary("p % ''"); |
| 8985 } | 10159 } |
| 10160 |
| 8986 void test_constEvalTypeNum_plus_String() { | 10161 void test_constEvalTypeNum_plus_String() { |
| 8987 Source source = addSource("const C = 'a' + 'b';"); | 10162 Source source = addSource("const C = 'a' + 'b';"); |
| 8988 resolve(source); | 10163 resolve(source); |
| 8989 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_NUM]); | 10164 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_NUM]); |
| 8990 verify([source]); | 10165 verify([source]); |
| 8991 } | 10166 } |
| 10167 |
| 8992 void test_constFormalParameter_fieldFormalParameter() { | 10168 void test_constFormalParameter_fieldFormalParameter() { |
| 8993 Source source = addSource(EngineTestCase.createSource(["class A {", " var x
;", " A(const this.x) {}", "}"])); | 10169 Source source = addSource(EngineTestCase.createSource(["class A {", " var x
;", " A(const this.x) {}", "}"])); |
| 8994 resolve(source); | 10170 resolve(source); |
| 8995 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); | 10171 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); |
| 8996 verify([source]); | 10172 verify([source]); |
| 8997 } | 10173 } |
| 10174 |
| 8998 void test_constFormalParameter_simpleFormalParameter() { | 10175 void test_constFormalParameter_simpleFormalParameter() { |
| 8999 Source source = addSource(EngineTestCase.createSource(["f(const x) {}"])); | 10176 Source source = addSource(EngineTestCase.createSource(["f(const x) {}"])); |
| 9000 resolve(source); | 10177 resolve(source); |
| 9001 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); | 10178 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); |
| 9002 verify([source]); | 10179 verify([source]); |
| 9003 } | 10180 } |
| 10181 |
| 9004 void test_constInitializedWithNonConstValue() { | 10182 void test_constInitializedWithNonConstValue() { |
| 9005 Source source = addSource(EngineTestCase.createSource(["f(p) {", " const C
= p;", "}"])); | 10183 Source source = addSource(EngineTestCase.createSource(["f(p) {", " const C
= p;", "}"])); |
| 9006 resolve(source); | 10184 resolve(source); |
| 9007 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); | 10185 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); |
| 9008 verify([source]); | 10186 verify([source]); |
| 9009 } | 10187 } |
| 10188 |
| 9010 void test_constInitializedWithNonConstValue_missingConstInListLiteral() { | 10189 void test_constInitializedWithNonConstValue_missingConstInListLiteral() { |
| 9011 Source source = addSource("const List L = [0];"); | 10190 Source source = addSource("const List L = [0];"); |
| 9012 resolve(source); | 10191 resolve(source); |
| 9013 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); | 10192 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); |
| 9014 verify([source]); | 10193 verify([source]); |
| 9015 } | 10194 } |
| 10195 |
| 9016 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() { | 10196 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() { |
| 9017 Source source = addSource("const Map M = {'a' : 0};"); | 10197 Source source = addSource("const Map M = {'a' : 0};"); |
| 9018 resolve(source); | 10198 resolve(source); |
| 9019 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); | 10199 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); |
| 9020 verify([source]); | 10200 verify([source]); |
| 9021 } | 10201 } |
| 10202 |
| 9022 void test_constInstanceField() { | 10203 void test_constInstanceField() { |
| 9023 Source source = addSource(EngineTestCase.createSource(["class C {", " const
int f = 0;", "}"])); | 10204 Source source = addSource(EngineTestCase.createSource(["class C {", " const
int f = 0;", "}"])); |
| 9024 resolve(source); | 10205 resolve(source); |
| 9025 assertErrors(source, [CompileTimeErrorCode.CONST_INSTANCE_FIELD]); | 10206 assertErrors(source, [CompileTimeErrorCode.CONST_INSTANCE_FIELD]); |
| 9026 verify([source]); | 10207 verify([source]); |
| 9027 } | 10208 } |
| 10209 |
| 9028 void test_constMapKeyTypeImplementsEquals_direct() { | 10210 void test_constMapKeyTypeImplementsEquals_direct() { |
| 9029 Source source = addSource(EngineTestCase.createSource([ | 10211 Source source = addSource(EngineTestCase.createSource([ |
| 9030 "class A {", | 10212 "class A {", |
| 9031 " const A();", | 10213 " const A();", |
| 9032 " operator ==(other) => false;", | 10214 " operator ==(other) => false;", |
| 9033 "}", | 10215 "}", |
| 9034 "main() {", | 10216 "main() {", |
| 9035 " const {const A() : 0};", | 10217 " const {const A() : 0};", |
| 9036 "}"])); | 10218 "}"])); |
| 9037 resolve(source); | 10219 resolve(source); |
| 9038 assertErrors(source, [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMP
LEMENTS_EQUALS]); | 10220 assertErrors(source, [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMP
LEMENTS_EQUALS]); |
| 9039 verify([source]); | 10221 verify([source]); |
| 9040 } | 10222 } |
| 10223 |
| 9041 void test_constMapKeyTypeImplementsEquals_super() { | 10224 void test_constMapKeyTypeImplementsEquals_super() { |
| 9042 Source source = addSource(EngineTestCase.createSource([ | 10225 Source source = addSource(EngineTestCase.createSource([ |
| 9043 "class A {", | 10226 "class A {", |
| 9044 " const A();", | 10227 " const A();", |
| 9045 " operator ==(other) => false;", | 10228 " operator ==(other) => false;", |
| 9046 "}", | 10229 "}", |
| 9047 "class B extends A {", | 10230 "class B extends A {", |
| 9048 " const B();", | 10231 " const B();", |
| 9049 "}", | 10232 "}", |
| 9050 "main() {", | 10233 "main() {", |
| 9051 " const {const B() : 0};", | 10234 " const {const B() : 0};", |
| 9052 "}"])); | 10235 "}"])); |
| 9053 resolve(source); | 10236 resolve(source); |
| 9054 assertErrors(source, [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMP
LEMENTS_EQUALS]); | 10237 assertErrors(source, [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMP
LEMENTS_EQUALS]); |
| 9055 verify([source]); | 10238 verify([source]); |
| 9056 } | 10239 } |
| 10240 |
| 9057 void test_constWithInvalidTypeParameters() { | 10241 void test_constWithInvalidTypeParameters() { |
| 9058 Source source = addSource(EngineTestCase.createSource([ | 10242 Source source = addSource(EngineTestCase.createSource([ |
| 9059 "class A {", | 10243 "class A {", |
| 9060 " const A();", | 10244 " const A();", |
| 9061 "}", | 10245 "}", |
| 9062 "f() { return const A<A>(); }"])); | 10246 "f() { return const A<A>(); }"])); |
| 9063 resolve(source); | 10247 resolve(source); |
| 9064 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER
S]); | 10248 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER
S]); |
| 9065 verify([source]); | 10249 verify([source]); |
| 9066 } | 10250 } |
| 10251 |
| 9067 void test_constWithInvalidTypeParameters_tooFew() { | 10252 void test_constWithInvalidTypeParameters_tooFew() { |
| 9068 Source source = addSource(EngineTestCase.createSource([ | 10253 Source source = addSource(EngineTestCase.createSource([ |
| 9069 "class A {}", | 10254 "class A {}", |
| 9070 "class C<K, V> {", | 10255 "class C<K, V> {", |
| 9071 " const C();", | 10256 " const C();", |
| 9072 "}", | 10257 "}", |
| 9073 "f(p) {", | 10258 "f(p) {", |
| 9074 " return const C<A>();", | 10259 " return const C<A>();", |
| 9075 "}"])); | 10260 "}"])); |
| 9076 resolve(source); | 10261 resolve(source); |
| 9077 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER
S]); | 10262 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER
S]); |
| 9078 verify([source]); | 10263 verify([source]); |
| 9079 } | 10264 } |
| 10265 |
| 9080 void test_constWithInvalidTypeParameters_tooMany() { | 10266 void test_constWithInvalidTypeParameters_tooMany() { |
| 9081 Source source = addSource(EngineTestCase.createSource([ | 10267 Source source = addSource(EngineTestCase.createSource([ |
| 9082 "class A {}", | 10268 "class A {}", |
| 9083 "class C<E> {", | 10269 "class C<E> {", |
| 9084 " const C();", | 10270 " const C();", |
| 9085 "}", | 10271 "}", |
| 9086 "f(p) {", | 10272 "f(p) {", |
| 9087 " return const C<A, A>();", | 10273 " return const C<A, A>();", |
| 9088 "}"])); | 10274 "}"])); |
| 9089 resolve(source); | 10275 resolve(source); |
| 9090 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER
S]); | 10276 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER
S]); |
| 9091 verify([source]); | 10277 verify([source]); |
| 9092 } | 10278 } |
| 10279 |
| 9093 void test_constWithNonConst() { | 10280 void test_constWithNonConst() { |
| 9094 Source source = addSource(EngineTestCase.createSource([ | 10281 Source source = addSource(EngineTestCase.createSource([ |
| 9095 "class T {", | 10282 "class T {", |
| 9096 " T(a, b, {c, d}) {}", | 10283 " T(a, b, {c, d}) {}", |
| 9097 "}", | 10284 "}", |
| 9098 "f() { return const T(0, 1, c: 2, d: 3); }"])); | 10285 "f() { return const T(0, 1, c: 2, d: 3); }"])); |
| 9099 resolve(source); | 10286 resolve(source); |
| 9100 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]); | 10287 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]); |
| 9101 verify([source]); | 10288 verify([source]); |
| 9102 } | 10289 } |
| 10290 |
| 9103 void test_constWithNonConstantArgument_annotation() { | 10291 void test_constWithNonConstantArgument_annotation() { |
| 9104 Source source = addSource(EngineTestCase.createSource([ | 10292 Source source = addSource(EngineTestCase.createSource([ |
| 9105 "class A {", | 10293 "class A {", |
| 9106 " const A(int p);", | 10294 " const A(int p);", |
| 9107 "}", | 10295 "}", |
| 9108 "var v = 42;", | 10296 "var v = 42;", |
| 9109 "@A(v)", | 10297 "@A(v)", |
| 9110 "main() {", | 10298 "main() {", |
| 9111 "}"])); | 10299 "}"])); |
| 9112 resolve(source); | 10300 resolve(source); |
| 9113 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]
); | 10301 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]
); |
| 9114 verify([source]); | 10302 verify([source]); |
| 9115 } | 10303 } |
| 10304 |
| 9116 void test_constWithNonConstantArgument_instanceCreation() { | 10305 void test_constWithNonConstantArgument_instanceCreation() { |
| 9117 Source source = addSource(EngineTestCase.createSource([ | 10306 Source source = addSource(EngineTestCase.createSource([ |
| 9118 "class A {", | 10307 "class A {", |
| 9119 " const A(a);", | 10308 " const A(a);", |
| 9120 "}", | 10309 "}", |
| 9121 "f(p) { return const A(p); }"])); | 10310 "f(p) { return const A(p); }"])); |
| 9122 resolve(source); | 10311 resolve(source); |
| 9123 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]
); | 10312 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]
); |
| 9124 verify([source]); | 10313 verify([source]); |
| 9125 } | 10314 } |
| 10315 |
| 9126 void test_constWithNonType() { | 10316 void test_constWithNonType() { |
| 9127 Source source = addSource(EngineTestCase.createSource(["int A;", "f() {", "
return const A();", "}"])); | 10317 Source source = addSource(EngineTestCase.createSource(["int A;", "f() {", "
return const A();", "}"])); |
| 9128 resolve(source); | 10318 resolve(source); |
| 9129 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); | 10319 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); |
| 9130 verify([source]); | 10320 verify([source]); |
| 9131 } | 10321 } |
| 10322 |
| 9132 void test_constWithNonType_fromLibrary() { | 10323 void test_constWithNonType_fromLibrary() { |
| 9133 Source source1 = addSource2("lib.dart", ""); | 10324 Source source1 = addSource2("lib.dart", ""); |
| 9134 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ | 10325 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ |
| 9135 "import 'lib.dart' as lib;", | 10326 "import 'lib.dart' as lib;", |
| 9136 "void f() {", | 10327 "void f() {", |
| 9137 " const lib.A();", | 10328 " const lib.A();", |
| 9138 "}"])); | 10329 "}"])); |
| 9139 resolve(source1); | 10330 resolve(source1); |
| 9140 resolve(source2); | 10331 resolve(source2); |
| 9141 assertErrors(source2, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); | 10332 assertErrors(source2, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); |
| 9142 verify([source1]); | 10333 verify([source1]); |
| 9143 } | 10334 } |
| 10335 |
| 9144 void test_constWithTypeParameters_direct() { | 10336 void test_constWithTypeParameters_direct() { |
| 9145 Source source = addSource(EngineTestCase.createSource([ | 10337 Source source = addSource(EngineTestCase.createSource([ |
| 9146 "class A<T> {", | 10338 "class A<T> {", |
| 9147 " static const V = const A<T>();", | 10339 " static const V = const A<T>();", |
| 9148 " const A();", | 10340 " const A();", |
| 9149 "}"])); | 10341 "}"])); |
| 9150 resolve(source); | 10342 resolve(source); |
| 9151 assertErrors(source, [ | 10343 assertErrors(source, [ |
| 9152 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, | 10344 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, |
| 9153 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 10345 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); |
| 9154 verify([source]); | 10346 verify([source]); |
| 9155 } | 10347 } |
| 10348 |
| 9156 void test_constWithTypeParameters_indirect() { | 10349 void test_constWithTypeParameters_indirect() { |
| 9157 Source source = addSource(EngineTestCase.createSource([ | 10350 Source source = addSource(EngineTestCase.createSource([ |
| 9158 "class A<T> {", | 10351 "class A<T> {", |
| 9159 " static const V = const A<List<T>>();", | 10352 " static const V = const A<List<T>>();", |
| 9160 " const A();", | 10353 " const A();", |
| 9161 "}"])); | 10354 "}"])); |
| 9162 resolve(source); | 10355 resolve(source); |
| 9163 assertErrors(source, [ | 10356 assertErrors(source, [ |
| 9164 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, | 10357 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, |
| 9165 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 10358 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); |
| 9166 verify([source]); | 10359 verify([source]); |
| 9167 } | 10360 } |
| 10361 |
| 9168 void test_constWithUndefinedConstructor() { | 10362 void test_constWithUndefinedConstructor() { |
| 9169 Source source = addSource(EngineTestCase.createSource([ | 10363 Source source = addSource(EngineTestCase.createSource([ |
| 9170 "class A {", | 10364 "class A {", |
| 9171 " const A();", | 10365 " const A();", |
| 9172 "}", | 10366 "}", |
| 9173 "f() {", | 10367 "f() {", |
| 9174 " return const A.noSuchConstructor();", | 10368 " return const A.noSuchConstructor();", |
| 9175 "}"])); | 10369 "}"])); |
| 9176 resolve(source); | 10370 resolve(source); |
| 9177 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]
); | 10371 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]
); |
| 9178 } | 10372 } |
| 10373 |
| 9179 void test_constWithUndefinedConstructorDefault() { | 10374 void test_constWithUndefinedConstructorDefault() { |
| 9180 Source source = addSource(EngineTestCase.createSource([ | 10375 Source source = addSource(EngineTestCase.createSource([ |
| 9181 "class A {", | 10376 "class A {", |
| 9182 " const A.name();", | 10377 " const A.name();", |
| 9183 "}", | 10378 "}", |
| 9184 "f() {", | 10379 "f() {", |
| 9185 " return const A();", | 10380 " return const A();", |
| 9186 "}"])); | 10381 "}"])); |
| 9187 resolve(source); | 10382 resolve(source); |
| 9188 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_
DEFAULT]); | 10383 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_
DEFAULT]); |
| 9189 verify([source]); | 10384 verify([source]); |
| 9190 } | 10385 } |
| 10386 |
| 9191 void test_defaultValueInFunctionTypeAlias() { | 10387 void test_defaultValueInFunctionTypeAlias() { |
| 9192 Source source = addSource(EngineTestCase.createSource(["typedef F([x = 0]);"
])); | 10388 Source source = addSource(EngineTestCase.createSource(["typedef F([x = 0]);"
])); |
| 9193 resolve(source); | 10389 resolve(source); |
| 9194 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_AL
IAS]); | 10390 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_AL
IAS]); |
| 9195 verify([source]); | 10391 verify([source]); |
| 9196 } | 10392 } |
| 10393 |
| 9197 void test_defaultValueInFunctionTypedParameter_named() { | 10394 void test_defaultValueInFunctionTypedParameter_named() { |
| 9198 Source source = addSource(EngineTestCase.createSource(["f(g({p: null})) {}"]
)); | 10395 Source source = addSource(EngineTestCase.createSource(["f(g({p: null})) {}"]
)); |
| 9199 resolve(source); | 10396 resolve(source); |
| 9200 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_P
ARAMETER]); | 10397 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_P
ARAMETER]); |
| 9201 verify([source]); | 10398 verify([source]); |
| 9202 } | 10399 } |
| 10400 |
| 9203 void test_defaultValueInFunctionTypedParameter_optional() { | 10401 void test_defaultValueInFunctionTypedParameter_optional() { |
| 9204 Source source = addSource(EngineTestCase.createSource(["f(g([p = null])) {}"
])); | 10402 Source source = addSource(EngineTestCase.createSource(["f(g([p = null])) {}"
])); |
| 9205 resolve(source); | 10403 resolve(source); |
| 9206 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_P
ARAMETER]); | 10404 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_P
ARAMETER]); |
| 9207 verify([source]); | 10405 verify([source]); |
| 9208 } | 10406 } |
| 10407 |
| 9209 void test_defaultValueInRedirectingFactoryConstructor() { | 10408 void test_defaultValueInRedirectingFactoryConstructor() { |
| 9210 Source source = addSource(EngineTestCase.createSource([ | 10409 Source source = addSource(EngineTestCase.createSource([ |
| 9211 "class A {", | 10410 "class A {", |
| 9212 " factory A([int x = 0]) = B;", | 10411 " factory A([int x = 0]) = B;", |
| 9213 "}", | 10412 "}", |
| 9214 "", | 10413 "", |
| 9215 "class B implements A {", | 10414 "class B implements A {", |
| 9216 " B([int x = 1]) {}", | 10415 " B([int x = 1]) {}", |
| 9217 "}"])); | 10416 "}"])); |
| 9218 resolve(source); | 10417 resolve(source); |
| 9219 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_REDIRECTING_FACT
ORY_CONSTRUCTOR]); | 10418 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_REDIRECTING_FACT
ORY_CONSTRUCTOR]); |
| 9220 verify([source]); | 10419 verify([source]); |
| 9221 } | 10420 } |
| 10421 |
| 9222 void test_duplicateConstructorName_named() { | 10422 void test_duplicateConstructorName_named() { |
| 9223 Source source = addSource(EngineTestCase.createSource(["class A {", " A.a()
{}", " A.a() {}", "}"])); | 10423 Source source = addSource(EngineTestCase.createSource(["class A {", " A.a()
{}", " A.a() {}", "}"])); |
| 9224 resolve(source); | 10424 resolve(source); |
| 9225 assertErrors(source, [ | 10425 assertErrors(source, [ |
| 9226 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, | 10426 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, |
| 9227 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME]); | 10427 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME]); |
| 9228 verify([source]); | 10428 verify([source]); |
| 9229 } | 10429 } |
| 10430 |
| 9230 void test_duplicateConstructorName_unnamed() { | 10431 void test_duplicateConstructorName_unnamed() { |
| 9231 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", " A() {}", "}"])); | 10432 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", " A() {}", "}"])); |
| 9232 resolve(source); | 10433 resolve(source); |
| 9233 assertErrors(source, [ | 10434 assertErrors(source, [ |
| 9234 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, | 10435 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, |
| 9235 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT]); | 10436 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT]); |
| 9236 verify([source]); | 10437 verify([source]); |
| 9237 } | 10438 } |
| 10439 |
| 9238 void test_duplicateDefinition() { | 10440 void test_duplicateDefinition() { |
| 9239 Source source = addSource(EngineTestCase.createSource(["f() {", " int m = 0
;", " m(a) {}", "}"])); | 10441 Source source = addSource(EngineTestCase.createSource(["f() {", " int m = 0
;", " m(a) {}", "}"])); |
| 9240 resolve(source); | 10442 resolve(source); |
| 9241 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 10443 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 9242 verify([source]); | 10444 verify([source]); |
| 9243 } | 10445 } |
| 10446 |
| 9244 void test_duplicateDefinition_acrossLibraries() { | 10447 void test_duplicateDefinition_acrossLibraries() { |
| 9245 Source librarySource = addSource2("/lib.dart", EngineTestCase.createSource([
"library lib;", "", "part 'a.dart';", "part 'b.dart';"])); | 10448 Source librarySource = addSource2("/lib.dart", EngineTestCase.createSource([
"library lib;", "", "part 'a.dart';", "part 'b.dart';"])); |
| 9246 Source sourceA = addSource2("/a.dart", EngineTestCase.createSource(["part of
lib;", "", "class A {}"])); | 10449 Source sourceA = addSource2("/a.dart", EngineTestCase.createSource(["part of
lib;", "", "class A {}"])); |
| 9247 Source sourceB = addSource2("/b.dart", EngineTestCase.createSource(["part of
lib;", "", "class A {}"])); | 10450 Source sourceB = addSource2("/b.dart", EngineTestCase.createSource(["part of
lib;", "", "class A {}"])); |
| 9248 resolve(librarySource); | 10451 resolve(librarySource); |
| 9249 assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 10452 assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 9250 verify([librarySource, sourceA, sourceB]); | 10453 verify([librarySource, sourceA, sourceB]); |
| 9251 } | 10454 } |
| 10455 |
| 9252 void test_duplicateDefinition_classMembers_fields() { | 10456 void test_duplicateDefinition_classMembers_fields() { |
| 9253 Source source = addSource(EngineTestCase.createSource(["class A {", " int a
;", " int a;", "}"])); | 10457 Source source = addSource(EngineTestCase.createSource(["class A {", " int a
;", " int a;", "}"])); |
| 9254 resolve(source); | 10458 resolve(source); |
| 9255 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 10459 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 9256 verify([source]); | 10460 verify([source]); |
| 9257 } | 10461 } |
| 10462 |
| 9258 void test_duplicateDefinition_classMembers_fields_oneStatic() { | 10463 void test_duplicateDefinition_classMembers_fields_oneStatic() { |
| 9259 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " static int x;", "}"])); | 10464 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " static int x;", "}"])); |
| 9260 resolve(source); | 10465 resolve(source); |
| 9261 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 10466 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 9262 verify([source]); | 10467 verify([source]); |
| 9263 } | 10468 } |
| 10469 |
| 9264 void test_duplicateDefinition_classMembers_methods() { | 10470 void test_duplicateDefinition_classMembers_methods() { |
| 9265 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", " m() {}", "}"])); | 10471 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", " m() {}", "}"])); |
| 9266 resolve(source); | 10472 resolve(source); |
| 9267 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 10473 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 9268 verify([source]); | 10474 verify([source]); |
| 9269 } | 10475 } |
| 10476 |
| 9270 void test_duplicateDefinition_localFields() { | 10477 void test_duplicateDefinition_localFields() { |
| 9271 Source source = addSource(EngineTestCase.createSource([ | 10478 Source source = addSource(EngineTestCase.createSource([ |
| 9272 "class A {", | 10479 "class A {", |
| 9273 " m() {", | 10480 " m() {", |
| 9274 " int a;", | 10481 " int a;", |
| 9275 " int a;", | 10482 " int a;", |
| 9276 " }", | 10483 " }", |
| 9277 "}"])); | 10484 "}"])); |
| 9278 resolve(source); | 10485 resolve(source); |
| 9279 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 10486 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 9280 verify([source]); | 10487 verify([source]); |
| 9281 } | 10488 } |
| 10489 |
| 9282 void test_duplicateDefinition_parameterWithFunctionName_local() { | 10490 void test_duplicateDefinition_parameterWithFunctionName_local() { |
| 9283 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) {
}", "}"])); | 10491 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) {
}", "}"])); |
| 9284 resolve(source); | 10492 resolve(source); |
| 9285 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 10493 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 9286 verify([source]); | 10494 verify([source]); |
| 9287 } | 10495 } |
| 10496 |
| 9288 void test_duplicateDefinition_parameterWithFunctionName_topLevel() { | 10497 void test_duplicateDefinition_parameterWithFunctionName_topLevel() { |
| 9289 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) {
}", "}"])); | 10498 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) {
}", "}"])); |
| 9290 resolve(source); | 10499 resolve(source); |
| 9291 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 10500 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 9292 verify([source]); | 10501 verify([source]); |
| 9293 } | 10502 } |
| 10503 |
| 9294 void test_duplicateDefinitionInheritance_instanceGetter_staticGetter() { | 10504 void test_duplicateDefinitionInheritance_instanceGetter_staticGetter() { |
| 9295 Source source = addSource(EngineTestCase.createSource([ | 10505 Source source = addSource(EngineTestCase.createSource([ |
| 9296 "class A {", | 10506 "class A {", |
| 9297 " int get x => 0;", | 10507 " int get x => 0;", |
| 9298 "}", | 10508 "}", |
| 9299 "class B extends A {", | 10509 "class B extends A {", |
| 9300 " static int get x => 0;", | 10510 " static int get x => 0;", |
| 9301 "}"])); | 10511 "}"])); |
| 9302 resolve(source); | 10512 resolve(source); |
| 9303 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); | 10513 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 9304 verify([source]); | 10514 verify([source]); |
| 9305 } | 10515 } |
| 10516 |
| 9306 void test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter()
{ | 10517 void test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter()
{ |
| 9307 Source source = addSource(EngineTestCase.createSource([ | 10518 Source source = addSource(EngineTestCase.createSource([ |
| 9308 "abstract class A {", | 10519 "abstract class A {", |
| 9309 " int get x;", | 10520 " int get x;", |
| 9310 "}", | 10521 "}", |
| 9311 "class B extends A {", | 10522 "class B extends A {", |
| 9312 " static int get x => 0;", | 10523 " static int get x => 0;", |
| 9313 "}"])); | 10524 "}"])); |
| 9314 resolve(source); | 10525 resolve(source); |
| 9315 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); | 10526 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 9316 verify([source]); | 10527 verify([source]); |
| 9317 } | 10528 } |
| 10529 |
| 9318 void test_duplicateDefinitionInheritance_instanceMethod_staticMethod() { | 10530 void test_duplicateDefinitionInheritance_instanceMethod_staticMethod() { |
| 9319 Source source = addSource(EngineTestCase.createSource([ | 10531 Source source = addSource(EngineTestCase.createSource([ |
| 9320 "class A {", | 10532 "class A {", |
| 9321 " x() {}", | 10533 " x() {}", |
| 9322 "}", | 10534 "}", |
| 9323 "class B extends A {", | 10535 "class B extends A {", |
| 9324 " static x() {}", | 10536 " static x() {}", |
| 9325 "}"])); | 10537 "}"])); |
| 9326 resolve(source); | 10538 resolve(source); |
| 9327 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); | 10539 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 9328 verify([source]); | 10540 verify([source]); |
| 9329 } | 10541 } |
| 10542 |
| 9330 void test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod()
{ | 10543 void test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod()
{ |
| 9331 Source source = addSource(EngineTestCase.createSource([ | 10544 Source source = addSource(EngineTestCase.createSource([ |
| 9332 "abstract class A {", | 10545 "abstract class A {", |
| 9333 " x();", | 10546 " x();", |
| 9334 "}", | 10547 "}", |
| 9335 "abstract class B extends A {", | 10548 "abstract class B extends A {", |
| 9336 " static x() {}", | 10549 " static x() {}", |
| 9337 "}"])); | 10550 "}"])); |
| 9338 resolve(source); | 10551 resolve(source); |
| 9339 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); | 10552 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 9340 verify([source]); | 10553 verify([source]); |
| 9341 } | 10554 } |
| 10555 |
| 9342 void test_duplicateDefinitionInheritance_instanceSetter_staticSetter() { | 10556 void test_duplicateDefinitionInheritance_instanceSetter_staticSetter() { |
| 9343 Source source = addSource(EngineTestCase.createSource([ | 10557 Source source = addSource(EngineTestCase.createSource([ |
| 9344 "class A {", | 10558 "class A {", |
| 9345 " set x(value) {}", | 10559 " set x(value) {}", |
| 9346 "}", | 10560 "}", |
| 9347 "class B extends A {", | 10561 "class B extends A {", |
| 9348 " static set x(value) {}", | 10562 " static set x(value) {}", |
| 9349 "}"])); | 10563 "}"])); |
| 9350 resolve(source); | 10564 resolve(source); |
| 9351 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); | 10565 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 9352 verify([source]); | 10566 verify([source]); |
| 9353 } | 10567 } |
| 10568 |
| 9354 void test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter()
{ | 10569 void test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter()
{ |
| 9355 Source source = addSource(EngineTestCase.createSource([ | 10570 Source source = addSource(EngineTestCase.createSource([ |
| 9356 "abstract class A {", | 10571 "abstract class A {", |
| 9357 " set x(value);", | 10572 " set x(value);", |
| 9358 "}", | 10573 "}", |
| 9359 "class B extends A {", | 10574 "class B extends A {", |
| 9360 " static set x(value) {}", | 10575 " static set x(value) {}", |
| 9361 "}"])); | 10576 "}"])); |
| 9362 resolve(source); | 10577 resolve(source); |
| 9363 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); | 10578 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 9364 verify([source]); | 10579 verify([source]); |
| 9365 } | 10580 } |
| 10581 |
| 9366 void test_duplicateNamedArgument() { | 10582 void test_duplicateNamedArgument() { |
| 9367 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main
() {", " f(a: 1, a: 2);", "}"])); | 10583 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main
() {", " f(a: 1, a: 2);", "}"])); |
| 9368 resolve(source); | 10584 resolve(source); |
| 9369 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]); | 10585 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]); |
| 9370 verify([source]); | 10586 verify([source]); |
| 9371 } | 10587 } |
| 10588 |
| 9372 void test_exportInternalLibrary() { | 10589 void test_exportInternalLibrary() { |
| 9373 Source source = addSource(EngineTestCase.createSource(["export 'dart:_interc
eptors';"])); | 10590 Source source = addSource(EngineTestCase.createSource(["export 'dart:_interc
eptors';"])); |
| 9374 resolve(source); | 10591 resolve(source); |
| 9375 assertErrors(source, [CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]); | 10592 assertErrors(source, [CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]); |
| 9376 verify([source]); | 10593 verify([source]); |
| 9377 } | 10594 } |
| 10595 |
| 9378 void test_exportOfNonLibrary() { | 10596 void test_exportOfNonLibrary() { |
| 9379 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); | 10597 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); |
| 9380 addSource2("/lib1.dart", EngineTestCase.createSource(["part of lib;"])); | 10598 addSource2("/lib1.dart", EngineTestCase.createSource(["part of lib;"])); |
| 9381 resolve(source); | 10599 resolve(source); |
| 9382 assertErrors(source, [CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]); | 10600 assertErrors(source, [CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]); |
| 9383 verify([source]); | 10601 verify([source]); |
| 9384 } | 10602 } |
| 10603 |
| 9385 void test_extendsDisallowedClass_bool() { | 10604 void test_extendsDisallowedClass_bool() { |
| 9386 Source source = addSource(EngineTestCase.createSource(["class A extends bool
{}"])); | 10605 Source source = addSource(EngineTestCase.createSource(["class A extends bool
{}"])); |
| 9387 resolve(source); | 10606 resolve(source); |
| 9388 assertErrors(source, [ | 10607 assertErrors(source, [ |
| 9389 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 10608 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 9390 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 10609 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 9391 verify([source]); | 10610 verify([source]); |
| 9392 } | 10611 } |
| 10612 |
| 9393 void test_extendsDisallowedClass_double() { | 10613 void test_extendsDisallowedClass_double() { |
| 9394 Source source = addSource(EngineTestCase.createSource(["class A extends doub
le {}"])); | 10614 Source source = addSource(EngineTestCase.createSource(["class A extends doub
le {}"])); |
| 9395 resolve(source); | 10615 resolve(source); |
| 9396 assertErrors(source, [ | 10616 assertErrors(source, [ |
| 9397 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 10617 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 9398 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 10618 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 9399 verify([source]); | 10619 verify([source]); |
| 9400 } | 10620 } |
| 10621 |
| 9401 void test_extendsDisallowedClass_int() { | 10622 void test_extendsDisallowedClass_int() { |
| 9402 Source source = addSource(EngineTestCase.createSource(["class A extends int
{}"])); | 10623 Source source = addSource(EngineTestCase.createSource(["class A extends int
{}"])); |
| 9403 resolve(source); | 10624 resolve(source); |
| 9404 assertErrors(source, [ | 10625 assertErrors(source, [ |
| 9405 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 10626 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 9406 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 10627 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 9407 verify([source]); | 10628 verify([source]); |
| 9408 } | 10629 } |
| 10630 |
| 9409 void test_extendsDisallowedClass_Null() { | 10631 void test_extendsDisallowedClass_Null() { |
| 9410 Source source = addSource(EngineTestCase.createSource(["class A extends Null
{}"])); | 10632 Source source = addSource(EngineTestCase.createSource(["class A extends Null
{}"])); |
| 9411 resolve(source); | 10633 resolve(source); |
| 9412 assertErrors(source, [ | 10634 assertErrors(source, [ |
| 9413 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 10635 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 9414 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 10636 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 9415 verify([source]); | 10637 verify([source]); |
| 9416 } | 10638 } |
| 10639 |
| 9417 void test_extendsDisallowedClass_num() { | 10640 void test_extendsDisallowedClass_num() { |
| 9418 Source source = addSource(EngineTestCase.createSource(["class A extends num
{}"])); | 10641 Source source = addSource(EngineTestCase.createSource(["class A extends num
{}"])); |
| 9419 resolve(source); | 10642 resolve(source); |
| 9420 assertErrors(source, [ | 10643 assertErrors(source, [ |
| 9421 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 10644 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 9422 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 10645 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 9423 verify([source]); | 10646 verify([source]); |
| 9424 } | 10647 } |
| 10648 |
| 9425 void test_extendsDisallowedClass_String() { | 10649 void test_extendsDisallowedClass_String() { |
| 9426 Source source = addSource(EngineTestCase.createSource(["class A extends Stri
ng {}"])); | 10650 Source source = addSource(EngineTestCase.createSource(["class A extends Stri
ng {}"])); |
| 9427 resolve(source); | 10651 resolve(source); |
| 9428 assertErrors(source, [ | 10652 assertErrors(source, [ |
| 9429 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 10653 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 9430 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 10654 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 9431 verify([source]); | 10655 verify([source]); |
| 9432 } | 10656 } |
| 10657 |
| 9433 void test_extendsNonClass_class() { | 10658 void test_extendsNonClass_class() { |
| 9434 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex
tends A {}"])); | 10659 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex
tends A {}"])); |
| 9435 resolve(source); | 10660 resolve(source); |
| 9436 assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]); | 10661 assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]); |
| 9437 verify([source]); | 10662 verify([source]); |
| 9438 } | 10663 } |
| 10664 |
| 9439 void test_extendsNonClass_dynamic() { | 10665 void test_extendsNonClass_dynamic() { |
| 9440 Source source = addSource(EngineTestCase.createSource(["class B extends dyna
mic {}"])); | 10666 Source source = addSource(EngineTestCase.createSource(["class B extends dyna
mic {}"])); |
| 9441 resolve(source); | 10667 resolve(source); |
| 9442 assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]); | 10668 assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]); |
| 9443 verify([source]); | 10669 verify([source]); |
| 9444 } | 10670 } |
| 10671 |
| 9445 void test_extraPositionalArguments_const() { | 10672 void test_extraPositionalArguments_const() { |
| 9446 Source source = addSource(EngineTestCase.createSource([ | 10673 Source source = addSource(EngineTestCase.createSource([ |
| 9447 "class A {", | 10674 "class A {", |
| 9448 " const A();", | 10675 " const A();", |
| 9449 "}", | 10676 "}", |
| 9450 "main() {", | 10677 "main() {", |
| 9451 " const A(0);", | 10678 " const A(0);", |
| 9452 "}"])); | 10679 "}"])); |
| 9453 resolve(source); | 10680 resolve(source); |
| 9454 assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]); | 10681 assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]); |
| 9455 verify([source]); | 10682 verify([source]); |
| 9456 } | 10683 } |
| 10684 |
| 9457 void test_extraPositionalArguments_const_super() { | 10685 void test_extraPositionalArguments_const_super() { |
| 9458 Source source = addSource(EngineTestCase.createSource([ | 10686 Source source = addSource(EngineTestCase.createSource([ |
| 9459 "class A {", | 10687 "class A {", |
| 9460 " const A();", | 10688 " const A();", |
| 9461 "}", | 10689 "}", |
| 9462 "class B extends A {", | 10690 "class B extends A {", |
| 9463 " const B() : super(0);", | 10691 " const B() : super(0);", |
| 9464 "}"])); | 10692 "}"])); |
| 9465 resolve(source); | 10693 resolve(source); |
| 9466 assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]); | 10694 assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]); |
| 9467 verify([source]); | 10695 verify([source]); |
| 9468 } | 10696 } |
| 10697 |
| 9469 void test_fieldInitializedByMultipleInitializers() { | 10698 void test_fieldInitializedByMultipleInitializers() { |
| 9470 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A() : x = 0, x = 1 {}", "}"])); | 10699 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A() : x = 0, x = 1 {}", "}"])); |
| 9471 resolve(source); | 10700 resolve(source); |
| 9472 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INI
TIALIZERS]); | 10701 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INI
TIALIZERS]); |
| 9473 verify([source]); | 10702 verify([source]); |
| 9474 } | 10703 } |
| 10704 |
| 9475 void test_fieldInitializedByMultipleInitializers_multipleInits() { | 10705 void test_fieldInitializedByMultipleInitializers_multipleInits() { |
| 9476 Source source = addSource(EngineTestCase.createSource([ | 10706 Source source = addSource(EngineTestCase.createSource([ |
| 9477 "class A {", | 10707 "class A {", |
| 9478 " int x;", | 10708 " int x;", |
| 9479 " A() : x = 0, x = 1, x = 2 {}", | 10709 " A() : x = 0, x = 1, x = 2 {}", |
| 9480 "}"])); | 10710 "}"])); |
| 9481 resolve(source); | 10711 resolve(source); |
| 9482 assertErrors(source, [ | 10712 assertErrors(source, [ |
| 9483 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, | 10713 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, |
| 9484 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); | 10714 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); |
| 9485 verify([source]); | 10715 verify([source]); |
| 9486 } | 10716 } |
| 10717 |
| 9487 void test_fieldInitializedByMultipleInitializers_multipleNames() { | 10718 void test_fieldInitializedByMultipleInitializers_multipleNames() { |
| 9488 Source source = addSource(EngineTestCase.createSource([ | 10719 Source source = addSource(EngineTestCase.createSource([ |
| 9489 "class A {", | 10720 "class A {", |
| 9490 " int x;", | 10721 " int x;", |
| 9491 " int y;", | 10722 " int y;", |
| 9492 " A() : x = 0, x = 1, y = 0, y = 1 {}", | 10723 " A() : x = 0, x = 1, y = 0, y = 1 {}", |
| 9493 "}"])); | 10724 "}"])); |
| 9494 resolve(source); | 10725 resolve(source); |
| 9495 assertErrors(source, [ | 10726 assertErrors(source, [ |
| 9496 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, | 10727 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, |
| 9497 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); | 10728 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); |
| 9498 verify([source]); | 10729 verify([source]); |
| 9499 } | 10730 } |
| 10731 |
| 9500 void test_fieldInitializedInParameterAndInitializer() { | 10732 void test_fieldInitializedInParameterAndInitializer() { |
| 9501 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) : x = 1 {}", "}"])); | 10733 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) : x = 1 {}", "}"])); |
| 9502 resolve(source); | 10734 resolve(source); |
| 9503 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AN
D_INITIALIZER]); | 10735 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AN
D_INITIALIZER]); |
| 9504 verify([source]); | 10736 verify([source]); |
| 9505 } | 10737 } |
| 10738 |
| 9506 void test_fieldInitializerFactoryConstructor() { | 10739 void test_fieldInitializerFactoryConstructor() { |
| 9507 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " factory A(this.x) {}", "}"])); | 10740 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " factory A(this.x) {}", "}"])); |
| 9508 resolve(source); | 10741 resolve(source); |
| 9509 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRU
CTOR]); | 10742 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRU
CTOR]); |
| 9510 verify([source]); | 10743 verify([source]); |
| 9511 } | 10744 } |
| 10745 |
| 9512 void test_fieldInitializerNotAssignable() { | 10746 void test_fieldInitializerNotAssignable() { |
| 9513 Source source = addSource(EngineTestCase.createSource([ | 10747 Source source = addSource(EngineTestCase.createSource([ |
| 9514 "class A {", | 10748 "class A {", |
| 9515 " final int x;", | 10749 " final int x;", |
| 9516 " const A() : x = '';", | 10750 " const A() : x = '';", |
| 9517 "}"])); | 10751 "}"])); |
| 9518 resolve(source); | 10752 resolve(source); |
| 9519 assertErrors(source, [CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIG
NABLE]); | 10753 assertErrors(source, [CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIG
NABLE]); |
| 9520 verify([source]); | 10754 verify([source]); |
| 9521 } | 10755 } |
| 10756 |
| 9522 void test_fieldInitializerOutsideConstructor() { | 10757 void test_fieldInitializerOutsideConstructor() { |
| 9523 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " m(this.x) {}", "}"])); | 10758 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " m(this.x) {}", "}"])); |
| 9524 resolve(source); | 10759 resolve(source); |
| 9525 assertErrors(source, [ | 10760 assertErrors(source, [ |
| 9526 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, | 10761 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, |
| 9527 CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); | 10762 CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); |
| 9528 verify([source]); | 10763 verify([source]); |
| 9529 } | 10764 } |
| 10765 |
| 9530 void test_fieldInitializerOutsideConstructor_defaultParameter() { | 10766 void test_fieldInitializerOutsideConstructor_defaultParameter() { |
| 9531 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " m([this.x]) {}", "}"])); | 10767 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " m([this.x]) {}", "}"])); |
| 9532 resolve(source); | 10768 resolve(source); |
| 9533 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRU
CTOR]); | 10769 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRU
CTOR]); |
| 9534 verify([source]); | 10770 verify([source]); |
| 9535 } | 10771 } |
| 10772 |
| 9536 void test_fieldInitializerRedirectingConstructor_afterRedirection() { | 10773 void test_fieldInitializerRedirectingConstructor_afterRedirection() { |
| 9537 Source source = addSource(EngineTestCase.createSource([ | 10774 Source source = addSource(EngineTestCase.createSource([ |
| 9538 "class A {", | 10775 "class A {", |
| 9539 " int x;", | 10776 " int x;", |
| 9540 " A.named() {}", | 10777 " A.named() {}", |
| 9541 " A() : this.named(), x = 42;", | 10778 " A() : this.named(), x = 42;", |
| 9542 "}"])); | 10779 "}"])); |
| 9543 resolve(source); | 10780 resolve(source); |
| 9544 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON
STRUCTOR]); | 10781 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON
STRUCTOR]); |
| 9545 verify([source]); | 10782 verify([source]); |
| 9546 } | 10783 } |
| 10784 |
| 9547 void test_fieldInitializerRedirectingConstructor_beforeRedirection() { | 10785 void test_fieldInitializerRedirectingConstructor_beforeRedirection() { |
| 9548 Source source = addSource(EngineTestCase.createSource([ | 10786 Source source = addSource(EngineTestCase.createSource([ |
| 9549 "class A {", | 10787 "class A {", |
| 9550 " int x;", | 10788 " int x;", |
| 9551 " A.named() {}", | 10789 " A.named() {}", |
| 9552 " A() : x = 42, this.named();", | 10790 " A() : x = 42, this.named();", |
| 9553 "}"])); | 10791 "}"])); |
| 9554 resolve(source); | 10792 resolve(source); |
| 9555 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON
STRUCTOR]); | 10793 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON
STRUCTOR]); |
| 9556 verify([source]); | 10794 verify([source]); |
| 9557 } | 10795 } |
| 10796 |
| 9558 void test_fieldInitializingFormalRedirectingConstructor() { | 10797 void test_fieldInitializingFormalRedirectingConstructor() { |
| 9559 Source source = addSource(EngineTestCase.createSource([ | 10798 Source source = addSource(EngineTestCase.createSource([ |
| 9560 "class A {", | 10799 "class A {", |
| 9561 " int x;", | 10800 " int x;", |
| 9562 " A.named() {}", | 10801 " A.named() {}", |
| 9563 " A(this.x) : this.named();", | 10802 " A(this.x) : this.named();", |
| 9564 "}"])); | 10803 "}"])); |
| 9565 resolve(source); | 10804 resolve(source); |
| 9566 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON
STRUCTOR]); | 10805 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON
STRUCTOR]); |
| 9567 verify([source]); | 10806 verify([source]); |
| 9568 } | 10807 } |
| 10808 |
| 9569 void test_finalInitializedMultipleTimes_initializers() { | 10809 void test_finalInitializedMultipleTimes_initializers() { |
| 9570 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A() : x = 0, x = 0 {}", "}"])); | 10810 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A() : x = 0, x = 0 {}", "}"])); |
| 9571 resolve(source); | 10811 resolve(source); |
| 9572 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INI
TIALIZERS]); | 10812 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INI
TIALIZERS]); |
| 9573 verify([source]); | 10813 verify([source]); |
| 9574 } | 10814 } |
| 9575 | 10815 |
| 9576 /** | 10816 /** |
| 9577 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests
the | 10817 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests
the |
| 9578 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided
here to show | 10818 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided
here to show |
| 9579 * coverage over all of the permutations of initializers in constructor declar
ations. | 10819 * coverage over all of the permutations of initializers in constructor declar
ations. |
| 9580 * | 10820 * |
| 9581 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of | 10821 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of |
| 9582 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead
of the broader code | 10822 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead
of the broader code |
| 9583 */ | 10823 */ |
| 9584 void test_finalInitializedMultipleTimes_initializingFormal_initializer() { | 10824 void test_finalInitializedMultipleTimes_initializingFormal_initializer() { |
| 9585 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x) : x = 0 {}", "}"])); | 10825 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x) : x = 0 {}", "}"])); |
| 9586 resolve(source); | 10826 resolve(source); |
| 9587 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AN
D_INITIALIZER]); | 10827 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AN
D_INITIALIZER]); |
| 9588 verify([source]); | 10828 verify([source]); |
| 9589 } | 10829 } |
| 10830 |
| 9590 void test_finalInitializedMultipleTimes_initializingFormals() { | 10831 void test_finalInitializedMultipleTimes_initializingFormals() { |
| 9591 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x, this.x) {}", "}"])); | 10832 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x, this.x) {}", "}"])); |
| 9592 resolve(source); | 10833 resolve(source); |
| 9593 assertErrors(source, [CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES]
); | 10834 assertErrors(source, [CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES]
); |
| 9594 verify([source]); | 10835 verify([source]); |
| 9595 } | 10836 } |
| 10837 |
| 9596 void test_finalNotInitialized_instanceField_const_static() { | 10838 void test_finalNotInitialized_instanceField_const_static() { |
| 9597 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c const F;", "}"])); | 10839 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c const F;", "}"])); |
| 9598 resolve(source); | 10840 resolve(source); |
| 9599 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); | 10841 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); |
| 9600 verify([source]); | 10842 verify([source]); |
| 9601 } | 10843 } |
| 10844 |
| 9602 void test_finalNotInitialized_library_const() { | 10845 void test_finalNotInitialized_library_const() { |
| 9603 Source source = addSource(EngineTestCase.createSource(["const F;"])); | 10846 Source source = addSource(EngineTestCase.createSource(["const F;"])); |
| 9604 resolve(source); | 10847 resolve(source); |
| 9605 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); | 10848 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); |
| 9606 verify([source]); | 10849 verify([source]); |
| 9607 } | 10850 } |
| 10851 |
| 9608 void test_finalNotInitialized_local_const() { | 10852 void test_finalNotInitialized_local_const() { |
| 9609 Source source = addSource(EngineTestCase.createSource(["f() {", " const int
x;", "}"])); | 10853 Source source = addSource(EngineTestCase.createSource(["f() {", " const int
x;", "}"])); |
| 9610 resolve(source); | 10854 resolve(source); |
| 9611 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); | 10855 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); |
| 9612 verify([source]); | 10856 verify([source]); |
| 9613 } | 10857 } |
| 10858 |
| 9614 void test_getterAndMethodWithSameName() { | 10859 void test_getterAndMethodWithSameName() { |
| 9615 Source source = addSource(EngineTestCase.createSource(["class A {", " x(y)
{}", " get x => 0;", "}"])); | 10860 Source source = addSource(EngineTestCase.createSource(["class A {", " x(y)
{}", " get x => 0;", "}"])); |
| 9616 resolve(source); | 10861 resolve(source); |
| 9617 assertErrors(source, [CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]
); | 10862 assertErrors(source, [CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]
); |
| 9618 verify([source]); | 10863 verify([source]); |
| 9619 } | 10864 } |
| 10865 |
| 9620 void test_implementsDisallowedClass_bool() { | 10866 void test_implementsDisallowedClass_bool() { |
| 9621 Source source = addSource(EngineTestCase.createSource(["class A implements b
ool {}"])); | 10867 Source source = addSource(EngineTestCase.createSource(["class A implements b
ool {}"])); |
| 9622 resolve(source); | 10868 resolve(source); |
| 9623 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 10869 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 9624 verify([source]); | 10870 verify([source]); |
| 9625 } | 10871 } |
| 10872 |
| 9626 void test_implementsDisallowedClass_double() { | 10873 void test_implementsDisallowedClass_double() { |
| 9627 Source source = addSource(EngineTestCase.createSource(["class A implements d
ouble {}"])); | 10874 Source source = addSource(EngineTestCase.createSource(["class A implements d
ouble {}"])); |
| 9628 resolve(source); | 10875 resolve(source); |
| 9629 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 10876 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 9630 verify([source]); | 10877 verify([source]); |
| 9631 } | 10878 } |
| 10879 |
| 9632 void test_implementsDisallowedClass_int() { | 10880 void test_implementsDisallowedClass_int() { |
| 9633 Source source = addSource(EngineTestCase.createSource(["class A implements i
nt {}"])); | 10881 Source source = addSource(EngineTestCase.createSource(["class A implements i
nt {}"])); |
| 9634 resolve(source); | 10882 resolve(source); |
| 9635 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 10883 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 9636 verify([source]); | 10884 verify([source]); |
| 9637 } | 10885 } |
| 10886 |
| 9638 void test_implementsDisallowedClass_Null() { | 10887 void test_implementsDisallowedClass_Null() { |
| 9639 Source source = addSource(EngineTestCase.createSource(["class A implements N
ull {}"])); | 10888 Source source = addSource(EngineTestCase.createSource(["class A implements N
ull {}"])); |
| 9640 resolve(source); | 10889 resolve(source); |
| 9641 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 10890 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 9642 verify([source]); | 10891 verify([source]); |
| 9643 } | 10892 } |
| 10893 |
| 9644 void test_implementsDisallowedClass_num() { | 10894 void test_implementsDisallowedClass_num() { |
| 9645 Source source = addSource(EngineTestCase.createSource(["class A implements n
um {}"])); | 10895 Source source = addSource(EngineTestCase.createSource(["class A implements n
um {}"])); |
| 9646 resolve(source); | 10896 resolve(source); |
| 9647 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 10897 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 9648 verify([source]); | 10898 verify([source]); |
| 9649 } | 10899 } |
| 10900 |
| 9650 void test_implementsDisallowedClass_String() { | 10901 void test_implementsDisallowedClass_String() { |
| 9651 Source source = addSource(EngineTestCase.createSource(["class A implements S
tring {}"])); | 10902 Source source = addSource(EngineTestCase.createSource(["class A implements S
tring {}"])); |
| 9652 resolve(source); | 10903 resolve(source); |
| 9653 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 10904 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 9654 verify([source]); | 10905 verify([source]); |
| 9655 } | 10906 } |
| 10907 |
| 9656 void test_implementsDynamic() { | 10908 void test_implementsDynamic() { |
| 9657 Source source = addSource(EngineTestCase.createSource(["class A implements d
ynamic {}"])); | 10909 Source source = addSource(EngineTestCase.createSource(["class A implements d
ynamic {}"])); |
| 9658 resolve(source); | 10910 resolve(source); |
| 9659 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]); | 10911 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]); |
| 9660 verify([source]); | 10912 verify([source]); |
| 9661 } | 10913 } |
| 10914 |
| 9662 void test_implementsNonClass_class() { | 10915 void test_implementsNonClass_class() { |
| 9663 Source source = addSource(EngineTestCase.createSource(["int A;", "class B im
plements A {}"])); | 10916 Source source = addSource(EngineTestCase.createSource(["int A;", "class B im
plements A {}"])); |
| 9664 resolve(source); | 10917 resolve(source); |
| 9665 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); | 10918 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); |
| 9666 verify([source]); | 10919 verify([source]); |
| 9667 } | 10920 } |
| 10921 |
| 9668 void test_implementsNonClass_typeAlias() { | 10922 void test_implementsNonClass_typeAlias() { |
| 9669 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B;
", "class C = A implements B;"])); | 10923 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B;
", "class C = A implements B;"])); |
| 9670 resolve(source); | 10924 resolve(source); |
| 9671 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); | 10925 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); |
| 9672 verify([source]); | 10926 verify([source]); |
| 9673 } | 10927 } |
| 10928 |
| 9674 void test_implementsRepeated() { | 10929 void test_implementsRepeated() { |
| 9675 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B implements A, A {}"])); | 10930 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B implements A, A {}"])); |
| 9676 resolve(source); | 10931 resolve(source); |
| 9677 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_REPEATED]); | 10932 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_REPEATED]); |
| 9678 verify([source]); | 10933 verify([source]); |
| 9679 } | 10934 } |
| 10935 |
| 9680 void test_implementsRepeated_3times() { | 10936 void test_implementsRepeated_3times() { |
| 9681 Source source = addSource(EngineTestCase.createSource([ | 10937 Source source = addSource(EngineTestCase.createSource([ |
| 9682 "class A {} class C{}", | 10938 "class A {} class C{}", |
| 9683 "class B implements A, A, A, A {}"])); | 10939 "class B implements A, A, A, A {}"])); |
| 9684 resolve(source); | 10940 resolve(source); |
| 9685 assertErrors(source, [ | 10941 assertErrors(source, [ |
| 9686 CompileTimeErrorCode.IMPLEMENTS_REPEATED, | 10942 CompileTimeErrorCode.IMPLEMENTS_REPEATED, |
| 9687 CompileTimeErrorCode.IMPLEMENTS_REPEATED, | 10943 CompileTimeErrorCode.IMPLEMENTS_REPEATED, |
| 9688 CompileTimeErrorCode.IMPLEMENTS_REPEATED]); | 10944 CompileTimeErrorCode.IMPLEMENTS_REPEATED]); |
| 9689 verify([source]); | 10945 verify([source]); |
| 9690 } | 10946 } |
| 10947 |
| 9691 void test_implementsSuperClass() { | 10948 void test_implementsSuperClass() { |
| 9692 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A implements A {}"])); | 10949 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A implements A {}"])); |
| 9693 resolve(source); | 10950 resolve(source); |
| 9694 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); | 10951 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); |
| 9695 verify([source]); | 10952 verify([source]); |
| 9696 } | 10953 } |
| 10954 |
| 9697 void test_implementsSuperClass_Object() { | 10955 void test_implementsSuperClass_Object() { |
| 9698 Source source = addSource(EngineTestCase.createSource(["class A implements O
bject {}"])); | 10956 Source source = addSource(EngineTestCase.createSource(["class A implements O
bject {}"])); |
| 9699 resolve(source); | 10957 resolve(source); |
| 9700 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); | 10958 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); |
| 9701 verify([source]); | 10959 verify([source]); |
| 9702 } | 10960 } |
| 10961 |
| 9703 void test_implicitThisReferenceInInitializer_field() { | 10962 void test_implicitThisReferenceInInitializer_field() { |
| 9704 Source source = addSource(EngineTestCase.createSource([ | 10963 Source source = addSource(EngineTestCase.createSource([ |
| 9705 "class A {", | 10964 "class A {", |
| 9706 " var v;", | 10965 " var v;", |
| 9707 " A() : v = f;", | 10966 " A() : v = f;", |
| 9708 " var f;", | 10967 " var f;", |
| 9709 "}"])); | 10968 "}"])); |
| 9710 resolve(source); | 10969 resolve(source); |
| 9711 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); | 10970 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 9712 verify([source]); | 10971 verify([source]); |
| 9713 } | 10972 } |
| 10973 |
| 9714 void test_implicitThisReferenceInInitializer_field2() { | 10974 void test_implicitThisReferenceInInitializer_field2() { |
| 9715 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " final y = x;", "}"])); | 10975 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " final y = x;", "}"])); |
| 9716 resolve(source); | 10976 resolve(source); |
| 9717 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); | 10977 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 9718 verify([source]); | 10978 verify([source]); |
| 9719 } | 10979 } |
| 10980 |
| 9720 void test_implicitThisReferenceInInitializer_invocation() { | 10981 void test_implicitThisReferenceInInitializer_invocation() { |
| 9721 Source source = addSource(EngineTestCase.createSource([ | 10982 Source source = addSource(EngineTestCase.createSource([ |
| 9722 "class A {", | 10983 "class A {", |
| 9723 " var v;", | 10984 " var v;", |
| 9724 " A() : v = f();", | 10985 " A() : v = f();", |
| 9725 " f() {}", | 10986 " f() {}", |
| 9726 "}"])); | 10987 "}"])); |
| 9727 resolve(source); | 10988 resolve(source); |
| 9728 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); | 10989 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 9729 verify([source]); | 10990 verify([source]); |
| 9730 } | 10991 } |
| 10992 |
| 9731 void test_implicitThisReferenceInInitializer_invocationInStatic() { | 10993 void test_implicitThisReferenceInInitializer_invocationInStatic() { |
| 9732 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c var F = m();", " m() {}", "}"])); | 10994 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c var F = m();", " m() {}", "}"])); |
| 9733 resolve(source); | 10995 resolve(source); |
| 9734 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); | 10996 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 9735 verify([source]); | 10997 verify([source]); |
| 9736 } | 10998 } |
| 10999 |
| 9737 void test_implicitThisReferenceInInitializer_redirectingConstructorInvocation(
) { | 11000 void test_implicitThisReferenceInInitializer_redirectingConstructorInvocation(
) { |
| 9738 Source source = addSource(EngineTestCase.createSource([ | 11001 Source source = addSource(EngineTestCase.createSource([ |
| 9739 "class A {", | 11002 "class A {", |
| 9740 " A(p) {}", | 11003 " A(p) {}", |
| 9741 " A.named() : this(f);", | 11004 " A.named() : this(f);", |
| 9742 " var f;", | 11005 " var f;", |
| 9743 "}"])); | 11006 "}"])); |
| 9744 resolve(source); | 11007 resolve(source); |
| 9745 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); | 11008 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 9746 verify([source]); | 11009 verify([source]); |
| 9747 } | 11010 } |
| 11011 |
| 9748 void test_implicitThisReferenceInInitializer_superConstructorInvocation() { | 11012 void test_implicitThisReferenceInInitializer_superConstructorInvocation() { |
| 9749 Source source = addSource(EngineTestCase.createSource([ | 11013 Source source = addSource(EngineTestCase.createSource([ |
| 9750 "class A {", | 11014 "class A {", |
| 9751 " A(p) {}", | 11015 " A(p) {}", |
| 9752 "}", | 11016 "}", |
| 9753 "class B extends A {", | 11017 "class B extends A {", |
| 9754 " B() : super(f);", | 11018 " B() : super(f);", |
| 9755 " var f;", | 11019 " var f;", |
| 9756 "}"])); | 11020 "}"])); |
| 9757 resolve(source); | 11021 resolve(source); |
| 9758 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); | 11022 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 9759 verify([source]); | 11023 verify([source]); |
| 9760 } | 11024 } |
| 11025 |
| 9761 void test_importInternalLibrary() { | 11026 void test_importInternalLibrary() { |
| 9762 Source source = addSource(EngineTestCase.createSource(["import 'dart:_interc
eptors';"])); | 11027 Source source = addSource(EngineTestCase.createSource(["import 'dart:_interc
eptors';"])); |
| 9763 resolve(source); | 11028 resolve(source); |
| 9764 assertErrors(source, [ | 11029 assertErrors(source, [ |
| 9765 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, | 11030 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, |
| 9766 HintCode.UNUSED_IMPORT]); | 11031 HintCode.UNUSED_IMPORT]); |
| 9767 verify([source]); | 11032 verify([source]); |
| 9768 } | 11033 } |
| 11034 |
| 9769 void test_importInternalLibrary_collection() { | 11035 void test_importInternalLibrary_collection() { |
| 9770 Source source = addSource(EngineTestCase.createSource(["import 'dart:_collec
tion-dev';"])); | 11036 Source source = addSource(EngineTestCase.createSource(["import 'dart:_collec
tion-dev';"])); |
| 9771 resolve(source); | 11037 resolve(source); |
| 9772 assertErrors(source, [ | 11038 assertErrors(source, [ |
| 9773 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, | 11039 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, |
| 9774 HintCode.UNUSED_IMPORT]); | 11040 HintCode.UNUSED_IMPORT]); |
| 9775 verify([source]); | 11041 verify([source]); |
| 9776 } | 11042 } |
| 11043 |
| 9777 void test_importOfNonLibrary() { | 11044 void test_importOfNonLibrary() { |
| 9778 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); | 11045 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); |
| 9779 addSource2("/part.dart", EngineTestCase.createSource(["part of lib;", "class
A{}"])); | 11046 addSource2("/part.dart", EngineTestCase.createSource(["part of lib;", "class
A{}"])); |
| 9780 resolve(source); | 11047 resolve(source); |
| 9781 assertErrors(source, [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]); | 11048 assertErrors(source, [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]); |
| 9782 verify([source]); | 11049 verify([source]); |
| 9783 } | 11050 } |
| 11051 |
| 9784 void test_inconsistentCaseExpressionTypes() { | 11052 void test_inconsistentCaseExpressionTypes() { |
| 9785 Source source = addSource(EngineTestCase.createSource([ | 11053 Source source = addSource(EngineTestCase.createSource([ |
| 9786 "f(var p) {", | 11054 "f(var p) {", |
| 9787 " switch (p) {", | 11055 " switch (p) {", |
| 9788 " case 1:", | 11056 " case 1:", |
| 9789 " break;", | 11057 " break;", |
| 9790 " case 'a':", | 11058 " case 'a':", |
| 9791 " break;", | 11059 " break;", |
| 9792 " }", | 11060 " }", |
| 9793 "}"])); | 11061 "}"])); |
| 9794 resolve(source); | 11062 resolve(source); |
| 9795 assertErrors(source, [CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPE
S]); | 11063 assertErrors(source, [CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPE
S]); |
| 9796 verify([source]); | 11064 verify([source]); |
| 9797 } | 11065 } |
| 11066 |
| 9798 void test_inconsistentCaseExpressionTypes_repeated() { | 11067 void test_inconsistentCaseExpressionTypes_repeated() { |
| 9799 Source source = addSource(EngineTestCase.createSource([ | 11068 Source source = addSource(EngineTestCase.createSource([ |
| 9800 "f(var p) {", | 11069 "f(var p) {", |
| 9801 " switch (p) {", | 11070 " switch (p) {", |
| 9802 " case 1:", | 11071 " case 1:", |
| 9803 " break;", | 11072 " break;", |
| 9804 " case 'a':", | 11073 " case 'a':", |
| 9805 " break;", | 11074 " break;", |
| 9806 " case 'b':", | 11075 " case 'b':", |
| 9807 " break;", | 11076 " break;", |
| 9808 " }", | 11077 " }", |
| 9809 "}"])); | 11078 "}"])); |
| 9810 resolve(source); | 11079 resolve(source); |
| 9811 assertErrors(source, [ | 11080 assertErrors(source, [ |
| 9812 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, | 11081 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, |
| 9813 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]); | 11082 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]); |
| 9814 verify([source]); | 11083 verify([source]); |
| 9815 } | 11084 } |
| 11085 |
| 9816 void test_initializerForNonExistant_initializer() { | 11086 void test_initializerForNonExistant_initializer() { |
| 9817 Source source = addSource(EngineTestCase.createSource(["class A {", " A() :
x = 0 {}", "}"])); | 11087 Source source = addSource(EngineTestCase.createSource(["class A {", " A() :
x = 0 {}", "}"])); |
| 9818 resolve(source); | 11088 resolve(source); |
| 9819 assertErrors(source, [CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FIEL
D]); | 11089 assertErrors(source, [CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FIEL
D]); |
| 9820 } | 11090 } |
| 11091 |
| 9821 void test_initializerForStaticField() { | 11092 void test_initializerForStaticField() { |
| 9822 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " A() : x = 0 {}", "}"])); | 11093 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " A() : x = 0 {}", "}"])); |
| 9823 resolve(source); | 11094 resolve(source); |
| 9824 assertErrors(source, [CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]); | 11095 assertErrors(source, [CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]); |
| 9825 verify([source]); | 11096 verify([source]); |
| 9826 } | 11097 } |
| 11098 |
| 9827 void test_initializingFormalForNonExistantField() { | 11099 void test_initializingFormalForNonExistantField() { |
| 9828 Source source = addSource(EngineTestCase.createSource(["class A {", " A(thi
s.x) {}", "}"])); | 11100 Source source = addSource(EngineTestCase.createSource(["class A {", " A(thi
s.x) {}", "}"])); |
| 9829 resolve(source); | 11101 resolve(source); |
| 9830 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); | 11102 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); |
| 9831 verify([source]); | 11103 verify([source]); |
| 9832 } | 11104 } |
| 11105 |
| 9833 void test_initializingFormalForNonExistantField_notInEnclosingClass() { | 11106 void test_initializingFormalForNonExistantField_notInEnclosingClass() { |
| 9834 Source source = addSource(EngineTestCase.createSource([ | 11107 Source source = addSource(EngineTestCase.createSource([ |
| 9835 "class A {", | 11108 "class A {", |
| 9836 "int x;", | 11109 "int x;", |
| 9837 "}", | 11110 "}", |
| 9838 "class B extends A {", | 11111 "class B extends A {", |
| 9839 " B(this.x) {}", | 11112 " B(this.x) {}", |
| 9840 "}"])); | 11113 "}"])); |
| 9841 resolve(source); | 11114 resolve(source); |
| 9842 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); | 11115 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); |
| 9843 verify([source]); | 11116 verify([source]); |
| 9844 } | 11117 } |
| 11118 |
| 9845 void test_initializingFormalForNonExistantField_optional() { | 11119 void test_initializingFormalForNonExistantField_optional() { |
| 9846 Source source = addSource(EngineTestCase.createSource(["class A {", " A([th
is.x]) {}", "}"])); | 11120 Source source = addSource(EngineTestCase.createSource(["class A {", " A([th
is.x]) {}", "}"])); |
| 9847 resolve(source); | 11121 resolve(source); |
| 9848 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); | 11122 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); |
| 9849 verify([source]); | 11123 verify([source]); |
| 9850 } | 11124 } |
| 11125 |
| 9851 void test_initializingFormalForNonExistantField_synthetic() { | 11126 void test_initializingFormalForNonExistantField_synthetic() { |
| 9852 Source source = addSource(EngineTestCase.createSource(["class A {", " int g
et x => 1;", " A(this.x) {}", "}"])); | 11127 Source source = addSource(EngineTestCase.createSource(["class A {", " int g
et x => 1;", " A(this.x) {}", "}"])); |
| 9853 resolve(source); | 11128 resolve(source); |
| 9854 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); | 11129 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); |
| 9855 verify([source]); | 11130 verify([source]); |
| 9856 } | 11131 } |
| 11132 |
| 9857 void test_initializingFormalForStaticField() { | 11133 void test_initializingFormalForStaticField() { |
| 9858 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " A([this.x]) {}", "}"])); | 11134 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " A([this.x]) {}", "}"])); |
| 9859 resolve(source); | 11135 resolve(source); |
| 9860 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FI
ELD]); | 11136 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FI
ELD]); |
| 9861 verify([source]); | 11137 verify([source]); |
| 9862 } | 11138 } |
| 11139 |
| 9863 void test_instanceMemberAccessFromStatic_field() { | 11140 void test_instanceMemberAccessFromStatic_field() { |
| 9864 Source source = addSource(EngineTestCase.createSource([ | 11141 Source source = addSource(EngineTestCase.createSource([ |
| 9865 "class A {", | 11142 "class A {", |
| 9866 " int f;", | 11143 " int f;", |
| 9867 " static foo() {", | 11144 " static foo() {", |
| 9868 " f;", | 11145 " f;", |
| 9869 " }", | 11146 " }", |
| 9870 "}"])); | 11147 "}"])); |
| 9871 resolve(source); | 11148 resolve(source); |
| 9872 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI
C]); | 11149 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI
C]); |
| 9873 verify([source]); | 11150 verify([source]); |
| 9874 } | 11151 } |
| 11152 |
| 9875 void test_instanceMemberAccessFromStatic_getter() { | 11153 void test_instanceMemberAccessFromStatic_getter() { |
| 9876 Source source = addSource(EngineTestCase.createSource([ | 11154 Source source = addSource(EngineTestCase.createSource([ |
| 9877 "class A {", | 11155 "class A {", |
| 9878 " get g => null;", | 11156 " get g => null;", |
| 9879 " static foo() {", | 11157 " static foo() {", |
| 9880 " g;", | 11158 " g;", |
| 9881 " }", | 11159 " }", |
| 9882 "}"])); | 11160 "}"])); |
| 9883 resolve(source); | 11161 resolve(source); |
| 9884 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI
C]); | 11162 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI
C]); |
| 9885 verify([source]); | 11163 verify([source]); |
| 9886 } | 11164 } |
| 11165 |
| 9887 void test_instanceMemberAccessFromStatic_method() { | 11166 void test_instanceMemberAccessFromStatic_method() { |
| 9888 Source source = addSource(EngineTestCase.createSource([ | 11167 Source source = addSource(EngineTestCase.createSource([ |
| 9889 "class A {", | 11168 "class A {", |
| 9890 " m() {}", | 11169 " m() {}", |
| 9891 " static foo() {", | 11170 " static foo() {", |
| 9892 " m();", | 11171 " m();", |
| 9893 " }", | 11172 " }", |
| 9894 "}"])); | 11173 "}"])); |
| 9895 resolve(source); | 11174 resolve(source); |
| 9896 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI
C]); | 11175 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI
C]); |
| 9897 verify([source]); | 11176 verify([source]); |
| 9898 } | 11177 } |
| 11178 |
| 9899 void test_invalidAnnotation_getter() { | 11179 void test_invalidAnnotation_getter() { |
| 9900 Source source = addSource(EngineTestCase.createSource(["get V => 0;", "@V",
"main() {", "}"])); | 11180 Source source = addSource(EngineTestCase.createSource(["get V => 0;", "@V",
"main() {", "}"])); |
| 9901 resolve(source); | 11181 resolve(source); |
| 9902 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 11182 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 9903 verify([source]); | 11183 verify([source]); |
| 9904 } | 11184 } |
| 11185 |
| 9905 void test_invalidAnnotation_importWithPrefix_getter() { | 11186 void test_invalidAnnotation_importWithPrefix_getter() { |
| 9906 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "get V
=> 0;"])); | 11187 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "get V
=> 0;"])); |
| 9907 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); | 11188 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); |
| 9908 resolve(source); | 11189 resolve(source); |
| 9909 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 11190 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 9910 verify([source]); | 11191 verify([source]); |
| 9911 } | 11192 } |
| 11193 |
| 9912 void test_invalidAnnotation_importWithPrefix_notConstantVariable() { | 11194 void test_invalidAnnotation_importWithPrefix_notConstantVariable() { |
| 9913 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "final
V = 0;"])); | 11195 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "final
V = 0;"])); |
| 9914 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); | 11196 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); |
| 9915 resolve(source); | 11197 resolve(source); |
| 9916 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 11198 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 9917 verify([source]); | 11199 verify([source]); |
| 9918 } | 11200 } |
| 11201 |
| 9919 void test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocatio
n() { | 11202 void test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocatio
n() { |
| 9920 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "typede
f V();"])); | 11203 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "typede
f V();"])); |
| 9921 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); | 11204 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); |
| 9922 resolve(source); | 11205 resolve(source); |
| 9923 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 11206 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 9924 verify([source]); | 11207 verify([source]); |
| 9925 } | 11208 } |
| 11209 |
| 9926 void test_invalidAnnotation_notConstantVariable() { | 11210 void test_invalidAnnotation_notConstantVariable() { |
| 9927 Source source = addSource(EngineTestCase.createSource(["final V = 0;", "@V",
"main() {", "}"])); | 11211 Source source = addSource(EngineTestCase.createSource(["final V = 0;", "@V",
"main() {", "}"])); |
| 9928 resolve(source); | 11212 resolve(source); |
| 9929 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 11213 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 9930 verify([source]); | 11214 verify([source]); |
| 9931 } | 11215 } |
| 11216 |
| 9932 void test_invalidAnnotation_notVariableOrConstructorInvocation() { | 11217 void test_invalidAnnotation_notVariableOrConstructorInvocation() { |
| 9933 Source source = addSource(EngineTestCase.createSource(["typedef V();", "@V",
"main() {", "}"])); | 11218 Source source = addSource(EngineTestCase.createSource(["typedef V();", "@V",
"main() {", "}"])); |
| 9934 resolve(source); | 11219 resolve(source); |
| 9935 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 11220 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 9936 verify([source]); | 11221 verify([source]); |
| 9937 } | 11222 } |
| 11223 |
| 9938 void test_invalidAnnotation_staticMethodReference() { | 11224 void test_invalidAnnotation_staticMethodReference() { |
| 9939 Source source = addSource(EngineTestCase.createSource([ | 11225 Source source = addSource(EngineTestCase.createSource([ |
| 9940 "class A {", | 11226 "class A {", |
| 9941 " static f() {}", | 11227 " static f() {}", |
| 9942 "}", | 11228 "}", |
| 9943 "@A.f", | 11229 "@A.f", |
| 9944 "main() {", | 11230 "main() {", |
| 9945 "}"])); | 11231 "}"])); |
| 9946 resolve(source); | 11232 resolve(source); |
| 9947 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 11233 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 9948 verify([source]); | 11234 verify([source]); |
| 9949 } | 11235 } |
| 11236 |
| 9950 void test_invalidAnnotation_unresolved_identifier() { | 11237 void test_invalidAnnotation_unresolved_identifier() { |
| 9951 Source source = addSource(EngineTestCase.createSource(["@unresolved", "main(
) {", "}"])); | 11238 Source source = addSource(EngineTestCase.createSource(["@unresolved", "main(
) {", "}"])); |
| 9952 resolve(source); | 11239 resolve(source); |
| 9953 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 11240 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 9954 } | 11241 } |
| 11242 |
| 9955 void test_invalidAnnotation_unresolved_invocation() { | 11243 void test_invalidAnnotation_unresolved_invocation() { |
| 9956 Source source = addSource(EngineTestCase.createSource(["@Unresolved()", "mai
n() {", "}"])); | 11244 Source source = addSource(EngineTestCase.createSource(["@Unresolved()", "mai
n() {", "}"])); |
| 9957 resolve(source); | 11245 resolve(source); |
| 9958 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 11246 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 9959 } | 11247 } |
| 11248 |
| 9960 void test_invalidAnnotation_unresolved_prefixedIdentifier() { | 11249 void test_invalidAnnotation_unresolved_prefixedIdentifier() { |
| 9961 Source source = addSource(EngineTestCase.createSource([ | 11250 Source source = addSource(EngineTestCase.createSource([ |
| 9962 "import 'dart:math' as p;", | 11251 "import 'dart:math' as p;", |
| 9963 "@p.unresolved", | 11252 "@p.unresolved", |
| 9964 "main() {", | 11253 "main() {", |
| 9965 "}"])); | 11254 "}"])); |
| 9966 resolve(source); | 11255 resolve(source); |
| 9967 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); | 11256 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 9968 } | 11257 } |
| 11258 |
| 9969 void test_invalidConstructorName_notEnclosingClassName_defined() { | 11259 void test_invalidConstructorName_notEnclosingClassName_defined() { |
| 9970 Source source = addSource(EngineTestCase.createSource(["class A {", " B() :
super();", "}", "class B {}"])); | 11260 Source source = addSource(EngineTestCase.createSource(["class A {", " B() :
super();", "}", "class B {}"])); |
| 9971 resolve(source); | 11261 resolve(source); |
| 9972 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); | 11262 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); |
| 9973 } | 11263 } |
| 11264 |
| 9974 void test_invalidConstructorName_notEnclosingClassName_undefined() { | 11265 void test_invalidConstructorName_notEnclosingClassName_undefined() { |
| 9975 Source source = addSource(EngineTestCase.createSource(["class A {", " B() :
super();", "}"])); | 11266 Source source = addSource(EngineTestCase.createSource(["class A {", " B() :
super();", "}"])); |
| 9976 resolve(source); | 11267 resolve(source); |
| 9977 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); | 11268 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); |
| 9978 } | 11269 } |
| 11270 |
| 9979 void test_invalidFactoryNameNotAClass_notClassName() { | 11271 void test_invalidFactoryNameNotAClass_notClassName() { |
| 9980 Source source = addSource(EngineTestCase.createSource(["int B;", "class A {"
, " factory B() {}", "}"])); | 11272 Source source = addSource(EngineTestCase.createSource(["int B;", "class A {"
, " factory B() {}", "}"])); |
| 9981 resolve(source); | 11273 resolve(source); |
| 9982 assertErrors(source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]
); | 11274 assertErrors(source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]
); |
| 9983 verify([source]); | 11275 verify([source]); |
| 9984 } | 11276 } |
| 11277 |
| 9985 void test_invalidFactoryNameNotAClass_notEnclosingClassName() { | 11278 void test_invalidFactoryNameNotAClass_notEnclosingClassName() { |
| 9986 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry B() {}", "}"])); | 11279 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry B() {}", "}"])); |
| 9987 resolve(source); | 11280 resolve(source); |
| 9988 assertErrors(source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]
); | 11281 assertErrors(source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]
); |
| 9989 } | 11282 } |
| 11283 |
| 9990 void test_invalidReferenceToThis_factoryConstructor() { | 11284 void test_invalidReferenceToThis_factoryConstructor() { |
| 9991 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() { return this; }", "}"])); | 11285 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() { return this; }", "}"])); |
| 9992 resolve(source); | 11286 resolve(source); |
| 9993 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 11287 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 9994 verify([source]); | 11288 verify([source]); |
| 9995 } | 11289 } |
| 11290 |
| 9996 void test_invalidReferenceToThis_instanceVariableInitializer_inConstructor() { | 11291 void test_invalidReferenceToThis_instanceVariableInitializer_inConstructor() { |
| 9997 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
;", " A() : f = this;", "}"])); | 11292 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
;", " A() : f = this;", "}"])); |
| 9998 resolve(source); | 11293 resolve(source); |
| 9999 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 11294 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 10000 verify([source]); | 11295 verify([source]); |
| 10001 } | 11296 } |
| 11297 |
| 10002 void test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration() { | 11298 void test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration() { |
| 10003 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
= this;", "}"])); | 11299 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
= this;", "}"])); |
| 10004 resolve(source); | 11300 resolve(source); |
| 10005 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 11301 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 10006 verify([source]); | 11302 verify([source]); |
| 10007 } | 11303 } |
| 11304 |
| 10008 void test_invalidReferenceToThis_staticMethod() { | 11305 void test_invalidReferenceToThis_staticMethod() { |
| 10009 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c m() { return this; }", "}"])); | 11306 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c m() { return this; }", "}"])); |
| 10010 resolve(source); | 11307 resolve(source); |
| 10011 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 11308 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 10012 verify([source]); | 11309 verify([source]); |
| 10013 } | 11310 } |
| 11311 |
| 10014 void test_invalidReferenceToThis_staticVariableInitializer() { | 11312 void test_invalidReferenceToThis_staticVariableInitializer() { |
| 10015 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c A f = this;", "}"])); | 11313 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c A f = this;", "}"])); |
| 10016 resolve(source); | 11314 resolve(source); |
| 10017 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 11315 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 10018 verify([source]); | 11316 verify([source]); |
| 10019 } | 11317 } |
| 11318 |
| 10020 void test_invalidReferenceToThis_superInitializer() { | 11319 void test_invalidReferenceToThis_superInitializer() { |
| 10021 Source source = addSource(EngineTestCase.createSource([ | 11320 Source source = addSource(EngineTestCase.createSource([ |
| 10022 "class A {", | 11321 "class A {", |
| 10023 " A(var x) {}", | 11322 " A(var x) {}", |
| 10024 "}", | 11323 "}", |
| 10025 "class B extends A {", | 11324 "class B extends A {", |
| 10026 " B() : super(this);", | 11325 " B() : super(this);", |
| 10027 "}"])); | 11326 "}"])); |
| 10028 resolve(source); | 11327 resolve(source); |
| 10029 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 11328 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 10030 verify([source]); | 11329 verify([source]); |
| 10031 } | 11330 } |
| 11331 |
| 10032 void test_invalidReferenceToThis_topLevelFunction() { | 11332 void test_invalidReferenceToThis_topLevelFunction() { |
| 10033 Source source = addSource("f() { return this; }"); | 11333 Source source = addSource("f() { return this; }"); |
| 10034 resolve(source); | 11334 resolve(source); |
| 10035 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 11335 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 10036 verify([source]); | 11336 verify([source]); |
| 10037 } | 11337 } |
| 11338 |
| 10038 void test_invalidReferenceToThis_variableInitializer() { | 11339 void test_invalidReferenceToThis_variableInitializer() { |
| 10039 Source source = addSource("int x = this;"); | 11340 Source source = addSource("int x = this;"); |
| 10040 resolve(source); | 11341 resolve(source); |
| 10041 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 11342 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 10042 verify([source]); | 11343 verify([source]); |
| 10043 } | 11344 } |
| 11345 |
| 10044 void test_invalidTypeArgumentInConstList() { | 11346 void test_invalidTypeArgumentInConstList() { |
| 10045 Source source = addSource(EngineTestCase.createSource([ | 11347 Source source = addSource(EngineTestCase.createSource([ |
| 10046 "class A<E> {", | 11348 "class A<E> {", |
| 10047 " m() {", | 11349 " m() {", |
| 10048 " return const <E>[];", | 11350 " return const <E>[];", |
| 10049 " }", | 11351 " }", |
| 10050 "}"])); | 11352 "}"])); |
| 10051 resolve(source); | 11353 resolve(source); |
| 10052 assertErrors(source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LI
ST]); | 11354 assertErrors(source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LI
ST]); |
| 10053 verify([source]); | 11355 verify([source]); |
| 10054 } | 11356 } |
| 11357 |
| 10055 void test_invalidTypeArgumentInConstMap() { | 11358 void test_invalidTypeArgumentInConstMap() { |
| 10056 Source source = addSource(EngineTestCase.createSource([ | 11359 Source source = addSource(EngineTestCase.createSource([ |
| 10057 "class A<E> {", | 11360 "class A<E> {", |
| 10058 " m() {", | 11361 " m() {", |
| 10059 " return const <String, E>{};", | 11362 " return const <String, E>{};", |
| 10060 " }", | 11363 " }", |
| 10061 "}"])); | 11364 "}"])); |
| 10062 resolve(source); | 11365 resolve(source); |
| 10063 assertErrors(source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MA
P]); | 11366 assertErrors(source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MA
P]); |
| 10064 verify([source]); | 11367 verify([source]); |
| 10065 } | 11368 } |
| 11369 |
| 10066 void test_invalidUri_export() { | 11370 void test_invalidUri_export() { |
| 10067 Source source = addSource(EngineTestCase.createSource(["export 'ht:';"])); | 11371 Source source = addSource(EngineTestCase.createSource(["export 'ht:';"])); |
| 10068 resolve(source); | 11372 resolve(source); |
| 10069 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); | 11373 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
| 10070 } | 11374 } |
| 11375 |
| 10071 void test_invalidUri_import() { | 11376 void test_invalidUri_import() { |
| 10072 Source source = addSource(EngineTestCase.createSource(["import 'ht:';"])); | 11377 Source source = addSource(EngineTestCase.createSource(["import 'ht:';"])); |
| 10073 resolve(source); | 11378 resolve(source); |
| 10074 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); | 11379 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
| 10075 } | 11380 } |
| 11381 |
| 10076 void test_invalidUri_part() { | 11382 void test_invalidUri_part() { |
| 10077 Source source = addSource(EngineTestCase.createSource(["part 'ht:';"])); | 11383 Source source = addSource(EngineTestCase.createSource(["part 'ht:';"])); |
| 10078 resolve(source); | 11384 resolve(source); |
| 10079 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); | 11385 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
| 10080 } | 11386 } |
| 11387 |
| 10081 void test_labelInOuterScope() { | 11388 void test_labelInOuterScope() { |
| 10082 Source source = addSource(EngineTestCase.createSource([ | 11389 Source source = addSource(EngineTestCase.createSource([ |
| 10083 "class A {", | 11390 "class A {", |
| 10084 " void m(int i) {", | 11391 " void m(int i) {", |
| 10085 " l: while (i > 0) {", | 11392 " l: while (i > 0) {", |
| 10086 " void f() {", | 11393 " void f() {", |
| 10087 " break l;", | 11394 " break l;", |
| 10088 " };", | 11395 " };", |
| 10089 " }", | 11396 " }", |
| 10090 " }", | 11397 " }", |
| 10091 "}"])); | 11398 "}"])); |
| 10092 resolve(source); | 11399 resolve(source); |
| 10093 assertErrors(source, [CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE]); | 11400 assertErrors(source, [CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE]); |
| 10094 } | 11401 } |
| 11402 |
| 10095 void test_labelUndefined_break() { | 11403 void test_labelUndefined_break() { |
| 10096 Source source = addSource(EngineTestCase.createSource([ | 11404 Source source = addSource(EngineTestCase.createSource([ |
| 10097 "f() {", | 11405 "f() {", |
| 10098 " x: while (true) {", | 11406 " x: while (true) {", |
| 10099 " break y;", | 11407 " break y;", |
| 10100 " }", | 11408 " }", |
| 10101 "}"])); | 11409 "}"])); |
| 10102 resolve(source); | 11410 resolve(source); |
| 10103 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]); | 11411 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]); |
| 10104 } | 11412 } |
| 11413 |
| 10105 void test_labelUndefined_continue() { | 11414 void test_labelUndefined_continue() { |
| 10106 Source source = addSource(EngineTestCase.createSource([ | 11415 Source source = addSource(EngineTestCase.createSource([ |
| 10107 "f() {", | 11416 "f() {", |
| 10108 " x: while (true) {", | 11417 " x: while (true) {", |
| 10109 " continue y;", | 11418 " continue y;", |
| 10110 " }", | 11419 " }", |
| 10111 "}"])); | 11420 "}"])); |
| 10112 resolve(source); | 11421 resolve(source); |
| 10113 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]); | 11422 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]); |
| 10114 } | 11423 } |
| 11424 |
| 10115 void test_listElementTypeNotAssignable() { | 11425 void test_listElementTypeNotAssignable() { |
| 10116 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g> [42];"])); | 11426 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g> [42];"])); |
| 10117 resolve(source); | 11427 resolve(source); |
| 10118 assertErrors(source, [CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]
); | 11428 assertErrors(source, [CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]
); |
| 10119 verify([source]); | 11429 verify([source]); |
| 10120 } | 11430 } |
| 11431 |
| 10121 void test_mapKeyTypeNotAssignable() { | 11432 void test_mapKeyTypeNotAssignable() { |
| 10122 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g, int > {1 : 2};"])); | 11433 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g, int > {1 : 2};"])); |
| 10123 resolve(source); | 11434 resolve(source); |
| 10124 assertErrors(source, [CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]); | 11435 assertErrors(source, [CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]); |
| 10125 verify([source]); | 11436 verify([source]); |
| 10126 } | 11437 } |
| 11438 |
| 10127 void test_mapValueTypeNotAssignable() { | 11439 void test_mapValueTypeNotAssignable() { |
| 10128 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g, String> {'a' : 2};"])); | 11440 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g, String> {'a' : 2};"])); |
| 10129 resolve(source); | 11441 resolve(source); |
| 10130 assertErrors(source, [CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]); | 11442 assertErrors(source, [CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]); |
| 10131 verify([source]); | 11443 verify([source]); |
| 10132 } | 11444 } |
| 11445 |
| 10133 void test_memberWithClassName_field() { | 11446 void test_memberWithClassName_field() { |
| 10134 Source source = addSource(EngineTestCase.createSource(["class A {", " int A
= 0;", "}"])); | 11447 Source source = addSource(EngineTestCase.createSource(["class A {", " int A
= 0;", "}"])); |
| 10135 resolve(source); | 11448 resolve(source); |
| 10136 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); | 11449 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); |
| 10137 verify([source]); | 11450 verify([source]); |
| 10138 } | 11451 } |
| 11452 |
| 10139 void test_memberWithClassName_field2() { | 11453 void test_memberWithClassName_field2() { |
| 10140 Source source = addSource(EngineTestCase.createSource(["class A {", " int z
, A, b = 0;", "}"])); | 11454 Source source = addSource(EngineTestCase.createSource(["class A {", " int z
, A, b = 0;", "}"])); |
| 10141 resolve(source); | 11455 resolve(source); |
| 10142 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); | 11456 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); |
| 10143 verify([source]); | 11457 verify([source]); |
| 10144 } | 11458 } |
| 11459 |
| 10145 void test_memberWithClassName_getter() { | 11460 void test_memberWithClassName_getter() { |
| 10146 Source source = addSource(EngineTestCase.createSource(["class A {", " get A
=> 0;", "}"])); | 11461 Source source = addSource(EngineTestCase.createSource(["class A {", " get A
=> 0;", "}"])); |
| 10147 resolve(source); | 11462 resolve(source); |
| 10148 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); | 11463 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); |
| 10149 verify([source]); | 11464 verify([source]); |
| 10150 } | 11465 } |
| 11466 |
| 10151 void test_memberWithClassName_method() { | 11467 void test_memberWithClassName_method() { |
| 10152 } | 11468 } |
| 11469 |
| 10153 void test_methodAndGetterWithSameName() { | 11470 void test_methodAndGetterWithSameName() { |
| 10154 Source source = addSource(EngineTestCase.createSource(["class A {", " get x
=> 0;", " x(y) {}", "}"])); | 11471 Source source = addSource(EngineTestCase.createSource(["class A {", " get x
=> 0;", " x(y) {}", "}"])); |
| 10155 resolve(source); | 11472 resolve(source); |
| 10156 assertErrors(source, [CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]
); | 11473 assertErrors(source, [CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]
); |
| 10157 verify([source]); | 11474 verify([source]); |
| 10158 } | 11475 } |
| 11476 |
| 10159 void test_mixinDeclaresConstructor_classDeclaration() { | 11477 void test_mixinDeclaresConstructor_classDeclaration() { |
| 10160 Source source = addSource(EngineTestCase.createSource([ | 11478 Source source = addSource(EngineTestCase.createSource([ |
| 10161 "class A {", | 11479 "class A {", |
| 10162 " A() {}", | 11480 " A() {}", |
| 10163 "}", | 11481 "}", |
| 10164 "class B extends Object with A {}"])); | 11482 "class B extends Object with A {}"])); |
| 10165 resolve(source); | 11483 resolve(source); |
| 10166 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); | 11484 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); |
| 10167 verify([source]); | 11485 verify([source]); |
| 10168 } | 11486 } |
| 11487 |
| 10169 void test_mixinDeclaresConstructor_typeAlias() { | 11488 void test_mixinDeclaresConstructor_typeAlias() { |
| 10170 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "class B = Object with A;"])); | 11489 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "class B = Object with A;"])); |
| 10171 resolve(source); | 11490 resolve(source); |
| 10172 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); | 11491 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); |
| 10173 verify([source]); | 11492 verify([source]); |
| 10174 } | 11493 } |
| 11494 |
| 10175 void test_mixinInheritsFromNotObject_classDeclaration_extends() { | 11495 void test_mixinInheritsFromNotObject_classDeclaration_extends() { |
| 10176 Source source = addSource(EngineTestCase.createSource([ | 11496 Source source = addSource(EngineTestCase.createSource([ |
| 10177 "class A {}", | 11497 "class A {}", |
| 10178 "class B extends A {}", | 11498 "class B extends A {}", |
| 10179 "class C extends Object with B {}"])); | 11499 "class C extends Object with B {}"])); |
| 10180 resolve(source); | 11500 resolve(source); |
| 10181 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); | 11501 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); |
| 10182 verify([source]); | 11502 verify([source]); |
| 10183 } | 11503 } |
| 11504 |
| 10184 void test_mixinInheritsFromNotObject_classDeclaration_with() { | 11505 void test_mixinInheritsFromNotObject_classDeclaration_with() { |
| 10185 Source source = addSource(EngineTestCase.createSource([ | 11506 Source source = addSource(EngineTestCase.createSource([ |
| 10186 "class A {}", | 11507 "class A {}", |
| 10187 "class B extends Object with A {}", | 11508 "class B extends Object with A {}", |
| 10188 "class C extends Object with B {}"])); | 11509 "class C extends Object with B {}"])); |
| 10189 resolve(source); | 11510 resolve(source); |
| 10190 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); | 11511 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); |
| 10191 verify([source]); | 11512 verify([source]); |
| 10192 } | 11513 } |
| 11514 |
| 10193 void test_mixinInheritsFromNotObject_typeAlias_extends() { | 11515 void test_mixinInheritsFromNotObject_typeAlias_extends() { |
| 10194 Source source = addSource(EngineTestCase.createSource([ | 11516 Source source = addSource(EngineTestCase.createSource([ |
| 10195 "class A {}", | 11517 "class A {}", |
| 10196 "class B extends A {}", | 11518 "class B extends A {}", |
| 10197 "class C = Object with B;"])); | 11519 "class C = Object with B;"])); |
| 10198 resolve(source); | 11520 resolve(source); |
| 10199 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); | 11521 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); |
| 10200 verify([source]); | 11522 verify([source]); |
| 10201 } | 11523 } |
| 11524 |
| 10202 void test_mixinInheritsFromNotObject_typeAlias_with() { | 11525 void test_mixinInheritsFromNotObject_typeAlias_with() { |
| 10203 Source source = addSource(EngineTestCase.createSource([ | 11526 Source source = addSource(EngineTestCase.createSource([ |
| 10204 "class A {}", | 11527 "class A {}", |
| 10205 "class B extends Object with A {}", | 11528 "class B extends Object with A {}", |
| 10206 "class C = Object with B;"])); | 11529 "class C = Object with B;"])); |
| 10207 resolve(source); | 11530 resolve(source); |
| 10208 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); | 11531 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); |
| 10209 verify([source]); | 11532 verify([source]); |
| 10210 } | 11533 } |
| 11534 |
| 10211 void test_mixinOfDisallowedClass_bool() { | 11535 void test_mixinOfDisallowedClass_bool() { |
| 10212 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with bool {}"])); | 11536 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with bool {}"])); |
| 10213 resolve(source); | 11537 resolve(source); |
| 10214 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 11538 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 10215 verify([source]); | 11539 verify([source]); |
| 10216 } | 11540 } |
| 11541 |
| 10217 void test_mixinOfDisallowedClass_double() { | 11542 void test_mixinOfDisallowedClass_double() { |
| 10218 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with double {}"])); | 11543 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with double {}"])); |
| 10219 resolve(source); | 11544 resolve(source); |
| 10220 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 11545 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 10221 verify([source]); | 11546 verify([source]); |
| 10222 } | 11547 } |
| 11548 |
| 10223 void test_mixinOfDisallowedClass_int() { | 11549 void test_mixinOfDisallowedClass_int() { |
| 10224 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with int {}"])); | 11550 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with int {}"])); |
| 10225 resolve(source); | 11551 resolve(source); |
| 10226 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 11552 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 10227 verify([source]); | 11553 verify([source]); |
| 10228 } | 11554 } |
| 11555 |
| 10229 void test_mixinOfDisallowedClass_Null() { | 11556 void test_mixinOfDisallowedClass_Null() { |
| 10230 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with Null {}"])); | 11557 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with Null {}"])); |
| 10231 resolve(source); | 11558 resolve(source); |
| 10232 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 11559 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 10233 verify([source]); | 11560 verify([source]); |
| 10234 } | 11561 } |
| 11562 |
| 10235 void test_mixinOfDisallowedClass_num() { | 11563 void test_mixinOfDisallowedClass_num() { |
| 10236 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with num {}"])); | 11564 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with num {}"])); |
| 10237 resolve(source); | 11565 resolve(source); |
| 10238 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 11566 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 10239 verify([source]); | 11567 verify([source]); |
| 10240 } | 11568 } |
| 11569 |
| 10241 void test_mixinOfDisallowedClass_String() { | 11570 void test_mixinOfDisallowedClass_String() { |
| 10242 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with String {}"])); | 11571 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with String {}"])); |
| 10243 resolve(source); | 11572 resolve(source); |
| 10244 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 11573 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 10245 verify([source]); | 11574 verify([source]); |
| 10246 } | 11575 } |
| 11576 |
| 10247 void test_mixinOfNonClass_class() { | 11577 void test_mixinOfNonClass_class() { |
| 10248 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex
tends Object with A {}"])); | 11578 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex
tends Object with A {}"])); |
| 10249 resolve(source); | 11579 resolve(source); |
| 10250 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); | 11580 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); |
| 10251 verify([source]); | 11581 verify([source]); |
| 10252 } | 11582 } |
| 11583 |
| 10253 void test_mixinOfNonClass_typeAlias() { | 11584 void test_mixinOfNonClass_typeAlias() { |
| 10254 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B;
", "class C = A with B;"])); | 11585 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B;
", "class C = A with B;"])); |
| 10255 resolve(source); | 11586 resolve(source); |
| 10256 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); | 11587 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); |
| 10257 verify([source]); | 11588 verify([source]); |
| 10258 } | 11589 } |
| 11590 |
| 10259 void test_mixinReferencesSuper() { | 11591 void test_mixinReferencesSuper() { |
| 10260 Source source = addSource(EngineTestCase.createSource([ | 11592 Source source = addSource(EngineTestCase.createSource([ |
| 10261 "class A {", | 11593 "class A {", |
| 10262 " toString() => super.toString();", | 11594 " toString() => super.toString();", |
| 10263 "}", | 11595 "}", |
| 10264 "class B extends Object with A {}"])); | 11596 "class B extends Object with A {}"])); |
| 10265 resolve(source); | 11597 resolve(source); |
| 10266 assertErrors(source, [CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]); | 11598 assertErrors(source, [CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]); |
| 10267 verify([source]); | 11599 verify([source]); |
| 10268 } | 11600 } |
| 11601 |
| 10269 void test_mixinWithNonClassSuperclass_class() { | 11602 void test_mixinWithNonClassSuperclass_class() { |
| 10270 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {}
", "class C extends A with B {}"])); | 11603 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {}
", "class C extends A with B {}"])); |
| 10271 resolve(source); | 11604 resolve(source); |
| 10272 assertErrors(source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS])
; | 11605 assertErrors(source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS])
; |
| 10273 verify([source]); | 11606 verify([source]); |
| 10274 } | 11607 } |
| 11608 |
| 10275 void test_mixinWithNonClassSuperclass_typeAlias() { | 11609 void test_mixinWithNonClassSuperclass_typeAlias() { |
| 10276 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {}
", "class C = A with B;"])); | 11610 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {}
", "class C = A with B;"])); |
| 10277 resolve(source); | 11611 resolve(source); |
| 10278 assertErrors(source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS])
; | 11612 assertErrors(source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS])
; |
| 10279 verify([source]); | 11613 verify([source]); |
| 10280 } | 11614 } |
| 11615 |
| 10281 void test_multipleRedirectingConstructorInvocations() { | 11616 void test_multipleRedirectingConstructorInvocations() { |
| 10282 Source source = addSource(EngineTestCase.createSource([ | 11617 Source source = addSource(EngineTestCase.createSource([ |
| 10283 "class A {", | 11618 "class A {", |
| 10284 " A() : this.a(), this.b();", | 11619 " A() : this.a(), this.b();", |
| 10285 " A.a() {}", | 11620 " A.a() {}", |
| 10286 " A.b() {}", | 11621 " A.b() {}", |
| 10287 "}"])); | 11622 "}"])); |
| 10288 resolve(source); | 11623 resolve(source); |
| 10289 assertErrors(source, [CompileTimeErrorCode.MULTIPLE_REDIRECTING_CONSTRUCTOR_
INVOCATIONS]); | 11624 assertErrors(source, [CompileTimeErrorCode.MULTIPLE_REDIRECTING_CONSTRUCTOR_
INVOCATIONS]); |
| 10290 verify([source]); | 11625 verify([source]); |
| 10291 } | 11626 } |
| 11627 |
| 10292 void test_multipleSuperInitializers() { | 11628 void test_multipleSuperInitializers() { |
| 10293 Source source = addSource(EngineTestCase.createSource([ | 11629 Source source = addSource(EngineTestCase.createSource([ |
| 10294 "class A {}", | 11630 "class A {}", |
| 10295 "class B extends A {", | 11631 "class B extends A {", |
| 10296 " B() : super(), super() {}", | 11632 " B() : super(), super() {}", |
| 10297 "}"])); | 11633 "}"])); |
| 10298 resolve(source); | 11634 resolve(source); |
| 10299 assertErrors(source, [CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]); | 11635 assertErrors(source, [CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]); |
| 10300 verify([source]); | 11636 verify([source]); |
| 10301 } | 11637 } |
| 11638 |
| 10302 void test_nativeClauseInNonSDKCode() { | 11639 void test_nativeClauseInNonSDKCode() { |
| 10303 Source source = addSource(EngineTestCase.createSource(["class A native 'stri
ng' {}"])); | 11640 Source source = addSource(EngineTestCase.createSource(["class A native 'stri
ng' {}"])); |
| 10304 resolve(source); | 11641 resolve(source); |
| 10305 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); | 11642 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); |
| 10306 verify([source]); | 11643 verify([source]); |
| 10307 } | 11644 } |
| 11645 |
| 10308 void test_nativeFunctionBodyInNonSDKCode_function() { | 11646 void test_nativeFunctionBodyInNonSDKCode_function() { |
| 10309 Source source = addSource(EngineTestCase.createSource(["int m(a) native 'str
ing';"])); | 11647 Source source = addSource(EngineTestCase.createSource(["int m(a) native 'str
ing';"])); |
| 10310 resolve(source); | 11648 resolve(source); |
| 10311 assertErrors(source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE])
; | 11649 assertErrors(source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE])
; |
| 10312 verify([source]); | 11650 verify([source]); |
| 10313 } | 11651 } |
| 11652 |
| 10314 void test_nativeFunctionBodyInNonSDKCode_method() { | 11653 void test_nativeFunctionBodyInNonSDKCode_method() { |
| 10315 Source source = addSource(EngineTestCase.createSource(["class A{", " static
int m(a) native 'string';", "}"])); | 11654 Source source = addSource(EngineTestCase.createSource(["class A{", " static
int m(a) native 'string';", "}"])); |
| 10316 resolve(source); | 11655 resolve(source); |
| 10317 assertErrors(source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE])
; | 11656 assertErrors(source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE])
; |
| 10318 verify([source]); | 11657 verify([source]); |
| 10319 } | 11658 } |
| 11659 |
| 10320 void test_noAnnotationConstructorArguments() { | 11660 void test_noAnnotationConstructorArguments() { |
| 10321 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A();", "}", "@A", "main() {", "}"])); | 11661 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A();", "}", "@A", "main() {", "}"])); |
| 10322 resolve(source); | 11662 resolve(source); |
| 10323 assertErrors(source, [CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMEN
TS]); | 11663 assertErrors(source, [CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMEN
TS]); |
| 10324 verify([source]); | 11664 verify([source]); |
| 10325 } | 11665 } |
| 11666 |
| 10326 void test_noDefaultSuperConstructorExplicit() { | 11667 void test_noDefaultSuperConstructorExplicit() { |
| 10327 Source source = addSource(EngineTestCase.createSource([ | 11668 Source source = addSource(EngineTestCase.createSource([ |
| 10328 "class A {", | 11669 "class A {", |
| 10329 " A(p);", | 11670 " A(p);", |
| 10330 "}", | 11671 "}", |
| 10331 "class B extends A {", | 11672 "class B extends A {", |
| 10332 " B() {}", | 11673 " B() {}", |
| 10333 "}"])); | 11674 "}"])); |
| 10334 resolve(source); | 11675 resolve(source); |
| 10335 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPL
ICIT]); | 11676 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPL
ICIT]); |
| 10336 verify([source]); | 11677 verify([source]); |
| 10337 } | 11678 } |
| 11679 |
| 10338 void test_noDefaultSuperConstructorImplicit_superHasParameters() { | 11680 void test_noDefaultSuperConstructorImplicit_superHasParameters() { |
| 10339 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p);
", "}", "class B extends A {", "}"])); | 11681 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p);
", "}", "class B extends A {", "}"])); |
| 10340 resolve(source); | 11682 resolve(source); |
| 10341 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPL
ICIT]); | 11683 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPL
ICIT]); |
| 10342 verify([source]); | 11684 verify([source]); |
| 10343 } | 11685 } |
| 11686 |
| 10344 void test_noDefaultSuperConstructorImplicit_superOnlyNamed() { | 11687 void test_noDefaultSuperConstructorImplicit_superOnlyNamed() { |
| 10345 Source source = addSource(EngineTestCase.createSource(["class A { A.named()
{} }", "class B extends A {}"])); | 11688 Source source = addSource(EngineTestCase.createSource(["class A { A.named()
{} }", "class B extends A {}"])); |
| 10346 resolve(source); | 11689 resolve(source); |
| 10347 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPL
ICIT]); | 11690 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPL
ICIT]); |
| 10348 verify([source]); | 11691 verify([source]); |
| 10349 } | 11692 } |
| 11693 |
| 10350 void test_nonConstantAnnotationConstructor_named() { | 11694 void test_nonConstantAnnotationConstructor_named() { |
| 10351 Source source = addSource(EngineTestCase.createSource([ | 11695 Source source = addSource(EngineTestCase.createSource([ |
| 10352 "class A {", | 11696 "class A {", |
| 10353 " A.fromInt() {}", | 11697 " A.fromInt() {}", |
| 10354 "}", | 11698 "}", |
| 10355 "@A.fromInt()", | 11699 "@A.fromInt()", |
| 10356 "main() {", | 11700 "main() {", |
| 10357 "}"])); | 11701 "}"])); |
| 10358 resolve(source); | 11702 resolve(source); |
| 10359 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCT
OR]); | 11703 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCT
OR]); |
| 10360 verify([source]); | 11704 verify([source]); |
| 10361 } | 11705 } |
| 11706 |
| 10362 void test_nonConstantAnnotationConstructor_unnamed() { | 11707 void test_nonConstantAnnotationConstructor_unnamed() { |
| 10363 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "@A()", "main() {", "}"])); | 11708 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "@A()", "main() {", "}"])); |
| 10364 resolve(source); | 11709 resolve(source); |
| 10365 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCT
OR]); | 11710 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCT
OR]); |
| 10366 verify([source]); | 11711 verify([source]); |
| 10367 } | 11712 } |
| 11713 |
| 10368 void test_nonConstantDefaultValue_function_named() { | 11714 void test_nonConstantDefaultValue_function_named() { |
| 10369 Source source = addSource(EngineTestCase.createSource(["int y;", "f({x : y})
{}"])); | 11715 Source source = addSource(EngineTestCase.createSource(["int y;", "f({x : y})
{}"])); |
| 10370 resolve(source); | 11716 resolve(source); |
| 10371 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 11717 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 10372 verify([source]); | 11718 verify([source]); |
| 10373 } | 11719 } |
| 11720 |
| 10374 void test_nonConstantDefaultValue_function_positional() { | 11721 void test_nonConstantDefaultValue_function_positional() { |
| 10375 Source source = addSource(EngineTestCase.createSource(["int y;", "f([x = y])
{}"])); | 11722 Source source = addSource(EngineTestCase.createSource(["int y;", "f([x = y])
{}"])); |
| 10376 resolve(source); | 11723 resolve(source); |
| 10377 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 11724 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 10378 verify([source]); | 11725 verify([source]); |
| 10379 } | 11726 } |
| 11727 |
| 10380 void test_nonConstantDefaultValue_inConstructor_named() { | 11728 void test_nonConstantDefaultValue_inConstructor_named() { |
| 10381 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " A({x : y}) {}", "}"])); | 11729 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " A({x : y}) {}", "}"])); |
| 10382 resolve(source); | 11730 resolve(source); |
| 10383 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 11731 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 10384 verify([source]); | 11732 verify([source]); |
| 10385 } | 11733 } |
| 11734 |
| 10386 void test_nonConstantDefaultValue_inConstructor_positional() { | 11735 void test_nonConstantDefaultValue_inConstructor_positional() { |
| 10387 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " A([x = y]) {}", "}"])); | 11736 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " A([x = y]) {}", "}"])); |
| 10388 resolve(source); | 11737 resolve(source); |
| 10389 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 11738 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 10390 verify([source]); | 11739 verify([source]); |
| 10391 } | 11740 } |
| 11741 |
| 10392 void test_nonConstantDefaultValue_method_named() { | 11742 void test_nonConstantDefaultValue_method_named() { |
| 10393 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " m({x : y}) {}", "}"])); | 11743 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " m({x : y}) {}", "}"])); |
| 10394 resolve(source); | 11744 resolve(source); |
| 10395 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 11745 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 10396 verify([source]); | 11746 verify([source]); |
| 10397 } | 11747 } |
| 11748 |
| 10398 void test_nonConstantDefaultValue_method_positional() { | 11749 void test_nonConstantDefaultValue_method_positional() { |
| 10399 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " m([x = y]) {}", "}"])); | 11750 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " m([x = y]) {}", "}"])); |
| 10400 resolve(source); | 11751 resolve(source); |
| 10401 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 11752 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 10402 verify([source]); | 11753 verify([source]); |
| 10403 } | 11754 } |
| 11755 |
| 10404 void test_nonConstCaseExpression() { | 11756 void test_nonConstCaseExpression() { |
| 10405 Source source = addSource(EngineTestCase.createSource([ | 11757 Source source = addSource(EngineTestCase.createSource([ |
| 10406 "f(int p, int q) {", | 11758 "f(int p, int q) {", |
| 10407 " switch (p) {", | 11759 " switch (p) {", |
| 10408 " case 3 + q:", | 11760 " case 3 + q:", |
| 10409 " break;", | 11761 " break;", |
| 10410 " }", | 11762 " }", |
| 10411 "}"])); | 11763 "}"])); |
| 10412 resolve(source); | 11764 resolve(source); |
| 10413 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]); | 11765 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]); |
| 10414 verify([source]); | 11766 verify([source]); |
| 10415 } | 11767 } |
| 11768 |
| 10416 void test_nonConstListElement() { | 11769 void test_nonConstListElement() { |
| 10417 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst [a];", "}"])); | 11770 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst [a];", "}"])); |
| 10418 resolve(source); | 11771 resolve(source); |
| 10419 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]); | 11772 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]); |
| 10420 verify([source]); | 11773 verify([source]); |
| 10421 } | 11774 } |
| 11775 |
| 10422 void test_nonConstMapAsExpressionStatement_begin() { | 11776 void test_nonConstMapAsExpressionStatement_begin() { |
| 10423 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0,
'b' : 1}.length;", "}"])); | 11777 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0,
'b' : 1}.length;", "}"])); |
| 10424 resolve(source); | 11778 resolve(source); |
| 10425 assertErrors(source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATE
MENT]); | 11779 assertErrors(source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATE
MENT]); |
| 10426 verify([source]); | 11780 verify([source]); |
| 10427 } | 11781 } |
| 11782 |
| 10428 void test_nonConstMapAsExpressionStatement_only() { | 11783 void test_nonConstMapAsExpressionStatement_only() { |
| 10429 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0,
'b' : 1};", "}"])); | 11784 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0,
'b' : 1};", "}"])); |
| 10430 resolve(source); | 11785 resolve(source); |
| 10431 assertErrors(source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATE
MENT]); | 11786 assertErrors(source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATE
MENT]); |
| 10432 verify([source]); | 11787 verify([source]); |
| 10433 } | 11788 } |
| 11789 |
| 10434 void test_nonConstMapKey() { | 11790 void test_nonConstMapKey() { |
| 10435 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst {a : 0};", "}"])); | 11791 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst {a : 0};", "}"])); |
| 10436 resolve(source); | 11792 resolve(source); |
| 10437 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]); | 11793 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]); |
| 10438 verify([source]); | 11794 verify([source]); |
| 10439 } | 11795 } |
| 11796 |
| 10440 void test_nonConstMapValue() { | 11797 void test_nonConstMapValue() { |
| 10441 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst {'a' : a};", "}"])); | 11798 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst {'a' : a};", "}"])); |
| 10442 resolve(source); | 11799 resolve(source); |
| 10443 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]); | 11800 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]); |
| 10444 verify([source]); | 11801 verify([source]); |
| 10445 } | 11802 } |
| 11803 |
| 10446 void test_nonConstValueInInitializer_binary_notBool_left() { | 11804 void test_nonConstValueInInitializer_binary_notBool_left() { |
| 10447 Source source = addSource(EngineTestCase.createSource([ | 11805 Source source = addSource(EngineTestCase.createSource([ |
| 10448 "class A {", | 11806 "class A {", |
| 10449 " final bool a;", | 11807 " final bool a;", |
| 10450 " const A(String p) : a = p && true;", | 11808 " const A(String p) : a = p && true;", |
| 10451 "}"])); | 11809 "}"])); |
| 10452 resolve(source); | 11810 resolve(source); |
| 10453 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); | 11811 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); |
| 10454 verify([source]); | 11812 verify([source]); |
| 10455 } | 11813 } |
| 11814 |
| 10456 void test_nonConstValueInInitializer_binary_notBool_right() { | 11815 void test_nonConstValueInInitializer_binary_notBool_right() { |
| 10457 Source source = addSource(EngineTestCase.createSource([ | 11816 Source source = addSource(EngineTestCase.createSource([ |
| 10458 "class A {", | 11817 "class A {", |
| 10459 " final bool a;", | 11818 " final bool a;", |
| 10460 " const A(String p) : a = true && p;", | 11819 " const A(String p) : a = true && p;", |
| 10461 "}"])); | 11820 "}"])); |
| 10462 resolve(source); | 11821 resolve(source); |
| 10463 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); | 11822 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); |
| 10464 verify([source]); | 11823 verify([source]); |
| 10465 } | 11824 } |
| 11825 |
| 10466 void test_nonConstValueInInitializer_binary_notInt() { | 11826 void test_nonConstValueInInitializer_binary_notInt() { |
| 10467 Source source = addSource(EngineTestCase.createSource([ | 11827 Source source = addSource(EngineTestCase.createSource([ |
| 10468 "class A {", | 11828 "class A {", |
| 10469 " final int a;", | 11829 " final int a;", |
| 10470 " const A(String p) : a = 5 & p;", | 11830 " const A(String p) : a = 5 & p;", |
| 10471 "}"])); | 11831 "}"])); |
| 10472 resolve(source); | 11832 resolve(source); |
| 10473 assertErrors(source, [ | 11833 assertErrors(source, [ |
| 10474 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, | 11834 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, |
| 10475 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 11835 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 10476 verify([source]); | 11836 verify([source]); |
| 10477 } | 11837 } |
| 11838 |
| 10478 void test_nonConstValueInInitializer_binary_notNum() { | 11839 void test_nonConstValueInInitializer_binary_notNum() { |
| 10479 Source source = addSource(EngineTestCase.createSource([ | 11840 Source source = addSource(EngineTestCase.createSource([ |
| 10480 "class A {", | 11841 "class A {", |
| 10481 " final int a;", | 11842 " final int a;", |
| 10482 " const A(String p) : a = 5 + p;", | 11843 " const A(String p) : a = 5 + p;", |
| 10483 "}"])); | 11844 "}"])); |
| 10484 resolve(source); | 11845 resolve(source); |
| 10485 assertErrors(source, [ | 11846 assertErrors(source, [ |
| 10486 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, | 11847 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, |
| 10487 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 11848 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 10488 verify([source]); | 11849 verify([source]); |
| 10489 } | 11850 } |
| 11851 |
| 10490 void test_nonConstValueInInitializer_field() { | 11852 void test_nonConstValueInInitializer_field() { |
| 10491 Source source = addSource(EngineTestCase.createSource([ | 11853 Source source = addSource(EngineTestCase.createSource([ |
| 10492 "class A {", | 11854 "class A {", |
| 10493 " static int C;", | 11855 " static int C;", |
| 10494 " final int a;", | 11856 " final int a;", |
| 10495 " const A() : a = C;", | 11857 " const A() : a = C;", |
| 10496 "}"])); | 11858 "}"])); |
| 10497 resolve(source); | 11859 resolve(source); |
| 10498 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER
]); | 11860 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER
]); |
| 10499 verify([source]); | 11861 verify([source]); |
| 10500 } | 11862 } |
| 11863 |
| 10501 void test_nonConstValueInInitializer_redirecting() { | 11864 void test_nonConstValueInInitializer_redirecting() { |
| 10502 Source source = addSource(EngineTestCase.createSource([ | 11865 Source source = addSource(EngineTestCase.createSource([ |
| 10503 "class A {", | 11866 "class A {", |
| 10504 " static var C;", | 11867 " static var C;", |
| 10505 " const A.named(p);", | 11868 " const A.named(p);", |
| 10506 " const A() : this.named(C);", | 11869 " const A() : this.named(C);", |
| 10507 "}"])); | 11870 "}"])); |
| 10508 resolve(source); | 11871 resolve(source); |
| 10509 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER
]); | 11872 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER
]); |
| 10510 verify([source]); | 11873 verify([source]); |
| 10511 } | 11874 } |
| 11875 |
| 10512 void test_nonConstValueInInitializer_super() { | 11876 void test_nonConstValueInInitializer_super() { |
| 10513 Source source = addSource(EngineTestCase.createSource([ | 11877 Source source = addSource(EngineTestCase.createSource([ |
| 10514 "class A {", | 11878 "class A {", |
| 10515 " const A(p);", | 11879 " const A(p);", |
| 10516 "}", | 11880 "}", |
| 10517 "class B extends A {", | 11881 "class B extends A {", |
| 10518 " static var C;", | 11882 " static var C;", |
| 10519 " const B() : super(C);", | 11883 " const B() : super(C);", |
| 10520 "}"])); | 11884 "}"])); |
| 10521 resolve(source); | 11885 resolve(source); |
| 10522 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER
]); | 11886 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER
]); |
| 10523 verify([source]); | 11887 verify([source]); |
| 10524 } | 11888 } |
| 11889 |
| 10525 void test_nonGenerativeConstructor_explicit() { | 11890 void test_nonGenerativeConstructor_explicit() { |
| 10526 Source source = addSource(EngineTestCase.createSource([ | 11891 Source source = addSource(EngineTestCase.createSource([ |
| 10527 "class A {", | 11892 "class A {", |
| 10528 " factory A.named() {}", | 11893 " factory A.named() {}", |
| 10529 "}", | 11894 "}", |
| 10530 "class B extends A {", | 11895 "class B extends A {", |
| 10531 " B() : super.named();", | 11896 " B() : super.named();", |
| 10532 "}"])); | 11897 "}"])); |
| 10533 resolve(source); | 11898 resolve(source); |
| 10534 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); | 11899 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); |
| 10535 verify([source]); | 11900 verify([source]); |
| 10536 } | 11901 } |
| 11902 |
| 10537 void test_nonGenerativeConstructor_implicit() { | 11903 void test_nonGenerativeConstructor_implicit() { |
| 10538 Source source = addSource(EngineTestCase.createSource([ | 11904 Source source = addSource(EngineTestCase.createSource([ |
| 10539 "class A {", | 11905 "class A {", |
| 10540 " factory A() {}", | 11906 " factory A() {}", |
| 10541 "}", | 11907 "}", |
| 10542 "class B extends A {", | 11908 "class B extends A {", |
| 10543 " B();", | 11909 " B();", |
| 10544 "}"])); | 11910 "}"])); |
| 10545 resolve(source); | 11911 resolve(source); |
| 10546 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); | 11912 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); |
| 10547 verify([source]); | 11913 verify([source]); |
| 10548 } | 11914 } |
| 11915 |
| 10549 void test_nonGenerativeConstructor_implicit2() { | 11916 void test_nonGenerativeConstructor_implicit2() { |
| 10550 Source source = addSource(EngineTestCase.createSource([ | 11917 Source source = addSource(EngineTestCase.createSource([ |
| 10551 "class A {", | 11918 "class A {", |
| 10552 " factory A() {}", | 11919 " factory A() {}", |
| 10553 "}", | 11920 "}", |
| 10554 "class B extends A {", | 11921 "class B extends A {", |
| 10555 "}"])); | 11922 "}"])); |
| 10556 resolve(source); | 11923 resolve(source); |
| 10557 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); | 11924 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); |
| 10558 verify([source]); | 11925 verify([source]); |
| 10559 } | 11926 } |
| 11927 |
| 10560 void test_notEnoughRequiredArguments_const() { | 11928 void test_notEnoughRequiredArguments_const() { |
| 10561 Source source = addSource(EngineTestCase.createSource([ | 11929 Source source = addSource(EngineTestCase.createSource([ |
| 10562 "class A {", | 11930 "class A {", |
| 10563 " const A(int p);", | 11931 " const A(int p);", |
| 10564 "}", | 11932 "}", |
| 10565 "main() {", | 11933 "main() {", |
| 10566 " const A();", | 11934 " const A();", |
| 10567 "}"])); | 11935 "}"])); |
| 10568 resolve(source); | 11936 resolve(source); |
| 10569 assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); | 11937 assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); |
| 10570 verify([source]); | 11938 verify([source]); |
| 10571 } | 11939 } |
| 11940 |
| 10572 void test_notEnoughRequiredArguments_const_super() { | 11941 void test_notEnoughRequiredArguments_const_super() { |
| 10573 Source source = addSource(EngineTestCase.createSource([ | 11942 Source source = addSource(EngineTestCase.createSource([ |
| 10574 "class A {", | 11943 "class A {", |
| 10575 " const A(int p);", | 11944 " const A(int p);", |
| 10576 "}", | 11945 "}", |
| 10577 "class B extends A {", | 11946 "class B extends A {", |
| 10578 " const B() : super();", | 11947 " const B() : super();", |
| 10579 "}"])); | 11948 "}"])); |
| 10580 resolve(source); | 11949 resolve(source); |
| 10581 assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); | 11950 assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); |
| 10582 verify([source]); | 11951 verify([source]); |
| 10583 } | 11952 } |
| 11953 |
| 10584 void test_optionalParameterInOperator_named() { | 11954 void test_optionalParameterInOperator_named() { |
| 10585 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +({p}) {}", "}"])); | 11955 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +({p}) {}", "}"])); |
| 10586 resolve(source); | 11956 resolve(source); |
| 10587 assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); | 11957 assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); |
| 10588 verify([source]); | 11958 verify([source]); |
| 10589 } | 11959 } |
| 11960 |
| 10590 void test_optionalParameterInOperator_positional() { | 11961 void test_optionalParameterInOperator_positional() { |
| 10591 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +([p]) {}", "}"])); | 11962 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +([p]) {}", "}"])); |
| 10592 resolve(source); | 11963 resolve(source); |
| 10593 assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); | 11964 assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); |
| 10594 verify([source]); | 11965 verify([source]); |
| 10595 } | 11966 } |
| 11967 |
| 10596 void test_partOfNonPart() { | 11968 void test_partOfNonPart() { |
| 10597 Source source = addSource(EngineTestCase.createSource(["library l1;", "part
'l2.dart';"])); | 11969 Source source = addSource(EngineTestCase.createSource(["library l1;", "part
'l2.dart';"])); |
| 10598 addSource2("/l2.dart", EngineTestCase.createSource(["library l2;"])); | 11970 addSource2("/l2.dart", EngineTestCase.createSource(["library l2;"])); |
| 10599 resolve(source); | 11971 resolve(source); |
| 10600 assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]); | 11972 assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]); |
| 10601 verify([source]); | 11973 verify([source]); |
| 10602 } | 11974 } |
| 11975 |
| 10603 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() { | 11976 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() { |
| 10604 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); | 11977 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); |
| 10605 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "typedef p();", "p.A a;"])); | 11978 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "typedef p();", "p.A a;"])); |
| 10606 resolve(source); | 11979 resolve(source); |
| 10607 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); | 11980 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); |
| 10608 verify([source]); | 11981 verify([source]); |
| 10609 } | 11982 } |
| 11983 |
| 10610 void test_prefixCollidesWithTopLevelMembers_topLevelFunction() { | 11984 void test_prefixCollidesWithTopLevelMembers_topLevelFunction() { |
| 10611 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); | 11985 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); |
| 10612 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "p() {}", "p.A a;"])); | 11986 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "p() {}", "p.A a;"])); |
| 10613 resolve(source); | 11987 resolve(source); |
| 10614 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); | 11988 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); |
| 10615 verify([source]); | 11989 verify([source]); |
| 10616 } | 11990 } |
| 11991 |
| 10617 void test_prefixCollidesWithTopLevelMembers_topLevelVariable() { | 11992 void test_prefixCollidesWithTopLevelMembers_topLevelVariable() { |
| 10618 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); | 11993 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); |
| 10619 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "var p = null;", "p.A a;"])); | 11994 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "var p = null;", "p.A a;"])); |
| 10620 resolve(source); | 11995 resolve(source); |
| 10621 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); | 11996 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); |
| 10622 verify([source]); | 11997 verify([source]); |
| 10623 } | 11998 } |
| 11999 |
| 10624 void test_prefixCollidesWithTopLevelMembers_type() { | 12000 void test_prefixCollidesWithTopLevelMembers_type() { |
| 10625 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); | 12001 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); |
| 10626 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "class p {}", "p.A a;"])); | 12002 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "class p {}", "p.A a;"])); |
| 10627 resolve(source); | 12003 resolve(source); |
| 10628 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); | 12004 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); |
| 10629 verify([source]); | 12005 verify([source]); |
| 10630 } | 12006 } |
| 12007 |
| 10631 void test_privateOptionalParameter() { | 12008 void test_privateOptionalParameter() { |
| 10632 Source source = addSource(EngineTestCase.createSource(["f({var _p}) {}"])); | 12009 Source source = addSource(EngineTestCase.createSource(["f({var _p}) {}"])); |
| 10633 resolve(source); | 12010 resolve(source); |
| 10634 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); | 12011 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); |
| 10635 verify([source]); | 12012 verify([source]); |
| 10636 } | 12013 } |
| 12014 |
| 10637 void test_privateOptionalParameter_fieldFormal() { | 12015 void test_privateOptionalParameter_fieldFormal() { |
| 10638 Source source = addSource(EngineTestCase.createSource(["class A {", " var _
p;", " A({this._p: 0});", "}"])); | 12016 Source source = addSource(EngineTestCase.createSource(["class A {", " var _
p;", " A({this._p: 0});", "}"])); |
| 10639 resolve(source); | 12017 resolve(source); |
| 10640 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); | 12018 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); |
| 10641 verify([source]); | 12019 verify([source]); |
| 10642 } | 12020 } |
| 12021 |
| 10643 void test_privateOptionalParameter_withDefaultValue() { | 12022 void test_privateOptionalParameter_withDefaultValue() { |
| 10644 Source source = addSource(EngineTestCase.createSource(["f({_p : 0}) {}"])); | 12023 Source source = addSource(EngineTestCase.createSource(["f({_p : 0}) {}"])); |
| 10645 resolve(source); | 12024 resolve(source); |
| 10646 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); | 12025 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); |
| 10647 verify([source]); | 12026 verify([source]); |
| 10648 } | 12027 } |
| 12028 |
| 10649 void test_recursiveConstructorRedirect() { | 12029 void test_recursiveConstructorRedirect() { |
| 10650 Source source = addSource(EngineTestCase.createSource([ | 12030 Source source = addSource(EngineTestCase.createSource([ |
| 10651 "class A {", | 12031 "class A {", |
| 10652 " A.a() : this.b();", | 12032 " A.a() : this.b();", |
| 10653 " A.b() : this.a();", | 12033 " A.b() : this.a();", |
| 10654 "}"])); | 12034 "}"])); |
| 10655 resolve(source); | 12035 resolve(source); |
| 10656 assertErrors(source, [ | 12036 assertErrors(source, [ |
| 10657 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT, | 12037 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT, |
| 10658 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]); | 12038 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]); |
| 10659 verify([source]); | 12039 verify([source]); |
| 10660 } | 12040 } |
| 12041 |
| 10661 void test_recursiveConstructorRedirect_directSelfReference() { | 12042 void test_recursiveConstructorRedirect_directSelfReference() { |
| 10662 Source source = addSource(EngineTestCase.createSource(["class A {", " A() :
this();", "}"])); | 12043 Source source = addSource(EngineTestCase.createSource(["class A {", " A() :
this();", "}"])); |
| 10663 resolve(source); | 12044 resolve(source); |
| 10664 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]); | 12045 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]); |
| 10665 verify([source]); | 12046 verify([source]); |
| 10666 } | 12047 } |
| 12048 |
| 10667 void test_recursiveFactoryRedirect() { | 12049 void test_recursiveFactoryRedirect() { |
| 10668 Source source = addSource(EngineTestCase.createSource([ | 12050 Source source = addSource(EngineTestCase.createSource([ |
| 10669 "class A implements B {", | 12051 "class A implements B {", |
| 10670 " factory A() = C;", | 12052 " factory A() = C;", |
| 10671 "}", | 12053 "}", |
| 10672 "class B implements C {", | 12054 "class B implements C {", |
| 10673 " factory B() = A;", | 12055 " factory B() = A;", |
| 10674 "}", | 12056 "}", |
| 10675 "class C implements A {", | 12057 "class C implements A {", |
| 10676 " factory C() = B;", | 12058 " factory C() = B;", |
| 10677 "}"])); | 12059 "}"])); |
| 10678 resolve(source); | 12060 resolve(source); |
| 10679 assertErrors(source, [ | 12061 assertErrors(source, [ |
| 10680 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 12062 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 10681 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 12063 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 10682 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 12064 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 10683 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12065 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10684 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12066 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10685 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 12067 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 10686 verify([source]); | 12068 verify([source]); |
| 10687 } | 12069 } |
| 12070 |
| 10688 void test_recursiveFactoryRedirect_directSelfReference() { | 12071 void test_recursiveFactoryRedirect_directSelfReference() { |
| 10689 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() = A;", "}"])); | 12072 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() = A;", "}"])); |
| 10690 resolve(source); | 12073 resolve(source); |
| 10691 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]); | 12074 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]); |
| 10692 verify([source]); | 12075 verify([source]); |
| 10693 } | 12076 } |
| 12077 |
| 10694 void test_recursiveFactoryRedirect_generic() { | 12078 void test_recursiveFactoryRedirect_generic() { |
| 10695 Source source = addSource(EngineTestCase.createSource([ | 12079 Source source = addSource(EngineTestCase.createSource([ |
| 10696 "class A<T> implements B<T> {", | 12080 "class A<T> implements B<T> {", |
| 10697 " factory A() = C;", | 12081 " factory A() = C;", |
| 10698 "}", | 12082 "}", |
| 10699 "class B<T> implements C<T> {", | 12083 "class B<T> implements C<T> {", |
| 10700 " factory B() = A;", | 12084 " factory B() = A;", |
| 10701 "}", | 12085 "}", |
| 10702 "class C<T> implements A<T> {", | 12086 "class C<T> implements A<T> {", |
| 10703 " factory C() = B;", | 12087 " factory C() = B;", |
| 10704 "}"])); | 12088 "}"])); |
| 10705 resolve(source); | 12089 resolve(source); |
| 10706 assertErrors(source, [ | 12090 assertErrors(source, [ |
| 10707 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 12091 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 10708 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 12092 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 10709 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 12093 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 10710 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12094 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10711 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12095 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10712 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 12096 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 10713 verify([source]); | 12097 verify([source]); |
| 10714 } | 12098 } |
| 12099 |
| 10715 void test_recursiveFactoryRedirect_named() { | 12100 void test_recursiveFactoryRedirect_named() { |
| 10716 Source source = addSource(EngineTestCase.createSource([ | 12101 Source source = addSource(EngineTestCase.createSource([ |
| 10717 "class A implements B {", | 12102 "class A implements B {", |
| 10718 " factory A.nameA() = C.nameC;", | 12103 " factory A.nameA() = C.nameC;", |
| 10719 "}", | 12104 "}", |
| 10720 "class B implements C {", | 12105 "class B implements C {", |
| 10721 " factory B.nameB() = A.nameA;", | 12106 " factory B.nameB() = A.nameA;", |
| 10722 "}", | 12107 "}", |
| 10723 "class C implements A {", | 12108 "class C implements A {", |
| 10724 " factory C.nameC() = B.nameB;", | 12109 " factory C.nameC() = B.nameB;", |
| (...skipping 25 matching lines...) Expand all Loading... |
| 10750 " factory C() = B;", | 12135 " factory C() = B;", |
| 10751 "}"])); | 12136 "}"])); |
| 10752 resolve(source); | 12137 resolve(source); |
| 10753 assertErrors(source, [ | 12138 assertErrors(source, [ |
| 10754 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 12139 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 10755 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 12140 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 10756 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12141 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10757 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 12142 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 10758 verify([source]); | 12143 verify([source]); |
| 10759 } | 12144 } |
| 12145 |
| 10760 void test_recursiveInterfaceInheritance_extends() { | 12146 void test_recursiveInterfaceInheritance_extends() { |
| 10761 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B extends A {}"])); | 12147 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B extends A {}"])); |
| 10762 resolve(source); | 12148 resolve(source); |
| 10763 assertErrors(source, [ | 12149 assertErrors(source, [ |
| 10764 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12150 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10765 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 12151 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 10766 verify([source]); | 12152 verify([source]); |
| 10767 } | 12153 } |
| 12154 |
| 10768 void test_recursiveInterfaceInheritance_extends_implements() { | 12155 void test_recursiveInterfaceInheritance_extends_implements() { |
| 10769 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B implements A {}"])); | 12156 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B implements A {}"])); |
| 10770 resolve(source); | 12157 resolve(source); |
| 10771 assertErrors(source, [ | 12158 assertErrors(source, [ |
| 10772 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12159 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10773 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 12160 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 10774 verify([source]); | 12161 verify([source]); |
| 10775 } | 12162 } |
| 12163 |
| 10776 void test_recursiveInterfaceInheritance_implements() { | 12164 void test_recursiveInterfaceInheritance_implements() { |
| 10777 Source source = addSource(EngineTestCase.createSource(["class A implements B
{}", "class B implements A {}"])); | 12165 Source source = addSource(EngineTestCase.createSource(["class A implements B
{}", "class B implements A {}"])); |
| 10778 resolve(source); | 12166 resolve(source); |
| 10779 assertErrors(source, [ | 12167 assertErrors(source, [ |
| 10780 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12168 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10781 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 12169 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 10782 verify([source]); | 12170 verify([source]); |
| 10783 } | 12171 } |
| 12172 |
| 10784 void test_recursiveInterfaceInheritance_tail() { | 12173 void test_recursiveInterfaceInheritance_tail() { |
| 10785 Source source = addSource(EngineTestCase.createSource([ | 12174 Source source = addSource(EngineTestCase.createSource([ |
| 10786 "abstract class A implements A {}", | 12175 "abstract class A implements A {}", |
| 10787 "class B implements A {}"])); | 12176 "class B implements A {}"])); |
| 10788 resolve(source); | 12177 resolve(source); |
| 10789 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_IMPLEMENTS]); | 12178 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_IMPLEMENTS]); |
| 10790 verify([source]); | 12179 verify([source]); |
| 10791 } | 12180 } |
| 12181 |
| 10792 void test_recursiveInterfaceInheritance_tail2() { | 12182 void test_recursiveInterfaceInheritance_tail2() { |
| 10793 Source source = addSource(EngineTestCase.createSource([ | 12183 Source source = addSource(EngineTestCase.createSource([ |
| 10794 "abstract class A implements B {}", | 12184 "abstract class A implements B {}", |
| 10795 "abstract class B implements A {}", | 12185 "abstract class B implements A {}", |
| 10796 "class C implements A {}"])); | 12186 "class C implements A {}"])); |
| 10797 resolve(source); | 12187 resolve(source); |
| 10798 assertErrors(source, [ | 12188 assertErrors(source, [ |
| 10799 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12189 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10800 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 12190 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 10801 verify([source]); | 12191 verify([source]); |
| 10802 } | 12192 } |
| 12193 |
| 10803 void test_recursiveInterfaceInheritance_tail3() { | 12194 void test_recursiveInterfaceInheritance_tail3() { |
| 10804 Source source = addSource(EngineTestCase.createSource([ | 12195 Source source = addSource(EngineTestCase.createSource([ |
| 10805 "abstract class A implements B {}", | 12196 "abstract class A implements B {}", |
| 10806 "abstract class B implements C {}", | 12197 "abstract class B implements C {}", |
| 10807 "abstract class C implements A {}", | 12198 "abstract class C implements A {}", |
| 10808 "class D implements A {}"])); | 12199 "class D implements A {}"])); |
| 10809 resolve(source); | 12200 resolve(source); |
| 10810 assertErrors(source, [ | 12201 assertErrors(source, [ |
| 10811 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12202 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10812 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 12203 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 10813 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 12204 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 10814 verify([source]); | 12205 verify([source]); |
| 10815 } | 12206 } |
| 12207 |
| 10816 void test_recursiveInterfaceInheritanceBaseCaseExtends() { | 12208 void test_recursiveInterfaceInheritanceBaseCaseExtends() { |
| 10817 Source source = addSource(EngineTestCase.createSource(["class A extends A {}
"])); | 12209 Source source = addSource(EngineTestCase.createSource(["class A extends A {}
"])); |
| 10818 resolve(source); | 12210 resolve(source); |
| 10819 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_EXTENDS]); | 12211 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_EXTENDS]); |
| 10820 verify([source]); | 12212 verify([source]); |
| 10821 } | 12213 } |
| 12214 |
| 10822 void test_recursiveInterfaceInheritanceBaseCaseImplements() { | 12215 void test_recursiveInterfaceInheritanceBaseCaseImplements() { |
| 10823 Source source = addSource(EngineTestCase.createSource(["class A implements A
{}"])); | 12216 Source source = addSource(EngineTestCase.createSource(["class A implements A
{}"])); |
| 10824 resolve(source); | 12217 resolve(source); |
| 10825 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_IMPLEMENTS]); | 12218 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_IMPLEMENTS]); |
| 10826 verify([source]); | 12219 verify([source]); |
| 10827 } | 12220 } |
| 12221 |
| 10828 void test_recursiveInterfaceInheritanceBaseCaseImplements_typeAlias() { | 12222 void test_recursiveInterfaceInheritanceBaseCaseImplements_typeAlias() { |
| 10829 Source source = addSource(EngineTestCase.createSource([ | 12223 Source source = addSource(EngineTestCase.createSource([ |
| 10830 "class A {}", | 12224 "class A {}", |
| 10831 "class M {}", | 12225 "class M {}", |
| 10832 "class B = A with M implements B;"])); | 12226 "class B = A with M implements B;"])); |
| 10833 resolve(source); | 12227 resolve(source); |
| 10834 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_IMPLEMENTS]); | 12228 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_IMPLEMENTS]); |
| 10835 verify([source]); | 12229 verify([source]); |
| 10836 } | 12230 } |
| 12231 |
| 10837 void test_redirectToMissingConstructor_named() { | 12232 void test_redirectToMissingConstructor_named() { |
| 10838 Source source = addSource(EngineTestCase.createSource([ | 12233 Source source = addSource(EngineTestCase.createSource([ |
| 10839 "class A implements B{", | 12234 "class A implements B{", |
| 10840 " A() {}", | 12235 " A() {}", |
| 10841 "}", | 12236 "}", |
| 10842 "class B {", | 12237 "class B {", |
| 10843 " const factory B() = A.name;", | 12238 " const factory B() = A.name;", |
| 10844 "}"])); | 12239 "}"])); |
| 10845 resolve(source); | 12240 resolve(source); |
| 10846 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR])
; | 12241 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR])
; |
| 10847 } | 12242 } |
| 12243 |
| 10848 void test_redirectToMissingConstructor_unnamed() { | 12244 void test_redirectToMissingConstructor_unnamed() { |
| 10849 Source source = addSource(EngineTestCase.createSource([ | 12245 Source source = addSource(EngineTestCase.createSource([ |
| 10850 "class A implements B{", | 12246 "class A implements B{", |
| 10851 " A.name() {}", | 12247 " A.name() {}", |
| 10852 "}", | 12248 "}", |
| 10853 "class B {", | 12249 "class B {", |
| 10854 " const factory B() = A;", | 12250 " const factory B() = A;", |
| 10855 "}"])); | 12251 "}"])); |
| 10856 resolve(source); | 12252 resolve(source); |
| 10857 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR])
; | 12253 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR])
; |
| 10858 } | 12254 } |
| 12255 |
| 10859 void test_redirectToNonClass_notAType() { | 12256 void test_redirectToNonClass_notAType() { |
| 10860 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {"
, " const factory B() = A;", "}"])); | 12257 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {"
, " const factory B() = A;", "}"])); |
| 10861 resolve(source); | 12258 resolve(source); |
| 10862 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CLASS]); | 12259 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CLASS]); |
| 10863 verify([source]); | 12260 verify([source]); |
| 10864 } | 12261 } |
| 12262 |
| 10865 void test_redirectToNonClass_undefinedIdentifier() { | 12263 void test_redirectToNonClass_undefinedIdentifier() { |
| 10866 Source source = addSource(EngineTestCase.createSource(["class B {", " const
factory B() = A;", "}"])); | 12264 Source source = addSource(EngineTestCase.createSource(["class B {", " const
factory B() = A;", "}"])); |
| 10867 resolve(source); | 12265 resolve(source); |
| 10868 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CLASS]); | 12266 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CLASS]); |
| 10869 verify([source]); | 12267 verify([source]); |
| 10870 } | 12268 } |
| 12269 |
| 10871 void test_redirectToNonConstConstructor() { | 12270 void test_redirectToNonConstConstructor() { |
| 10872 Source source = addSource(EngineTestCase.createSource([ | 12271 Source source = addSource(EngineTestCase.createSource([ |
| 10873 "class A {", | 12272 "class A {", |
| 10874 " A.a() {}", | 12273 " A.a() {}", |
| 10875 " const factory A.b() = A.a;", | 12274 " const factory A.b() = A.a;", |
| 10876 "}"])); | 12275 "}"])); |
| 10877 resolve(source); | 12276 resolve(source); |
| 10878 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR
]); | 12277 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR
]); |
| 10879 verify([source]); | 12278 verify([source]); |
| 10880 } | 12279 } |
| 12280 |
| 10881 void test_referencedBeforeDeclaration_hideInBlock_function() { | 12281 void test_referencedBeforeDeclaration_hideInBlock_function() { |
| 10882 Source source = addSource(EngineTestCase.createSource([ | 12282 Source source = addSource(EngineTestCase.createSource([ |
| 10883 "var v = 1;", | 12283 "var v = 1;", |
| 10884 "main() {", | 12284 "main() {", |
| 10885 " print(v);", | 12285 " print(v);", |
| 10886 " v() {}", | 12286 " v() {}", |
| 10887 "}", | 12287 "}", |
| 10888 "print(x) {}"])); | 12288 "print(x) {}"])); |
| 10889 resolve(source); | 12289 resolve(source); |
| 10890 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); | 12290 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); |
| 10891 } | 12291 } |
| 12292 |
| 10892 void test_referencedBeforeDeclaration_hideInBlock_local() { | 12293 void test_referencedBeforeDeclaration_hideInBlock_local() { |
| 10893 Source source = addSource(EngineTestCase.createSource([ | 12294 Source source = addSource(EngineTestCase.createSource([ |
| 10894 "var v = 1;", | 12295 "var v = 1;", |
| 10895 "main() {", | 12296 "main() {", |
| 10896 " print(v);", | 12297 " print(v);", |
| 10897 " var v = 2;", | 12298 " var v = 2;", |
| 10898 "}", | 12299 "}", |
| 10899 "print(x) {}"])); | 12300 "print(x) {}"])); |
| 10900 resolve(source); | 12301 resolve(source); |
| 10901 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); | 12302 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); |
| 10902 } | 12303 } |
| 12304 |
| 10903 void test_referencedBeforeDeclaration_hideInBlock_subBlock() { | 12305 void test_referencedBeforeDeclaration_hideInBlock_subBlock() { |
| 10904 Source source = addSource(EngineTestCase.createSource([ | 12306 Source source = addSource(EngineTestCase.createSource([ |
| 10905 "var v = 1;", | 12307 "var v = 1;", |
| 10906 "main() {", | 12308 "main() {", |
| 10907 " {", | 12309 " {", |
| 10908 " print(v);", | 12310 " print(v);", |
| 10909 " }", | 12311 " }", |
| 10910 " var v = 2;", | 12312 " var v = 2;", |
| 10911 "}", | 12313 "}", |
| 10912 "print(x) {}"])); | 12314 "print(x) {}"])); |
| 10913 resolve(source); | 12315 resolve(source); |
| 10914 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); | 12316 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); |
| 10915 } | 12317 } |
| 12318 |
| 12319 void test_referencedBeforeDeclaration_inInitializer_closure() { |
| 12320 Source source = addSource(EngineTestCase.createSource(["main() {", " var v
= () => v;", "}"])); |
| 12321 resolve(source); |
| 12322 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); |
| 12323 } |
| 12324 |
| 12325 void test_referencedBeforeDeclaration_inInitializer_directly() { |
| 12326 Source source = addSource(EngineTestCase.createSource(["main() {", " var v
= v;", "}"])); |
| 12327 resolve(source); |
| 12328 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]); |
| 12329 } |
| 12330 |
| 10916 void test_rethrowOutsideCatch() { | 12331 void test_rethrowOutsideCatch() { |
| 10917 Source source = addSource(EngineTestCase.createSource(["f() {", " rethrow;"
, "}"])); | 12332 Source source = addSource(EngineTestCase.createSource(["f() {", " rethrow;"
, "}"])); |
| 10918 resolve(source); | 12333 resolve(source); |
| 10919 assertErrors(source, [CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]); | 12334 assertErrors(source, [CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]); |
| 10920 verify([source]); | 12335 verify([source]); |
| 10921 } | 12336 } |
| 12337 |
| 10922 void test_returnInGenerativeConstructor() { | 12338 void test_returnInGenerativeConstructor() { |
| 10923 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
return 0; }", "}"])); | 12339 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
return 0; }", "}"])); |
| 10924 resolve(source); | 12340 resolve(source); |
| 10925 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]
); | 12341 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]
); |
| 10926 verify([source]); | 12342 verify([source]); |
| 10927 } | 12343 } |
| 12344 |
| 10928 void test_returnInGenerativeConstructor_expressionFunctionBody() { | 12345 void test_returnInGenerativeConstructor_expressionFunctionBody() { |
| 10929 Source source = addSource(EngineTestCase.createSource(["class A {", " A() =
> null;", "}"])); | 12346 Source source = addSource(EngineTestCase.createSource(["class A {", " A() =
> null;", "}"])); |
| 10930 resolve(source); | 12347 resolve(source); |
| 10931 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]
); | 12348 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]
); |
| 10932 verify([source]); | 12349 verify([source]); |
| 10933 } | 12350 } |
| 12351 |
| 10934 void test_superInInvalidContext_binaryExpression() { | 12352 void test_superInInvalidContext_binaryExpression() { |
| 10935 Source source = addSource(EngineTestCase.createSource(["var v = super + 0;"]
)); | 12353 Source source = addSource(EngineTestCase.createSource(["var v = super + 0;"]
)); |
| 10936 resolve(source); | 12354 resolve(source); |
| 10937 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 12355 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 10938 } | 12356 } |
| 12357 |
| 10939 void test_superInInvalidContext_constructorFieldInitializer() { | 12358 void test_superInInvalidContext_constructorFieldInitializer() { |
| 10940 Source source = addSource(EngineTestCase.createSource([ | 12359 Source source = addSource(EngineTestCase.createSource([ |
| 10941 "class A {", | 12360 "class A {", |
| 10942 " m() {}", | 12361 " m() {}", |
| 10943 "}", | 12362 "}", |
| 10944 "class B extends A {", | 12363 "class B extends A {", |
| 10945 " var f;", | 12364 " var f;", |
| 10946 " B() : f = super.m();", | 12365 " B() : f = super.m();", |
| 10947 "}"])); | 12366 "}"])); |
| 10948 resolve(source); | 12367 resolve(source); |
| 10949 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 12368 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 10950 } | 12369 } |
| 12370 |
| 10951 void test_superInInvalidContext_factoryConstructor() { | 12371 void test_superInInvalidContext_factoryConstructor() { |
| 10952 Source source = addSource(EngineTestCase.createSource([ | 12372 Source source = addSource(EngineTestCase.createSource([ |
| 10953 "class A {", | 12373 "class A {", |
| 10954 " m() {}", | 12374 " m() {}", |
| 10955 "}", | 12375 "}", |
| 10956 "class B extends A {", | 12376 "class B extends A {", |
| 10957 " factory B() {", | 12377 " factory B() {", |
| 10958 " super.m();", | 12378 " super.m();", |
| 10959 " }", | 12379 " }", |
| 10960 "}"])); | 12380 "}"])); |
| 10961 resolve(source); | 12381 resolve(source); |
| 10962 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 12382 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 10963 } | 12383 } |
| 12384 |
| 10964 void test_superInInvalidContext_instanceVariableInitializer() { | 12385 void test_superInInvalidContext_instanceVariableInitializer() { |
| 10965 Source source = addSource(EngineTestCase.createSource([ | 12386 Source source = addSource(EngineTestCase.createSource([ |
| 10966 "class A {", | 12387 "class A {", |
| 10967 " var a;", | 12388 " var a;", |
| 10968 "}", | 12389 "}", |
| 10969 "class B extends A {", | 12390 "class B extends A {", |
| 10970 " var b = super.a;", | 12391 " var b = super.a;", |
| 10971 "}"])); | 12392 "}"])); |
| 10972 resolve(source); | 12393 resolve(source); |
| 10973 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 12394 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 10974 } | 12395 } |
| 12396 |
| 10975 void test_superInInvalidContext_staticMethod() { | 12397 void test_superInInvalidContext_staticMethod() { |
| 10976 Source source = addSource(EngineTestCase.createSource([ | 12398 Source source = addSource(EngineTestCase.createSource([ |
| 10977 "class A {", | 12399 "class A {", |
| 10978 " static m() {}", | 12400 " static m() {}", |
| 10979 "}", | 12401 "}", |
| 10980 "class B extends A {", | 12402 "class B extends A {", |
| 10981 " static n() { return super.m(); }", | 12403 " static n() { return super.m(); }", |
| 10982 "}"])); | 12404 "}"])); |
| 10983 resolve(source); | 12405 resolve(source); |
| 10984 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 12406 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 10985 } | 12407 } |
| 12408 |
| 10986 void test_superInInvalidContext_staticVariableInitializer() { | 12409 void test_superInInvalidContext_staticVariableInitializer() { |
| 10987 Source source = addSource(EngineTestCase.createSource([ | 12410 Source source = addSource(EngineTestCase.createSource([ |
| 10988 "class A {", | 12411 "class A {", |
| 10989 " static int a = 0;", | 12412 " static int a = 0;", |
| 10990 "}", | 12413 "}", |
| 10991 "class B extends A {", | 12414 "class B extends A {", |
| 10992 " static int b = super.a;", | 12415 " static int b = super.a;", |
| 10993 "}"])); | 12416 "}"])); |
| 10994 resolve(source); | 12417 resolve(source); |
| 10995 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 12418 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 10996 } | 12419 } |
| 12420 |
| 10997 void test_superInInvalidContext_topLevelFunction() { | 12421 void test_superInInvalidContext_topLevelFunction() { |
| 10998 Source source = addSource(EngineTestCase.createSource(["f() {", " super.f()
;", "}"])); | 12422 Source source = addSource(EngineTestCase.createSource(["f() {", " super.f()
;", "}"])); |
| 10999 resolve(source); | 12423 resolve(source); |
| 11000 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 12424 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 11001 } | 12425 } |
| 12426 |
| 11002 void test_superInInvalidContext_topLevelVariableInitializer() { | 12427 void test_superInInvalidContext_topLevelVariableInitializer() { |
| 11003 Source source = addSource(EngineTestCase.createSource(["var v = super.y;"]))
; | 12428 Source source = addSource(EngineTestCase.createSource(["var v = super.y;"]))
; |
| 11004 resolve(source); | 12429 resolve(source); |
| 11005 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 12430 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 11006 } | 12431 } |
| 12432 |
| 11007 void test_superInRedirectingConstructor_redirectionSuper() { | 12433 void test_superInRedirectingConstructor_redirectionSuper() { |
| 11008 Source source = addSource(EngineTestCase.createSource([ | 12434 Source source = addSource(EngineTestCase.createSource([ |
| 11009 "class A {}", | 12435 "class A {}", |
| 11010 "class B {", | 12436 "class B {", |
| 11011 " B() : this.name(), super();", | 12437 " B() : this.name(), super();", |
| 11012 " B.name() {}", | 12438 " B.name() {}", |
| 11013 "}"])); | 12439 "}"])); |
| 11014 resolve(source); | 12440 resolve(source); |
| 11015 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]
); | 12441 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]
); |
| 11016 verify([source]); | 12442 verify([source]); |
| 11017 } | 12443 } |
| 12444 |
| 11018 void test_superInRedirectingConstructor_superRedirection() { | 12445 void test_superInRedirectingConstructor_superRedirection() { |
| 11019 Source source = addSource(EngineTestCase.createSource([ | 12446 Source source = addSource(EngineTestCase.createSource([ |
| 11020 "class A {}", | 12447 "class A {}", |
| 11021 "class B {", | 12448 "class B {", |
| 11022 " B() : super(), this.name();", | 12449 " B() : super(), this.name();", |
| 11023 " B.name() {}", | 12450 " B.name() {}", |
| 11024 "}"])); | 12451 "}"])); |
| 11025 resolve(source); | 12452 resolve(source); |
| 11026 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]
); | 12453 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]
); |
| 11027 verify([source]); | 12454 verify([source]); |
| 11028 } | 12455 } |
| 12456 |
| 11029 void test_typeAliasCannotReferenceItself_parameterType_named() { | 12457 void test_typeAliasCannotReferenceItself_parameterType_named() { |
| 11030 Source source = addSource(EngineTestCase.createSource(["typedef A({A a});"])
); | 12458 Source source = addSource(EngineTestCase.createSource(["typedef A({A a});"])
); |
| 11031 resolve(source); | 12459 resolve(source); |
| 11032 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); | 12460 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 11033 verify([source]); | 12461 verify([source]); |
| 11034 } | 12462 } |
| 12463 |
| 11035 void test_typeAliasCannotReferenceItself_parameterType_positional() { | 12464 void test_typeAliasCannotReferenceItself_parameterType_positional() { |
| 11036 Source source = addSource(EngineTestCase.createSource(["typedef A([A a]);"])
); | 12465 Source source = addSource(EngineTestCase.createSource(["typedef A([A a]);"])
); |
| 11037 resolve(source); | 12466 resolve(source); |
| 11038 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); | 12467 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 11039 verify([source]); | 12468 verify([source]); |
| 11040 } | 12469 } |
| 12470 |
| 11041 void test_typeAliasCannotReferenceItself_parameterType_required() { | 12471 void test_typeAliasCannotReferenceItself_parameterType_required() { |
| 11042 Source source = addSource(EngineTestCase.createSource(["typedef A(A a);"])); | 12472 Source source = addSource(EngineTestCase.createSource(["typedef A(A a);"])); |
| 11043 resolve(source); | 12473 resolve(source); |
| 11044 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); | 12474 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 11045 verify([source]); | 12475 verify([source]); |
| 11046 } | 12476 } |
| 12477 |
| 11047 void test_typeAliasCannotReferenceItself_parameterType_typeArgument() { | 12478 void test_typeAliasCannotReferenceItself_parameterType_typeArgument() { |
| 11048 Source source = addSource(EngineTestCase.createSource(["typedef A(List<A> a)
;"])); | 12479 Source source = addSource(EngineTestCase.createSource(["typedef A(List<A> a)
;"])); |
| 11049 resolve(source); | 12480 resolve(source); |
| 11050 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); | 12481 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 11051 verify([source]); | 12482 verify([source]); |
| 11052 } | 12483 } |
| 12484 |
| 11053 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { | 12485 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { |
| 11054 Source source = addSource(EngineTestCase.createSource([ | 12486 Source source = addSource(EngineTestCase.createSource([ |
| 11055 "typedef C A();", | 12487 "typedef C A();", |
| 11056 "typedef A B();", | 12488 "typedef A B();", |
| 11057 "class C {", | 12489 "class C {", |
| 11058 " B a;", | 12490 " B a;", |
| 11059 "}"])); | 12491 "}"])); |
| 11060 resolve(source); | 12492 resolve(source); |
| 11061 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); | 12493 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 11062 verify([source]); | 12494 verify([source]); |
| 11063 } | 12495 } |
| 12496 |
| 11064 void test_typeAliasCannotReferenceItself_returnType() { | 12497 void test_typeAliasCannotReferenceItself_returnType() { |
| 11065 Source source = addSource(EngineTestCase.createSource(["typedef A A();"])); | 12498 Source source = addSource(EngineTestCase.createSource(["typedef A A();"])); |
| 11066 resolve(source); | 12499 resolve(source); |
| 11067 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); | 12500 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 11068 verify([source]); | 12501 verify([source]); |
| 11069 } | 12502 } |
| 12503 |
| 11070 void test_typeAliasCannotReferenceItself_returnType_indirect() { | 12504 void test_typeAliasCannotReferenceItself_returnType_indirect() { |
| 11071 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "ty
pedef A B();"])); | 12505 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "ty
pedef A B();"])); |
| 11072 resolve(source); | 12506 resolve(source); |
| 11073 assertErrors(source, [ | 12507 assertErrors(source, [ |
| 11074 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, | 12508 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, |
| 11075 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 12509 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); |
| 11076 verify([source]); | 12510 verify([source]); |
| 11077 } | 12511 } |
| 12512 |
| 11078 void test_typeAliasCannotReferenceItself_typeVariableBounds() { | 12513 void test_typeAliasCannotReferenceItself_typeVariableBounds() { |
| 11079 Source source = addSource(EngineTestCase.createSource(["typedef A<T extends
A>();"])); | 12514 Source source = addSource(EngineTestCase.createSource(["typedef A<T extends
A>();"])); |
| 11080 resolve(source); | 12515 resolve(source); |
| 11081 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); | 12516 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 11082 verify([source]); | 12517 verify([source]); |
| 11083 } | 12518 } |
| 12519 |
| 11084 void test_typeAliasCannotRereferenceItself_mixin_direct() { | 12520 void test_typeAliasCannotRereferenceItself_mixin_direct() { |
| 11085 Source source = addSource(EngineTestCase.createSource(["class M = Object wit
h M;"])); | 12521 Source source = addSource(EngineTestCase.createSource(["class M = Object wit
h M;"])); |
| 11086 resolve(source); | 12522 resolve(source); |
| 11087 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); | 12523 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 11088 verify([source]); | 12524 verify([source]); |
| 11089 } | 12525 } |
| 12526 |
| 11090 void test_typeAliasCannotRereferenceItself_mixin_indirect() { | 12527 void test_typeAliasCannotRereferenceItself_mixin_indirect() { |
| 11091 Source source = addSource(EngineTestCase.createSource([ | 12528 Source source = addSource(EngineTestCase.createSource([ |
| 11092 "class M1 = Object with M2;", | 12529 "class M1 = Object with M2;", |
| 11093 "class M2 = Object with M1;"])); | 12530 "class M2 = Object with M1;"])); |
| 11094 resolve(source); | 12531 resolve(source); |
| 11095 assertErrors(source, [ | 12532 assertErrors(source, [ |
| 11096 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, | 12533 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, |
| 11097 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 12534 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); |
| 11098 verify([source]); | 12535 verify([source]); |
| 11099 } | 12536 } |
| 12537 |
| 11100 void test_typeArgumentNotMatchingBounds_const() { | 12538 void test_typeArgumentNotMatchingBounds_const() { |
| 11101 Source source = addSource(EngineTestCase.createSource([ | 12539 Source source = addSource(EngineTestCase.createSource([ |
| 11102 "class A {}", | 12540 "class A {}", |
| 11103 "class B {}", | 12541 "class B {}", |
| 11104 "class G<E extends A> {", | 12542 "class G<E extends A> {", |
| 11105 " const G();", | 12543 " const G();", |
| 11106 "}", | 12544 "}", |
| 11107 "f() { return const G<B>(); }"])); | 12545 "f() { return const G<B>(); }"])); |
| 11108 resolve(source); | 12546 resolve(source); |
| 11109 assertErrors(source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
]); | 12547 assertErrors(source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
]); |
| 11110 verify([source]); | 12548 verify([source]); |
| 11111 } | 12549 } |
| 12550 |
| 11112 void test_undefinedClass_const() { | 12551 void test_undefinedClass_const() { |
| 11113 Source source = addSource(EngineTestCase.createSource(["f() {", " return co
nst A();", "}"])); | 12552 Source source = addSource(EngineTestCase.createSource(["f() {", " return co
nst A();", "}"])); |
| 11114 resolve(source); | 12553 resolve(source); |
| 11115 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CLASS]); | 12554 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CLASS]); |
| 11116 verify([source]); | 12555 verify([source]); |
| 11117 } | 12556 } |
| 12557 |
| 11118 void test_undefinedConstructorInInitializer_explicit_named() { | 12558 void test_undefinedConstructorInInitializer_explicit_named() { |
| 11119 Source source = addSource(EngineTestCase.createSource([ | 12559 Source source = addSource(EngineTestCase.createSource([ |
| 11120 "class A {}", | 12560 "class A {}", |
| 11121 "class B extends A {", | 12561 "class B extends A {", |
| 11122 " B() : super.named();", | 12562 " B() : super.named();", |
| 11123 "}"])); | 12563 "}"])); |
| 11124 resolve(source); | 12564 resolve(source); |
| 11125 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER]); | 12565 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER]); |
| 11126 } | 12566 } |
| 12567 |
| 11127 void test_undefinedConstructorInInitializer_explicit_unnamed() { | 12568 void test_undefinedConstructorInInitializer_explicit_unnamed() { |
| 11128 Source source = addSource(EngineTestCase.createSource([ | 12569 Source source = addSource(EngineTestCase.createSource([ |
| 11129 "class A {", | 12570 "class A {", |
| 11130 " A.named() {}", | 12571 " A.named() {}", |
| 11131 "}", | 12572 "}", |
| 11132 "class B extends A {", | 12573 "class B extends A {", |
| 11133 " B() : super();", | 12574 " B() : super();", |
| 11134 "}"])); | 12575 "}"])); |
| 11135 resolve(source); | 12576 resolve(source); |
| 11136 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER_DEFAULT]); | 12577 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER_DEFAULT]); |
| 11137 verify([source]); | 12578 verify([source]); |
| 11138 } | 12579 } |
| 12580 |
| 11139 void test_undefinedConstructorInInitializer_implicit() { | 12581 void test_undefinedConstructorInInitializer_implicit() { |
| 11140 Source source = addSource(EngineTestCase.createSource([ | 12582 Source source = addSource(EngineTestCase.createSource([ |
| 11141 "class A {", | 12583 "class A {", |
| 11142 " A.named() {}", | 12584 " A.named() {}", |
| 11143 "}", | 12585 "}", |
| 11144 "class B extends A {", | 12586 "class B extends A {", |
| 11145 " B();", | 12587 " B();", |
| 11146 "}"])); | 12588 "}"])); |
| 11147 resolve(source); | 12589 resolve(source); |
| 11148 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER_DEFAULT]); | 12590 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER_DEFAULT]); |
| 11149 verify([source]); | 12591 verify([source]); |
| 11150 } | 12592 } |
| 12593 |
| 11151 void test_undefinedFunction() { | 12594 void test_undefinedFunction() { |
| 11152 Source source = addSource(EngineTestCase.createSource(["void f() {", " g();
", "}"])); | 12595 Source source = addSource(EngineTestCase.createSource(["void f() {", " g();
", "}"])); |
| 11153 resolve(source); | 12596 resolve(source); |
| 11154 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]); | 12597 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]); |
| 11155 } | 12598 } |
| 12599 |
| 11156 void test_undefinedFunction_hasImportPrefix() { | 12600 void test_undefinedFunction_hasImportPrefix() { |
| 11157 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
f;", "main() { return f(); }"])); | 12601 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
f;", "main() { return f(); }"])); |
| 11158 addSource2("/lib.dart", "library lib;"); | 12602 addSource2("/lib.dart", "library lib;"); |
| 11159 resolve(source); | 12603 resolve(source); |
| 11160 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]); | 12604 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]); |
| 11161 } | 12605 } |
| 12606 |
| 11162 void test_undefinedFunction_inCatch() { | 12607 void test_undefinedFunction_inCatch() { |
| 11163 Source source = addSource(EngineTestCase.createSource([ | 12608 Source source = addSource(EngineTestCase.createSource([ |
| 11164 "void f() {", | 12609 "void f() {", |
| 11165 " try {", | 12610 " try {", |
| 11166 " } on Object {", | 12611 " } on Object {", |
| 11167 " g();", | 12612 " g();", |
| 11168 " }", | 12613 " }", |
| 11169 "}"])); | 12614 "}"])); |
| 11170 resolve(source); | 12615 resolve(source); |
| 11171 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]); | 12616 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]); |
| 11172 } | 12617 } |
| 12618 |
| 11173 void test_undefinedNamedParameter() { | 12619 void test_undefinedNamedParameter() { |
| 11174 Source source = addSource(EngineTestCase.createSource([ | 12620 Source source = addSource(EngineTestCase.createSource([ |
| 11175 "class A {", | 12621 "class A {", |
| 11176 " const A();", | 12622 " const A();", |
| 11177 "}", | 12623 "}", |
| 11178 "main() {", | 12624 "main() {", |
| 11179 " const A(p: 0);", | 12625 " const A(p: 0);", |
| 11180 "}"])); | 12626 "}"])); |
| 11181 resolve(source); | 12627 resolve(source); |
| 11182 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER]); | 12628 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER]); |
| 11183 } | 12629 } |
| 12630 |
| 11184 void test_uriDoesNotExist_export() { | 12631 void test_uriDoesNotExist_export() { |
| 11185 Source source = addSource(EngineTestCase.createSource(["export 'unknown.dart
';"])); | 12632 Source source = addSource(EngineTestCase.createSource(["export 'unknown.dart
';"])); |
| 11186 resolve(source); | 12633 resolve(source); |
| 11187 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 12634 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 11188 } | 12635 } |
| 12636 |
| 11189 void test_uriDoesNotExist_import() { | 12637 void test_uriDoesNotExist_import() { |
| 11190 Source source = addSource(EngineTestCase.createSource(["import 'unknown.dart
';"])); | 12638 Source source = addSource(EngineTestCase.createSource(["import 'unknown.dart
';"])); |
| 11191 resolve(source); | 12639 resolve(source); |
| 11192 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 12640 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 11193 } | 12641 } |
| 12642 |
| 11194 void test_uriDoesNotExist_part() { | 12643 void test_uriDoesNotExist_part() { |
| 11195 Source source = addSource(EngineTestCase.createSource(["part 'unknown.dart';
"])); | 12644 Source source = addSource(EngineTestCase.createSource(["part 'unknown.dart';
"])); |
| 11196 resolve(source); | 12645 resolve(source); |
| 11197 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 12646 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 11198 } | 12647 } |
| 12648 |
| 11199 void test_uriWithInterpolation_constant() { | 12649 void test_uriWithInterpolation_constant() { |
| 11200 Source source = addSource(EngineTestCase.createSource(["import 'stuff_\$plat
form.dart';"])); | 12650 Source source = addSource(EngineTestCase.createSource(["import 'stuff_\$plat
form.dart';"])); |
| 11201 resolve(source); | 12651 resolve(source); |
| 11202 assertErrors(source, [ | 12652 assertErrors(source, [ |
| 11203 CompileTimeErrorCode.URI_WITH_INTERPOLATION, | 12653 CompileTimeErrorCode.URI_WITH_INTERPOLATION, |
| 11204 StaticWarningCode.UNDEFINED_IDENTIFIER]); | 12654 StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 11205 } | 12655 } |
| 12656 |
| 11206 void test_uriWithInterpolation_nonConstant() { | 12657 void test_uriWithInterpolation_nonConstant() { |
| 11207 Source source = addSource(EngineTestCase.createSource(["library lib;", "part
'\${'a'}.dart';"])); | 12658 Source source = addSource(EngineTestCase.createSource(["library lib;", "part
'\${'a'}.dart';"])); |
| 11208 resolve(source); | 12659 resolve(source); |
| 11209 assertErrors(source, [CompileTimeErrorCode.URI_WITH_INTERPOLATION]); | 12660 assertErrors(source, [CompileTimeErrorCode.URI_WITH_INTERPOLATION]); |
| 11210 } | 12661 } |
| 12662 |
| 11211 void test_wrongNumberOfParametersForOperator_minus() { | 12663 void test_wrongNumberOfParametersForOperator_minus() { |
| 11212 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor -(a, b) {}", "}"])); | 12664 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor -(a, b) {}", "}"])); |
| 11213 resolve(source); | 12665 resolve(source); |
| 11214 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OP
ERATOR_MINUS]); | 12666 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OP
ERATOR_MINUS]); |
| 11215 verify([source]); | 12667 verify([source]); |
| 11216 reset(); | 12668 reset(); |
| 11217 } | 12669 } |
| 12670 |
| 11218 void test_wrongNumberOfParametersForOperator_tilde() { | 12671 void test_wrongNumberOfParametersForOperator_tilde() { |
| 11219 check_wrongNumberOfParametersForOperator("~", "a"); | 12672 check_wrongNumberOfParametersForOperator("~", "a"); |
| 11220 check_wrongNumberOfParametersForOperator("~", "a, b"); | 12673 check_wrongNumberOfParametersForOperator("~", "a, b"); |
| 11221 } | 12674 } |
| 12675 |
| 11222 void test_wrongNumberOfParametersForOperator1() { | 12676 void test_wrongNumberOfParametersForOperator1() { |
| 11223 check_wrongNumberOfParametersForOperator1("<"); | 12677 check_wrongNumberOfParametersForOperator1("<"); |
| 11224 check_wrongNumberOfParametersForOperator1(">"); | 12678 check_wrongNumberOfParametersForOperator1(">"); |
| 11225 check_wrongNumberOfParametersForOperator1("<="); | 12679 check_wrongNumberOfParametersForOperator1("<="); |
| 11226 check_wrongNumberOfParametersForOperator1(">="); | 12680 check_wrongNumberOfParametersForOperator1(">="); |
| 11227 check_wrongNumberOfParametersForOperator1("+"); | 12681 check_wrongNumberOfParametersForOperator1("+"); |
| 11228 check_wrongNumberOfParametersForOperator1("/"); | 12682 check_wrongNumberOfParametersForOperator1("/"); |
| 11229 check_wrongNumberOfParametersForOperator1("~/"); | 12683 check_wrongNumberOfParametersForOperator1("~/"); |
| 11230 check_wrongNumberOfParametersForOperator1("*"); | 12684 check_wrongNumberOfParametersForOperator1("*"); |
| 11231 check_wrongNumberOfParametersForOperator1("%"); | 12685 check_wrongNumberOfParametersForOperator1("%"); |
| 11232 check_wrongNumberOfParametersForOperator1("|"); | 12686 check_wrongNumberOfParametersForOperator1("|"); |
| 11233 check_wrongNumberOfParametersForOperator1("^"); | 12687 check_wrongNumberOfParametersForOperator1("^"); |
| 11234 check_wrongNumberOfParametersForOperator1("&"); | 12688 check_wrongNumberOfParametersForOperator1("&"); |
| 11235 check_wrongNumberOfParametersForOperator1("<<"); | 12689 check_wrongNumberOfParametersForOperator1("<<"); |
| 11236 check_wrongNumberOfParametersForOperator1(">>"); | 12690 check_wrongNumberOfParametersForOperator1(">>"); |
| 11237 check_wrongNumberOfParametersForOperator1("[]"); | 12691 check_wrongNumberOfParametersForOperator1("[]"); |
| 11238 } | 12692 } |
| 12693 |
| 11239 void test_wrongNumberOfParametersForSetter_function_named() { | 12694 void test_wrongNumberOfParametersForSetter_function_named() { |
| 11240 Source source = addSource("set x({p}) {}"); | 12695 Source source = addSource("set x({p}) {}"); |
| 11241 resolve(source); | 12696 resolve(source); |
| 11242 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); | 12697 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 11243 verify([source]); | 12698 verify([source]); |
| 11244 } | 12699 } |
| 12700 |
| 11245 void test_wrongNumberOfParametersForSetter_function_optional() { | 12701 void test_wrongNumberOfParametersForSetter_function_optional() { |
| 11246 Source source = addSource("set x([p]) {}"); | 12702 Source source = addSource("set x([p]) {}"); |
| 11247 resolve(source); | 12703 resolve(source); |
| 11248 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); | 12704 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 11249 verify([source]); | 12705 verify([source]); |
| 11250 } | 12706 } |
| 12707 |
| 11251 void test_wrongNumberOfParametersForSetter_function_tooFew() { | 12708 void test_wrongNumberOfParametersForSetter_function_tooFew() { |
| 11252 Source source = addSource("set x() {}"); | 12709 Source source = addSource("set x() {}"); |
| 11253 resolve(source); | 12710 resolve(source); |
| 11254 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); | 12711 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 11255 verify([source]); | 12712 verify([source]); |
| 11256 } | 12713 } |
| 12714 |
| 11257 void test_wrongNumberOfParametersForSetter_function_tooMany() { | 12715 void test_wrongNumberOfParametersForSetter_function_tooMany() { |
| 11258 Source source = addSource("set x(a, b) {}"); | 12716 Source source = addSource("set x(a, b) {}"); |
| 11259 resolve(source); | 12717 resolve(source); |
| 11260 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); | 12718 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 11261 verify([source]); | 12719 verify([source]); |
| 11262 } | 12720 } |
| 12721 |
| 11263 void test_wrongNumberOfParametersForSetter_method_named() { | 12722 void test_wrongNumberOfParametersForSetter_method_named() { |
| 11264 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
({p}) {}", "}"])); | 12723 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
({p}) {}", "}"])); |
| 11265 resolve(source); | 12724 resolve(source); |
| 11266 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); | 12725 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 11267 verify([source]); | 12726 verify([source]); |
| 11268 } | 12727 } |
| 12728 |
| 11269 void test_wrongNumberOfParametersForSetter_method_optional() { | 12729 void test_wrongNumberOfParametersForSetter_method_optional() { |
| 11270 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
([p]) {}", "}"])); | 12730 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
([p]) {}", "}"])); |
| 11271 resolve(source); | 12731 resolve(source); |
| 11272 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); | 12732 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 11273 verify([source]); | 12733 verify([source]); |
| 11274 } | 12734 } |
| 12735 |
| 11275 void test_wrongNumberOfParametersForSetter_method_tooFew() { | 12736 void test_wrongNumberOfParametersForSetter_method_tooFew() { |
| 11276 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
() {}", "}"])); | 12737 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
() {}", "}"])); |
| 11277 resolve(source); | 12738 resolve(source); |
| 11278 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); | 12739 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 11279 verify([source]); | 12740 verify([source]); |
| 11280 } | 12741 } |
| 12742 |
| 11281 void test_wrongNumberOfParametersForSetter_method_tooMany() { | 12743 void test_wrongNumberOfParametersForSetter_method_tooMany() { |
| 11282 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(a, b) {}", "}"])); | 12744 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(a, b) {}", "}"])); |
| 11283 resolve(source); | 12745 resolve(source); |
| 11284 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); | 12746 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 11285 verify([source]); | 12747 verify([source]); |
| 11286 } | 12748 } |
| 12749 |
| 11287 void check_constEvalThrowsException_binary_null(String expr, bool resolved) { | 12750 void check_constEvalThrowsException_binary_null(String expr, bool resolved) { |
| 11288 Source source = addSource("const C = ${expr};"); | 12751 Source source = addSource("const C = ${expr};"); |
| 11289 resolve(source); | 12752 resolve(source); |
| 11290 if (resolved) { | 12753 if (resolved) { |
| 11291 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); | 12754 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); |
| 11292 verify([source]); | 12755 verify([source]); |
| 11293 } else { | 12756 } else { |
| 11294 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); | 12757 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); |
| 11295 } | 12758 } |
| 11296 reset(); | 12759 reset(); |
| 11297 } | 12760 } |
| 12761 |
| 11298 void check_constEvalTypeBool_withParameter_binary(String expr) { | 12762 void check_constEvalTypeBool_withParameter_binary(String expr) { |
| 11299 Source source = addSource(EngineTestCase.createSource([ | 12763 Source source = addSource(EngineTestCase.createSource([ |
| 11300 "class A {", | 12764 "class A {", |
| 11301 " final a;", | 12765 " final a;", |
| 11302 " const A(bool p) : a = ${expr};", | 12766 " const A(bool p) : a = ${expr};", |
| 11303 "}"])); | 12767 "}"])); |
| 11304 resolve(source); | 12768 resolve(source); |
| 11305 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); | 12769 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); |
| 11306 verify([source]); | 12770 verify([source]); |
| 11307 reset(); | 12771 reset(); |
| 11308 } | 12772 } |
| 12773 |
| 11309 void check_constEvalTypeInt_withParameter_binary(String expr) { | 12774 void check_constEvalTypeInt_withParameter_binary(String expr) { |
| 11310 Source source = addSource(EngineTestCase.createSource([ | 12775 Source source = addSource(EngineTestCase.createSource([ |
| 11311 "class A {", | 12776 "class A {", |
| 11312 " final a;", | 12777 " final a;", |
| 11313 " const A(int p) : a = ${expr};", | 12778 " const A(int p) : a = ${expr};", |
| 11314 "}"])); | 12779 "}"])); |
| 11315 resolve(source); | 12780 resolve(source); |
| 11316 assertErrors(source, [ | 12781 assertErrors(source, [ |
| 11317 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, | 12782 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, |
| 11318 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12783 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 11319 verify([source]); | 12784 verify([source]); |
| 11320 reset(); | 12785 reset(); |
| 11321 } | 12786 } |
| 12787 |
| 11322 void check_constEvalTypeNum_withParameter_binary(String expr) { | 12788 void check_constEvalTypeNum_withParameter_binary(String expr) { |
| 11323 Source source = addSource(EngineTestCase.createSource([ | 12789 Source source = addSource(EngineTestCase.createSource([ |
| 11324 "class A {", | 12790 "class A {", |
| 11325 " final a;", | 12791 " final a;", |
| 11326 " const A(num p) : a = ${expr};", | 12792 " const A(num p) : a = ${expr};", |
| 11327 "}"])); | 12793 "}"])); |
| 11328 resolve(source); | 12794 resolve(source); |
| 11329 assertErrors(source, [ | 12795 assertErrors(source, [ |
| 11330 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, | 12796 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, |
| 11331 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12797 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 11332 verify([source]); | 12798 verify([source]); |
| 11333 reset(); | 12799 reset(); |
| 11334 } | 12800 } |
| 12801 |
| 11335 void check_wrongNumberOfParametersForOperator(String name, String parameters)
{ | 12802 void check_wrongNumberOfParametersForOperator(String name, String parameters)
{ |
| 11336 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor ${name}(${parameters}) {}", "}"])); | 12803 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor ${name}(${parameters}) {}", "}"])); |
| 11337 resolve(source); | 12804 resolve(source); |
| 11338 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OP
ERATOR]); | 12805 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OP
ERATOR]); |
| 11339 verify([source]); | 12806 verify([source]); |
| 11340 reset(); | 12807 reset(); |
| 11341 } | 12808 } |
| 12809 |
| 11342 void check_wrongNumberOfParametersForOperator1(String name) { | 12810 void check_wrongNumberOfParametersForOperator1(String name) { |
| 11343 check_wrongNumberOfParametersForOperator(name, ""); | 12811 check_wrongNumberOfParametersForOperator(name, ""); |
| 11344 check_wrongNumberOfParametersForOperator(name, "a, b"); | 12812 check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 11345 } | 12813 } |
| 12814 |
| 11346 static dartSuite() { | 12815 static dartSuite() { |
| 11347 _ut.group('CompileTimeErrorCodeTest', () { | 12816 _ut.group('CompileTimeErrorCodeTest', () { |
| 11348 _ut.test('test_ambiguousExport', () { | 12817 _ut.test('test_ambiguousExport', () { |
| 11349 final __test = new CompileTimeErrorCodeTest(); | 12818 final __test = new CompileTimeErrorCodeTest(); |
| 11350 runJUnitTest(__test, __test.test_ambiguousExport); | 12819 runJUnitTest(__test, __test.test_ambiguousExport); |
| 11351 }); | 12820 }); |
| 11352 _ut.test('test_ambiguousImport_function', () { | 12821 _ut.test('test_ambiguousImport_function', () { |
| 11353 final __test = new CompileTimeErrorCodeTest(); | 12822 final __test = new CompileTimeErrorCodeTest(); |
| 11354 runJUnitTest(__test, __test.test_ambiguousImport_function); | 12823 runJUnitTest(__test, __test.test_ambiguousImport_function); |
| 11355 }); | 12824 }); |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12426 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_hideInBlock
_function); | 13895 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_hideInBlock
_function); |
| 12427 }); | 13896 }); |
| 12428 _ut.test('test_referencedBeforeDeclaration_hideInBlock_local', () { | 13897 _ut.test('test_referencedBeforeDeclaration_hideInBlock_local', () { |
| 12429 final __test = new CompileTimeErrorCodeTest(); | 13898 final __test = new CompileTimeErrorCodeTest(); |
| 12430 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_hideInBlock
_local); | 13899 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_hideInBlock
_local); |
| 12431 }); | 13900 }); |
| 12432 _ut.test('test_referencedBeforeDeclaration_hideInBlock_subBlock', () { | 13901 _ut.test('test_referencedBeforeDeclaration_hideInBlock_subBlock', () { |
| 12433 final __test = new CompileTimeErrorCodeTest(); | 13902 final __test = new CompileTimeErrorCodeTest(); |
| 12434 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_hideInBlock
_subBlock); | 13903 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_hideInBlock
_subBlock); |
| 12435 }); | 13904 }); |
| 13905 _ut.test('test_referencedBeforeDeclaration_inInitializer_closure', () { |
| 13906 final __test = new CompileTimeErrorCodeTest(); |
| 13907 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_inInitializ
er_closure); |
| 13908 }); |
| 13909 _ut.test('test_referencedBeforeDeclaration_inInitializer_directly', () { |
| 13910 final __test = new CompileTimeErrorCodeTest(); |
| 13911 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_inInitializ
er_directly); |
| 13912 }); |
| 12436 _ut.test('test_rethrowOutsideCatch', () { | 13913 _ut.test('test_rethrowOutsideCatch', () { |
| 12437 final __test = new CompileTimeErrorCodeTest(); | 13914 final __test = new CompileTimeErrorCodeTest(); |
| 12438 runJUnitTest(__test, __test.test_rethrowOutsideCatch); | 13915 runJUnitTest(__test, __test.test_rethrowOutsideCatch); |
| 12439 }); | 13916 }); |
| 12440 _ut.test('test_returnInGenerativeConstructor', () { | 13917 _ut.test('test_returnInGenerativeConstructor', () { |
| 12441 final __test = new CompileTimeErrorCodeTest(); | 13918 final __test = new CompileTimeErrorCodeTest(); |
| 12442 runJUnitTest(__test, __test.test_returnInGenerativeConstructor); | 13919 runJUnitTest(__test, __test.test_returnInGenerativeConstructor); |
| 12443 }); | 13920 }); |
| 12444 _ut.test('test_returnInGenerativeConstructor_expressionFunctionBody', () { | 13921 _ut.test('test_returnInGenerativeConstructor_expressionFunctionBody', () { |
| 12445 final __test = new CompileTimeErrorCodeTest(); | 13922 final __test = new CompileTimeErrorCodeTest(); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12621 final __test = new CompileTimeErrorCodeTest(); | 14098 final __test = new CompileTimeErrorCodeTest(); |
| 12622 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method
_tooFew); | 14099 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method
_tooFew); |
| 12623 }); | 14100 }); |
| 12624 _ut.test('test_wrongNumberOfParametersForSetter_method_tooMany', () { | 14101 _ut.test('test_wrongNumberOfParametersForSetter_method_tooMany', () { |
| 12625 final __test = new CompileTimeErrorCodeTest(); | 14102 final __test = new CompileTimeErrorCodeTest(); |
| 12626 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method
_tooMany); | 14103 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method
_tooMany); |
| 12627 }); | 14104 }); |
| 12628 }); | 14105 }); |
| 12629 } | 14106 } |
| 12630 } | 14107 } |
| 14108 |
| 12631 /** | 14109 /** |
| 12632 * Instances of the class `StaticTypeVerifier` verify that all of the nodes in a
n AST | 14110 * Instances of the class `StaticTypeVerifier` verify that all of the nodes in a
n AST |
| 12633 * structure that should have a static type associated with them do have a stati
c type. | 14111 * structure that should have a static type associated with them do have a stati
c type. |
| 12634 */ | 14112 */ |
| 12635 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> { | 14113 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> { |
| 12636 | |
| 12637 /** | 14114 /** |
| 12638 * A list containing all of the AST Expression nodes that were not resolved. | 14115 * A list containing all of the AST Expression nodes that were not resolved. |
| 12639 */ | 14116 */ |
| 12640 List<Expression> _unresolvedExpressions = new List<Expression>(); | 14117 List<Expression> _unresolvedExpressions = new List<Expression>(); |
| 12641 | 14118 |
| 12642 /** | 14119 /** |
| 12643 * A list containing all of the AST Expression nodes for which a propagated ty
pe was computed but | 14120 * A list containing all of the AST Expression nodes for which a propagated ty
pe was computed but |
| 12644 * where that type was not more specific than the static type. | 14121 * where that type was not more specific than the static type. |
| 12645 */ | 14122 */ |
| 12646 List<Expression> _invalidlyPropagatedExpressions = new List<Expression>(); | 14123 List<Expression> _invalidlyPropagatedExpressions = new List<Expression>(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12723 writer.print(" "); | 14200 writer.print(" "); |
| 12724 writer.print(getFileName(expression)); | 14201 writer.print(getFileName(expression)); |
| 12725 writer.print(" : "); | 14202 writer.print(" : "); |
| 12726 writer.print(expression.offset); | 14203 writer.print(expression.offset); |
| 12727 writer.println(")"); | 14204 writer.println(")"); |
| 12728 } | 14205 } |
| 12729 } | 14206 } |
| 12730 JUnitTestCase.fail(writer.toString()); | 14207 JUnitTestCase.fail(writer.toString()); |
| 12731 } | 14208 } |
| 12732 } | 14209 } |
| 14210 |
| 12733 Object visitBreakStatement(BreakStatement node) => null; | 14211 Object visitBreakStatement(BreakStatement node) => null; |
| 14212 |
| 12734 Object visitCommentReference(CommentReference node) => null; | 14213 Object visitCommentReference(CommentReference node) => null; |
| 14214 |
| 12735 Object visitContinueStatement(ContinueStatement node) => null; | 14215 Object visitContinueStatement(ContinueStatement node) => null; |
| 14216 |
| 12736 Object visitExportDirective(ExportDirective node) => null; | 14217 Object visitExportDirective(ExportDirective node) => null; |
| 14218 |
| 12737 Object visitExpression(Expression node) { | 14219 Object visitExpression(Expression node) { |
| 12738 node.visitChildren(this); | 14220 node.visitChildren(this); |
| 12739 Type2 staticType = node.staticType; | 14221 Type2 staticType = node.staticType; |
| 12740 if (staticType == null) { | 14222 if (staticType == null) { |
| 12741 _unresolvedExpressions.add(node); | 14223 _unresolvedExpressions.add(node); |
| 12742 } else { | 14224 } else { |
| 12743 _resolvedExpressionCount++; | 14225 _resolvedExpressionCount++; |
| 12744 Type2 propagatedType = node.propagatedType; | 14226 Type2 propagatedType = node.propagatedType; |
| 12745 if (propagatedType != null) { | 14227 if (propagatedType != null) { |
| 12746 _propagatedExpressionCount++; | 14228 _propagatedExpressionCount++; |
| 12747 if (!propagatedType.isMoreSpecificThan(staticType)) { | 14229 if (!propagatedType.isMoreSpecificThan(staticType)) { |
| 12748 _invalidlyPropagatedExpressions.add(node); | 14230 _invalidlyPropagatedExpressions.add(node); |
| 12749 } | 14231 } |
| 12750 } | 14232 } |
| 12751 } | 14233 } |
| 12752 return null; | 14234 return null; |
| 12753 } | 14235 } |
| 14236 |
| 12754 Object visitImportDirective(ImportDirective node) => null; | 14237 Object visitImportDirective(ImportDirective node) => null; |
| 14238 |
| 12755 Object visitLabel(Label node) => null; | 14239 Object visitLabel(Label node) => null; |
| 14240 |
| 12756 Object visitLibraryIdentifier(LibraryIdentifier node) => null; | 14241 Object visitLibraryIdentifier(LibraryIdentifier node) => null; |
| 14242 |
| 12757 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 14243 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 12758 if (node.staticType == null && identical(node.prefix.staticType, DynamicType
Impl.instance)) { | 14244 if (node.staticType == null && identical(node.prefix.staticType, DynamicType
Impl.instance)) { |
| 12759 return null; | 14245 return null; |
| 12760 } | 14246 } |
| 12761 return super.visitPrefixedIdentifier(node); | 14247 return super.visitPrefixedIdentifier(node); |
| 12762 } | 14248 } |
| 14249 |
| 12763 Object visitSimpleIdentifier(SimpleIdentifier node) { | 14250 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 12764 ASTNode parent = node.parent; | 14251 ASTNode parent = node.parent; |
| 12765 if (parent is MethodInvocation && identical(node, ((parent as MethodInvocati
on)).methodName)) { | 14252 if (parent is MethodInvocation && identical(node, (parent as MethodInvocatio
n).methodName)) { |
| 12766 return null; | 14253 return null; |
| 12767 } else if (parent is RedirectingConstructorInvocation && identical(node, ((p
arent as RedirectingConstructorInvocation)).constructorName)) { | 14254 } else if (parent is RedirectingConstructorInvocation && identical(node, (pa
rent as RedirectingConstructorInvocation).constructorName)) { |
| 12768 return null; | 14255 return null; |
| 12769 } else if (parent is SuperConstructorInvocation && identical(node, ((parent
as SuperConstructorInvocation)).constructorName)) { | 14256 } else if (parent is SuperConstructorInvocation && identical(node, (parent a
s SuperConstructorInvocation).constructorName)) { |
| 12770 return null; | 14257 return null; |
| 12771 } else if (parent is ConstructorName && identical(node, ((parent as Construc
torName)).name)) { | 14258 } else if (parent is ConstructorName && identical(node, (parent as Construct
orName).name)) { |
| 12772 return null; | 14259 return null; |
| 12773 } else if (parent is ConstructorFieldInitializer && identical(node, ((parent
as ConstructorFieldInitializer)).fieldName)) { | 14260 } else if (parent is ConstructorFieldInitializer && identical(node, (parent
as ConstructorFieldInitializer).fieldName)) { |
| 12774 return null; | 14261 return null; |
| 12775 } else if (node.staticElement is PrefixElement) { | 14262 } else if (node.staticElement is PrefixElement) { |
| 12776 return null; | 14263 return null; |
| 12777 } | 14264 } |
| 12778 return super.visitSimpleIdentifier(node); | 14265 return super.visitSimpleIdentifier(node); |
| 12779 } | 14266 } |
| 14267 |
| 12780 Object visitTypeName(TypeName node) { | 14268 Object visitTypeName(TypeName node) { |
| 12781 if (node.type == null) { | 14269 if (node.type == null) { |
| 12782 _unresolvedTypes.add(node); | 14270 _unresolvedTypes.add(node); |
| 12783 } else { | 14271 } else { |
| 12784 _resolvedTypeCount++; | 14272 _resolvedTypeCount++; |
| 12785 } | 14273 } |
| 12786 return null; | 14274 return null; |
| 12787 } | 14275 } |
| 14276 |
| 12788 String getFileName(ASTNode node) { | 14277 String getFileName(ASTNode node) { |
| 12789 if (node != null) { | 14278 if (node != null) { |
| 12790 ASTNode root = node.root; | 14279 ASTNode root = node.root; |
| 12791 if (root is CompilationUnit) { | 14280 if (root is CompilationUnit) { |
| 12792 CompilationUnit rootCU = root as CompilationUnit; | 14281 CompilationUnit rootCU = root as CompilationUnit; |
| 12793 if (rootCU.element != null) { | 14282 if (rootCU.element != null) { |
| 12794 return rootCU.element.source.fullName; | 14283 return rootCU.element.source.fullName; |
| 12795 } else { | 14284 } else { |
| 12796 return "<unknown file- CompilationUnit.getElement() returned null>"; | 14285 return "<unknown file- CompilationUnit.getElement() returned null>"; |
| 12797 } | 14286 } |
| 12798 } else { | 14287 } else { |
| 12799 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni
t>"; | 14288 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni
t>"; |
| 12800 } | 14289 } |
| 12801 } | 14290 } |
| 12802 return "<unknown file- ASTNode is null>"; | 14291 return "<unknown file- ASTNode is null>"; |
| 12803 } | 14292 } |
| 12804 } | 14293 } |
| 14294 |
| 12805 /** | 14295 /** |
| 12806 * The class `StrictModeTest` contains tests to ensure that the correct errors a
nd warnings | 14296 * The class `StrictModeTest` contains tests to ensure that the correct errors a
nd warnings |
| 12807 * are reported when the analysis engine is run in strict mode. | 14297 * are reported when the analysis engine is run in strict mode. |
| 12808 */ | 14298 */ |
| 12809 class StrictModeTest extends ResolverTestCase { | 14299 class StrictModeTest extends ResolverTestCase { |
| 12810 void fail_for() { | 14300 void fail_for() { |
| 12811 Source source = addSource(EngineTestCase.createSource([ | 14301 Source source = addSource(EngineTestCase.createSource([ |
| 12812 "int f(List<int> list) {", | 14302 "int f(List<int> list) {", |
| 12813 " num sum = 0;", | 14303 " num sum = 0;", |
| 12814 " for (num i = 0; i < list.length; i++) {", | 14304 " for (num i = 0; i < list.length; i++) {", |
| 12815 " sum += list[i];", | 14305 " sum += list[i];", |
| 12816 " }", | 14306 " }", |
| 12817 "}"])); | 14307 "}"])); |
| 12818 resolve(source); | 14308 resolve(source); |
| 12819 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 14309 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 12820 } | 14310 } |
| 14311 |
| 12821 void setUp() { | 14312 void setUp() { |
| 12822 super.setUp(); | 14313 super.setUp(); |
| 12823 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 14314 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 12824 options.strictMode = true; | 14315 options.strictMode = true; |
| 12825 options.hint = false; | 14316 options.hint = false; |
| 12826 analysisContext.analysisOptions = options; | 14317 analysisContext.analysisOptions = options; |
| 12827 } | 14318 } |
| 14319 |
| 12828 void test_assert_is() { | 14320 void test_assert_is() { |
| 12829 Source source = addSource(EngineTestCase.createSource([ | 14321 Source source = addSource(EngineTestCase.createSource([ |
| 12830 "int f(num n) {", | 14322 "int f(num n) {", |
| 12831 " assert (n is int);", | 14323 " assert (n is int);", |
| 12832 " return n & 0x0F;", | 14324 " return n & 0x0F;", |
| 12833 "}"])); | 14325 "}"])); |
| 12834 resolve(source); | 14326 resolve(source); |
| 12835 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 14327 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 12836 } | 14328 } |
| 14329 |
| 12837 void test_conditional_and_is() { | 14330 void test_conditional_and_is() { |
| 12838 Source source = addSource(EngineTestCase.createSource([ | 14331 Source source = addSource(EngineTestCase.createSource([ |
| 12839 "int f(num n) {", | 14332 "int f(num n) {", |
| 12840 " return (n is int && n > 0) ? n & 0x0F : 0;", | 14333 " return (n is int && n > 0) ? n & 0x0F : 0;", |
| 12841 "}"])); | 14334 "}"])); |
| 12842 resolve(source); | 14335 resolve(source); |
| 12843 assertNoErrors(source); | 14336 assertNoErrors(source); |
| 12844 } | 14337 } |
| 14338 |
| 12845 void test_conditional_is() { | 14339 void test_conditional_is() { |
| 12846 Source source = addSource(EngineTestCase.createSource([ | 14340 Source source = addSource(EngineTestCase.createSource([ |
| 12847 "int f(num n) {", | 14341 "int f(num n) {", |
| 12848 " return (n is int) ? n & 0x0F : 0;", | 14342 " return (n is int) ? n & 0x0F : 0;", |
| 12849 "}"])); | 14343 "}"])); |
| 12850 resolve(source); | 14344 resolve(source); |
| 12851 assertNoErrors(source); | 14345 assertNoErrors(source); |
| 12852 } | 14346 } |
| 14347 |
| 12853 void test_conditional_isNot() { | 14348 void test_conditional_isNot() { |
| 12854 Source source = addSource(EngineTestCase.createSource([ | 14349 Source source = addSource(EngineTestCase.createSource([ |
| 12855 "int f(num n) {", | 14350 "int f(num n) {", |
| 12856 " return (n is! int) ? 0 : n & 0x0F;", | 14351 " return (n is! int) ? 0 : n & 0x0F;", |
| 12857 "}"])); | 14352 "}"])); |
| 12858 resolve(source); | 14353 resolve(source); |
| 12859 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 14354 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 12860 } | 14355 } |
| 14356 |
| 12861 void test_conditional_or_is() { | 14357 void test_conditional_or_is() { |
| 12862 Source source = addSource(EngineTestCase.createSource([ | 14358 Source source = addSource(EngineTestCase.createSource([ |
| 12863 "int f(num n) {", | 14359 "int f(num n) {", |
| 12864 " return (n is! int || n < 0) ? 0 : n & 0x0F;", | 14360 " return (n is! int || n < 0) ? 0 : n & 0x0F;", |
| 12865 "}"])); | 14361 "}"])); |
| 12866 resolve(source); | 14362 resolve(source); |
| 12867 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 14363 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 12868 } | 14364 } |
| 14365 |
| 12869 void test_forEach() { | 14366 void test_forEach() { |
| 12870 Source source = addSource(EngineTestCase.createSource([ | 14367 Source source = addSource(EngineTestCase.createSource([ |
| 12871 "int f(List<int> list) {", | 14368 "int f(List<int> list) {", |
| 12872 " num sum = 0;", | 14369 " num sum = 0;", |
| 12873 " for (num n in list) {", | 14370 " for (num n in list) {", |
| 12874 " sum += n & 0x0F;", | 14371 " sum += n & 0x0F;", |
| 12875 " }", | 14372 " }", |
| 12876 "}"])); | 14373 "}"])); |
| 12877 resolve(source); | 14374 resolve(source); |
| 12878 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 14375 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 12879 } | 14376 } |
| 14377 |
| 12880 void test_if_and_is() { | 14378 void test_if_and_is() { |
| 12881 Source source = addSource(EngineTestCase.createSource([ | 14379 Source source = addSource(EngineTestCase.createSource([ |
| 12882 "int f(num n) {", | 14380 "int f(num n) {", |
| 12883 " if (n is int && n > 0) {", | 14381 " if (n is int && n > 0) {", |
| 12884 " return n & 0x0F;", | 14382 " return n & 0x0F;", |
| 12885 " }", | 14383 " }", |
| 12886 " return 0;", | 14384 " return 0;", |
| 12887 "}"])); | 14385 "}"])); |
| 12888 resolve(source); | 14386 resolve(source); |
| 12889 assertNoErrors(source); | 14387 assertNoErrors(source); |
| 12890 } | 14388 } |
| 14389 |
| 12891 void test_if_is() { | 14390 void test_if_is() { |
| 12892 Source source = addSource(EngineTestCase.createSource([ | 14391 Source source = addSource(EngineTestCase.createSource([ |
| 12893 "int f(num n) {", | 14392 "int f(num n) {", |
| 12894 " if (n is int) {", | 14393 " if (n is int) {", |
| 12895 " return n & 0x0F;", | 14394 " return n & 0x0F;", |
| 12896 " }", | 14395 " }", |
| 12897 " return 0;", | 14396 " return 0;", |
| 12898 "}"])); | 14397 "}"])); |
| 12899 resolve(source); | 14398 resolve(source); |
| 12900 assertNoErrors(source); | 14399 assertNoErrors(source); |
| 12901 } | 14400 } |
| 14401 |
| 12902 void test_if_isNot() { | 14402 void test_if_isNot() { |
| 12903 Source source = addSource(EngineTestCase.createSource([ | 14403 Source source = addSource(EngineTestCase.createSource([ |
| 12904 "int f(num n) {", | 14404 "int f(num n) {", |
| 12905 " if (n is! int) {", | 14405 " if (n is! int) {", |
| 12906 " return 0;", | 14406 " return 0;", |
| 12907 " } else {", | 14407 " } else {", |
| 12908 " return n & 0x0F;", | 14408 " return n & 0x0F;", |
| 12909 " }", | 14409 " }", |
| 12910 "}"])); | 14410 "}"])); |
| 12911 resolve(source); | 14411 resolve(source); |
| 12912 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 14412 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 12913 } | 14413 } |
| 14414 |
| 12914 void test_if_isNot_abrupt() { | 14415 void test_if_isNot_abrupt() { |
| 12915 Source source = addSource(EngineTestCase.createSource([ | 14416 Source source = addSource(EngineTestCase.createSource([ |
| 12916 "int f(num n) {", | 14417 "int f(num n) {", |
| 12917 " if (n is! int) {", | 14418 " if (n is! int) {", |
| 12918 " return 0;", | 14419 " return 0;", |
| 12919 " }", | 14420 " }", |
| 12920 " return n & 0x0F;", | 14421 " return n & 0x0F;", |
| 12921 "}"])); | 14422 "}"])); |
| 12922 resolve(source); | 14423 resolve(source); |
| 12923 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 14424 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 12924 } | 14425 } |
| 14426 |
| 12925 void test_if_or_is() { | 14427 void test_if_or_is() { |
| 12926 Source source = addSource(EngineTestCase.createSource([ | 14428 Source source = addSource(EngineTestCase.createSource([ |
| 12927 "int f(num n) {", | 14429 "int f(num n) {", |
| 12928 " if (n is! int || n < 0) {", | 14430 " if (n is! int || n < 0) {", |
| 12929 " return 0;", | 14431 " return 0;", |
| 12930 " } else {", | 14432 " } else {", |
| 12931 " return n & 0x0F;", | 14433 " return n & 0x0F;", |
| 12932 " }", | 14434 " }", |
| 12933 "}"])); | 14435 "}"])); |
| 12934 resolve(source); | 14436 resolve(source); |
| 12935 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 14437 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 12936 } | 14438 } |
| 14439 |
| 12937 void test_localVar() { | 14440 void test_localVar() { |
| 12938 Source source = addSource(EngineTestCase.createSource(["int f() {", " num n
= 1234;", " return n & 0x0F;", "}"])); | 14441 Source source = addSource(EngineTestCase.createSource(["int f() {", " num n
= 1234;", " return n & 0x0F;", "}"])); |
| 12939 resolve(source); | 14442 resolve(source); |
| 12940 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 14443 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 12941 } | 14444 } |
| 14445 |
| 12942 static dartSuite() { | 14446 static dartSuite() { |
| 12943 _ut.group('StrictModeTest', () { | 14447 _ut.group('StrictModeTest', () { |
| 12944 _ut.test('test_assert_is', () { | 14448 _ut.test('test_assert_is', () { |
| 12945 final __test = new StrictModeTest(); | 14449 final __test = new StrictModeTest(); |
| 12946 runJUnitTest(__test, __test.test_assert_is); | 14450 runJUnitTest(__test, __test.test_assert_is); |
| 12947 }); | 14451 }); |
| 12948 _ut.test('test_conditional_and_is', () { | 14452 _ut.test('test_conditional_and_is', () { |
| 12949 final __test = new StrictModeTest(); | 14453 final __test = new StrictModeTest(); |
| 12950 runJUnitTest(__test, __test.test_conditional_and_is); | 14454 runJUnitTest(__test, __test.test_conditional_and_is); |
| 12951 }); | 14455 }); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12985 final __test = new StrictModeTest(); | 14489 final __test = new StrictModeTest(); |
| 12986 runJUnitTest(__test, __test.test_if_or_is); | 14490 runJUnitTest(__test, __test.test_if_or_is); |
| 12987 }); | 14491 }); |
| 12988 _ut.test('test_localVar', () { | 14492 _ut.test('test_localVar', () { |
| 12989 final __test = new StrictModeTest(); | 14493 final __test = new StrictModeTest(); |
| 12990 runJUnitTest(__test, __test.test_localVar); | 14494 runJUnitTest(__test, __test.test_localVar); |
| 12991 }); | 14495 }); |
| 12992 }); | 14496 }); |
| 12993 } | 14497 } |
| 12994 } | 14498 } |
| 14499 |
| 12995 class ElementResolverTest extends EngineTestCase { | 14500 class ElementResolverTest extends EngineTestCase { |
| 12996 | |
| 12997 /** | 14501 /** |
| 12998 * The error listener to which errors will be reported. | 14502 * The error listener to which errors will be reported. |
| 12999 */ | 14503 */ |
| 13000 GatheringErrorListener _listener; | 14504 GatheringErrorListener _listener; |
| 13001 | 14505 |
| 13002 /** | 14506 /** |
| 13003 * The type provider used to access the types. | 14507 * The type provider used to access the types. |
| 13004 */ | 14508 */ |
| 13005 TestTypeProvider _typeProvider; | 14509 TestTypeProvider _typeProvider; |
| 13006 | 14510 |
| 13007 /** | 14511 /** |
| 13008 * The library containing the code being resolved. | 14512 * The library containing the code being resolved. |
| 13009 */ | 14513 */ |
| 13010 LibraryElementImpl _definingLibrary; | 14514 LibraryElementImpl _definingLibrary; |
| 13011 | 14515 |
| 13012 /** | 14516 /** |
| 13013 * The resolver visitor that maintains the state for the resolver. | 14517 * The resolver visitor that maintains the state for the resolver. |
| 13014 */ | 14518 */ |
| 13015 ResolverVisitor _visitor; | 14519 ResolverVisitor _visitor; |
| 13016 | 14520 |
| 13017 /** | 14521 /** |
| 13018 * The resolver being used to resolve the test cases. | 14522 * The resolver being used to resolve the test cases. |
| 13019 */ | 14523 */ |
| 13020 ElementResolver _resolver; | 14524 ElementResolver _resolver; |
| 14525 |
| 13021 void fail_visitExportDirective_combinators() { | 14526 void fail_visitExportDirective_combinators() { |
| 13022 JUnitTestCase.fail("Not yet tested"); | 14527 JUnitTestCase.fail("Not yet tested"); |
| 13023 ExportDirective directive = ASTFactory.exportDirective2(null, [ASTFactory.hi
deCombinator2(["A"])]); | 14528 ExportDirective directive = ASTFactory.exportDirective2(null, [ASTFactory.hi
deCombinator2(["A"])]); |
| 13024 resolveNode(directive, []); | 14529 resolveNode(directive, []); |
| 13025 _listener.assertNoErrors(); | 14530 _listener.assertNoErrors(); |
| 13026 } | 14531 } |
| 14532 |
| 13027 void fail_visitFunctionExpressionInvocation() { | 14533 void fail_visitFunctionExpressionInvocation() { |
| 13028 JUnitTestCase.fail("Not yet tested"); | 14534 JUnitTestCase.fail("Not yet tested"); |
| 13029 _listener.assertNoErrors(); | 14535 _listener.assertNoErrors(); |
| 13030 } | 14536 } |
| 14537 |
| 13031 void fail_visitImportDirective_combinators_noPrefix() { | 14538 void fail_visitImportDirective_combinators_noPrefix() { |
| 13032 JUnitTestCase.fail("Not yet tested"); | 14539 JUnitTestCase.fail("Not yet tested"); |
| 13033 ImportDirective directive = ASTFactory.importDirective2(null, null, [ASTFact
ory.showCombinator2(["A"])]); | 14540 ImportDirective directive = ASTFactory.importDirective2(null, null, [ASTFact
ory.showCombinator2(["A"])]); |
| 13034 resolveNode(directive, []); | 14541 resolveNode(directive, []); |
| 13035 _listener.assertNoErrors(); | 14542 _listener.assertNoErrors(); |
| 13036 } | 14543 } |
| 14544 |
| 13037 void fail_visitImportDirective_combinators_prefix() { | 14545 void fail_visitImportDirective_combinators_prefix() { |
| 13038 JUnitTestCase.fail("Not yet tested"); | 14546 JUnitTestCase.fail("Not yet tested"); |
| 13039 String prefixName = "p"; | 14547 String prefixName = "p"; |
| 13040 _definingLibrary.imports = <ImportElement> [ElementFactory.importFor(null, E
lementFactory.prefix(prefixName), [])]; | 14548 _definingLibrary.imports = <ImportElement> [ElementFactory.importFor(null, E
lementFactory.prefix(prefixName), [])]; |
| 13041 ImportDirective directive = ASTFactory.importDirective2(null, prefixName, [ | 14549 ImportDirective directive = ASTFactory.importDirective2(null, prefixName, [ |
| 13042 ASTFactory.showCombinator2(["A"]), | 14550 ASTFactory.showCombinator2(["A"]), |
| 13043 ASTFactory.hideCombinator2(["B"])]); | 14551 ASTFactory.hideCombinator2(["B"])]); |
| 13044 resolveNode(directive, []); | 14552 resolveNode(directive, []); |
| 13045 _listener.assertNoErrors(); | 14553 _listener.assertNoErrors(); |
| 13046 } | 14554 } |
| 14555 |
| 13047 void fail_visitRedirectingConstructorInvocation() { | 14556 void fail_visitRedirectingConstructorInvocation() { |
| 13048 JUnitTestCase.fail("Not yet tested"); | 14557 JUnitTestCase.fail("Not yet tested"); |
| 13049 _listener.assertNoErrors(); | 14558 _listener.assertNoErrors(); |
| 13050 } | 14559 } |
| 14560 |
| 13051 void setUp() { | 14561 void setUp() { |
| 13052 _listener = new GatheringErrorListener(); | 14562 _listener = new GatheringErrorListener(); |
| 13053 _typeProvider = new TestTypeProvider(); | 14563 _typeProvider = new TestTypeProvider(); |
| 13054 _resolver = createResolver(); | 14564 _resolver = createResolver(); |
| 13055 } | 14565 } |
| 14566 |
| 13056 void test_lookUpMethodInInterfaces() { | 14567 void test_lookUpMethodInInterfaces() { |
| 13057 InterfaceType intType = _typeProvider.intType; | 14568 InterfaceType intType = _typeProvider.intType; |
| 13058 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14569 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13059 MethodElement operator = ElementFactory.methodElement("[]", intType, [intTyp
e]); | 14570 MethodElement operator = ElementFactory.methodElement("[]", intType, [intTyp
e]); |
| 13060 classA.methods = <MethodElement> [operator]; | 14571 classA.methods = <MethodElement> [operator]; |
| 13061 ClassElementImpl classB = ElementFactory.classElement2("B", []); | 14572 ClassElementImpl classB = ElementFactory.classElement2("B", []); |
| 13062 classB.interfaces = <InterfaceType> [classA.type]; | 14573 classB.interfaces = <InterfaceType> [classA.type]; |
| 13063 ClassElementImpl classC = ElementFactory.classElement2("C", []); | 14574 ClassElementImpl classC = ElementFactory.classElement2("C", []); |
| 13064 classC.mixins = <InterfaceType> [classB.type]; | 14575 classC.mixins = <InterfaceType> [classB.type]; |
| 13065 ClassElementImpl classD = ElementFactory.classElement("D", classC.type, []); | 14576 ClassElementImpl classD = ElementFactory.classElement("D", classC.type, []); |
| 13066 SimpleIdentifier array = ASTFactory.identifier3("a"); | 14577 SimpleIdentifier array = ASTFactory.identifier3("a"); |
| 13067 array.staticType = classD.type; | 14578 array.staticType = classD.type; |
| 13068 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); | 14579 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); |
| 13069 JUnitTestCase.assertSame(operator, resolve5(expression, [])); | 14580 JUnitTestCase.assertSame(operator, resolve5(expression, [])); |
| 13070 _listener.assertNoErrors(); | 14581 _listener.assertNoErrors(); |
| 13071 } | 14582 } |
| 14583 |
| 13072 void test_visitAssignmentExpression_compound() { | 14584 void test_visitAssignmentExpression_compound() { |
| 13073 InterfaceType intType = _typeProvider.intType; | 14585 InterfaceType intType = _typeProvider.intType; |
| 13074 SimpleIdentifier leftHandSide = ASTFactory.identifier3("a"); | 14586 SimpleIdentifier leftHandSide = ASTFactory.identifier3("a"); |
| 13075 leftHandSide.staticType = intType; | 14587 leftHandSide.staticType = intType; |
| 13076 AssignmentExpression assignment = ASTFactory.assignmentExpression(leftHandSi
de, TokenType.PLUS_EQ, ASTFactory.integer(1)); | 14588 AssignmentExpression assignment = ASTFactory.assignmentExpression(leftHandSi
de, TokenType.PLUS_EQ, ASTFactory.integer(1)); |
| 13077 resolveNode(assignment, []); | 14589 resolveNode(assignment, []); |
| 13078 JUnitTestCase.assertSame(getMethod(_typeProvider.numType, "+"), assignment.s
taticElement); | 14590 JUnitTestCase.assertSame(getMethod(_typeProvider.numType, "+"), assignment.s
taticElement); |
| 13079 _listener.assertNoErrors(); | 14591 _listener.assertNoErrors(); |
| 13080 } | 14592 } |
| 14593 |
| 13081 void test_visitAssignmentExpression_simple() { | 14594 void test_visitAssignmentExpression_simple() { |
| 13082 AssignmentExpression expression = ASTFactory.assignmentExpression(ASTFactory
.identifier3("x"), TokenType.EQ, ASTFactory.integer(0)); | 14595 AssignmentExpression expression = ASTFactory.assignmentExpression(ASTFactory
.identifier3("x"), TokenType.EQ, ASTFactory.integer(0)); |
| 13083 resolveNode(expression, []); | 14596 resolveNode(expression, []); |
| 13084 JUnitTestCase.assertNull(expression.staticElement); | 14597 JUnitTestCase.assertNull(expression.staticElement); |
| 13085 _listener.assertNoErrors(); | 14598 _listener.assertNoErrors(); |
| 13086 } | 14599 } |
| 14600 |
| 13087 void test_visitBinaryExpression() { | 14601 void test_visitBinaryExpression() { |
| 13088 InterfaceType numType = _typeProvider.numType; | 14602 InterfaceType numType = _typeProvider.numType; |
| 13089 SimpleIdentifier left = ASTFactory.identifier3("i"); | 14603 SimpleIdentifier left = ASTFactory.identifier3("i"); |
| 13090 left.staticType = numType; | 14604 left.staticType = numType; |
| 13091 BinaryExpression expression = ASTFactory.binaryExpression(left, TokenType.PL
US, ASTFactory.identifier3("j")); | 14605 BinaryExpression expression = ASTFactory.binaryExpression(left, TokenType.PL
US, ASTFactory.identifier3("j")); |
| 13092 resolveNode(expression, []); | 14606 resolveNode(expression, []); |
| 13093 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.staticElement
); | 14607 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.staticElement
); |
| 13094 _listener.assertNoErrors(); | 14608 _listener.assertNoErrors(); |
| 13095 } | 14609 } |
| 14610 |
| 13096 void test_visitBreakStatement_withLabel() { | 14611 void test_visitBreakStatement_withLabel() { |
| 13097 String label = "loop"; | 14612 String label = "loop"; |
| 13098 LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3(
label), false, false); | 14613 LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3(
label), false, false); |
| 13099 BreakStatement statement = ASTFactory.breakStatement2(label); | 14614 BreakStatement statement = ASTFactory.breakStatement2(label); |
| 13100 JUnitTestCase.assertSame(labelElement, resolve(statement, labelElement)); | 14615 JUnitTestCase.assertSame(labelElement, resolve(statement, labelElement)); |
| 13101 _listener.assertNoErrors(); | 14616 _listener.assertNoErrors(); |
| 13102 } | 14617 } |
| 14618 |
| 13103 void test_visitBreakStatement_withoutLabel() { | 14619 void test_visitBreakStatement_withoutLabel() { |
| 13104 BreakStatement statement = ASTFactory.breakStatement(); | 14620 BreakStatement statement = ASTFactory.breakStatement(); |
| 13105 resolveStatement(statement, null); | 14621 resolveStatement(statement, null); |
| 13106 _listener.assertNoErrors(); | 14622 _listener.assertNoErrors(); |
| 13107 } | 14623 } |
| 14624 |
| 13108 void test_visitConstructorName_named() { | 14625 void test_visitConstructorName_named() { |
| 13109 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14626 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13110 String constructorName = "a"; | 14627 String constructorName = "a"; |
| 13111 ConstructorElement constructor = ElementFactory.constructorElement(classA, c
onstructorName); | 14628 ConstructorElement constructor = ElementFactory.constructorElement2(classA,
constructorName, []); |
| 13112 classA.constructors = <ConstructorElement> [constructor]; | 14629 classA.constructors = <ConstructorElement> [constructor]; |
| 13113 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); | 14630 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); |
| 13114 resolveNode(name, []); | 14631 resolveNode(name, []); |
| 13115 JUnitTestCase.assertSame(constructor, name.staticElement); | 14632 JUnitTestCase.assertSame(constructor, name.staticElement); |
| 13116 _listener.assertNoErrors(); | 14633 _listener.assertNoErrors(); |
| 13117 } | 14634 } |
| 14635 |
| 13118 void test_visitConstructorName_unnamed() { | 14636 void test_visitConstructorName_unnamed() { |
| 13119 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14637 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13120 String constructorName = null; | 14638 String constructorName = null; |
| 13121 ConstructorElement constructor = ElementFactory.constructorElement(classA, c
onstructorName); | 14639 ConstructorElement constructor = ElementFactory.constructorElement2(classA,
constructorName, []); |
| 13122 classA.constructors = <ConstructorElement> [constructor]; | 14640 classA.constructors = <ConstructorElement> [constructor]; |
| 13123 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); | 14641 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); |
| 13124 resolveNode(name, []); | 14642 resolveNode(name, []); |
| 13125 JUnitTestCase.assertSame(constructor, name.staticElement); | 14643 JUnitTestCase.assertSame(constructor, name.staticElement); |
| 13126 _listener.assertNoErrors(); | 14644 _listener.assertNoErrors(); |
| 13127 } | 14645 } |
| 14646 |
| 13128 void test_visitContinueStatement_withLabel() { | 14647 void test_visitContinueStatement_withLabel() { |
| 13129 String label = "loop"; | 14648 String label = "loop"; |
| 13130 LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3(
label), false, false); | 14649 LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3(
label), false, false); |
| 13131 ContinueStatement statement = ASTFactory.continueStatement2(label); | 14650 ContinueStatement statement = ASTFactory.continueStatement2(label); |
| 13132 JUnitTestCase.assertSame(labelElement, resolve3(statement, labelElement)); | 14651 JUnitTestCase.assertSame(labelElement, resolve3(statement, labelElement)); |
| 13133 _listener.assertNoErrors(); | 14652 _listener.assertNoErrors(); |
| 13134 } | 14653 } |
| 14654 |
| 13135 void test_visitContinueStatement_withoutLabel() { | 14655 void test_visitContinueStatement_withoutLabel() { |
| 13136 ContinueStatement statement = ASTFactory.continueStatement(); | 14656 ContinueStatement statement = ASTFactory.continueStatement(); |
| 13137 resolveStatement(statement, null); | 14657 resolveStatement(statement, null); |
| 13138 _listener.assertNoErrors(); | 14658 _listener.assertNoErrors(); |
| 13139 } | 14659 } |
| 14660 |
| 13140 void test_visitExportDirective_noCombinators() { | 14661 void test_visitExportDirective_noCombinators() { |
| 13141 ExportDirective directive = ASTFactory.exportDirective2(null, []); | 14662 ExportDirective directive = ASTFactory.exportDirective2(null, []); |
| 13142 directive.element = ElementFactory.exportFor(ElementFactory.library(_definin
gLibrary.context, "lib"), []); | 14663 directive.element = ElementFactory.exportFor(ElementFactory.library(_definin
gLibrary.context, "lib"), []); |
| 13143 resolveNode(directive, []); | 14664 resolveNode(directive, []); |
| 13144 _listener.assertNoErrors(); | 14665 _listener.assertNoErrors(); |
| 13145 } | 14666 } |
| 14667 |
| 13146 void test_visitFieldFormalParameter() { | 14668 void test_visitFieldFormalParameter() { |
| 13147 InterfaceType intType = _typeProvider.intType; | 14669 InterfaceType intType = _typeProvider.intType; |
| 13148 String fieldName = "f"; | 14670 String fieldName = "f"; |
| 13149 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14671 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13150 classA.fields = <FieldElement> [ElementFactory.fieldElement(fieldName, false
, false, false, intType)]; | 14672 classA.fields = <FieldElement> [ElementFactory.fieldElement(fieldName, false
, false, false, intType)]; |
| 13151 FieldFormalParameter parameter = ASTFactory.fieldFormalParameter3(fieldName)
; | 14673 FieldFormalParameter parameter = ASTFactory.fieldFormalParameter3(fieldName)
; |
| 13152 parameter.identifier.staticElement = ElementFactory.fieldFormalParameter(par
ameter.identifier); | 14674 parameter.identifier.staticElement = ElementFactory.fieldFormalParameter(par
ameter.identifier); |
| 13153 resolveInClass(parameter, classA); | 14675 resolveInClass(parameter, classA); |
| 13154 JUnitTestCase.assertSame(intType, parameter.element.type); | 14676 JUnitTestCase.assertSame(intType, parameter.element.type); |
| 13155 } | 14677 } |
| 14678 |
| 13156 void test_visitImportDirective_noCombinators_noPrefix() { | 14679 void test_visitImportDirective_noCombinators_noPrefix() { |
| 13157 ImportDirective directive = ASTFactory.importDirective2(null, null, []); | 14680 ImportDirective directive = ASTFactory.importDirective2(null, null, []); |
| 13158 directive.element = ElementFactory.importFor(ElementFactory.library(_definin
gLibrary.context, "lib"), null, []); | 14681 directive.element = ElementFactory.importFor(ElementFactory.library(_definin
gLibrary.context, "lib"), null, []); |
| 13159 resolveNode(directive, []); | 14682 resolveNode(directive, []); |
| 13160 _listener.assertNoErrors(); | 14683 _listener.assertNoErrors(); |
| 13161 } | 14684 } |
| 14685 |
| 13162 void test_visitImportDirective_noCombinators_prefix() { | 14686 void test_visitImportDirective_noCombinators_prefix() { |
| 13163 String prefixName = "p"; | 14687 String prefixName = "p"; |
| 13164 ImportElement importElement = ElementFactory.importFor(ElementFactory.librar
y(_definingLibrary.context, "lib"), ElementFactory.prefix(prefixName), []); | 14688 ImportElement importElement = ElementFactory.importFor(ElementFactory.librar
y(_definingLibrary.context, "lib"), ElementFactory.prefix(prefixName), []); |
| 13165 _definingLibrary.imports = <ImportElement> [importElement]; | 14689 _definingLibrary.imports = <ImportElement> [importElement]; |
| 13166 ImportDirective directive = ASTFactory.importDirective2(null, prefixName, []
); | 14690 ImportDirective directive = ASTFactory.importDirective2(null, prefixName, []
); |
| 13167 directive.element = importElement; | 14691 directive.element = importElement; |
| 13168 resolveNode(directive, []); | 14692 resolveNode(directive, []); |
| 13169 _listener.assertNoErrors(); | 14693 _listener.assertNoErrors(); |
| 13170 } | 14694 } |
| 14695 |
| 13171 void test_visitIndexExpression_get() { | 14696 void test_visitIndexExpression_get() { |
| 13172 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14697 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13173 InterfaceType intType = _typeProvider.intType; | 14698 InterfaceType intType = _typeProvider.intType; |
| 13174 MethodElement getter = ElementFactory.methodElement("[]", intType, [intType]
); | 14699 MethodElement getter = ElementFactory.methodElement("[]", intType, [intType]
); |
| 13175 classA.methods = <MethodElement> [getter]; | 14700 classA.methods = <MethodElement> [getter]; |
| 13176 SimpleIdentifier array = ASTFactory.identifier3("a"); | 14701 SimpleIdentifier array = ASTFactory.identifier3("a"); |
| 13177 array.staticType = classA.type; | 14702 array.staticType = classA.type; |
| 13178 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); | 14703 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); |
| 13179 JUnitTestCase.assertSame(getter, resolve5(expression, [])); | 14704 JUnitTestCase.assertSame(getter, resolve5(expression, [])); |
| 13180 _listener.assertNoErrors(); | 14705 _listener.assertNoErrors(); |
| 13181 } | 14706 } |
| 14707 |
| 13182 void test_visitIndexExpression_set() { | 14708 void test_visitIndexExpression_set() { |
| 13183 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14709 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13184 InterfaceType intType = _typeProvider.intType; | 14710 InterfaceType intType = _typeProvider.intType; |
| 13185 MethodElement setter = ElementFactory.methodElement("[]=", intType, [intType
]); | 14711 MethodElement setter = ElementFactory.methodElement("[]=", intType, [intType
]); |
| 13186 classA.methods = <MethodElement> [setter]; | 14712 classA.methods = <MethodElement> [setter]; |
| 13187 SimpleIdentifier array = ASTFactory.identifier3("a"); | 14713 SimpleIdentifier array = ASTFactory.identifier3("a"); |
| 13188 array.staticType = classA.type; | 14714 array.staticType = classA.type; |
| 13189 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); | 14715 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id
entifier3("i")); |
| 13190 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.integer
(0)); | 14716 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.integer
(0)); |
| 13191 JUnitTestCase.assertSame(setter, resolve5(expression, [])); | 14717 JUnitTestCase.assertSame(setter, resolve5(expression, [])); |
| 13192 _listener.assertNoErrors(); | 14718 _listener.assertNoErrors(); |
| 13193 } | 14719 } |
| 14720 |
| 13194 void test_visitInstanceCreationExpression_named() { | 14721 void test_visitInstanceCreationExpression_named() { |
| 13195 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14722 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13196 String constructorName = "a"; | 14723 String constructorName = "a"; |
| 13197 ConstructorElement constructor = ElementFactory.constructorElement(classA, c
onstructorName); | 14724 ConstructorElement constructor = ElementFactory.constructorElement2(classA,
constructorName, []); |
| 13198 classA.constructors = <ConstructorElement> [constructor]; | 14725 classA.constructors = <ConstructorElement> [constructor]; |
| 13199 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); | 14726 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); |
| 13200 name.staticElement = constructor; | 14727 name.staticElement = constructor; |
| 13201 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression(
Keyword.NEW, name, []); | 14728 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression(
Keyword.NEW, name, []); |
| 13202 resolveNode(creation, []); | 14729 resolveNode(creation, []); |
| 13203 JUnitTestCase.assertSame(constructor, creation.staticElement); | 14730 JUnitTestCase.assertSame(constructor, creation.staticElement); |
| 13204 _listener.assertNoErrors(); | 14731 _listener.assertNoErrors(); |
| 13205 } | 14732 } |
| 14733 |
| 13206 void test_visitInstanceCreationExpression_unnamed() { | 14734 void test_visitInstanceCreationExpression_unnamed() { |
| 13207 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14735 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13208 String constructorName = null; | 14736 String constructorName = null; |
| 13209 ConstructorElement constructor = ElementFactory.constructorElement(classA, c
onstructorName); | 14737 ConstructorElement constructor = ElementFactory.constructorElement2(classA,
constructorName, []); |
| 13210 classA.constructors = <ConstructorElement> [constructor]; | 14738 classA.constructors = <ConstructorElement> [constructor]; |
| 13211 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); | 14739 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); |
| 13212 name.staticElement = constructor; | 14740 name.staticElement = constructor; |
| 13213 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression(
Keyword.NEW, name, []); | 14741 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression(
Keyword.NEW, name, []); |
| 13214 resolveNode(creation, []); | 14742 resolveNode(creation, []); |
| 13215 JUnitTestCase.assertSame(constructor, creation.staticElement); | 14743 JUnitTestCase.assertSame(constructor, creation.staticElement); |
| 13216 _listener.assertNoErrors(); | 14744 _listener.assertNoErrors(); |
| 13217 } | 14745 } |
| 14746 |
| 13218 void test_visitInstanceCreationExpression_unnamed_namedParameter() { | 14747 void test_visitInstanceCreationExpression_unnamed_namedParameter() { |
| 13219 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14748 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13220 String constructorName = null; | 14749 String constructorName = null; |
| 13221 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
A, constructorName); | 14750 ConstructorElementImpl constructor = ElementFactory.constructorElement2(clas
sA, constructorName, []); |
| 13222 String parameterName = "a"; | 14751 String parameterName = "a"; |
| 13223 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 14752 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
| 13224 constructor.parameters = <ParameterElement> [parameter]; | 14753 constructor.parameters = <ParameterElement> [parameter]; |
| 13225 classA.constructors = <ConstructorElement> [constructor]; | 14754 classA.constructors = <ConstructorElement> [constructor]; |
| 13226 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); | 14755 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA
, []), constructorName); |
| 13227 name.staticElement = constructor; | 14756 name.staticElement = constructor; |
| 13228 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression(
Keyword.NEW, name, [ASTFactory.namedExpression2(parameterName, ASTFactory.intege
r(0))]); | 14757 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression(
Keyword.NEW, name, [ASTFactory.namedExpression2(parameterName, ASTFactory.intege
r(0))]); |
| 13229 resolveNode(creation, []); | 14758 resolveNode(creation, []); |
| 13230 JUnitTestCase.assertSame(constructor, creation.staticElement); | 14759 JUnitTestCase.assertSame(constructor, creation.staticElement); |
| 13231 JUnitTestCase.assertSame(parameter, ((creation.argumentList.arguments[0] as
NamedExpression)).name.label.staticElement); | 14760 JUnitTestCase.assertSame(parameter, (creation.argumentList.arguments[0] as N
amedExpression).name.label.staticElement); |
| 13232 _listener.assertNoErrors(); | 14761 _listener.assertNoErrors(); |
| 13233 } | 14762 } |
| 14763 |
| 13234 void test_visitMethodInvocation() { | 14764 void test_visitMethodInvocation() { |
| 13235 InterfaceType numType = _typeProvider.numType; | 14765 InterfaceType numType = _typeProvider.numType; |
| 13236 SimpleIdentifier left = ASTFactory.identifier3("i"); | 14766 SimpleIdentifier left = ASTFactory.identifier3("i"); |
| 13237 left.staticType = numType; | 14767 left.staticType = numType; |
| 13238 String methodName = "abs"; | 14768 String methodName = "abs"; |
| 13239 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName,
[]); | 14769 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName,
[]); |
| 13240 resolveNode(invocation, []); | 14770 resolveNode(invocation, []); |
| 13241 JUnitTestCase.assertSame(getMethod(numType, methodName), invocation.methodNa
me.staticElement); | 14771 JUnitTestCase.assertSame(getMethod(numType, methodName), invocation.methodNa
me.staticElement); |
| 13242 _listener.assertNoErrors(); | 14772 _listener.assertNoErrors(); |
| 13243 } | 14773 } |
| 14774 |
| 13244 void test_visitMethodInvocation_namedParameter() { | 14775 void test_visitMethodInvocation_namedParameter() { |
| 13245 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14776 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13246 String methodName = "m"; | 14777 String methodName = "m"; |
| 13247 String parameterName = "p"; | 14778 String parameterName = "p"; |
| 13248 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); | 14779 MethodElementImpl method = ElementFactory.methodElement(methodName, null, []
); |
| 13249 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 14780 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
| 13250 method.parameters = <ParameterElement> [parameter]; | 14781 method.parameters = <ParameterElement> [parameter]; |
| 13251 classA.methods = <MethodElement> [method]; | 14782 classA.methods = <MethodElement> [method]; |
| 13252 SimpleIdentifier left = ASTFactory.identifier3("i"); | 14783 SimpleIdentifier left = ASTFactory.identifier3("i"); |
| 13253 left.staticType = classA.type; | 14784 left.staticType = classA.type; |
| 13254 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName,
[ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); | 14785 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName,
[ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); |
| 13255 resolveNode(invocation, []); | 14786 resolveNode(invocation, []); |
| 13256 JUnitTestCase.assertSame(method, invocation.methodName.staticElement); | 14787 JUnitTestCase.assertSame(method, invocation.methodName.staticElement); |
| 13257 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a
s NamedExpression)).name.label.staticElement); | 14788 JUnitTestCase.assertSame(parameter, (invocation.argumentList.arguments[0] as
NamedExpression).name.label.staticElement); |
| 13258 _listener.assertNoErrors(); | 14789 _listener.assertNoErrors(); |
| 13259 } | 14790 } |
| 14791 |
| 13260 void test_visitPostfixExpression() { | 14792 void test_visitPostfixExpression() { |
| 13261 InterfaceType numType = _typeProvider.numType; | 14793 InterfaceType numType = _typeProvider.numType; |
| 13262 SimpleIdentifier operand = ASTFactory.identifier3("i"); | 14794 SimpleIdentifier operand = ASTFactory.identifier3("i"); |
| 13263 operand.staticType = numType; | 14795 operand.staticType = numType; |
| 13264 PostfixExpression expression = ASTFactory.postfixExpression(operand, TokenTy
pe.PLUS_PLUS); | 14796 PostfixExpression expression = ASTFactory.postfixExpression(operand, TokenTy
pe.PLUS_PLUS); |
| 13265 resolveNode(expression, []); | 14797 resolveNode(expression, []); |
| 13266 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.staticElement
); | 14798 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.staticElement
); |
| 13267 _listener.assertNoErrors(); | 14799 _listener.assertNoErrors(); |
| 13268 } | 14800 } |
| 14801 |
| 13269 void test_visitPrefixedIdentifier_dynamic() { | 14802 void test_visitPrefixedIdentifier_dynamic() { |
| 13270 Type2 dynamicType = _typeProvider.dynamicType; | 14803 Type2 dynamicType = _typeProvider.dynamicType; |
| 13271 SimpleIdentifier target = ASTFactory.identifier3("a"); | 14804 SimpleIdentifier target = ASTFactory.identifier3("a"); |
| 13272 VariableElementImpl variable = ElementFactory.localVariableElement(target); | 14805 VariableElementImpl variable = ElementFactory.localVariableElement(target); |
| 13273 variable.type = dynamicType; | 14806 variable.type = dynamicType; |
| 13274 target.staticElement = variable; | 14807 target.staticElement = variable; |
| 13275 target.staticType = dynamicType; | 14808 target.staticType = dynamicType; |
| 13276 PrefixedIdentifier identifier = ASTFactory.identifier(target, ASTFactory.ide
ntifier3("b")); | 14809 PrefixedIdentifier identifier = ASTFactory.identifier(target, ASTFactory.ide
ntifier3("b")); |
| 13277 resolveNode(identifier, []); | 14810 resolveNode(identifier, []); |
| 13278 JUnitTestCase.assertNull(identifier.staticElement); | 14811 JUnitTestCase.assertNull(identifier.staticElement); |
| 13279 JUnitTestCase.assertNull(identifier.identifier.staticElement); | 14812 JUnitTestCase.assertNull(identifier.identifier.staticElement); |
| 13280 _listener.assertNoErrors(); | 14813 _listener.assertNoErrors(); |
| 13281 } | 14814 } |
| 14815 |
| 13282 void test_visitPrefixedIdentifier_nonDynamic() { | 14816 void test_visitPrefixedIdentifier_nonDynamic() { |
| 13283 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14817 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13284 String getterName = "b"; | 14818 String getterName = "b"; |
| 13285 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, _typeProvider.intType); | 14819 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, _typeProvider.intType); |
| 13286 classA.accessors = <PropertyAccessorElement> [getter]; | 14820 classA.accessors = <PropertyAccessorElement> [getter]; |
| 13287 SimpleIdentifier target = ASTFactory.identifier3("a"); | 14821 SimpleIdentifier target = ASTFactory.identifier3("a"); |
| 13288 VariableElementImpl variable = ElementFactory.localVariableElement(target); | 14822 VariableElementImpl variable = ElementFactory.localVariableElement(target); |
| 13289 variable.type = classA.type; | 14823 variable.type = classA.type; |
| 13290 target.staticElement = variable; | 14824 target.staticElement = variable; |
| 13291 target.staticType = classA.type; | 14825 target.staticType = classA.type; |
| 13292 PrefixedIdentifier identifier = ASTFactory.identifier(target, ASTFactory.ide
ntifier3(getterName)); | 14826 PrefixedIdentifier identifier = ASTFactory.identifier(target, ASTFactory.ide
ntifier3(getterName)); |
| 13293 resolveNode(identifier, []); | 14827 resolveNode(identifier, []); |
| 13294 JUnitTestCase.assertSame(getter, identifier.staticElement); | 14828 JUnitTestCase.assertSame(getter, identifier.staticElement); |
| 13295 JUnitTestCase.assertSame(getter, identifier.identifier.staticElement); | 14829 JUnitTestCase.assertSame(getter, identifier.identifier.staticElement); |
| 13296 _listener.assertNoErrors(); | 14830 _listener.assertNoErrors(); |
| 13297 } | 14831 } |
| 14832 |
| 13298 void test_visitPrefixExpression() { | 14833 void test_visitPrefixExpression() { |
| 13299 InterfaceType numType = _typeProvider.numType; | 14834 InterfaceType numType = _typeProvider.numType; |
| 13300 SimpleIdentifier operand = ASTFactory.identifier3("i"); | 14835 SimpleIdentifier operand = ASTFactory.identifier3("i"); |
| 13301 operand.staticType = numType; | 14836 operand.staticType = numType; |
| 13302 PrefixExpression expression = ASTFactory.prefixExpression(TokenType.PLUS_PLU
S, operand); | 14837 PrefixExpression expression = ASTFactory.prefixExpression(TokenType.PLUS_PLU
S, operand); |
| 13303 resolveNode(expression, []); | 14838 resolveNode(expression, []); |
| 13304 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.staticElement
); | 14839 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.staticElement
); |
| 13305 _listener.assertNoErrors(); | 14840 _listener.assertNoErrors(); |
| 13306 } | 14841 } |
| 14842 |
| 13307 void test_visitPropertyAccess_getter_identifier() { | 14843 void test_visitPropertyAccess_getter_identifier() { |
| 13308 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14844 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13309 String getterName = "b"; | 14845 String getterName = "b"; |
| 13310 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, _typeProvider.intType); | 14846 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, _typeProvider.intType); |
| 13311 classA.accessors = <PropertyAccessorElement> [getter]; | 14847 classA.accessors = <PropertyAccessorElement> [getter]; |
| 13312 SimpleIdentifier target = ASTFactory.identifier3("a"); | 14848 SimpleIdentifier target = ASTFactory.identifier3("a"); |
| 13313 target.staticType = classA.type; | 14849 target.staticType = classA.type; |
| 13314 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName); | 14850 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName); |
| 13315 resolveNode(access, []); | 14851 resolveNode(access, []); |
| 13316 JUnitTestCase.assertSame(getter, access.propertyName.staticElement); | 14852 JUnitTestCase.assertSame(getter, access.propertyName.staticElement); |
| 13317 _listener.assertNoErrors(); | 14853 _listener.assertNoErrors(); |
| 13318 } | 14854 } |
| 14855 |
| 13319 void test_visitPropertyAccess_getter_super() { | 14856 void test_visitPropertyAccess_getter_super() { |
| 13320 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14857 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13321 String getterName = "b"; | 14858 String getterName = "b"; |
| 13322 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, _typeProvider.intType); | 14859 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa
lse, _typeProvider.intType); |
| 13323 classA.accessors = <PropertyAccessorElement> [getter]; | 14860 classA.accessors = <PropertyAccessorElement> [getter]; |
| 13324 SuperExpression target = ASTFactory.superExpression(); | 14861 SuperExpression target = ASTFactory.superExpression(); |
| 13325 target.staticType = ElementFactory.classElement("B", classA.type, []).type; | 14862 target.staticType = ElementFactory.classElement("B", classA.type, []).type; |
| 13326 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName); | 14863 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName); |
| 13327 ASTFactory.methodDeclaration2(null, null, null, null, ASTFactory.identifier3
("m"), ASTFactory.formalParameterList([]), ASTFactory.expressionFunctionBody(acc
ess)); | 14864 ASTFactory.methodDeclaration2(null, null, null, null, ASTFactory.identifier3
("m"), ASTFactory.formalParameterList([]), ASTFactory.expressionFunctionBody(acc
ess)); |
| 13328 resolveNode(access, []); | 14865 resolveNode(access, []); |
| 13329 JUnitTestCase.assertSame(getter, access.propertyName.staticElement); | 14866 JUnitTestCase.assertSame(getter, access.propertyName.staticElement); |
| 13330 _listener.assertNoErrors(); | 14867 _listener.assertNoErrors(); |
| 13331 } | 14868 } |
| 14869 |
| 13332 void test_visitPropertyAccess_setter_this() { | 14870 void test_visitPropertyAccess_setter_this() { |
| 13333 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14871 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13334 String setterName = "b"; | 14872 String setterName = "b"; |
| 13335 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa
lse, _typeProvider.intType); | 14873 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa
lse, _typeProvider.intType); |
| 13336 classA.accessors = <PropertyAccessorElement> [setter]; | 14874 classA.accessors = <PropertyAccessorElement> [setter]; |
| 13337 ThisExpression target = ASTFactory.thisExpression(); | 14875 ThisExpression target = ASTFactory.thisExpression(); |
| 13338 target.staticType = classA.type; | 14876 target.staticType = classA.type; |
| 13339 PropertyAccess access = ASTFactory.propertyAccess2(target, setterName); | 14877 PropertyAccess access = ASTFactory.propertyAccess2(target, setterName); |
| 13340 ASTFactory.assignmentExpression(access, TokenType.EQ, ASTFactory.integer(0))
; | 14878 ASTFactory.assignmentExpression(access, TokenType.EQ, ASTFactory.integer(0))
; |
| 13341 resolveNode(access, []); | 14879 resolveNode(access, []); |
| 13342 JUnitTestCase.assertSame(setter, access.propertyName.staticElement); | 14880 JUnitTestCase.assertSame(setter, access.propertyName.staticElement); |
| 13343 _listener.assertNoErrors(); | 14881 _listener.assertNoErrors(); |
| 13344 } | 14882 } |
| 14883 |
| 13345 void test_visitSimpleIdentifier_classScope() { | 14884 void test_visitSimpleIdentifier_classScope() { |
| 13346 InterfaceType doubleType = _typeProvider.doubleType; | 14885 InterfaceType doubleType = _typeProvider.doubleType; |
| 13347 String fieldName = "NAN"; | 14886 String fieldName = "NAN"; |
| 13348 SimpleIdentifier node = ASTFactory.identifier3(fieldName); | 14887 SimpleIdentifier node = ASTFactory.identifier3(fieldName); |
| 13349 resolveInClass(node, doubleType.element); | 14888 resolveInClass(node, doubleType.element); |
| 13350 JUnitTestCase.assertEquals(getGetter(doubleType, fieldName), node.staticElem
ent); | 14889 JUnitTestCase.assertEquals(getGetter(doubleType, fieldName), node.staticElem
ent); |
| 13351 _listener.assertNoErrors(); | 14890 _listener.assertNoErrors(); |
| 13352 } | 14891 } |
| 14892 |
| 13353 void test_visitSimpleIdentifier_dynamic() { | 14893 void test_visitSimpleIdentifier_dynamic() { |
| 13354 SimpleIdentifier node = ASTFactory.identifier3("dynamic"); | 14894 SimpleIdentifier node = ASTFactory.identifier3("dynamic"); |
| 13355 resolve4(node, []); | 14895 resolve4(node, []); |
| 13356 JUnitTestCase.assertSame(_typeProvider.dynamicType.element, node.staticEleme
nt); | 14896 JUnitTestCase.assertSame(_typeProvider.dynamicType.element, node.staticEleme
nt); |
| 13357 JUnitTestCase.assertSame(_typeProvider.typeType, node.staticType); | 14897 JUnitTestCase.assertSame(_typeProvider.typeType, node.staticType); |
| 13358 _listener.assertNoErrors(); | 14898 _listener.assertNoErrors(); |
| 13359 } | 14899 } |
| 14900 |
| 13360 void test_visitSimpleIdentifier_lexicalScope() { | 14901 void test_visitSimpleIdentifier_lexicalScope() { |
| 13361 SimpleIdentifier node = ASTFactory.identifier3("i"); | 14902 SimpleIdentifier node = ASTFactory.identifier3("i"); |
| 13362 VariableElementImpl element = ElementFactory.localVariableElement(node); | 14903 VariableElementImpl element = ElementFactory.localVariableElement(node); |
| 13363 JUnitTestCase.assertSame(element, resolve4(node, [element])); | 14904 JUnitTestCase.assertSame(element, resolve4(node, [element])); |
| 13364 _listener.assertNoErrors(); | 14905 _listener.assertNoErrors(); |
| 13365 } | 14906 } |
| 14907 |
| 13366 void test_visitSimpleIdentifier_lexicalScope_field_setter() { | 14908 void test_visitSimpleIdentifier_lexicalScope_field_setter() { |
| 13367 InterfaceType intType = _typeProvider.intType; | 14909 InterfaceType intType = _typeProvider.intType; |
| 13368 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 14910 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 13369 String fieldName = "a"; | 14911 String fieldName = "a"; |
| 13370 FieldElement field = ElementFactory.fieldElement(fieldName, false, false, fa
lse, intType); | 14912 FieldElement field = ElementFactory.fieldElement(fieldName, false, false, fa
lse, intType); |
| 13371 classA.fields = <FieldElement> [field]; | 14913 classA.fields = <FieldElement> [field]; |
| 13372 classA.accessors = <PropertyAccessorElement> [field.getter, field.setter]; | 14914 classA.accessors = <PropertyAccessorElement> [field.getter, field.setter]; |
| 13373 SimpleIdentifier node = ASTFactory.identifier3(fieldName); | 14915 SimpleIdentifier node = ASTFactory.identifier3(fieldName); |
| 13374 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); | 14916 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); |
| 13375 resolveInClass(node, classA); | 14917 resolveInClass(node, classA); |
| 13376 Element element = node.staticElement; | 14918 Element element = node.staticElement; |
| 13377 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element); | 14919 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element); |
| 13378 JUnitTestCase.assertTrue(((element as PropertyAccessorElement)).isSetter); | 14920 JUnitTestCase.assertTrue((element as PropertyAccessorElement).isSetter); |
| 13379 _listener.assertNoErrors(); | 14921 _listener.assertNoErrors(); |
| 13380 } | 14922 } |
| 14923 |
| 13381 void test_visitSuperConstructorInvocation() { | 14924 void test_visitSuperConstructorInvocation() { |
| 13382 ClassElementImpl superclass = ElementFactory.classElement2("A", []); | 14925 ClassElementImpl superclass = ElementFactory.classElement2("A", []); |
| 13383 ConstructorElementImpl superConstructor = ElementFactory.constructorElement(
superclass, null); | 14926 ConstructorElementImpl superConstructor = ElementFactory.constructorElement2
(superclass, null, []); |
| 13384 superclass.constructors = <ConstructorElement> [superConstructor]; | 14927 superclass.constructors = <ConstructorElement> [superConstructor]; |
| 13385 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type
, []); | 14928 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type
, []); |
| 13386 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su
bclass, null); | 14929 ConstructorElementImpl subConstructor = ElementFactory.constructorElement2(s
ubclass, null, []); |
| 13387 subclass.constructors = <ConstructorElement> [subConstructor]; | 14930 subclass.constructors = <ConstructorElement> [subConstructor]; |
| 13388 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio
n([]); | 14931 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio
n([]); |
| 13389 resolveInClass(invocation, subclass); | 14932 resolveInClass(invocation, subclass); |
| 13390 JUnitTestCase.assertEquals(superConstructor, invocation.staticElement); | 14933 JUnitTestCase.assertEquals(superConstructor, invocation.staticElement); |
| 13391 _listener.assertNoErrors(); | 14934 _listener.assertNoErrors(); |
| 13392 } | 14935 } |
| 14936 |
| 13393 void test_visitSuperConstructorInvocation_namedParameter() { | 14937 void test_visitSuperConstructorInvocation_namedParameter() { |
| 13394 ClassElementImpl superclass = ElementFactory.classElement2("A", []); | 14938 ClassElementImpl superclass = ElementFactory.classElement2("A", []); |
| 13395 ConstructorElementImpl superConstructor = ElementFactory.constructorElement(
superclass, null); | 14939 ConstructorElementImpl superConstructor = ElementFactory.constructorElement2
(superclass, null, []); |
| 13396 String parameterName = "p"; | 14940 String parameterName = "p"; |
| 13397 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 14941 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
| 13398 superConstructor.parameters = <ParameterElement> [parameter]; | 14942 superConstructor.parameters = <ParameterElement> [parameter]; |
| 13399 superclass.constructors = <ConstructorElement> [superConstructor]; | 14943 superclass.constructors = <ConstructorElement> [superConstructor]; |
| 13400 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type
, []); | 14944 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type
, []); |
| 13401 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su
bclass, null); | 14945 ConstructorElementImpl subConstructor = ElementFactory.constructorElement2(s
ubclass, null, []); |
| 13402 subclass.constructors = <ConstructorElement> [subConstructor]; | 14946 subclass.constructors = <ConstructorElement> [subConstructor]; |
| 13403 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio
n([ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); | 14947 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio
n([ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); |
| 13404 resolveInClass(invocation, subclass); | 14948 resolveInClass(invocation, subclass); |
| 13405 JUnitTestCase.assertEquals(superConstructor, invocation.staticElement); | 14949 JUnitTestCase.assertEquals(superConstructor, invocation.staticElement); |
| 13406 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a
s NamedExpression)).name.label.staticElement); | 14950 JUnitTestCase.assertSame(parameter, (invocation.argumentList.arguments[0] as
NamedExpression).name.label.staticElement); |
| 13407 _listener.assertNoErrors(); | 14951 _listener.assertNoErrors(); |
| 13408 } | 14952 } |
| 13409 | 14953 |
| 13410 /** | 14954 /** |
| 13411 * Create the resolver used by the tests. | 14955 * Create the resolver used by the tests. |
| 13412 * | 14956 * |
| 13413 * @return the resolver that was created | 14957 * @return the resolver that was created |
| 13414 */ | 14958 */ |
| 13415 ElementResolver createResolver() { | 14959 ElementResolver createResolver() { |
| 13416 AnalysisContextImpl context = new AnalysisContextImpl(); | 14960 AnalysisContextImpl context = new AnalysisContextImpl(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13558 } | 15102 } |
| 13559 _visitor.labelScope_J2DAccessor = innerScope; | 15103 _visitor.labelScope_J2DAccessor = innerScope; |
| 13560 statement.accept(_resolver); | 15104 statement.accept(_resolver); |
| 13561 } finally { | 15105 } finally { |
| 13562 _visitor.labelScope_J2DAccessor = outerScope; | 15106 _visitor.labelScope_J2DAccessor = outerScope; |
| 13563 } | 15107 } |
| 13564 } on JavaException catch (exception) { | 15108 } on JavaException catch (exception) { |
| 13565 throw new IllegalArgumentException("Could not resolve node", exception); | 15109 throw new IllegalArgumentException("Could not resolve node", exception); |
| 13566 } | 15110 } |
| 13567 } | 15111 } |
| 15112 |
| 13568 static dartSuite() { | 15113 static dartSuite() { |
| 13569 _ut.group('ElementResolverTest', () { | 15114 _ut.group('ElementResolverTest', () { |
| 13570 _ut.test('test_lookUpMethodInInterfaces', () { | 15115 _ut.test('test_lookUpMethodInInterfaces', () { |
| 13571 final __test = new ElementResolverTest(); | 15116 final __test = new ElementResolverTest(); |
| 13572 runJUnitTest(__test, __test.test_lookUpMethodInInterfaces); | 15117 runJUnitTest(__test, __test.test_lookUpMethodInInterfaces); |
| 13573 }); | 15118 }); |
| 13574 _ut.test('test_visitAssignmentExpression_compound', () { | 15119 _ut.test('test_visitAssignmentExpression_compound', () { |
| 13575 final __test = new ElementResolverTest(); | 15120 final __test = new ElementResolverTest(); |
| 13576 runJUnitTest(__test, __test.test_visitAssignmentExpression_compound); | 15121 runJUnitTest(__test, __test.test_visitAssignmentExpression_compound); |
| 13577 }); | 15122 }); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13699 final __test = new ElementResolverTest(); | 15244 final __test = new ElementResolverTest(); |
| 13700 runJUnitTest(__test, __test.test_visitSuperConstructorInvocation); | 15245 runJUnitTest(__test, __test.test_visitSuperConstructorInvocation); |
| 13701 }); | 15246 }); |
| 13702 _ut.test('test_visitSuperConstructorInvocation_namedParameter', () { | 15247 _ut.test('test_visitSuperConstructorInvocation_namedParameter', () { |
| 13703 final __test = new ElementResolverTest(); | 15248 final __test = new ElementResolverTest(); |
| 13704 runJUnitTest(__test, __test.test_visitSuperConstructorInvocation_namedPa
rameter); | 15249 runJUnitTest(__test, __test.test_visitSuperConstructorInvocation_namedPa
rameter); |
| 13705 }); | 15250 }); |
| 13706 }); | 15251 }); |
| 13707 } | 15252 } |
| 13708 } | 15253 } |
| 15254 |
| 13709 class TypeOverrideManagerTest extends EngineTestCase { | 15255 class TypeOverrideManagerTest extends EngineTestCase { |
| 13710 void test_exitScope_noScopes() { | 15256 void test_exitScope_noScopes() { |
| 13711 TypeOverrideManager manager = new TypeOverrideManager(); | 15257 TypeOverrideManager manager = new TypeOverrideManager(); |
| 13712 try { | 15258 try { |
| 13713 manager.exitScope(); | 15259 manager.exitScope(); |
| 13714 JUnitTestCase.fail("Expected IllegalStateException"); | 15260 JUnitTestCase.fail("Expected IllegalStateException"); |
| 13715 } on IllegalStateException catch (exception) { | 15261 } on IllegalStateException catch (exception) { |
| 13716 } | 15262 } |
| 13717 } | 15263 } |
| 15264 |
| 13718 void test_exitScope_oneScope() { | 15265 void test_exitScope_oneScope() { |
| 13719 TypeOverrideManager manager = new TypeOverrideManager(); | 15266 TypeOverrideManager manager = new TypeOverrideManager(); |
| 13720 manager.enterScope(); | 15267 manager.enterScope(); |
| 13721 manager.exitScope(); | 15268 manager.exitScope(); |
| 13722 try { | 15269 try { |
| 13723 manager.exitScope(); | 15270 manager.exitScope(); |
| 13724 JUnitTestCase.fail("Expected IllegalStateException"); | 15271 JUnitTestCase.fail("Expected IllegalStateException"); |
| 13725 } on IllegalStateException catch (exception) { | 15272 } on IllegalStateException catch (exception) { |
| 13726 } | 15273 } |
| 13727 } | 15274 } |
| 15275 |
| 13728 void test_exitScope_twoScopes() { | 15276 void test_exitScope_twoScopes() { |
| 13729 TypeOverrideManager manager = new TypeOverrideManager(); | 15277 TypeOverrideManager manager = new TypeOverrideManager(); |
| 13730 manager.enterScope(); | 15278 manager.enterScope(); |
| 13731 manager.exitScope(); | 15279 manager.exitScope(); |
| 13732 manager.enterScope(); | 15280 manager.enterScope(); |
| 13733 manager.exitScope(); | 15281 manager.exitScope(); |
| 13734 try { | 15282 try { |
| 13735 manager.exitScope(); | 15283 manager.exitScope(); |
| 13736 JUnitTestCase.fail("Expected IllegalStateException"); | 15284 JUnitTestCase.fail("Expected IllegalStateException"); |
| 13737 } on IllegalStateException catch (exception) { | 15285 } on IllegalStateException catch (exception) { |
| 13738 } | 15286 } |
| 13739 } | 15287 } |
| 15288 |
| 13740 void test_getType_enclosedOverride() { | 15289 void test_getType_enclosedOverride() { |
| 13741 TypeOverrideManager manager = new TypeOverrideManager(); | 15290 TypeOverrideManager manager = new TypeOverrideManager(); |
| 13742 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v")
; | 15291 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v")
; |
| 13743 InterfaceType type = ElementFactory.classElement2("C", []).type; | 15292 InterfaceType type = ElementFactory.classElement2("C", []).type; |
| 13744 manager.enterScope(); | 15293 manager.enterScope(); |
| 13745 manager.setType(element, type); | 15294 manager.setType(element, type); |
| 13746 manager.enterScope(); | 15295 manager.enterScope(); |
| 13747 JUnitTestCase.assertSame(type, manager.getType(element)); | 15296 JUnitTestCase.assertSame(type, manager.getType(element)); |
| 13748 } | 15297 } |
| 15298 |
| 13749 void test_getType_immediateOverride() { | 15299 void test_getType_immediateOverride() { |
| 13750 TypeOverrideManager manager = new TypeOverrideManager(); | 15300 TypeOverrideManager manager = new TypeOverrideManager(); |
| 13751 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v")
; | 15301 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v")
; |
| 13752 InterfaceType type = ElementFactory.classElement2("C", []).type; | 15302 InterfaceType type = ElementFactory.classElement2("C", []).type; |
| 13753 manager.enterScope(); | 15303 manager.enterScope(); |
| 13754 manager.setType(element, type); | 15304 manager.setType(element, type); |
| 13755 JUnitTestCase.assertSame(type, manager.getType(element)); | 15305 JUnitTestCase.assertSame(type, manager.getType(element)); |
| 13756 } | 15306 } |
| 15307 |
| 13757 void test_getType_noOverride() { | 15308 void test_getType_noOverride() { |
| 13758 TypeOverrideManager manager = new TypeOverrideManager(); | 15309 TypeOverrideManager manager = new TypeOverrideManager(); |
| 13759 manager.enterScope(); | 15310 manager.enterScope(); |
| 13760 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement
2("v"))); | 15311 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement
2("v"))); |
| 13761 } | 15312 } |
| 15313 |
| 13762 void test_getType_noScope() { | 15314 void test_getType_noScope() { |
| 13763 TypeOverrideManager manager = new TypeOverrideManager(); | 15315 TypeOverrideManager manager = new TypeOverrideManager(); |
| 13764 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement
2("v"))); | 15316 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement
2("v"))); |
| 13765 } | 15317 } |
| 15318 |
| 13766 static dartSuite() { | 15319 static dartSuite() { |
| 13767 _ut.group('TypeOverrideManagerTest', () { | 15320 _ut.group('TypeOverrideManagerTest', () { |
| 13768 _ut.test('test_exitScope_noScopes', () { | 15321 _ut.test('test_exitScope_noScopes', () { |
| 13769 final __test = new TypeOverrideManagerTest(); | 15322 final __test = new TypeOverrideManagerTest(); |
| 13770 runJUnitTest(__test, __test.test_exitScope_noScopes); | 15323 runJUnitTest(__test, __test.test_exitScope_noScopes); |
| 13771 }); | 15324 }); |
| 13772 _ut.test('test_exitScope_oneScope', () { | 15325 _ut.test('test_exitScope_oneScope', () { |
| 13773 final __test = new TypeOverrideManagerTest(); | 15326 final __test = new TypeOverrideManagerTest(); |
| 13774 runJUnitTest(__test, __test.test_exitScope_oneScope); | 15327 runJUnitTest(__test, __test.test_exitScope_oneScope); |
| 13775 }); | 15328 }); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 13789 final __test = new TypeOverrideManagerTest(); | 15342 final __test = new TypeOverrideManagerTest(); |
| 13790 runJUnitTest(__test, __test.test_getType_noOverride); | 15343 runJUnitTest(__test, __test.test_getType_noOverride); |
| 13791 }); | 15344 }); |
| 13792 _ut.test('test_getType_noScope', () { | 15345 _ut.test('test_getType_noScope', () { |
| 13793 final __test = new TypeOverrideManagerTest(); | 15346 final __test = new TypeOverrideManagerTest(); |
| 13794 runJUnitTest(__test, __test.test_getType_noScope); | 15347 runJUnitTest(__test, __test.test_getType_noScope); |
| 13795 }); | 15348 }); |
| 13796 }); | 15349 }); |
| 13797 } | 15350 } |
| 13798 } | 15351 } |
| 15352 |
| 13799 class PubSuggestionCodeTest extends ResolverTestCase { | 15353 class PubSuggestionCodeTest extends ResolverTestCase { |
| 13800 void test_import_package() { | 15354 void test_import_package() { |
| 13801 Source source = addSource(EngineTestCase.createSource(["import 'package:some
package/other.dart';"])); | 15355 Source source = addSource(EngineTestCase.createSource(["import 'package:some
package/other.dart';"])); |
| 13802 resolve(source); | 15356 resolve(source); |
| 13803 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 15357 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 13804 } | 15358 } |
| 15359 |
| 13805 void test_import_packageWithDotDot() { | 15360 void test_import_packageWithDotDot() { |
| 13806 Source source = addSource(EngineTestCase.createSource(["import 'package:some
package/../other.dart';"])); | 15361 Source source = addSource(EngineTestCase.createSource(["import 'package:some
package/../other.dart';"])); |
| 13807 resolve(source); | 15362 resolve(source); |
| 13808 assertErrors(source, [ | 15363 assertErrors(source, [ |
| 13809 CompileTimeErrorCode.URI_DOES_NOT_EXIST, | 15364 CompileTimeErrorCode.URI_DOES_NOT_EXIST, |
| 13810 PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]); | 15365 PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]); |
| 13811 } | 15366 } |
| 15367 |
| 13812 void test_import_packageWithLeadingDotDot() { | 15368 void test_import_packageWithLeadingDotDot() { |
| 13813 Source source = addSource(EngineTestCase.createSource(["import 'package:../o
ther.dart';"])); | 15369 Source source = addSource(EngineTestCase.createSource(["import 'package:../o
ther.dart';"])); |
| 13814 resolve(source); | 15370 resolve(source); |
| 13815 assertErrors(source, [ | 15371 assertErrors(source, [ |
| 13816 CompileTimeErrorCode.URI_DOES_NOT_EXIST, | 15372 CompileTimeErrorCode.URI_DOES_NOT_EXIST, |
| 13817 PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]); | 15373 PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]); |
| 13818 } | 15374 } |
| 15375 |
| 13819 void test_import_referenceIntoLibDirectory() { | 15376 void test_import_referenceIntoLibDirectory() { |
| 13820 cacheSource("/myproj/pubspec.yaml", ""); | 15377 cacheSource("/myproj/pubspec.yaml", ""); |
| 13821 cacheSource("/myproj/lib/other.dart", ""); | 15378 cacheSource("/myproj/lib/other.dart", ""); |
| 13822 Source source = addSource2("/myproj/web/test.dart", EngineTestCase.createSou
rce(["import '../lib/other.dart';"])); | 15379 Source source = addSource2("/myproj/web/test.dart", EngineTestCase.createSou
rce(["import '../lib/other.dart';"])); |
| 13823 resolve(source); | 15380 resolve(source); |
| 13824 assertErrors(source, [PubSuggestionCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_F
ILE_INSIDE]); | 15381 assertErrors(source, [PubSuggestionCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_F
ILE_INSIDE]); |
| 13825 } | 15382 } |
| 15383 |
| 13826 void test_import_referenceIntoLibDirectory_no_pubspec() { | 15384 void test_import_referenceIntoLibDirectory_no_pubspec() { |
| 13827 cacheSource("/myproj/lib/other.dart", ""); | 15385 cacheSource("/myproj/lib/other.dart", ""); |
| 13828 Source source = addSource2("/myproj/web/test.dart", EngineTestCase.createSou
rce(["import '../lib/other.dart';"])); | 15386 Source source = addSource2("/myproj/web/test.dart", EngineTestCase.createSou
rce(["import '../lib/other.dart';"])); |
| 13829 resolve(source); | 15387 resolve(source); |
| 13830 assertNoErrors(source); | 15388 assertNoErrors(source); |
| 13831 } | 15389 } |
| 15390 |
| 13832 void test_import_referenceOutOfLibDirectory() { | 15391 void test_import_referenceOutOfLibDirectory() { |
| 13833 cacheSource("/myproj/pubspec.yaml", ""); | 15392 cacheSource("/myproj/pubspec.yaml", ""); |
| 13834 cacheSource("/myproj/web/other.dart", ""); | 15393 cacheSource("/myproj/web/other.dart", ""); |
| 13835 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import '../web/other.dart';"])); | 15394 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import '../web/other.dart';"])); |
| 13836 resolve(source); | 15395 resolve(source); |
| 13837 assertErrors(source, [PubSuggestionCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FI
LE_OUTSIDE]); | 15396 assertErrors(source, [PubSuggestionCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FI
LE_OUTSIDE]); |
| 13838 } | 15397 } |
| 15398 |
| 13839 void test_import_referenceOutOfLibDirectory_no_pubspec() { | 15399 void test_import_referenceOutOfLibDirectory_no_pubspec() { |
| 13840 cacheSource("/myproj/web/other.dart", ""); | 15400 cacheSource("/myproj/web/other.dart", ""); |
| 13841 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import '../web/other.dart';"])); | 15401 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import '../web/other.dart';"])); |
| 13842 resolve(source); | 15402 resolve(source); |
| 13843 assertNoErrors(source); | 15403 assertNoErrors(source); |
| 13844 } | 15404 } |
| 15405 |
| 13845 void test_import_valid_inside_lib1() { | 15406 void test_import_valid_inside_lib1() { |
| 13846 cacheSource("/myproj/pubspec.yaml", ""); | 15407 cacheSource("/myproj/pubspec.yaml", ""); |
| 13847 cacheSource("/myproj/lib/other.dart", ""); | 15408 cacheSource("/myproj/lib/other.dart", ""); |
| 13848 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import 'other.dart';"])); | 15409 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import 'other.dart';"])); |
| 13849 resolve(source); | 15410 resolve(source); |
| 13850 assertNoErrors(source); | 15411 assertNoErrors(source); |
| 13851 } | 15412 } |
| 15413 |
| 13852 void test_import_valid_inside_lib2() { | 15414 void test_import_valid_inside_lib2() { |
| 13853 cacheSource("/myproj/pubspec.yaml", ""); | 15415 cacheSource("/myproj/pubspec.yaml", ""); |
| 13854 cacheSource("/myproj/lib/bar/other.dart", ""); | 15416 cacheSource("/myproj/lib/bar/other.dart", ""); |
| 13855 Source source = addSource2("/myproj/lib/foo/test.dart", EngineTestCase.creat
eSource(["import '../bar/other.dart';"])); | 15417 Source source = addSource2("/myproj/lib/foo/test.dart", EngineTestCase.creat
eSource(["import '../bar/other.dart';"])); |
| 13856 resolve(source); | 15418 resolve(source); |
| 13857 assertNoErrors(source); | 15419 assertNoErrors(source); |
| 13858 } | 15420 } |
| 15421 |
| 13859 void test_import_valid_outside_lib() { | 15422 void test_import_valid_outside_lib() { |
| 13860 cacheSource("/myproj/pubspec.yaml", ""); | 15423 cacheSource("/myproj/pubspec.yaml", ""); |
| 13861 cacheSource("/myproj/web/other.dart", ""); | 15424 cacheSource("/myproj/web/other.dart", ""); |
| 13862 Source source = addSource2("/myproj/lib2/test.dart", EngineTestCase.createSo
urce(["import '../web/other.dart';"])); | 15425 Source source = addSource2("/myproj/lib2/test.dart", EngineTestCase.createSo
urce(["import '../web/other.dart';"])); |
| 13863 resolve(source); | 15426 resolve(source); |
| 13864 assertNoErrors(source); | 15427 assertNoErrors(source); |
| 13865 } | 15428 } |
| 15429 |
| 13866 static dartSuite() { | 15430 static dartSuite() { |
| 13867 _ut.group('PubSuggestionCodeTest', () { | 15431 _ut.group('PubSuggestionCodeTest', () { |
| 13868 _ut.test('test_import_package', () { | 15432 _ut.test('test_import_package', () { |
| 13869 final __test = new PubSuggestionCodeTest(); | 15433 final __test = new PubSuggestionCodeTest(); |
| 13870 runJUnitTest(__test, __test.test_import_package); | 15434 runJUnitTest(__test, __test.test_import_package); |
| 13871 }); | 15435 }); |
| 13872 _ut.test('test_import_packageWithDotDot', () { | 15436 _ut.test('test_import_packageWithDotDot', () { |
| 13873 final __test = new PubSuggestionCodeTest(); | 15437 final __test = new PubSuggestionCodeTest(); |
| 13874 runJUnitTest(__test, __test.test_import_packageWithDotDot); | 15438 runJUnitTest(__test, __test.test_import_packageWithDotDot); |
| 13875 }); | 15439 }); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 13901 final __test = new PubSuggestionCodeTest(); | 15465 final __test = new PubSuggestionCodeTest(); |
| 13902 runJUnitTest(__test, __test.test_import_valid_inside_lib2); | 15466 runJUnitTest(__test, __test.test_import_valid_inside_lib2); |
| 13903 }); | 15467 }); |
| 13904 _ut.test('test_import_valid_outside_lib', () { | 15468 _ut.test('test_import_valid_outside_lib', () { |
| 13905 final __test = new PubSuggestionCodeTest(); | 15469 final __test = new PubSuggestionCodeTest(); |
| 13906 runJUnitTest(__test, __test.test_import_valid_outside_lib); | 15470 runJUnitTest(__test, __test.test_import_valid_outside_lib); |
| 13907 }); | 15471 }); |
| 13908 }); | 15472 }); |
| 13909 } | 15473 } |
| 13910 } | 15474 } |
| 15475 |
| 13911 class StaticWarningCodeTest extends ResolverTestCase { | 15476 class StaticWarningCodeTest extends ResolverTestCase { |
| 13912 void fail_undefinedGetter() { | 15477 void fail_undefinedGetter() { |
| 13913 Source source = addSource(EngineTestCase.createSource([])); | 15478 Source source = addSource(EngineTestCase.createSource([])); |
| 13914 resolve(source); | 15479 resolve(source); |
| 13915 assertErrors(source, [StaticWarningCode.UNDEFINED_GETTER]); | 15480 assertErrors(source, [StaticWarningCode.UNDEFINED_GETTER]); |
| 13916 verify([source]); | 15481 verify([source]); |
| 13917 } | 15482 } |
| 15483 |
| 13918 void fail_undefinedIdentifier_commentReference() { | 15484 void fail_undefinedIdentifier_commentReference() { |
| 13919 Source source = addSource(EngineTestCase.createSource(["/** [m] xxx [new B.c
] */", "class A {", "}"])); | 15485 Source source = addSource(EngineTestCase.createSource(["/** [m] xxx [new B.c
] */", "class A {", "}"])); |
| 13920 resolve(source); | 15486 resolve(source); |
| 13921 assertErrors(source, [ | 15487 assertErrors(source, [ |
| 13922 StaticWarningCode.UNDEFINED_IDENTIFIER, | 15488 StaticWarningCode.UNDEFINED_IDENTIFIER, |
| 13923 StaticWarningCode.UNDEFINED_IDENTIFIER]); | 15489 StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 13924 } | 15490 } |
| 15491 |
| 13925 void fail_undefinedSetter() { | 15492 void fail_undefinedSetter() { |
| 13926 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " C.m = 0;", "}"])); | 15493 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " C.m = 0;", "}"])); |
| 13927 resolve(source); | 15494 resolve(source); |
| 13928 assertErrors(source, [StaticWarningCode.UNDEFINED_SETTER]); | 15495 assertErrors(source, [StaticWarningCode.UNDEFINED_SETTER]); |
| 13929 verify([source]); | 15496 verify([source]); |
| 13930 } | 15497 } |
| 13931 void fail_undefinedStaticMethodOrGetter_getter() { | 15498 |
| 13932 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " f(C.m);", "}"])); | |
| 13933 resolve(source); | |
| 13934 assertErrors(source, [StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]); | |
| 13935 verify([source]); | |
| 13936 } | |
| 13937 void fail_undefinedStaticMethodOrGetter_method() { | |
| 13938 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " f(C.m());", "}"])); | |
| 13939 resolve(source); | |
| 13940 assertErrors(source, [StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]); | |
| 13941 verify([source]); | |
| 13942 } | |
| 13943 void test_ambiguousImport_as() { | 15499 void test_ambiguousImport_as() { |
| 13944 Source source = addSource(EngineTestCase.createSource([ | 15500 Source source = addSource(EngineTestCase.createSource([ |
| 13945 "import 'lib1.dart';", | 15501 "import 'lib1.dart';", |
| 13946 "import 'lib2.dart';", | 15502 "import 'lib2.dart';", |
| 13947 "f(p) {p as N;}"])); | 15503 "f(p) {p as N;}"])); |
| 13948 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 15504 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 13949 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 15505 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 13950 resolve(source); | 15506 resolve(source); |
| 13951 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 15507 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 13952 } | 15508 } |
| 15509 |
| 13953 void test_ambiguousImport_extends() { | 15510 void test_ambiguousImport_extends() { |
| 13954 Source source = addSource(EngineTestCase.createSource([ | 15511 Source source = addSource(EngineTestCase.createSource([ |
| 13955 "import 'lib1.dart';", | 15512 "import 'lib1.dart';", |
| 13956 "import 'lib2.dart';", | 15513 "import 'lib2.dart';", |
| 13957 "class A extends N {}"])); | 15514 "class A extends N {}"])); |
| 13958 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 15515 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 13959 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 15516 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 13960 resolve(source); | 15517 resolve(source); |
| 13961 assertErrors(source, [ | 15518 assertErrors(source, [ |
| 13962 StaticWarningCode.AMBIGUOUS_IMPORT, | 15519 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 13963 CompileTimeErrorCode.EXTENDS_NON_CLASS]); | 15520 CompileTimeErrorCode.EXTENDS_NON_CLASS]); |
| 13964 } | 15521 } |
| 15522 |
| 13965 void test_ambiguousImport_implements() { | 15523 void test_ambiguousImport_implements() { |
| 13966 Source source = addSource(EngineTestCase.createSource([ | 15524 Source source = addSource(EngineTestCase.createSource([ |
| 13967 "import 'lib1.dart';", | 15525 "import 'lib1.dart';", |
| 13968 "import 'lib2.dart';", | 15526 "import 'lib2.dart';", |
| 13969 "class A implements N {}"])); | 15527 "class A implements N {}"])); |
| 13970 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 15528 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 13971 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 15529 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 13972 resolve(source); | 15530 resolve(source); |
| 13973 assertErrors(source, [ | 15531 assertErrors(source, [ |
| 13974 StaticWarningCode.AMBIGUOUS_IMPORT, | 15532 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 13975 CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); | 15533 CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); |
| 13976 } | 15534 } |
| 15535 |
| 13977 void test_ambiguousImport_inPart() { | 15536 void test_ambiguousImport_inPart() { |
| 13978 Source source = addSource(EngineTestCase.createSource([ | 15537 Source source = addSource(EngineTestCase.createSource([ |
| 13979 "library lib;", | 15538 "library lib;", |
| 13980 "import 'lib1.dart';", | 15539 "import 'lib1.dart';", |
| 13981 "import 'lib2.dart';", | 15540 "import 'lib2.dart';", |
| 13982 "part 'part.dart';"])); | 15541 "part 'part.dart';"])); |
| 13983 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 15542 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 13984 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 15543 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 13985 Source partSource = addSource2("/part.dart", EngineTestCase.createSource(["p
art of lib;", "class A extends N {}"])); | 15544 Source partSource = addSource2("/part.dart", EngineTestCase.createSource(["p
art of lib;", "class A extends N {}"])); |
| 13986 resolve(source); | 15545 resolve(source); |
| 13987 assertErrors(partSource, [ | 15546 assertErrors(partSource, [ |
| 13988 StaticWarningCode.AMBIGUOUS_IMPORT, | 15547 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 13989 CompileTimeErrorCode.EXTENDS_NON_CLASS]); | 15548 CompileTimeErrorCode.EXTENDS_NON_CLASS]); |
| 13990 } | 15549 } |
| 15550 |
| 13991 void test_ambiguousImport_instanceCreation() { | 15551 void test_ambiguousImport_instanceCreation() { |
| 13992 Source source = addSource(EngineTestCase.createSource([ | 15552 Source source = addSource(EngineTestCase.createSource([ |
| 13993 "library L;", | 15553 "library L;", |
| 13994 "import 'lib1.dart';", | 15554 "import 'lib1.dart';", |
| 13995 "import 'lib2.dart';", | 15555 "import 'lib2.dart';", |
| 13996 "f() {new N();}"])); | 15556 "f() {new N();}"])); |
| 13997 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 15557 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 13998 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 15558 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 13999 resolve(source); | 15559 resolve(source); |
| 14000 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 15560 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 14001 } | 15561 } |
| 15562 |
| 14002 void test_ambiguousImport_is() { | 15563 void test_ambiguousImport_is() { |
| 14003 Source source = addSource(EngineTestCase.createSource([ | 15564 Source source = addSource(EngineTestCase.createSource([ |
| 14004 "import 'lib1.dart';", | 15565 "import 'lib1.dart';", |
| 14005 "import 'lib2.dart';", | 15566 "import 'lib2.dart';", |
| 14006 "f(p) {p is N;}"])); | 15567 "f(p) {p is N;}"])); |
| 14007 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 15568 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 14008 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 15569 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 14009 resolve(source); | 15570 resolve(source); |
| 14010 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 15571 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 14011 } | 15572 } |
| 15573 |
| 14012 void test_ambiguousImport_qualifier() { | 15574 void test_ambiguousImport_qualifier() { |
| 14013 Source source = addSource(EngineTestCase.createSource([ | 15575 Source source = addSource(EngineTestCase.createSource([ |
| 14014 "import 'lib1.dart';", | 15576 "import 'lib1.dart';", |
| 14015 "import 'lib2.dart';", | 15577 "import 'lib2.dart';", |
| 14016 "g() { N.FOO; }"])); | 15578 "g() { N.FOO; }"])); |
| 14017 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 15579 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 14018 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 15580 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 14019 resolve(source); | 15581 resolve(source); |
| 14020 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 15582 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 14021 } | 15583 } |
| 15584 |
| 14022 void test_ambiguousImport_typeAnnotation() { | 15585 void test_ambiguousImport_typeAnnotation() { |
| 14023 Source source = addSource(EngineTestCase.createSource([ | 15586 Source source = addSource(EngineTestCase.createSource([ |
| 14024 "import 'lib1.dart';", | 15587 "import 'lib1.dart';", |
| 14025 "import 'lib2.dart';", | 15588 "import 'lib2.dart';", |
| 14026 "typedef N FT(N p);", | 15589 "typedef N FT(N p);", |
| 14027 "N f(N p) {", | 15590 "N f(N p) {", |
| 14028 " N v;", | 15591 " N v;", |
| 14029 "}", | 15592 "}", |
| 14030 "class A {", | 15593 "class A {", |
| 14031 " N m() {}", | 15594 " N m() {}", |
| 14032 "}", | 15595 "}", |
| 14033 "class B<T extends N> {}"])); | 15596 "class B<T extends N> {}"])); |
| 14034 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 15597 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 14035 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 15598 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 14036 resolve(source); | 15599 resolve(source); |
| 14037 assertErrors(source, [ | 15600 assertErrors(source, [ |
| 14038 StaticWarningCode.AMBIGUOUS_IMPORT, | 15601 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 14039 StaticWarningCode.AMBIGUOUS_IMPORT, | 15602 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 14040 StaticWarningCode.AMBIGUOUS_IMPORT, | 15603 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 14041 StaticWarningCode.AMBIGUOUS_IMPORT, | 15604 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 14042 StaticWarningCode.AMBIGUOUS_IMPORT, | 15605 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 14043 StaticWarningCode.AMBIGUOUS_IMPORT, | 15606 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 14044 StaticWarningCode.AMBIGUOUS_IMPORT]); | 15607 StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 14045 } | 15608 } |
| 15609 |
| 14046 void test_ambiguousImport_typeArgument_annotation() { | 15610 void test_ambiguousImport_typeArgument_annotation() { |
| 14047 Source source = addSource(EngineTestCase.createSource([ | 15611 Source source = addSource(EngineTestCase.createSource([ |
| 14048 "import 'lib1.dart';", | 15612 "import 'lib1.dart';", |
| 14049 "import 'lib2.dart';", | 15613 "import 'lib2.dart';", |
| 14050 "class A<T> {}", | 15614 "class A<T> {}", |
| 14051 "A<N> f() {}"])); | 15615 "A<N> f() {}"])); |
| 14052 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 15616 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 14053 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 15617 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 14054 resolve(source); | 15618 resolve(source); |
| 14055 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 15619 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 14056 } | 15620 } |
| 15621 |
| 14057 void test_ambiguousImport_typeArgument_instanceCreation() { | 15622 void test_ambiguousImport_typeArgument_instanceCreation() { |
| 14058 Source source = addSource(EngineTestCase.createSource([ | 15623 Source source = addSource(EngineTestCase.createSource([ |
| 14059 "import 'lib1.dart';", | 15624 "import 'lib1.dart';", |
| 14060 "import 'lib2.dart';", | 15625 "import 'lib2.dart';", |
| 14061 "class A<T> {}", | 15626 "class A<T> {}", |
| 14062 "f() {new A<N>();}"])); | 15627 "f() {new A<N>();}"])); |
| 14063 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 15628 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 14064 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 15629 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 14065 resolve(source); | 15630 resolve(source); |
| 14066 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 15631 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 14067 } | 15632 } |
| 15633 |
| 14068 void test_ambiguousImport_varRead() { | 15634 void test_ambiguousImport_varRead() { |
| 14069 Source source = addSource(EngineTestCase.createSource([ | 15635 Source source = addSource(EngineTestCase.createSource([ |
| 14070 "import 'lib1.dart';", | 15636 "import 'lib1.dart';", |
| 14071 "import 'lib2.dart';", | 15637 "import 'lib2.dart';", |
| 14072 "f() { g(v); }", | 15638 "f() { g(v); }", |
| 14073 "g(p) {}"])); | 15639 "g(p) {}"])); |
| 14074 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var
v;"])); | 15640 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var
v;"])); |
| 14075 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var
v;"])); | 15641 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var
v;"])); |
| 14076 resolve(source); | 15642 resolve(source); |
| 14077 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 15643 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 14078 } | 15644 } |
| 15645 |
| 14079 void test_ambiguousImport_varWrite() { | 15646 void test_ambiguousImport_varWrite() { |
| 14080 Source source = addSource(EngineTestCase.createSource([ | 15647 Source source = addSource(EngineTestCase.createSource([ |
| 14081 "import 'lib1.dart';", | 15648 "import 'lib1.dart';", |
| 14082 "import 'lib2.dart';", | 15649 "import 'lib2.dart';", |
| 14083 "f() { v = 0; }"])); | 15650 "f() { v = 0; }"])); |
| 14084 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var
v;"])); | 15651 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var
v;"])); |
| 14085 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var
v;"])); | 15652 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var
v;"])); |
| 14086 resolve(source); | 15653 resolve(source); |
| 14087 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); | 15654 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 14088 } | 15655 } |
| 15656 |
| 14089 void test_argumentTypeNotAssignable_annotation_namedConstructor() { | 15657 void test_argumentTypeNotAssignable_annotation_namedConstructor() { |
| 14090 Source source = addSource(EngineTestCase.createSource([ | 15658 Source source = addSource(EngineTestCase.createSource([ |
| 14091 "class A {", | 15659 "class A {", |
| 14092 " const A.fromInt(int p);", | 15660 " const A.fromInt(int p);", |
| 14093 "}", | 15661 "}", |
| 14094 "@A.fromInt('0')", | 15662 "@A.fromInt('0')", |
| 14095 "main() {", | 15663 "main() {", |
| 14096 "}"])); | 15664 "}"])); |
| 14097 resolve(source); | 15665 resolve(source); |
| 14098 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15666 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14099 verify([source]); | 15667 verify([source]); |
| 14100 } | 15668 } |
| 15669 |
| 14101 void test_argumentTypeNotAssignable_annotation_unnamedConstructor() { | 15670 void test_argumentTypeNotAssignable_annotation_unnamedConstructor() { |
| 14102 Source source = addSource(EngineTestCase.createSource([ | 15671 Source source = addSource(EngineTestCase.createSource([ |
| 14103 "class A {", | 15672 "class A {", |
| 14104 " const A(int p);", | 15673 " const A(int p);", |
| 14105 "}", | 15674 "}", |
| 14106 "@A('0')", | 15675 "@A('0')", |
| 14107 "main() {", | 15676 "main() {", |
| 14108 "}"])); | 15677 "}"])); |
| 14109 resolve(source); | 15678 resolve(source); |
| 14110 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15679 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14111 verify([source]); | 15680 verify([source]); |
| 14112 } | 15681 } |
| 15682 |
| 14113 void test_argumentTypeNotAssignable_binary() { | 15683 void test_argumentTypeNotAssignable_binary() { |
| 14114 Source source = addSource(EngineTestCase.createSource([ | 15684 Source source = addSource(EngineTestCase.createSource([ |
| 14115 "class A {", | 15685 "class A {", |
| 14116 " operator +(int p) {}", | 15686 " operator +(int p) {}", |
| 14117 "}", | 15687 "}", |
| 14118 "f(A a) {", | 15688 "f(A a) {", |
| 14119 " a + '0';", | 15689 " a + '0';", |
| 14120 "}"])); | 15690 "}"])); |
| 14121 resolve(source); | 15691 resolve(source); |
| 14122 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15692 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14123 verify([source]); | 15693 verify([source]); |
| 14124 } | 15694 } |
| 15695 |
| 14125 void test_argumentTypeNotAssignable_cascadeSEcond() { | 15696 void test_argumentTypeNotAssignable_cascadeSEcond() { |
| 14126 Source source = addSource(EngineTestCase.createSource([ | 15697 Source source = addSource(EngineTestCase.createSource([ |
| 14127 "// filler filler filler filler filler filler filler filler filler fille
r", | 15698 "// filler filler filler filler filler filler filler filler filler fille
r", |
| 14128 "class A {", | 15699 "class A {", |
| 14129 " B ma() {}", | 15700 " B ma() {}", |
| 14130 "}", | 15701 "}", |
| 14131 "class B {", | 15702 "class B {", |
| 14132 " mb(String p) {}", | 15703 " mb(String p) {}", |
| 14133 "}", | 15704 "}", |
| 14134 "", | 15705 "", |
| 14135 "main() {", | 15706 "main() {", |
| 14136 " A a = new A();", | 15707 " A a = new A();", |
| 14137 " a.. ma().mb(0);", | 15708 " a.. ma().mb(0);", |
| 14138 "}"])); | 15709 "}"])); |
| 14139 resolve(source); | 15710 resolve(source); |
| 14140 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15711 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14141 verify([source]); | 15712 verify([source]); |
| 14142 } | 15713 } |
| 15714 |
| 14143 void test_argumentTypeNotAssignable_const() { | 15715 void test_argumentTypeNotAssignable_const() { |
| 14144 Source source = addSource(EngineTestCase.createSource([ | 15716 Source source = addSource(EngineTestCase.createSource([ |
| 14145 "class A {", | 15717 "class A {", |
| 14146 " const A(String p);", | 15718 " const A(String p);", |
| 14147 "}", | 15719 "}", |
| 14148 "main() {", | 15720 "main() {", |
| 14149 " const A(42);", | 15721 " const A(42);", |
| 14150 "}"])); | 15722 "}"])); |
| 14151 resolve(source); | 15723 resolve(source); |
| 14152 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15724 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14153 verify([source]); | 15725 verify([source]); |
| 14154 } | 15726 } |
| 15727 |
| 14155 void test_argumentTypeNotAssignable_const_super() { | 15728 void test_argumentTypeNotAssignable_const_super() { |
| 14156 Source source = addSource(EngineTestCase.createSource([ | 15729 Source source = addSource(EngineTestCase.createSource([ |
| 14157 "class A {", | 15730 "class A {", |
| 14158 " const A(String p);", | 15731 " const A(String p);", |
| 14159 "}", | 15732 "}", |
| 14160 "class B extends A {", | 15733 "class B extends A {", |
| 14161 " const B() : super(42);", | 15734 " const B() : super(42);", |
| 14162 "}"])); | 15735 "}"])); |
| 14163 resolve(source); | 15736 resolve(source); |
| 14164 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15737 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14165 verify([source]); | 15738 verify([source]); |
| 14166 } | 15739 } |
| 15740 |
| 14167 void test_argumentTypeNotAssignable_functionExpressionInvocation_required() { | 15741 void test_argumentTypeNotAssignable_functionExpressionInvocation_required() { |
| 14168 Source source = addSource(EngineTestCase.createSource(["main() {", " (int x
) {} ('');", "}"])); | 15742 Source source = addSource(EngineTestCase.createSource(["main() {", " (int x
) {} ('');", "}"])); |
| 14169 resolve(source); | 15743 resolve(source); |
| 14170 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15744 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14171 verify([source]); | 15745 verify([source]); |
| 14172 } | 15746 } |
| 15747 |
| 14173 void test_argumentTypeNotAssignable_index() { | 15748 void test_argumentTypeNotAssignable_index() { |
| 14174 Source source = addSource(EngineTestCase.createSource([ | 15749 Source source = addSource(EngineTestCase.createSource([ |
| 14175 "class A {", | 15750 "class A {", |
| 14176 " operator [](int index) {}", | 15751 " operator [](int index) {}", |
| 14177 "}", | 15752 "}", |
| 14178 "f(A a) {", | 15753 "f(A a) {", |
| 14179 " a['0'];", | 15754 " a['0'];", |
| 14180 "}"])); | 15755 "}"])); |
| 14181 resolve(source); | 15756 resolve(source); |
| 14182 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15757 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14183 verify([source]); | 15758 verify([source]); |
| 14184 } | 15759 } |
| 15760 |
| 14185 void test_argumentTypeNotAssignable_invocation_callParameter() { | 15761 void test_argumentTypeNotAssignable_invocation_callParameter() { |
| 14186 Source source = addSource(EngineTestCase.createSource([ | 15762 Source source = addSource(EngineTestCase.createSource([ |
| 14187 "class A {", | 15763 "class A {", |
| 14188 " call(int p) {}", | 15764 " call(int p) {}", |
| 14189 "}", | 15765 "}", |
| 14190 "f(A a) {", | 15766 "f(A a) {", |
| 14191 " a('0');", | 15767 " a('0');", |
| 14192 "}"])); | 15768 "}"])); |
| 14193 resolve(source); | 15769 resolve(source); |
| 14194 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15770 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14195 verify([source]); | 15771 verify([source]); |
| 14196 } | 15772 } |
| 15773 |
| 14197 void test_argumentTypeNotAssignable_invocation_callVariable() { | 15774 void test_argumentTypeNotAssignable_invocation_callVariable() { |
| 14198 Source source = addSource(EngineTestCase.createSource([ | 15775 Source source = addSource(EngineTestCase.createSource([ |
| 14199 "class A {", | 15776 "class A {", |
| 14200 " call(int p) {}", | 15777 " call(int p) {}", |
| 14201 "}", | 15778 "}", |
| 14202 "main() {", | 15779 "main() {", |
| 14203 " A a = new A();", | 15780 " A a = new A();", |
| 14204 " a('0');", | 15781 " a('0');", |
| 14205 "}"])); | 15782 "}"])); |
| 14206 resolve(source); | 15783 resolve(source); |
| 14207 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15784 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14208 verify([source]); | 15785 verify([source]); |
| 14209 } | 15786 } |
| 15787 |
| 14210 void test_argumentTypeNotAssignable_invocation_functionParameter() { | 15788 void test_argumentTypeNotAssignable_invocation_functionParameter() { |
| 14211 Source source = addSource(EngineTestCase.createSource(["a(b(int p)) {", " b
('0');", "}"])); | 15789 Source source = addSource(EngineTestCase.createSource(["a(b(int p)) {", " b
('0');", "}"])); |
| 14212 resolve(source); | 15790 resolve(source); |
| 14213 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15791 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14214 verify([source]); | 15792 verify([source]); |
| 14215 } | 15793 } |
| 15794 |
| 14216 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() { | 15795 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() { |
| 14217 Source source = addSource(EngineTestCase.createSource([ | 15796 Source source = addSource(EngineTestCase.createSource([ |
| 14218 "class A<K, V> {", | 15797 "class A<K, V> {", |
| 14219 " m(f(K k), V v) {", | 15798 " m(f(K k), V v) {", |
| 14220 " f(v);", | 15799 " f(v);", |
| 14221 " }", | 15800 " }", |
| 14222 "}"])); | 15801 "}"])); |
| 14223 resolve(source); | 15802 resolve(source); |
| 14224 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15803 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14225 verify([source]); | 15804 verify([source]); |
| 14226 } | 15805 } |
| 15806 |
| 14227 void test_argumentTypeNotAssignable_invocation_functionTypes_optional() { | 15807 void test_argumentTypeNotAssignable_invocation_functionTypes_optional() { |
| 14228 Source source = addSource(EngineTestCase.createSource([ | 15808 Source source = addSource(EngineTestCase.createSource([ |
| 14229 "void acceptFunNumOptBool(void funNumOptBool([bool b])) {}", | 15809 "void acceptFunNumOptBool(void funNumOptBool([bool b])) {}", |
| 14230 "void funNumBool(bool b) {}", | 15810 "void funNumBool(bool b) {}", |
| 14231 "main() {", | 15811 "main() {", |
| 14232 " acceptFunNumOptBool(funNumBool);", | 15812 " acceptFunNumOptBool(funNumBool);", |
| 14233 "}"])); | 15813 "}"])); |
| 14234 resolve(source); | 15814 resolve(source); |
| 14235 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15815 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14236 verify([source]); | 15816 verify([source]); |
| 14237 } | 15817 } |
| 15818 |
| 14238 void test_argumentTypeNotAssignable_invocation_generic() { | 15819 void test_argumentTypeNotAssignable_invocation_generic() { |
| 14239 Source source = addSource(EngineTestCase.createSource([ | 15820 Source source = addSource(EngineTestCase.createSource([ |
| 14240 "class A<T> {", | 15821 "class A<T> {", |
| 14241 " m(T t) {}", | 15822 " m(T t) {}", |
| 14242 "}", | 15823 "}", |
| 14243 "f(A<String> a) {", | 15824 "f(A<String> a) {", |
| 14244 " a.m(1);", | 15825 " a.m(1);", |
| 14245 "}"])); | 15826 "}"])); |
| 14246 resolve(source); | 15827 resolve(source); |
| 14247 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15828 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14248 verify([source]); | 15829 verify([source]); |
| 14249 } | 15830 } |
| 15831 |
| 14250 void test_argumentTypeNotAssignable_invocation_named() { | 15832 void test_argumentTypeNotAssignable_invocation_named() { |
| 14251 Source source = addSource(EngineTestCase.createSource(["f({String p}) {}", "
main() {", " f(p: 42);", "}"])); | 15833 Source source = addSource(EngineTestCase.createSource(["f({String p}) {}", "
main() {", " f(p: 42);", "}"])); |
| 14252 resolve(source); | 15834 resolve(source); |
| 14253 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15835 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14254 verify([source]); | 15836 verify([source]); |
| 14255 } | 15837 } |
| 15838 |
| 14256 void test_argumentTypeNotAssignable_invocation_optional() { | 15839 void test_argumentTypeNotAssignable_invocation_optional() { |
| 14257 Source source = addSource(EngineTestCase.createSource(["f([String p]) {}", "
main() {", " f(42);", "}"])); | 15840 Source source = addSource(EngineTestCase.createSource(["f([String p]) {}", "
main() {", " f(42);", "}"])); |
| 14258 resolve(source); | 15841 resolve(source); |
| 14259 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15842 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14260 verify([source]); | 15843 verify([source]); |
| 14261 } | 15844 } |
| 15845 |
| 14262 void test_argumentTypeNotAssignable_invocation_required() { | 15846 void test_argumentTypeNotAssignable_invocation_required() { |
| 14263 Source source = addSource(EngineTestCase.createSource(["f(String p) {}", "ma
in() {", " f(42);", "}"])); | 15847 Source source = addSource(EngineTestCase.createSource(["f(String p) {}", "ma
in() {", " f(42);", "}"])); |
| 14264 resolve(source); | 15848 resolve(source); |
| 14265 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15849 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14266 verify([source]); | 15850 verify([source]); |
| 14267 } | 15851 } |
| 15852 |
| 14268 void test_argumentTypeNotAssignable_invocation_typedef_generic() { | 15853 void test_argumentTypeNotAssignable_invocation_typedef_generic() { |
| 14269 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);",
"f(A<int> a) {", " a('1');", "}"])); | 15854 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);",
"f(A<int> a) {", " a('1');", "}"])); |
| 14270 resolve(source); | 15855 resolve(source); |
| 14271 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15856 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14272 verify([source]); | 15857 verify([source]); |
| 14273 } | 15858 } |
| 15859 |
| 14274 void test_argumentTypeNotAssignable_invocation_typedef_local() { | 15860 void test_argumentTypeNotAssignable_invocation_typedef_local() { |
| 14275 Source source = addSource(EngineTestCase.createSource([ | 15861 Source source = addSource(EngineTestCase.createSource([ |
| 14276 "typedef A(int p);", | 15862 "typedef A(int p);", |
| 14277 "A getA() => null;", | 15863 "A getA() => null;", |
| 14278 "main() {", | 15864 "main() {", |
| 14279 " A a = getA();", | 15865 " A a = getA();", |
| 14280 " a('1');", | 15866 " a('1');", |
| 14281 "}"])); | 15867 "}"])); |
| 14282 resolve(source); | 15868 resolve(source); |
| 14283 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15869 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14284 verify([source]); | 15870 verify([source]); |
| 14285 } | 15871 } |
| 15872 |
| 14286 void test_argumentTypeNotAssignable_invocation_typedef_parameter() { | 15873 void test_argumentTypeNotAssignable_invocation_typedef_parameter() { |
| 14287 Source source = addSource(EngineTestCase.createSource(["typedef A(int p);",
"f(A a) {", " a('1');", "}"])); | 15874 Source source = addSource(EngineTestCase.createSource(["typedef A(int p);",
"f(A a) {", " a('1');", "}"])); |
| 14288 resolve(source); | 15875 resolve(source); |
| 14289 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15876 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14290 verify([source]); | 15877 verify([source]); |
| 14291 } | 15878 } |
| 15879 |
| 14292 void test_argumentTypeNotAssignable_new_generic() { | 15880 void test_argumentTypeNotAssignable_new_generic() { |
| 14293 Source source = addSource(EngineTestCase.createSource([ | 15881 Source source = addSource(EngineTestCase.createSource([ |
| 14294 "class A<T> {", | 15882 "class A<T> {", |
| 14295 " A(T p) {}", | 15883 " A(T p) {}", |
| 14296 "}", | 15884 "}", |
| 14297 "main() {", | 15885 "main() {", |
| 14298 " new A<String>(42);", | 15886 " new A<String>(42);", |
| 14299 "}"])); | 15887 "}"])); |
| 14300 resolve(source); | 15888 resolve(source); |
| 14301 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15889 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14302 verify([source]); | 15890 verify([source]); |
| 14303 } | 15891 } |
| 15892 |
| 14304 void test_argumentTypeNotAssignable_new_optional() { | 15893 void test_argumentTypeNotAssignable_new_optional() { |
| 14305 Source source = addSource(EngineTestCase.createSource([ | 15894 Source source = addSource(EngineTestCase.createSource([ |
| 14306 "class A {", | 15895 "class A {", |
| 14307 " A([String p]) {}", | 15896 " A([String p]) {}", |
| 14308 "}", | 15897 "}", |
| 14309 "main() {", | 15898 "main() {", |
| 14310 " new A(42);", | 15899 " new A(42);", |
| 14311 "}"])); | 15900 "}"])); |
| 14312 resolve(source); | 15901 resolve(source); |
| 14313 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15902 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14314 verify([source]); | 15903 verify([source]); |
| 14315 } | 15904 } |
| 15905 |
| 14316 void test_argumentTypeNotAssignable_new_required() { | 15906 void test_argumentTypeNotAssignable_new_required() { |
| 14317 Source source = addSource(EngineTestCase.createSource([ | 15907 Source source = addSource(EngineTestCase.createSource([ |
| 14318 "class A {", | 15908 "class A {", |
| 14319 " A(String p) {}", | 15909 " A(String p) {}", |
| 14320 "}", | 15910 "}", |
| 14321 "main() {", | 15911 "main() {", |
| 14322 " new A(42);", | 15912 " new A(42);", |
| 14323 "}"])); | 15913 "}"])); |
| 14324 resolve(source); | 15914 resolve(source); |
| 14325 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 15915 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 14326 verify([source]); | 15916 verify([source]); |
| 14327 } | 15917 } |
| 15918 |
| 14328 void test_assignmentToConst_instanceVariable() { | 15919 void test_assignmentToConst_instanceVariable() { |
| 14329 Source source = addSource(EngineTestCase.createSource([ | 15920 Source source = addSource(EngineTestCase.createSource([ |
| 14330 "class A {", | 15921 "class A {", |
| 14331 " static const v = 0;", | 15922 " static const v = 0;", |
| 14332 "}", | 15923 "}", |
| 14333 "f() {", | 15924 "f() {", |
| 14334 " A.v = 1;", | 15925 " A.v = 1;", |
| 14335 "}"])); | 15926 "}"])); |
| 14336 resolve(source); | 15927 resolve(source); |
| 14337 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]); | 15928 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]); |
| 14338 verify([source]); | 15929 verify([source]); |
| 14339 } | 15930 } |
| 15931 |
| 14340 void test_assignmentToConst_localVariable() { | 15932 void test_assignmentToConst_localVariable() { |
| 14341 Source source = addSource(EngineTestCase.createSource(["f() {", " const x =
0;", " x = 1;", "}"])); | 15933 Source source = addSource(EngineTestCase.createSource(["f() {", " const x =
0;", " x = 1;", "}"])); |
| 14342 resolve(source); | 15934 resolve(source); |
| 14343 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]); | 15935 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]); |
| 14344 verify([source]); | 15936 verify([source]); |
| 14345 } | 15937 } |
| 15938 |
| 14346 void test_assignmentToFinal_instanceVariable() { | 15939 void test_assignmentToFinal_instanceVariable() { |
| 14347 Source source = addSource(EngineTestCase.createSource([ | 15940 Source source = addSource(EngineTestCase.createSource([ |
| 14348 "class A {", | 15941 "class A {", |
| 14349 " final v = 0;", | 15942 " final v = 0;", |
| 14350 "}", | 15943 "}", |
| 14351 "f() {", | 15944 "f() {", |
| 14352 " A a = new A();", | 15945 " A a = new A();", |
| 14353 " a.v = 1;", | 15946 " a.v = 1;", |
| 14354 "}"])); | 15947 "}"])); |
| 14355 resolve(source); | 15948 resolve(source); |
| 14356 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 15949 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 14357 verify([source]); | 15950 verify([source]); |
| 14358 } | 15951 } |
| 15952 |
| 14359 void test_assignmentToFinal_localVariable() { | 15953 void test_assignmentToFinal_localVariable() { |
| 14360 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x = 1;", "}"])); | 15954 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x = 1;", "}"])); |
| 14361 resolve(source); | 15955 resolve(source); |
| 14362 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 15956 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 14363 verify([source]); | 15957 verify([source]); |
| 14364 } | 15958 } |
| 15959 |
| 14365 void test_assignmentToFinal_prefixMinusMinus() { | 15960 void test_assignmentToFinal_prefixMinusMinus() { |
| 14366 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " --x;", "}"])); | 15961 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " --x;", "}"])); |
| 14367 resolve(source); | 15962 resolve(source); |
| 14368 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 15963 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 14369 verify([source]); | 15964 verify([source]); |
| 14370 } | 15965 } |
| 15966 |
| 14371 void test_assignmentToFinal_prefixPlusPlus() { | 15967 void test_assignmentToFinal_prefixPlusPlus() { |
| 14372 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " ++x;", "}"])); | 15968 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " ++x;", "}"])); |
| 14373 resolve(source); | 15969 resolve(source); |
| 14374 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 15970 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 14375 verify([source]); | 15971 verify([source]); |
| 14376 } | 15972 } |
| 15973 |
| 14377 void test_assignmentToFinal_propertyAccess() { | 15974 void test_assignmentToFinal_propertyAccess() { |
| 14378 Source source = addSource(EngineTestCase.createSource([ | 15975 Source source = addSource(EngineTestCase.createSource([ |
| 14379 "class A {", | 15976 "class A {", |
| 14380 " int get x => 0;", | 15977 " int get x => 0;", |
| 14381 "}", | 15978 "}", |
| 14382 "class B {", | 15979 "class B {", |
| 14383 " static A a;", | 15980 " static A a;", |
| 14384 "}", | 15981 "}", |
| 14385 "main() {", | 15982 "main() {", |
| 14386 " B.a.x = 0;", | 15983 " B.a.x = 0;", |
| 14387 "}"])); | 15984 "}"])); |
| 14388 resolve(source); | 15985 resolve(source); |
| 14389 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 15986 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 14390 verify([source]); | 15987 verify([source]); |
| 14391 } | 15988 } |
| 15989 |
| 14392 void test_assignmentToFinal_suffixMinusMinus() { | 15990 void test_assignmentToFinal_suffixMinusMinus() { |
| 14393 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x--;", "}"])); | 15991 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x--;", "}"])); |
| 14394 resolve(source); | 15992 resolve(source); |
| 14395 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 15993 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 14396 verify([source]); | 15994 verify([source]); |
| 14397 } | 15995 } |
| 15996 |
| 14398 void test_assignmentToFinal_suffixPlusPlus() { | 15997 void test_assignmentToFinal_suffixPlusPlus() { |
| 14399 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x++;", "}"])); | 15998 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x++;", "}"])); |
| 14400 resolve(source); | 15999 resolve(source); |
| 14401 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 16000 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 14402 verify([source]); | 16001 verify([source]); |
| 14403 } | 16002 } |
| 16003 |
| 14404 void test_assignmentToFinal_topLevelVariable() { | 16004 void test_assignmentToFinal_topLevelVariable() { |
| 14405 Source source = addSource(EngineTestCase.createSource(["final x = 0;", "f()
{ x = 1; }"])); | 16005 Source source = addSource(EngineTestCase.createSource(["final x = 0;", "f()
{ x = 1; }"])); |
| 14406 resolve(source); | 16006 resolve(source); |
| 14407 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 16007 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 14408 verify([source]); | 16008 verify([source]); |
| 14409 } | 16009 } |
| 16010 |
| 14410 void test_assignmentToMethod() { | 16011 void test_assignmentToMethod() { |
| 14411 Source source = addSource(EngineTestCase.createSource([ | 16012 Source source = addSource(EngineTestCase.createSource([ |
| 14412 "class A {", | 16013 "class A {", |
| 14413 " m() {}", | 16014 " m() {}", |
| 14414 "}", | 16015 "}", |
| 14415 "f(A a) {", | 16016 "f(A a) {", |
| 14416 " a.m = () {};", | 16017 " a.m = () {};", |
| 14417 "}"])); | 16018 "}"])); |
| 14418 resolve(source); | 16019 resolve(source); |
| 14419 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_METHOD]); | 16020 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_METHOD]); |
| 14420 verify([source]); | 16021 verify([source]); |
| 14421 } | 16022 } |
| 16023 |
| 14422 void test_caseBlockNotTerminated() { | 16024 void test_caseBlockNotTerminated() { |
| 14423 Source source = addSource(EngineTestCase.createSource([ | 16025 Source source = addSource(EngineTestCase.createSource([ |
| 14424 "f(int p) {", | 16026 "f(int p) {", |
| 14425 " switch (p) {", | 16027 " switch (p) {", |
| 14426 " case 0:", | 16028 " case 0:", |
| 14427 " f(p);", | 16029 " f(p);", |
| 14428 " case 1:", | 16030 " case 1:", |
| 14429 " break;", | 16031 " break;", |
| 14430 " }", | 16032 " }", |
| 14431 "}"])); | 16033 "}"])); |
| 14432 resolve(source); | 16034 resolve(source); |
| 14433 assertErrors(source, [StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]); | 16035 assertErrors(source, [StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]); |
| 14434 verify([source]); | 16036 verify([source]); |
| 14435 } | 16037 } |
| 16038 |
| 14436 void test_castToNonType() { | 16039 void test_castToNonType() { |
| 14437 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(Stri
ng s) { var x = s as A; }"])); | 16040 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(Stri
ng s) { var x = s as A; }"])); |
| 14438 resolve(source); | 16041 resolve(source); |
| 14439 assertErrors(source, [StaticWarningCode.CAST_TO_NON_TYPE]); | 16042 assertErrors(source, [StaticWarningCode.CAST_TO_NON_TYPE]); |
| 14440 verify([source]); | 16043 verify([source]); |
| 14441 } | 16044 } |
| 16045 |
| 14442 void test_concreteClassWithAbstractMember() { | 16046 void test_concreteClassWithAbstractMember() { |
| 14443 Source source = addSource(EngineTestCase.createSource(["class A {", " m();"
, "}"])); | 16047 Source source = addSource(EngineTestCase.createSource(["class A {", " m();"
, "}"])); |
| 14444 resolve(source); | 16048 resolve(source); |
| 14445 assertErrors(source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]
); | 16049 assertErrors(source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]
); |
| 14446 verify([source]); | 16050 verify([source]); |
| 14447 } | 16051 } |
| 16052 |
| 14448 void test_conflictingDartImport() { | 16053 void test_conflictingDartImport() { |
| 14449 Source source = addSource(EngineTestCase.createSource([ | 16054 Source source = addSource(EngineTestCase.createSource([ |
| 14450 "import 'lib.dart';", | 16055 "import 'lib.dart';", |
| 14451 "import 'dart:async';", | 16056 "import 'dart:async';", |
| 14452 "Future f = null;", | 16057 "Future f = null;", |
| 14453 "Stream s;"])); | 16058 "Stream s;"])); |
| 14454 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
Future {}"])); | 16059 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
Future {}"])); |
| 14455 resolve(source); | 16060 resolve(source); |
| 14456 assertErrors(source, [StaticWarningCode.CONFLICTING_DART_IMPORT]); | 16061 assertErrors(source, [StaticWarningCode.CONFLICTING_DART_IMPORT]); |
| 14457 } | 16062 } |
| 14458 void test_conflictingInstanceGetterAndSuperclassMember_direct_field() { | 16063 |
| 16064 void test_conflictingInstanceGetterAndSuperclassMember_declField_direct_setter
() { |
| 14459 Source source = addSource(EngineTestCase.createSource([ | 16065 Source source = addSource(EngineTestCase.createSource([ |
| 14460 "class A {", | 16066 "class A {", |
| 14461 " static int v;", | 16067 " static set v(x) {}", |
| 14462 "}", | 16068 "}", |
| 14463 "class B extends A {", | 16069 "class B extends A {", |
| 14464 " get v => 0;", | 16070 " var v;", |
| 14465 "}"])); | 16071 "}"])); |
| 14466 resolve(source); | 16072 resolve(source); |
| 14467 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); | 16073 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 14468 verify([source]); | 16074 verify([source]); |
| 14469 } | 16075 } |
| 14470 void test_conflictingInstanceGetterAndSuperclassMember_direct_getter() { | 16076 |
| 16077 void test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_gette
r() { |
| 14471 Source source = addSource(EngineTestCase.createSource([ | 16078 Source source = addSource(EngineTestCase.createSource([ |
| 14472 "class A {", | 16079 "class A {", |
| 14473 " static get v => 0;", | 16080 " static get v => 0;", |
| 14474 "}", | 16081 "}", |
| 14475 "class B extends A {", | 16082 "class B extends A {", |
| 14476 " get v => 0;", | 16083 " get v => 0;", |
| 14477 "}"])); | 16084 "}"])); |
| 14478 resolve(source); | 16085 resolve(source); |
| 14479 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); | 16086 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 14480 verify([source]); | 16087 verify([source]); |
| 14481 } | 16088 } |
| 14482 void test_conflictingInstanceGetterAndSuperclassMember_direct_method() { | 16089 |
| 16090 void test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_metho
d() { |
| 14483 Source source = addSource(EngineTestCase.createSource([ | 16091 Source source = addSource(EngineTestCase.createSource([ |
| 14484 "class A {", | 16092 "class A {", |
| 14485 " static v() {}", | 16093 " static v() {}", |
| 14486 "}", | 16094 "}", |
| 14487 "class B extends A {", | 16095 "class B extends A {", |
| 14488 " get v => 0;", | 16096 " get v => 0;", |
| 14489 "}"])); | 16097 "}"])); |
| 14490 resolve(source); | 16098 resolve(source); |
| 14491 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); | 16099 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 14492 verify([source]); | 16100 verify([source]); |
| 14493 } | 16101 } |
| 14494 void test_conflictingInstanceGetterAndSuperclassMember_direct_setter() { | 16102 |
| 16103 void test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_sette
r() { |
| 14495 Source source = addSource(EngineTestCase.createSource([ | 16104 Source source = addSource(EngineTestCase.createSource([ |
| 14496 "class A {", | 16105 "class A {", |
| 14497 " static set v(x) {}", | 16106 " static set v(x) {}", |
| 14498 "}", | 16107 "}", |
| 14499 "class B extends A {", | 16108 "class B extends A {", |
| 14500 " get v => 0;", | 16109 " get v => 0;", |
| 14501 "}"])); | 16110 "}"])); |
| 14502 resolve(source); | 16111 resolve(source); |
| 14503 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); | 16112 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 14504 verify([source]); | 16113 verify([source]); |
| 14505 } | 16114 } |
| 14506 void test_conflictingInstanceGetterAndSuperclassMember_indirect() { | 16115 |
| 16116 void test_conflictingInstanceGetterAndSuperclassMember_declGetter_indirect() { |
| 14507 Source source = addSource(EngineTestCase.createSource([ | 16117 Source source = addSource(EngineTestCase.createSource([ |
| 14508 "class A {", | 16118 "class A {", |
| 14509 " static int v;", | 16119 " static int v;", |
| 14510 "}", | 16120 "}", |
| 14511 "class B extends A {}", | 16121 "class B extends A {}", |
| 14512 "class C extends B {", | 16122 "class C extends B {", |
| 14513 " get v => 0;", | 16123 " get v => 0;", |
| 14514 "}"])); | 16124 "}"])); |
| 14515 resolve(source); | 16125 resolve(source); |
| 14516 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); | 16126 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 14517 verify([source]); | 16127 verify([source]); |
| 14518 } | 16128 } |
| 14519 void test_conflictingInstanceGetterAndSuperclassMember_mixin() { | 16129 |
| 16130 void test_conflictingInstanceGetterAndSuperclassMember_declGetter_mixin() { |
| 14520 Source source = addSource(EngineTestCase.createSource([ | 16131 Source source = addSource(EngineTestCase.createSource([ |
| 14521 "class M {", | 16132 "class M {", |
| 14522 " static int v;", | 16133 " static int v;", |
| 14523 "}", | 16134 "}", |
| 14524 "class B extends Object with M {", | 16135 "class B extends Object with M {", |
| 14525 " get v => 0;", | 16136 " get v => 0;", |
| 14526 "}"])); | 16137 "}"])); |
| 14527 resolve(source); | 16138 resolve(source); |
| 14528 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); | 16139 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 14529 verify([source]); | 16140 verify([source]); |
| 14530 } | 16141 } |
| 16142 |
| 16143 void test_conflictingInstanceGetterAndSuperclassMember_direct_field() { |
| 16144 Source source = addSource(EngineTestCase.createSource([ |
| 16145 "class A {", |
| 16146 " static int v;", |
| 16147 "}", |
| 16148 "class B extends A {", |
| 16149 " get v => 0;", |
| 16150 "}"])); |
| 16151 resolve(source); |
| 16152 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 16153 verify([source]); |
| 16154 } |
| 16155 |
| 16156 void test_conflictingInstanceMethodSetter_sameClass() { |
| 16157 Source source = addSource(EngineTestCase.createSource(["class A {", " foo()
{}", " set foo(a) {}", "}"])); |
| 16158 resolve(source); |
| 16159 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER])
; |
| 16160 verify([source]); |
| 16161 } |
| 16162 |
| 16163 void test_conflictingInstanceMethodSetter_setterInInterface() { |
| 16164 Source source = addSource(EngineTestCase.createSource([ |
| 16165 "abstract class A {", |
| 16166 " set foo(a);", |
| 16167 "}", |
| 16168 "abstract class B implements A {", |
| 16169 " foo() {}", |
| 16170 "}"])); |
| 16171 resolve(source); |
| 16172 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER])
; |
| 16173 verify([source]); |
| 16174 } |
| 16175 |
| 16176 void test_conflictingInstanceMethodSetter_setterInSuper() { |
| 16177 Source source = addSource(EngineTestCase.createSource([ |
| 16178 "class A {", |
| 16179 " set foo(a) {}", |
| 16180 "}", |
| 16181 "class B extends A {", |
| 16182 " foo() {}", |
| 16183 "}"])); |
| 16184 resolve(source); |
| 16185 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER])
; |
| 16186 verify([source]); |
| 16187 } |
| 16188 |
| 14531 void test_conflictingInstanceSetterAndSuperclassMember() { | 16189 void test_conflictingInstanceSetterAndSuperclassMember() { |
| 14532 Source source = addSource(EngineTestCase.createSource([ | 16190 Source source = addSource(EngineTestCase.createSource([ |
| 14533 "class A {", | 16191 "class A {", |
| 14534 " static int v;", | 16192 " static int v;", |
| 14535 "}", | 16193 "}", |
| 14536 "class B extends A {", | 16194 "class B extends A {", |
| 14537 " set v(x) {}", | 16195 " set v(x) {}", |
| 14538 "}"])); | 16196 "}"])); |
| 14539 resolve(source); | 16197 resolve(source); |
| 14540 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPE
RCLASS_MEMBER]); | 16198 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPE
RCLASS_MEMBER]); |
| 14541 verify([source]); | 16199 verify([source]); |
| 14542 } | 16200 } |
| 16201 |
| 14543 void test_conflictingStaticGetterAndInstanceSetter_mixin() { | 16202 void test_conflictingStaticGetterAndInstanceSetter_mixin() { |
| 14544 Source source = addSource(EngineTestCase.createSource([ | 16203 Source source = addSource(EngineTestCase.createSource([ |
| 14545 "class A {", | 16204 "class A {", |
| 14546 " set x(int p) {}", | 16205 " set x(int p) {}", |
| 14547 "}", | 16206 "}", |
| 14548 "class B extends Object with A {", | 16207 "class B extends Object with A {", |
| 14549 " static get x => 0;", | 16208 " static get x => 0;", |
| 14550 "}"])); | 16209 "}"])); |
| 14551 resolve(source); | 16210 resolve(source); |
| 14552 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN
CE_SETTER]); | 16211 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN
CE_SETTER]); |
| 14553 verify([source]); | 16212 verify([source]); |
| 14554 } | 16213 } |
| 16214 |
| 14555 void test_conflictingStaticGetterAndInstanceSetter_superClass() { | 16215 void test_conflictingStaticGetterAndInstanceSetter_superClass() { |
| 14556 Source source = addSource(EngineTestCase.createSource([ | 16216 Source source = addSource(EngineTestCase.createSource([ |
| 14557 "class A {", | 16217 "class A {", |
| 14558 " set x(int p) {}", | 16218 " set x(int p) {}", |
| 14559 "}", | 16219 "}", |
| 14560 "class B extends A {", | 16220 "class B extends A {", |
| 14561 " static get x => 0;", | 16221 " static get x => 0;", |
| 14562 "}"])); | 16222 "}"])); |
| 14563 resolve(source); | 16223 resolve(source); |
| 14564 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN
CE_SETTER]); | 16224 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN
CE_SETTER]); |
| 14565 verify([source]); | 16225 verify([source]); |
| 14566 } | 16226 } |
| 16227 |
| 14567 void test_conflictingStaticGetterAndInstanceSetter_thisClass() { | 16228 void test_conflictingStaticGetterAndInstanceSetter_thisClass() { |
| 14568 Source source = addSource(EngineTestCase.createSource([ | 16229 Source source = addSource(EngineTestCase.createSource([ |
| 14569 "class A {", | 16230 "class A {", |
| 14570 " static get x => 0;", | 16231 " static get x => 0;", |
| 14571 " set x(int p) {}", | 16232 " set x(int p) {}", |
| 14572 "}"])); | 16233 "}"])); |
| 14573 resolve(source); | 16234 resolve(source); |
| 14574 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN
CE_SETTER]); | 16235 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN
CE_SETTER]); |
| 14575 verify([source]); | 16236 verify([source]); |
| 14576 } | 16237 } |
| 16238 |
| 14577 void test_conflictingStaticSetterAndInstanceMember_thisClass_getter() { | 16239 void test_conflictingStaticSetterAndInstanceMember_thisClass_getter() { |
| 14578 Source source = addSource(EngineTestCase.createSource([ | 16240 Source source = addSource(EngineTestCase.createSource([ |
| 14579 "class A {", | 16241 "class A {", |
| 14580 " get x => 0;", | 16242 " get x => 0;", |
| 14581 " static set x(int p) {}", | 16243 " static set x(int p) {}", |
| 14582 "}"])); | 16244 "}"])); |
| 14583 resolve(source); | 16245 resolve(source); |
| 14584 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTAN
CE_MEMBER]); | 16246 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTAN
CE_MEMBER]); |
| 14585 verify([source]); | 16247 verify([source]); |
| 14586 } | 16248 } |
| 16249 |
| 14587 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() { | 16250 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() { |
| 14588 Source source = addSource(EngineTestCase.createSource(["class A {", " x() {
}", " static set x(int p) {}", "}"])); | 16251 Source source = addSource(EngineTestCase.createSource(["class A {", " x() {
}", " static set x(int p) {}", "}"])); |
| 14589 resolve(source); | 16252 resolve(source); |
| 14590 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTAN
CE_MEMBER]); | 16253 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTAN
CE_MEMBER]); |
| 14591 verify([source]); | 16254 verify([source]); |
| 14592 } | 16255 } |
| 16256 |
| 14593 void test_constWithAbstractClass() { | 16257 void test_constWithAbstractClass() { |
| 14594 Source source = addSource(EngineTestCase.createSource([ | 16258 Source source = addSource(EngineTestCase.createSource([ |
| 14595 "abstract class A {", | 16259 "abstract class A {", |
| 14596 " const A();", | 16260 " const A();", |
| 14597 "}", | 16261 "}", |
| 14598 "void f() {", | 16262 "void f() {", |
| 14599 " A a = const A();", | 16263 " A a = const A();", |
| 14600 "}"])); | 16264 "}"])); |
| 14601 resolve(source); | 16265 resolve(source); |
| 14602 assertErrors(source, [StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]); | 16266 assertErrors(source, [StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]); |
| 14603 verify([source]); | 16267 verify([source]); |
| 14604 } | 16268 } |
| 16269 |
| 14605 void test_equalKeysInMap() { | 16270 void test_equalKeysInMap() { |
| 14606 Source source = addSource(EngineTestCase.createSource(["var m = {'a' : 0, 'b
' : 1, 'a' : 2};"])); | 16271 Source source = addSource(EngineTestCase.createSource(["var m = {'a' : 0, 'b
' : 1, 'a' : 2};"])); |
| 14607 resolve(source); | 16272 resolve(source); |
| 14608 assertErrors(source, [StaticWarningCode.EQUAL_KEYS_IN_MAP]); | 16273 assertErrors(source, [StaticWarningCode.EQUAL_KEYS_IN_MAP]); |
| 14609 verify([source]); | 16274 verify([source]); |
| 14610 } | 16275 } |
| 16276 |
| 14611 void test_exportDuplicatedLibraryName() { | 16277 void test_exportDuplicatedLibraryName() { |
| 14612 Source source = addSource(EngineTestCase.createSource([ | 16278 Source source = addSource(EngineTestCase.createSource([ |
| 14613 "library test;", | 16279 "library test;", |
| 14614 "export 'lib1.dart';", | 16280 "export 'lib1.dart';", |
| 14615 "export 'lib2.dart';"])); | 16281 "export 'lib2.dart';"])); |
| 14616 addSource2("/lib1.dart", "library lib;"); | 16282 addSource2("/lib1.dart", "library lib;"); |
| 14617 addSource2("/lib2.dart", "library lib;"); | 16283 addSource2("/lib2.dart", "library lib;"); |
| 14618 resolve(source); | 16284 resolve(source); |
| 14619 assertErrors(source, [StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAME]); | 16285 assertErrors(source, [StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAME]); |
| 14620 verify([source]); | 16286 verify([source]); |
| 14621 } | 16287 } |
| 16288 |
| 14622 void test_extraPositionalArguments() { | 16289 void test_extraPositionalArguments() { |
| 14623 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" f(0, 1, '2');", "}"])); | 16290 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" f(0, 1, '2');", "}"])); |
| 14624 resolve(source); | 16291 resolve(source); |
| 14625 assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); | 16292 assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); |
| 14626 verify([source]); | 16293 verify([source]); |
| 14627 } | 16294 } |
| 16295 |
| 14628 void test_extraPositionalArguments_functionExpression() { | 16296 void test_extraPositionalArguments_functionExpression() { |
| 14629 Source source = addSource(EngineTestCase.createSource(["main() {", " (int x
) {} (0, 1);", "}"])); | 16297 Source source = addSource(EngineTestCase.createSource(["main() {", " (int x
) {} (0, 1);", "}"])); |
| 14630 resolve(source); | 16298 resolve(source); |
| 14631 assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); | 16299 assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); |
| 14632 verify([source]); | 16300 verify([source]); |
| 14633 } | 16301 } |
| 16302 |
| 14634 void test_fieldInitializedInInitializerAndDeclaration_final() { | 16303 void test_fieldInitializedInInitializerAndDeclaration_final() { |
| 14635 Source source = addSource(EngineTestCase.createSource([ | 16304 Source source = addSource(EngineTestCase.createSource([ |
| 14636 "class A {", | 16305 "class A {", |
| 14637 " final int x = 0;", | 16306 " final int x = 0;", |
| 14638 " A() : x = 1 {}", | 16307 " A() : x = 1 {}", |
| 14639 "}"])); | 16308 "}"])); |
| 14640 resolve(source); | 16309 resolve(source); |
| 14641 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND
_DECLARATION]); | 16310 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND
_DECLARATION]); |
| 14642 verify([source]); | 16311 verify([source]); |
| 14643 } | 16312 } |
| 16313 |
| 14644 void test_fieldInitializerNotAssignable() { | 16314 void test_fieldInitializerNotAssignable() { |
| 14645 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A() : x = '';", "}"])); | 16315 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A() : x = '';", "}"])); |
| 14646 resolve(source); | 16316 resolve(source); |
| 14647 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]); | 16317 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]); |
| 14648 verify([source]); | 16318 verify([source]); |
| 14649 } | 16319 } |
| 16320 |
| 14650 void test_fieldInitializingFormalNotAssignable() { | 16321 void test_fieldInitializingFormalNotAssignable() { |
| 14651 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(String this.x) {}", "}"])); | 16322 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(String this.x) {}", "}"])); |
| 14652 resolve(source); | 16323 resolve(source); |
| 14653 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGN
ABLE]); | 16324 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGN
ABLE]); |
| 14654 verify([source]); | 16325 verify([source]); |
| 14655 } | 16326 } |
| 14656 | 16327 |
| 14657 /** | 16328 /** |
| 14658 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR
code, but tests the | 16329 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR
code, but tests the |
| 14659 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid
ed here to show | 16330 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid
ed here to show |
| 14660 * coverage over all of the permutations of initializers in constructor declar
ations. | 16331 * coverage over all of the permutations of initializers in constructor declar
ations. |
| 14661 * | 16332 * |
| 14662 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of | 16333 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of |
| 14663 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w
e use it instead of | 16334 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w
e use it instead of |
| 14664 * the broader code | 16335 * the broader code |
| 14665 */ | 16336 */ |
| 14666 void test_finalInitializedInDeclarationAndConstructor_initializers() { | 16337 void test_finalInitializedInDeclarationAndConstructor_initializers() { |
| 14667 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " A() : x = 0 {}", "}"])); | 16338 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " A() : x = 0 {}", "}"])); |
| 14668 resolve(source); | 16339 resolve(source); |
| 14669 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND
_DECLARATION]); | 16340 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND
_DECLARATION]); |
| 14670 verify([source]); | 16341 verify([source]); |
| 14671 } | 16342 } |
| 16343 |
| 14672 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { | 16344 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { |
| 14673 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " A(this.x) {}", "}"])); | 16345 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " A(this.x) {}", "}"])); |
| 14674 resolve(source); | 16346 resolve(source); |
| 14675 assertErrors(source, [StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND
_CONSTRUCTOR]); | 16347 assertErrors(source, [StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND
_CONSTRUCTOR]); |
| 14676 verify([source]); | 16348 verify([source]); |
| 14677 } | 16349 } |
| 16350 |
| 14678 void test_finalNotInitialized_inConstructor() { | 16351 void test_finalNotInitialized_inConstructor() { |
| 14679 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() {}", "}"])); | 16352 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() {}", "}"])); |
| 14680 resolve(source); | 16353 resolve(source); |
| 14681 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); | 16354 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); |
| 14682 verify([source]); | 16355 verify([source]); |
| 14683 } | 16356 } |
| 16357 |
| 14684 void test_finalNotInitialized_instanceField_final() { | 16358 void test_finalNotInitialized_instanceField_final() { |
| 14685 Source source = addSource(EngineTestCase.createSource(["class A {", " final
F;", "}"])); | 16359 Source source = addSource(EngineTestCase.createSource(["class A {", " final
F;", "}"])); |
| 14686 resolve(source); | 16360 resolve(source); |
| 14687 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); | 16361 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); |
| 14688 verify([source]); | 16362 verify([source]); |
| 14689 } | 16363 } |
| 16364 |
| 14690 void test_finalNotInitialized_instanceField_final_static() { | 16365 void test_finalNotInitialized_instanceField_final_static() { |
| 14691 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c final F;", "}"])); | 16366 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c final F;", "}"])); |
| 14692 resolve(source); | 16367 resolve(source); |
| 14693 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); | 16368 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); |
| 14694 verify([source]); | 16369 verify([source]); |
| 14695 } | 16370 } |
| 16371 |
| 14696 void test_finalNotInitialized_library_final() { | 16372 void test_finalNotInitialized_library_final() { |
| 14697 Source source = addSource(EngineTestCase.createSource(["final F;"])); | 16373 Source source = addSource(EngineTestCase.createSource(["final F;"])); |
| 14698 resolve(source); | 16374 resolve(source); |
| 14699 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); | 16375 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); |
| 14700 verify([source]); | 16376 verify([source]); |
| 14701 } | 16377 } |
| 16378 |
| 14702 void test_finalNotInitialized_local_final() { | 16379 void test_finalNotInitialized_local_final() { |
| 14703 Source source = addSource(EngineTestCase.createSource(["f() {", " final int
x;", "}"])); | 16380 Source source = addSource(EngineTestCase.createSource(["f() {", " final int
x;", "}"])); |
| 14704 resolve(source); | 16381 resolve(source); |
| 14705 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); | 16382 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); |
| 14706 verify([source]); | 16383 verify([source]); |
| 14707 } | 16384 } |
| 16385 |
| 14708 void test_functionWithoutCall_direct() { | 16386 void test_functionWithoutCall_direct() { |
| 14709 Source source = addSource(EngineTestCase.createSource(["class A implements F
unction {", "}"])); | 16387 Source source = addSource(EngineTestCase.createSource(["class A implements F
unction {", "}"])); |
| 14710 resolve(source); | 16388 resolve(source); |
| 14711 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); | 16389 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); |
| 14712 verify([source]); | 16390 verify([source]); |
| 14713 } | 16391 } |
| 16392 |
| 14714 void test_functionWithoutCall_indirect_extends() { | 16393 void test_functionWithoutCall_indirect_extends() { |
| 14715 Source source = addSource(EngineTestCase.createSource([ | 16394 Source source = addSource(EngineTestCase.createSource([ |
| 14716 "abstract class A implements Function {", | 16395 "abstract class A implements Function {", |
| 14717 "}", | 16396 "}", |
| 14718 "class B extends A {", | 16397 "class B extends A {", |
| 14719 "}"])); | 16398 "}"])); |
| 14720 resolve(source); | 16399 resolve(source); |
| 14721 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); | 16400 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); |
| 14722 verify([source]); | 16401 verify([source]); |
| 14723 } | 16402 } |
| 16403 |
| 14724 void test_functionWithoutCall_indirect_implements() { | 16404 void test_functionWithoutCall_indirect_implements() { |
| 14725 Source source = addSource(EngineTestCase.createSource([ | 16405 Source source = addSource(EngineTestCase.createSource([ |
| 14726 "abstract class A implements Function {", | 16406 "abstract class A implements Function {", |
| 14727 "}", | 16407 "}", |
| 14728 "class B implements A {", | 16408 "class B implements A {", |
| 14729 "}"])); | 16409 "}"])); |
| 14730 resolve(source); | 16410 resolve(source); |
| 14731 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); | 16411 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]); |
| 14732 verify([source]); | 16412 verify([source]); |
| 14733 } | 16413 } |
| 16414 |
| 14734 void test_importDuplicatedLibraryName() { | 16415 void test_importDuplicatedLibraryName() { |
| 14735 Source source = addSource(EngineTestCase.createSource([ | 16416 Source source = addSource(EngineTestCase.createSource([ |
| 14736 "library test;", | 16417 "library test;", |
| 14737 "import 'lib1.dart';", | 16418 "import 'lib1.dart';", |
| 14738 "import 'lib2.dart';"])); | 16419 "import 'lib2.dart';"])); |
| 14739 addSource2("/lib1.dart", "library lib;"); | 16420 addSource2("/lib1.dart", "library lib;"); |
| 14740 addSource2("/lib2.dart", "library lib;"); | 16421 addSource2("/lib2.dart", "library lib;"); |
| 14741 resolve(source); | 16422 resolve(source); |
| 14742 assertErrors(source, [ | 16423 assertErrors(source, [ |
| 14743 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAME, | 16424 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAME, |
| 14744 HintCode.UNUSED_IMPORT, | 16425 HintCode.UNUSED_IMPORT, |
| 14745 HintCode.UNUSED_IMPORT]); | 16426 HintCode.UNUSED_IMPORT]); |
| 14746 verify([source]); | 16427 verify([source]); |
| 14747 } | 16428 } |
| 16429 |
| 14748 void test_inconsistentMethodInheritanceGetterAndMethod() { | 16430 void test_inconsistentMethodInheritanceGetterAndMethod() { |
| 14749 Source source = addSource(EngineTestCase.createSource([ | 16431 Source source = addSource(EngineTestCase.createSource([ |
| 14750 "abstract class A {", | 16432 "abstract class A {", |
| 14751 " int x();", | 16433 " int x();", |
| 14752 "}", | 16434 "}", |
| 14753 "abstract class B {", | 16435 "abstract class B {", |
| 14754 " int get x;", | 16436 " int get x;", |
| 14755 "}", | 16437 "}", |
| 14756 "class C implements A, B {", | 16438 "class C implements A, B {", |
| 14757 "}"])); | 16439 "}"])); |
| 14758 resolve(source); | 16440 resolve(source); |
| 14759 assertErrors(source, [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETT
ER_AND_METHOD]); | 16441 assertErrors(source, [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETT
ER_AND_METHOD]); |
| 14760 verify([source]); | 16442 verify([source]); |
| 14761 } | 16443 } |
| 16444 |
| 14762 void test_instanceMethodNameCollidesWithSuperclassStatic_field() { | 16445 void test_instanceMethodNameCollidesWithSuperclassStatic_field() { |
| 14763 Source source = addSource(EngineTestCase.createSource([ | 16446 Source source = addSource(EngineTestCase.createSource([ |
| 14764 "class A {", | 16447 "class A {", |
| 14765 " static var n;", | 16448 " static var n;", |
| 14766 "}", | 16449 "}", |
| 14767 "class B extends A {", | 16450 "class B extends A {", |
| 14768 " void n() {}", | 16451 " void n() {}", |
| 14769 "}"])); | 16452 "}"])); |
| 14770 resolve(source); | 16453 resolve(source); |
| 14771 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); | 16454 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 14772 verify([source]); | 16455 verify([source]); |
| 14773 } | 16456 } |
| 16457 |
| 14774 void test_instanceMethodNameCollidesWithSuperclassStatic_field2() { | 16458 void test_instanceMethodNameCollidesWithSuperclassStatic_field2() { |
| 14775 Source source = addSource(EngineTestCase.createSource([ | 16459 Source source = addSource(EngineTestCase.createSource([ |
| 14776 "class A {", | 16460 "class A {", |
| 14777 " static var n;", | 16461 " static var n;", |
| 14778 "}", | 16462 "}", |
| 14779 "class B extends A {", | 16463 "class B extends A {", |
| 14780 "}", | 16464 "}", |
| 14781 "class C extends B {", | 16465 "class C extends B {", |
| 14782 " void n() {}", | 16466 " void n() {}", |
| 14783 "}"])); | 16467 "}"])); |
| 14784 resolve(source); | 16468 resolve(source); |
| 14785 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); | 16469 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 14786 verify([source]); | 16470 verify([source]); |
| 14787 } | 16471 } |
| 16472 |
| 14788 void test_instanceMethodNameCollidesWithSuperclassStatic_getter() { | 16473 void test_instanceMethodNameCollidesWithSuperclassStatic_getter() { |
| 14789 Source source = addSource(EngineTestCase.createSource([ | 16474 Source source = addSource(EngineTestCase.createSource([ |
| 14790 "class A {", | 16475 "class A {", |
| 14791 " static get n {return 0;}", | 16476 " static get n {return 0;}", |
| 14792 "}", | 16477 "}", |
| 14793 "class B extends A {", | 16478 "class B extends A {", |
| 14794 " void n() {}", | 16479 " void n() {}", |
| 14795 "}"])); | 16480 "}"])); |
| 14796 resolve(source); | 16481 resolve(source); |
| 14797 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); | 16482 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 14798 verify([source]); | 16483 verify([source]); |
| 14799 } | 16484 } |
| 16485 |
| 14800 void test_instanceMethodNameCollidesWithSuperclassStatic_getter2() { | 16486 void test_instanceMethodNameCollidesWithSuperclassStatic_getter2() { |
| 14801 Source source = addSource(EngineTestCase.createSource([ | 16487 Source source = addSource(EngineTestCase.createSource([ |
| 14802 "class A {", | 16488 "class A {", |
| 14803 " static get n {return 0;}", | 16489 " static get n {return 0;}", |
| 14804 "}", | 16490 "}", |
| 14805 "class B extends A {", | 16491 "class B extends A {", |
| 14806 "}", | 16492 "}", |
| 14807 "class C extends B {", | 16493 "class C extends B {", |
| 14808 " void n() {}", | 16494 " void n() {}", |
| 14809 "}"])); | 16495 "}"])); |
| 14810 resolve(source); | 16496 resolve(source); |
| 14811 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); | 16497 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 14812 verify([source]); | 16498 verify([source]); |
| 14813 } | 16499 } |
| 16500 |
| 14814 void test_instanceMethodNameCollidesWithSuperclassStatic_method() { | 16501 void test_instanceMethodNameCollidesWithSuperclassStatic_method() { |
| 14815 Source source = addSource(EngineTestCase.createSource([ | 16502 Source source = addSource(EngineTestCase.createSource([ |
| 14816 "class A {", | 16503 "class A {", |
| 14817 " static n () {}", | 16504 " static n () {}", |
| 14818 "}", | 16505 "}", |
| 14819 "class B extends A {", | 16506 "class B extends A {", |
| 14820 " void n() {}", | 16507 " void n() {}", |
| 14821 "}"])); | 16508 "}"])); |
| 14822 resolve(source); | 16509 resolve(source); |
| 14823 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); | 16510 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 14824 verify([source]); | 16511 verify([source]); |
| 14825 } | 16512 } |
| 16513 |
| 14826 void test_instanceMethodNameCollidesWithSuperclassStatic_method2() { | 16514 void test_instanceMethodNameCollidesWithSuperclassStatic_method2() { |
| 14827 Source source = addSource(EngineTestCase.createSource([ | 16515 Source source = addSource(EngineTestCase.createSource([ |
| 14828 "class A {", | 16516 "class A {", |
| 14829 " static n () {}", | 16517 " static n () {}", |
| 14830 "}", | 16518 "}", |
| 14831 "class B extends A {", | 16519 "class B extends A {", |
| 14832 "}", | 16520 "}", |
| 14833 "class C extends B {", | 16521 "class C extends B {", |
| 14834 " void n() {}", | 16522 " void n() {}", |
| 14835 "}"])); | 16523 "}"])); |
| 14836 resolve(source); | 16524 resolve(source); |
| 14837 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); | 16525 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 14838 verify([source]); | 16526 verify([source]); |
| 14839 } | 16527 } |
| 16528 |
| 14840 void test_instanceMethodNameCollidesWithSuperclassStatic_setter() { | 16529 void test_instanceMethodNameCollidesWithSuperclassStatic_setter() { |
| 14841 Source source = addSource(EngineTestCase.createSource([ | 16530 Source source = addSource(EngineTestCase.createSource([ |
| 14842 "class A {", | 16531 "class A {", |
| 14843 " static set n(int x) {}", | 16532 " static set n(int x) {}", |
| 14844 "}", | 16533 "}", |
| 14845 "class B extends A {", | 16534 "class B extends A {", |
| 14846 " void n() {}", | 16535 " void n() {}", |
| 14847 "}"])); | 16536 "}"])); |
| 14848 resolve(source); | 16537 resolve(source); |
| 14849 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); | 16538 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 14850 verify([source]); | 16539 verify([source]); |
| 14851 } | 16540 } |
| 16541 |
| 14852 void test_instanceMethodNameCollidesWithSuperclassStatic_setter2() { | 16542 void test_instanceMethodNameCollidesWithSuperclassStatic_setter2() { |
| 14853 Source source = addSource(EngineTestCase.createSource([ | 16543 Source source = addSource(EngineTestCase.createSource([ |
| 14854 "class A {", | 16544 "class A {", |
| 14855 " static set n(int x) {}", | 16545 " static set n(int x) {}", |
| 14856 "}", | 16546 "}", |
| 14857 "class B extends A {", | 16547 "class B extends A {", |
| 14858 "}", | 16548 "}", |
| 14859 "class C extends B {", | 16549 "class C extends B {", |
| 14860 " void n() {}", | 16550 " void n() {}", |
| 14861 "}"])); | 16551 "}"])); |
| 14862 resolve(source); | 16552 resolve(source); |
| 14863 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); | 16553 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 14864 verify([source]); | 16554 verify([source]); |
| 14865 } | 16555 } |
| 16556 |
| 14866 void test_invalidGetterOverrideReturnType() { | 16557 void test_invalidGetterOverrideReturnType() { |
| 14867 Source source = addSource(EngineTestCase.createSource([ | 16558 Source source = addSource(EngineTestCase.createSource([ |
| 14868 "class A {", | 16559 "class A {", |
| 14869 " int get g { return 0; }", | 16560 " int get g { return 0; }", |
| 14870 "}", | 16561 "}", |
| 14871 "class B extends A {", | 16562 "class B extends A {", |
| 14872 " String get g { return 'a'; }", | 16563 " String get g { return 'a'; }", |
| 14873 "}"])); | 16564 "}"])); |
| 14874 resolve(source); | 16565 resolve(source); |
| 14875 assertErrors(source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]
); | 16566 assertErrors(source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]
); |
| 14876 verify([source]); | 16567 verify([source]); |
| 14877 } | 16568 } |
| 16569 |
| 14878 void test_invalidGetterOverrideReturnType_implicit() { | 16570 void test_invalidGetterOverrideReturnType_implicit() { |
| 14879 Source source = addSource(EngineTestCase.createSource([ | 16571 Source source = addSource(EngineTestCase.createSource([ |
| 14880 "class A {", | 16572 "class A {", |
| 14881 " String f;", | 16573 " String f;", |
| 14882 "}", | 16574 "}", |
| 14883 "class B extends A {", | 16575 "class B extends A {", |
| 14884 " int f;", | 16576 " int f;", |
| 14885 "}"])); | 16577 "}"])); |
| 14886 resolve(source); | 16578 resolve(source); |
| 14887 assertErrors(source, [ | 16579 assertErrors(source, [ |
| 14888 StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE, | 16580 StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE, |
| 14889 StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]); | 16581 StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]); |
| 14890 verify([source]); | 16582 verify([source]); |
| 14891 } | 16583 } |
| 16584 |
| 14892 void test_invalidMethodOverrideNamedParamType() { | 16585 void test_invalidMethodOverrideNamedParamType() { |
| 14893 Source source = addSource(EngineTestCase.createSource([ | 16586 Source source = addSource(EngineTestCase.createSource([ |
| 14894 "class A {", | 16587 "class A {", |
| 14895 " m({int a}) {}", | 16588 " m({int a}) {}", |
| 14896 "}", | 16589 "}", |
| 14897 "class B implements A {", | 16590 "class B implements A {", |
| 14898 " m({String a}) {}", | 16591 " m({String a}) {}", |
| 14899 "}"])); | 16592 "}"])); |
| 14900 resolve(source); | 16593 resolve(source); |
| 14901 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_
TYPE]); | 16594 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_
TYPE]); |
| 14902 verify([source]); | 16595 verify([source]); |
| 14903 } | 16596 } |
| 16597 |
| 14904 void test_invalidMethodOverrideNormalParamType() { | 16598 void test_invalidMethodOverrideNormalParamType() { |
| 14905 Source source = addSource(EngineTestCase.createSource([ | 16599 Source source = addSource(EngineTestCase.createSource([ |
| 14906 "class A {", | 16600 "class A {", |
| 14907 " m(int a) {}", | 16601 " m(int a) {}", |
| 14908 "}", | 16602 "}", |
| 14909 "class B implements A {", | 16603 "class B implements A {", |
| 14910 " m(String a) {}", | 16604 " m(String a) {}", |
| 14911 "}"])); | 16605 "}"])); |
| 14912 resolve(source); | 16606 resolve(source); |
| 14913 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM
_TYPE]); | 16607 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM
_TYPE]); |
| 14914 verify([source]); | 16608 verify([source]); |
| 14915 } | 16609 } |
| 16610 |
| 14916 void test_invalidMethodOverrideOptionalParamType() { | 16611 void test_invalidMethodOverrideOptionalParamType() { |
| 14917 Source source = addSource(EngineTestCase.createSource([ | 16612 Source source = addSource(EngineTestCase.createSource([ |
| 14918 "class A {", | 16613 "class A {", |
| 14919 " m([int a]) {}", | 16614 " m([int a]) {}", |
| 14920 "}", | 16615 "}", |
| 14921 "class B implements A {", | 16616 "class B implements A {", |
| 14922 " m([String a]) {}", | 16617 " m([String a]) {}", |
| 14923 "}"])); | 16618 "}"])); |
| 14924 resolve(source); | 16619 resolve(source); |
| 14925 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PAR
AM_TYPE]); | 16620 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PAR
AM_TYPE]); |
| 14926 verify([source]); | 16621 verify([source]); |
| 14927 } | 16622 } |
| 16623 |
| 14928 void test_invalidMethodOverrideReturnType_interface() { | 16624 void test_invalidMethodOverrideReturnType_interface() { |
| 14929 Source source = addSource(EngineTestCase.createSource([ | 16625 Source source = addSource(EngineTestCase.createSource([ |
| 14930 "class A {", | 16626 "class A {", |
| 14931 " int m() { return 0; }", | 16627 " int m() { return 0; }", |
| 14932 "}", | 16628 "}", |
| 14933 "class B implements A {", | 16629 "class B implements A {", |
| 14934 " String m() { return 'a'; }", | 16630 " String m() { return 'a'; }", |
| 14935 "}"])); | 16631 "}"])); |
| 14936 resolve(source); | 16632 resolve(source); |
| 14937 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); | 16633 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 14938 verify([source]); | 16634 verify([source]); |
| 14939 } | 16635 } |
| 16636 |
| 14940 void test_invalidMethodOverrideReturnType_interface2() { | 16637 void test_invalidMethodOverrideReturnType_interface2() { |
| 14941 Source source = addSource(EngineTestCase.createSource([ | 16638 Source source = addSource(EngineTestCase.createSource([ |
| 14942 "abstract class A {", | 16639 "abstract class A {", |
| 14943 " int m();", | 16640 " int m();", |
| 14944 "}", | 16641 "}", |
| 14945 "abstract class B implements A {", | 16642 "abstract class B implements A {", |
| 14946 "}", | 16643 "}", |
| 14947 "class C implements B {", | 16644 "class C implements B {", |
| 14948 " String m() { return 'a'; }", | 16645 " String m() { return 'a'; }", |
| 14949 "}"])); | 16646 "}"])); |
| 14950 resolve(source); | 16647 resolve(source); |
| 14951 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); | 16648 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 14952 verify([source]); | 16649 verify([source]); |
| 14953 } | 16650 } |
| 16651 |
| 14954 void test_invalidMethodOverrideReturnType_mixin() { | 16652 void test_invalidMethodOverrideReturnType_mixin() { |
| 14955 Source source = addSource(EngineTestCase.createSource([ | 16653 Source source = addSource(EngineTestCase.createSource([ |
| 14956 "class A {", | 16654 "class A {", |
| 14957 " int m() { return 0; }", | 16655 " int m() { return 0; }", |
| 14958 "}", | 16656 "}", |
| 14959 "class B extends Object with A {", | 16657 "class B extends Object with A {", |
| 14960 " String m() { return 'a'; }", | 16658 " String m() { return 'a'; }", |
| 14961 "}"])); | 16659 "}"])); |
| 14962 resolve(source); | 16660 resolve(source); |
| 14963 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); | 16661 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 14964 verify([source]); | 16662 verify([source]); |
| 14965 } | 16663 } |
| 16664 |
| 14966 void test_invalidMethodOverrideReturnType_superclass() { | 16665 void test_invalidMethodOverrideReturnType_superclass() { |
| 14967 Source source = addSource(EngineTestCase.createSource([ | 16666 Source source = addSource(EngineTestCase.createSource([ |
| 14968 "class A {", | 16667 "class A {", |
| 14969 " int m() { return 0; }", | 16668 " int m() { return 0; }", |
| 14970 "}", | 16669 "}", |
| 14971 "class B extends A {", | 16670 "class B extends A {", |
| 14972 " String m() { return 'a'; }", | 16671 " String m() { return 'a'; }", |
| 14973 "}"])); | 16672 "}"])); |
| 14974 resolve(source); | 16673 resolve(source); |
| 14975 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); | 16674 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 14976 verify([source]); | 16675 verify([source]); |
| 14977 } | 16676 } |
| 16677 |
| 14978 void test_invalidMethodOverrideReturnType_superclass2() { | 16678 void test_invalidMethodOverrideReturnType_superclass2() { |
| 14979 Source source = addSource(EngineTestCase.createSource([ | 16679 Source source = addSource(EngineTestCase.createSource([ |
| 14980 "class A {", | 16680 "class A {", |
| 14981 " int m() { return 0; }", | 16681 " int m() { return 0; }", |
| 14982 "}", | 16682 "}", |
| 14983 "class B extends A {", | 16683 "class B extends A {", |
| 14984 "}", | 16684 "}", |
| 14985 "class C extends B {", | 16685 "class C extends B {", |
| 14986 " String m() { return 'a'; }", | 16686 " String m() { return 'a'; }", |
| 14987 "}"])); | 16687 "}"])); |
| 14988 resolve(source); | 16688 resolve(source); |
| 14989 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); | 16689 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 14990 verify([source]); | 16690 verify([source]); |
| 14991 } | 16691 } |
| 16692 |
| 14992 void test_invalidMethodOverrideReturnType_void() { | 16693 void test_invalidMethodOverrideReturnType_void() { |
| 14993 Source source = addSource(EngineTestCase.createSource([ | 16694 Source source = addSource(EngineTestCase.createSource([ |
| 14994 "class A {", | 16695 "class A {", |
| 14995 " int m() {}", | 16696 " int m() {}", |
| 14996 "}", | 16697 "}", |
| 14997 "class B extends A {", | 16698 "class B extends A {", |
| 14998 " void m() {}", | 16699 " void m() {}", |
| 14999 "}"])); | 16700 "}"])); |
| 15000 resolve(source); | 16701 resolve(source); |
| 15001 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); | 16702 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 15002 verify([source]); | 16703 verify([source]); |
| 15003 } | 16704 } |
| 16705 |
| 15004 void test_invalidOverrideDifferentDefaultValues_named() { | 16706 void test_invalidOverrideDifferentDefaultValues_named() { |
| 15005 Source source = addSource(EngineTestCase.createSource([ | 16707 Source source = addSource(EngineTestCase.createSource([ |
| 15006 "class A {", | 16708 "class A {", |
| 15007 " m({int p : 0}) {}", | 16709 " m({int p : 0}) {}", |
| 15008 "}", | 16710 "}", |
| 15009 "class B extends A {", | 16711 "class B extends A {", |
| 15010 " m({int p : 1}) {}", | 16712 " m({int p : 1}) {}", |
| 15011 "}"])); | 16713 "}"])); |
| 15012 resolve(source); | 16714 resolve(source); |
| 15013 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_V
ALUES_NAMED]); | 16715 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_V
ALUES_NAMED]); |
| 15014 verify([source]); | 16716 verify([source]); |
| 15015 } | 16717 } |
| 16718 |
| 15016 void test_invalidOverrideDifferentDefaultValues_positional() { | 16719 void test_invalidOverrideDifferentDefaultValues_positional() { |
| 15017 Source source = addSource(EngineTestCase.createSource([ | 16720 Source source = addSource(EngineTestCase.createSource([ |
| 15018 "class A {", | 16721 "class A {", |
| 15019 " m([int p = 0]) {}", | 16722 " m([int p = 0]) {}", |
| 15020 "}", | 16723 "}", |
| 15021 "class B extends A {", | 16724 "class B extends A {", |
| 15022 " m([int p = 1]) {}", | 16725 " m([int p = 1]) {}", |
| 15023 "}"])); | 16726 "}"])); |
| 15024 resolve(source); | 16727 resolve(source); |
| 15025 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_V
ALUES_POSITIONAL]); | 16728 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_V
ALUES_POSITIONAL]); |
| 15026 verify([source]); | 16729 verify([source]); |
| 15027 } | 16730 } |
| 16731 |
| 15028 void test_invalidOverrideNamed_fewerNamedParameters() { | 16732 void test_invalidOverrideNamed_fewerNamedParameters() { |
| 15029 Source source = addSource(EngineTestCase.createSource([ | 16733 Source source = addSource(EngineTestCase.createSource([ |
| 15030 "class A {", | 16734 "class A {", |
| 15031 " m({a, b}) {}", | 16735 " m({a, b}) {}", |
| 15032 "}", | 16736 "}", |
| 15033 "class B extends A {", | 16737 "class B extends A {", |
| 15034 " m({a}) {}", | 16738 " m({a}) {}", |
| 15035 "}"])); | 16739 "}"])); |
| 15036 resolve(source); | 16740 resolve(source); |
| 15037 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]); | 16741 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]); |
| 15038 verify([source]); | 16742 verify([source]); |
| 15039 } | 16743 } |
| 16744 |
| 15040 void test_invalidOverrideNamed_missingNamedParameter() { | 16745 void test_invalidOverrideNamed_missingNamedParameter() { |
| 15041 Source source = addSource(EngineTestCase.createSource([ | 16746 Source source = addSource(EngineTestCase.createSource([ |
| 15042 "class A {", | 16747 "class A {", |
| 15043 " m({a, b}) {}", | 16748 " m({a, b}) {}", |
| 15044 "}", | 16749 "}", |
| 15045 "class B extends A {", | 16750 "class B extends A {", |
| 15046 " m({a, c}) {}", | 16751 " m({a, c}) {}", |
| 15047 "}"])); | 16752 "}"])); |
| 15048 resolve(source); | 16753 resolve(source); |
| 15049 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]); | 16754 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]); |
| 15050 verify([source]); | 16755 verify([source]); |
| 15051 } | 16756 } |
| 16757 |
| 15052 void test_invalidOverridePositional_optional() { | 16758 void test_invalidOverridePositional_optional() { |
| 15053 Source source = addSource(EngineTestCase.createSource([ | 16759 Source source = addSource(EngineTestCase.createSource([ |
| 15054 "class A {", | 16760 "class A {", |
| 15055 " m([a, b]) {}", | 16761 " m([a, b]) {}", |
| 15056 "}", | 16762 "}", |
| 15057 "class B extends A {", | 16763 "class B extends A {", |
| 15058 " m([a]) {}", | 16764 " m([a]) {}", |
| 15059 "}"])); | 16765 "}"])); |
| 15060 resolve(source); | 16766 resolve(source); |
| 15061 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); | 16767 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); |
| 15062 verify([source]); | 16768 verify([source]); |
| 15063 } | 16769 } |
| 16770 |
| 15064 void test_invalidOverridePositional_optionalAndRequired() { | 16771 void test_invalidOverridePositional_optionalAndRequired() { |
| 15065 Source source = addSource(EngineTestCase.createSource([ | 16772 Source source = addSource(EngineTestCase.createSource([ |
| 15066 "class A {", | 16773 "class A {", |
| 15067 " m(a, b, [c, d]) {}", | 16774 " m(a, b, [c, d]) {}", |
| 15068 "}", | 16775 "}", |
| 15069 "class B extends A {", | 16776 "class B extends A {", |
| 15070 " m(a, b, [c]) {}", | 16777 " m(a, b, [c]) {}", |
| 15071 "}"])); | 16778 "}"])); |
| 15072 resolve(source); | 16779 resolve(source); |
| 15073 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); | 16780 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); |
| 15074 verify([source]); | 16781 verify([source]); |
| 15075 } | 16782 } |
| 16783 |
| 15076 void test_invalidOverridePositional_optionalAndRequired2() { | 16784 void test_invalidOverridePositional_optionalAndRequired2() { |
| 15077 Source source = addSource(EngineTestCase.createSource([ | 16785 Source source = addSource(EngineTestCase.createSource([ |
| 15078 "class A {", | 16786 "class A {", |
| 15079 " m(a, b, [c, d]) {}", | 16787 " m(a, b, [c, d]) {}", |
| 15080 "}", | 16788 "}", |
| 15081 "class B extends A {", | 16789 "class B extends A {", |
| 15082 " m(a, [c, d]) {}", | 16790 " m(a, [c, d]) {}", |
| 15083 "}"])); | 16791 "}"])); |
| 15084 resolve(source); | 16792 resolve(source); |
| 15085 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); | 16793 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); |
| 15086 verify([source]); | 16794 verify([source]); |
| 15087 } | 16795 } |
| 16796 |
| 15088 void test_invalidOverrideRequired() { | 16797 void test_invalidOverrideRequired() { |
| 15089 Source source = addSource(EngineTestCase.createSource([ | 16798 Source source = addSource(EngineTestCase.createSource([ |
| 15090 "class A {", | 16799 "class A {", |
| 15091 " m(a) {}", | 16800 " m(a) {}", |
| 15092 "}", | 16801 "}", |
| 15093 "class B extends A {", | 16802 "class B extends A {", |
| 15094 " m(a, b) {}", | 16803 " m(a, b) {}", |
| 15095 "}"])); | 16804 "}"])); |
| 15096 resolve(source); | 16805 resolve(source); |
| 15097 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_REQUIRED]); | 16806 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_REQUIRED]); |
| 15098 verify([source]); | 16807 verify([source]); |
| 15099 } | 16808 } |
| 16809 |
| 15100 void test_invalidSetterOverrideNormalParamType() { | 16810 void test_invalidSetterOverrideNormalParamType() { |
| 15101 Source source = addSource(EngineTestCase.createSource([ | 16811 Source source = addSource(EngineTestCase.createSource([ |
| 15102 "class A {", | 16812 "class A {", |
| 15103 " void set s(int v) {}", | 16813 " void set s(int v) {}", |
| 15104 "}", | 16814 "}", |
| 15105 "class B extends A {", | 16815 "class B extends A {", |
| 15106 " void set s(String v) {}", | 16816 " void set s(String v) {}", |
| 15107 "}"])); | 16817 "}"])); |
| 15108 resolve(source); | 16818 resolve(source); |
| 15109 assertErrors(source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM
_TYPE]); | 16819 assertErrors(source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM
_TYPE]); |
| 15110 verify([source]); | 16820 verify([source]); |
| 15111 } | 16821 } |
| 16822 |
| 15112 void test_listElementTypeNotAssignable() { | 16823 void test_listElementTypeNotAssignable() { |
| 15113 Source source = addSource(EngineTestCase.createSource(["var v = <String> [42
];"])); | 16824 Source source = addSource(EngineTestCase.createSource(["var v = <String> [42
];"])); |
| 15114 resolve(source); | 16825 resolve(source); |
| 15115 assertErrors(source, [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]); | 16826 assertErrors(source, [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]); |
| 15116 verify([source]); | 16827 verify([source]); |
| 15117 } | 16828 } |
| 16829 |
| 15118 void test_mapKeyTypeNotAssignable() { | 16830 void test_mapKeyTypeNotAssignable() { |
| 15119 Source source = addSource(EngineTestCase.createSource(["var v = <String, int
> {1 : 2};"])); | 16831 Source source = addSource(EngineTestCase.createSource(["var v = <String, int
> {1 : 2};"])); |
| 15120 resolve(source); | 16832 resolve(source); |
| 15121 assertErrors(source, [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]); | 16833 assertErrors(source, [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]); |
| 15122 verify([source]); | 16834 verify([source]); |
| 15123 } | 16835 } |
| 16836 |
| 15124 void test_mapValueTypeNotAssignable() { | 16837 void test_mapValueTypeNotAssignable() { |
| 15125 Source source = addSource(EngineTestCase.createSource(["var v = <String, Str
ing> {'a' : 2};"])); | 16838 Source source = addSource(EngineTestCase.createSource(["var v = <String, Str
ing> {'a' : 2};"])); |
| 15126 resolve(source); | 16839 resolve(source); |
| 15127 assertErrors(source, [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]); | 16840 assertErrors(source, [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]); |
| 15128 verify([source]); | 16841 verify([source]); |
| 15129 } | 16842 } |
| 16843 |
| 15130 void test_mismatchedAccessorTypes_class() { | 16844 void test_mismatchedAccessorTypes_class() { |
| 15131 Source source = addSource(EngineTestCase.createSource([ | 16845 Source source = addSource(EngineTestCase.createSource([ |
| 15132 "class A {", | 16846 "class A {", |
| 15133 " int get g { return 0; }", | 16847 " int get g { return 0; }", |
| 15134 " set g(String v) {}", | 16848 " set g(String v) {}", |
| 15135 "}"])); | 16849 "}"])); |
| 15136 resolve(source); | 16850 resolve(source); |
| 15137 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; | 16851 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; |
| 15138 verify([source]); | 16852 verify([source]); |
| 15139 } | 16853 } |
| 16854 |
| 15140 void test_mismatchedAccessorTypes_getterAndSuperSetter() { | 16855 void test_mismatchedAccessorTypes_getterAndSuperSetter() { |
| 15141 Source source = addSource(EngineTestCase.createSource([ | 16856 Source source = addSource(EngineTestCase.createSource([ |
| 15142 "class A {", | 16857 "class A {", |
| 15143 " int get g { return 0; }", | 16858 " int get g { return 0; }", |
| 15144 "}", | 16859 "}", |
| 15145 "class B extends A {", | 16860 "class B extends A {", |
| 15146 " set g(String v) {}", | 16861 " set g(String v) {}", |
| 15147 "}"])); | 16862 "}"])); |
| 15148 resolve(source); | 16863 resolve(source); |
| 15149 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_F
ROM_SUPERTYPE]); | 16864 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_F
ROM_SUPERTYPE]); |
| 15150 verify([source]); | 16865 verify([source]); |
| 15151 } | 16866 } |
| 16867 |
| 15152 void test_mismatchedAccessorTypes_setterAndSuperGetter() { | 16868 void test_mismatchedAccessorTypes_setterAndSuperGetter() { |
| 15153 Source source = addSource(EngineTestCase.createSource([ | 16869 Source source = addSource(EngineTestCase.createSource([ |
| 15154 "class A {", | 16870 "class A {", |
| 15155 " set g(int v) {}", | 16871 " set g(int v) {}", |
| 15156 "}", | 16872 "}", |
| 15157 "class B extends A {", | 16873 "class B extends A {", |
| 15158 " String get g { return ''; }", | 16874 " String get g { return ''; }", |
| 15159 "}"])); | 16875 "}"])); |
| 15160 resolve(source); | 16876 resolve(source); |
| 15161 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_F
ROM_SUPERTYPE]); | 16877 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_F
ROM_SUPERTYPE]); |
| 15162 verify([source]); | 16878 verify([source]); |
| 15163 } | 16879 } |
| 16880 |
| 15164 void test_mismatchedAccessorTypes_topLevel() { | 16881 void test_mismatchedAccessorTypes_topLevel() { |
| 15165 Source source = addSource(EngineTestCase.createSource(["int get g { return 0
; }", "set g(String v) {}"])); | 16882 Source source = addSource(EngineTestCase.createSource(["int get g { return 0
; }", "set g(String v) {}"])); |
| 15166 resolve(source); | 16883 resolve(source); |
| 15167 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; | 16884 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; |
| 15168 verify([source]); | 16885 verify([source]); |
| 15169 } | 16886 } |
| 16887 |
| 15170 void test_mixedReturnTypes_localFunction() { | 16888 void test_mixedReturnTypes_localFunction() { |
| 15171 Source source = addSource(EngineTestCase.createSource([ | 16889 Source source = addSource(EngineTestCase.createSource([ |
| 15172 "class C {", | 16890 "class C {", |
| 15173 " m(int x) {", | 16891 " m(int x) {", |
| 15174 " return (int y) {", | 16892 " return (int y) {", |
| 15175 " if (y < 0) {", | 16893 " if (y < 0) {", |
| 15176 " return;", | 16894 " return;", |
| 15177 " }", | 16895 " }", |
| 15178 " return 0;", | 16896 " return 0;", |
| 15179 " };", | 16897 " };", |
| 15180 " }", | 16898 " }", |
| 15181 "}"])); | 16899 "}"])); |
| 15182 resolve(source); | 16900 resolve(source); |
| 15183 assertErrors(source, [StaticWarningCode.MIXED_RETURN_TYPES]); | 16901 assertErrors(source, [StaticWarningCode.MIXED_RETURN_TYPES]); |
| 15184 verify([source]); | 16902 verify([source]); |
| 15185 } | 16903 } |
| 16904 |
| 15186 void test_mixedReturnTypes_method() { | 16905 void test_mixedReturnTypes_method() { |
| 15187 Source source = addSource(EngineTestCase.createSource([ | 16906 Source source = addSource(EngineTestCase.createSource([ |
| 15188 "class C {", | 16907 "class C {", |
| 15189 " m(int x) {", | 16908 " m(int x) {", |
| 15190 " if (x < 0) {", | 16909 " if (x < 0) {", |
| 15191 " return;", | 16910 " return;", |
| 15192 " }", | 16911 " }", |
| 15193 " return 0;", | 16912 " return 0;", |
| 15194 " }", | 16913 " }", |
| 15195 "}"])); | 16914 "}"])); |
| 15196 resolve(source); | 16915 resolve(source); |
| 15197 assertErrors(source, [StaticWarningCode.MIXED_RETURN_TYPES]); | 16916 assertErrors(source, [StaticWarningCode.MIXED_RETURN_TYPES]); |
| 15198 verify([source]); | 16917 verify([source]); |
| 15199 } | 16918 } |
| 16919 |
| 15200 void test_mixedReturnTypes_topLevelFunction() { | 16920 void test_mixedReturnTypes_topLevelFunction() { |
| 15201 Source source = addSource(EngineTestCase.createSource([ | 16921 Source source = addSource(EngineTestCase.createSource([ |
| 15202 "f(int x) {", | 16922 "f(int x) {", |
| 15203 " if (x < 0) {", | 16923 " if (x < 0) {", |
| 15204 " return;", | 16924 " return;", |
| 15205 " }", | 16925 " }", |
| 15206 " return 0;", | 16926 " return 0;", |
| 15207 "}"])); | 16927 "}"])); |
| 15208 resolve(source); | 16928 resolve(source); |
| 15209 assertErrors(source, [StaticWarningCode.MIXED_RETURN_TYPES]); | 16929 assertErrors(source, [StaticWarningCode.MIXED_RETURN_TYPES]); |
| 15210 verify([source]); | 16930 verify([source]); |
| 15211 } | 16931 } |
| 16932 |
| 15212 void test_newWithAbstractClass() { | 16933 void test_newWithAbstractClass() { |
| 15213 Source source = addSource(EngineTestCase.createSource([ | 16934 Source source = addSource(EngineTestCase.createSource([ |
| 15214 "abstract class A {}", | 16935 "abstract class A {}", |
| 15215 "void f() {", | 16936 "void f() {", |
| 15216 " A a = new A();", | 16937 " A a = new A();", |
| 15217 "}"])); | 16938 "}"])); |
| 15218 resolve(source); | 16939 resolve(source); |
| 15219 assertErrors(source, [StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]); | 16940 assertErrors(source, [StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]); |
| 15220 verify([source]); | 16941 verify([source]); |
| 15221 } | 16942 } |
| 16943 |
| 15222 void test_newWithInvalidTypeParameters() { | 16944 void test_newWithInvalidTypeParameters() { |
| 15223 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() {
return new A<A>(); }"])); | 16945 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() {
return new A<A>(); }"])); |
| 15224 resolve(source); | 16946 resolve(source); |
| 15225 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); | 16947 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); |
| 15226 verify([source]); | 16948 verify([source]); |
| 15227 } | 16949 } |
| 16950 |
| 15228 void test_newWithInvalidTypeParameters_tooFew() { | 16951 void test_newWithInvalidTypeParameters_tooFew() { |
| 15229 Source source = addSource(EngineTestCase.createSource([ | 16952 Source source = addSource(EngineTestCase.createSource([ |
| 15230 "class A {}", | 16953 "class A {}", |
| 15231 "class C<K, V> {}", | 16954 "class C<K, V> {}", |
| 15232 "f(p) {", | 16955 "f(p) {", |
| 15233 " return new C<A>();", | 16956 " return new C<A>();", |
| 15234 "}"])); | 16957 "}"])); |
| 15235 resolve(source); | 16958 resolve(source); |
| 15236 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); | 16959 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); |
| 15237 verify([source]); | 16960 verify([source]); |
| 15238 } | 16961 } |
| 16962 |
| 15239 void test_newWithInvalidTypeParameters_tooMany() { | 16963 void test_newWithInvalidTypeParameters_tooMany() { |
| 15240 Source source = addSource(EngineTestCase.createSource([ | 16964 Source source = addSource(EngineTestCase.createSource([ |
| 15241 "class A {}", | 16965 "class A {}", |
| 15242 "class C<E> {}", | 16966 "class C<E> {}", |
| 15243 "f(p) {", | 16967 "f(p) {", |
| 15244 " return new C<A, A>();", | 16968 " return new C<A, A>();", |
| 15245 "}"])); | 16969 "}"])); |
| 15246 resolve(source); | 16970 resolve(source); |
| 15247 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); | 16971 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); |
| 15248 verify([source]); | 16972 verify([source]); |
| 15249 } | 16973 } |
| 16974 |
| 15250 void test_newWithNonType() { | 16975 void test_newWithNonType() { |
| 15251 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "void f
() {", " var a = new A();", "}"])); | 16976 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "void f
() {", " var a = new A();", "}"])); |
| 15252 resolve(source); | 16977 resolve(source); |
| 15253 assertErrors(source, [StaticWarningCode.NEW_WITH_NON_TYPE]); | 16978 assertErrors(source, [StaticWarningCode.NEW_WITH_NON_TYPE]); |
| 15254 verify([source]); | 16979 verify([source]); |
| 15255 } | 16980 } |
| 16981 |
| 15256 void test_newWithNonType_fromLibrary() { | 16982 void test_newWithNonType_fromLibrary() { |
| 15257 Source source1 = addSource2("lib.dart", "class B {}"); | 16983 Source source1 = addSource2("lib.dart", "class B {}"); |
| 15258 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ | 16984 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ |
| 15259 "import 'lib.dart' as lib;", | 16985 "import 'lib.dart' as lib;", |
| 15260 "void f() {", | 16986 "void f() {", |
| 15261 " var a = new lib.A();", | 16987 " var a = new lib.A();", |
| 15262 "}", | 16988 "}", |
| 15263 "lib.B b;"])); | 16989 "lib.B b;"])); |
| 15264 resolve(source1); | 16990 resolve(source1); |
| 15265 resolve(source2); | 16991 resolve(source2); |
| 15266 assertErrors(source2, [StaticWarningCode.NEW_WITH_NON_TYPE]); | 16992 assertErrors(source2, [StaticWarningCode.NEW_WITH_NON_TYPE]); |
| 15267 verify([source1]); | 16993 verify([source1]); |
| 15268 } | 16994 } |
| 16995 |
| 15269 void test_newWithUndefinedConstructor() { | 16996 void test_newWithUndefinedConstructor() { |
| 15270 Source source = addSource(EngineTestCase.createSource([ | 16997 Source source = addSource(EngineTestCase.createSource([ |
| 15271 "class A {", | 16998 "class A {", |
| 15272 " A() {}", | 16999 " A() {}", |
| 15273 "}", | 17000 "}", |
| 15274 "f() {", | 17001 "f() {", |
| 15275 " new A.name();", | 17002 " new A.name();", |
| 15276 "}"])); | 17003 "}"])); |
| 15277 resolve(source); | 17004 resolve(source); |
| 15278 assertErrors(source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]); | 17005 assertErrors(source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]); |
| 15279 } | 17006 } |
| 17007 |
| 15280 void test_newWithUndefinedConstructorDefault() { | 17008 void test_newWithUndefinedConstructorDefault() { |
| 15281 Source source = addSource(EngineTestCase.createSource([ | 17009 Source source = addSource(EngineTestCase.createSource([ |
| 15282 "class A {", | 17010 "class A {", |
| 15283 " A.name() {}", | 17011 " A.name() {}", |
| 15284 "}", | 17012 "}", |
| 15285 "f() {", | 17013 "f() {", |
| 15286 " new A();", | 17014 " new A();", |
| 15287 "}"])); | 17015 "}"])); |
| 15288 resolve(source); | 17016 resolve(source); |
| 15289 assertErrors(source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAU
LT]); | 17017 assertErrors(source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAU
LT]); |
| 15290 verify([source]); | 17018 verify([source]); |
| 15291 } | 17019 } |
| 17020 |
| 15292 void test_nonAbstractClassInheritsAbstractMemberFivePlus() { | 17021 void test_nonAbstractClassInheritsAbstractMemberFivePlus() { |
| 15293 Source source = addSource(EngineTestCase.createSource([ | 17022 Source source = addSource(EngineTestCase.createSource([ |
| 15294 "abstract class A {", | 17023 "abstract class A {", |
| 15295 " m();", | 17024 " m();", |
| 15296 " n();", | 17025 " n();", |
| 15297 " o();", | 17026 " o();", |
| 15298 " p();", | 17027 " p();", |
| 15299 " q();", | 17028 " q();", |
| 15300 "}", | 17029 "}", |
| 15301 "class C extends A {", | 17030 "class C extends A {", |
| 15302 "}"])); | 17031 "}"])); |
| 15303 resolve(source); | 17032 resolve(source); |
| 15304 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_FIVE_PLUS]); | 17033 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_FIVE_PLUS]); |
| 15305 verify([source]); | 17034 verify([source]); |
| 15306 } | 17035 } |
| 17036 |
| 15307 void test_nonAbstractClassInheritsAbstractMemberFour() { | 17037 void test_nonAbstractClassInheritsAbstractMemberFour() { |
| 15308 Source source = addSource(EngineTestCase.createSource([ | 17038 Source source = addSource(EngineTestCase.createSource([ |
| 15309 "abstract class A {", | 17039 "abstract class A {", |
| 15310 " m();", | 17040 " m();", |
| 15311 " n();", | 17041 " n();", |
| 15312 " o();", | 17042 " o();", |
| 15313 " p();", | 17043 " p();", |
| 15314 "}", | 17044 "}", |
| 15315 "class C extends A {", | 17045 "class C extends A {", |
| 15316 "}"])); | 17046 "}"])); |
| 15317 resolve(source); | 17047 resolve(source); |
| 15318 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_FOUR]); | 17048 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_FOUR]); |
| 15319 verify([source]); | 17049 verify([source]); |
| 15320 } | 17050 } |
| 17051 |
| 15321 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterface() { | 17052 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterface() { |
| 15322 Source source = addSource(EngineTestCase.createSource([ | 17053 Source source = addSource(EngineTestCase.createSource([ |
| 15323 "class I {", | 17054 "class I {", |
| 15324 " int get g {return 1;}", | 17055 " int get g {return 1;}", |
| 15325 "}", | 17056 "}", |
| 15326 "class C implements I {", | 17057 "class C implements I {", |
| 15327 "}"])); | 17058 "}"])); |
| 15328 resolve(source); | 17059 resolve(source); |
| 15329 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); | 17060 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 15330 verify([source]); | 17061 verify([source]); |
| 15331 } | 17062 } |
| 17063 |
| 15332 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperclass() { | 17064 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperclass() { |
| 15333 Source source = addSource(EngineTestCase.createSource([ | 17065 Source source = addSource(EngineTestCase.createSource([ |
| 15334 "abstract class A {", | 17066 "abstract class A {", |
| 15335 " int get g;", | 17067 " int get g;", |
| 15336 "}", | 17068 "}", |
| 15337 "class C extends A {", | 17069 "class C extends A {", |
| 15338 "}"])); | 17070 "}"])); |
| 15339 resolve(source); | 17071 resolve(source); |
| 15340 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); | 17072 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 15341 verify([source]); | 17073 verify([source]); |
| 15342 } | 17074 } |
| 17075 |
| 15343 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterface() { | 17076 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterface() { |
| 15344 Source source = addSource(EngineTestCase.createSource([ | 17077 Source source = addSource(EngineTestCase.createSource([ |
| 15345 "class I {", | 17078 "class I {", |
| 15346 " m(p) {}", | 17079 " m(p) {}", |
| 15347 "}", | 17080 "}", |
| 15348 "class C implements I {", | 17081 "class C implements I {", |
| 15349 "}"])); | 17082 "}"])); |
| 15350 resolve(source); | 17083 resolve(source); |
| 15351 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); | 17084 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 15352 verify([source]); | 17085 verify([source]); |
| 15353 } | 17086 } |
| 17087 |
| 15354 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperclass() { | 17088 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperclass() { |
| 15355 Source source = addSource(EngineTestCase.createSource([ | 17089 Source source = addSource(EngineTestCase.createSource([ |
| 15356 "abstract class A {", | 17090 "abstract class A {", |
| 15357 " m(p);", | 17091 " m(p);", |
| 15358 "}", | 17092 "}", |
| 15359 "class C extends A {", | 17093 "class C extends A {", |
| 15360 "}"])); | 17094 "}"])); |
| 15361 resolve(source); | 17095 resolve(source); |
| 15362 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); | 17096 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 15363 verify([source]); | 17097 verify([source]); |
| 15364 } | 17098 } |
| 17099 |
| 15365 void test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount(
) { | 17100 void test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount(
) { |
| 15366 Source source = addSource(EngineTestCase.createSource([ | 17101 Source source = addSource(EngineTestCase.createSource([ |
| 15367 "abstract class A {", | 17102 "abstract class A {", |
| 15368 " int x(int a);", | 17103 " int x(int a);", |
| 15369 "}", | 17104 "}", |
| 15370 "abstract class B {", | 17105 "abstract class B {", |
| 15371 " int x(int a, [int b]);", | 17106 " int x(int a, [int b]);", |
| 15372 "}", | 17107 "}", |
| 15373 "class C implements A, B {", | 17108 "class C implements A, B {", |
| 15374 "}"])); | 17109 "}"])); |
| 15375 resolve(source); | 17110 resolve(source); |
| 15376 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); | 17111 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 15377 verify([source]); | 17112 verify([source]); |
| 15378 } | 17113 } |
| 17114 |
| 15379 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterface() { | 17115 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterface() { |
| 15380 Source source = addSource(EngineTestCase.createSource([ | 17116 Source source = addSource(EngineTestCase.createSource([ |
| 15381 "class I {", | 17117 "class I {", |
| 15382 " set s(int i) {}", | 17118 " set s(int i) {}", |
| 15383 "}", | 17119 "}", |
| 15384 "class C implements I {", | 17120 "class C implements I {", |
| 15385 "}"])); | 17121 "}"])); |
| 15386 resolve(source); | 17122 resolve(source); |
| 15387 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); | 17123 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 15388 verify([source]); | 17124 verify([source]); |
| 15389 } | 17125 } |
| 17126 |
| 15390 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() { | 17127 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() { |
| 15391 Source source = addSource(EngineTestCase.createSource([ | 17128 Source source = addSource(EngineTestCase.createSource([ |
| 15392 "abstract class A {", | 17129 "abstract class A {", |
| 15393 " set s(int i);", | 17130 " set s(int i);", |
| 15394 "}", | 17131 "}", |
| 15395 "class C extends A {", | 17132 "class C extends A {", |
| 15396 "}"])); | 17133 "}"])); |
| 15397 resolve(source); | 17134 resolve(source); |
| 15398 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); | 17135 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 15399 verify([source]); | 17136 verify([source]); |
| 15400 } | 17137 } |
| 17138 |
| 15401 void test_nonAbstractClassInheritsAbstractMemberOne_superclasses_interface() { | 17139 void test_nonAbstractClassInheritsAbstractMemberOne_superclasses_interface() { |
| 15402 Source source = addSource(EngineTestCase.createSource([ | 17140 Source source = addSource(EngineTestCase.createSource([ |
| 15403 "class A {", | 17141 "class A {", |
| 15404 " get a => 'a';", | 17142 " get a => 'a';", |
| 15405 "}", | 17143 "}", |
| 15406 "abstract class B implements A {", | 17144 "abstract class B implements A {", |
| 15407 " get b => 'b';", | 17145 " get b => 'b';", |
| 15408 "}", | 17146 "}", |
| 15409 "class C extends B {", | 17147 "class C extends B {", |
| 15410 "}"])); | 17148 "}"])); |
| 15411 resolve(source); | 17149 resolve(source); |
| 15412 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); | 17150 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 15413 verify([source]); | 17151 verify([source]); |
| 15414 } | 17152 } |
| 17153 |
| 15415 void test_nonAbstractClassInheritsAbstractMemberThree() { | 17154 void test_nonAbstractClassInheritsAbstractMemberThree() { |
| 15416 Source source = addSource(EngineTestCase.createSource([ | 17155 Source source = addSource(EngineTestCase.createSource([ |
| 15417 "abstract class A {", | 17156 "abstract class A {", |
| 15418 " m();", | 17157 " m();", |
| 15419 " n();", | 17158 " n();", |
| 15420 " o();", | 17159 " o();", |
| 15421 "}", | 17160 "}", |
| 15422 "class C extends A {", | 17161 "class C extends A {", |
| 15423 "}"])); | 17162 "}"])); |
| 15424 resolve(source); | 17163 resolve(source); |
| 15425 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_THREE]); | 17164 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_THREE]); |
| 15426 verify([source]); | 17165 verify([source]); |
| 15427 } | 17166 } |
| 17167 |
| 15428 void test_nonAbstractClassInheritsAbstractMemberTwo() { | 17168 void test_nonAbstractClassInheritsAbstractMemberTwo() { |
| 15429 Source source = addSource(EngineTestCase.createSource([ | 17169 Source source = addSource(EngineTestCase.createSource([ |
| 15430 "abstract class A {", | 17170 "abstract class A {", |
| 15431 " m();", | 17171 " m();", |
| 15432 " n();", | 17172 " n();", |
| 15433 "}", | 17173 "}", |
| 15434 "class C extends A {", | 17174 "class C extends A {", |
| 15435 "}"])); | 17175 "}"])); |
| 15436 resolve(source); | 17176 resolve(source); |
| 15437 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_TWO]); | 17177 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_TWO]); |
| 15438 verify([source]); | 17178 verify([source]); |
| 15439 } | 17179 } |
| 17180 |
| 15440 void test_nonTypeInCatchClause_noElement() { | 17181 void test_nonTypeInCatchClause_noElement() { |
| 15441 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", "
} on T catch (e) {", " }", "}"])); | 17182 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", "
} on T catch (e) {", " }", "}"])); |
| 15442 resolve(source); | 17183 resolve(source); |
| 15443 assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); | 17184 assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); |
| 15444 verify([source]); | 17185 verify([source]); |
| 15445 } | 17186 } |
| 17187 |
| 15446 void test_nonTypeInCatchClause_notType() { | 17188 void test_nonTypeInCatchClause_notType() { |
| 15447 Source source = addSource(EngineTestCase.createSource([ | 17189 Source source = addSource(EngineTestCase.createSource([ |
| 15448 "var T = 0;", | 17190 "var T = 0;", |
| 15449 "f() {", | 17191 "f() {", |
| 15450 " try {", | 17192 " try {", |
| 15451 " } on T catch (e) {", | 17193 " } on T catch (e) {", |
| 15452 " }", | 17194 " }", |
| 15453 "}"])); | 17195 "}"])); |
| 15454 resolve(source); | 17196 resolve(source); |
| 15455 assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); | 17197 assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); |
| 15456 verify([source]); | 17198 verify([source]); |
| 15457 } | 17199 } |
| 17200 |
| 15458 void test_nonVoidReturnForOperator() { | 17201 void test_nonVoidReturnForOperator() { |
| 15459 Source source = addSource(EngineTestCase.createSource(["class A {", " int o
perator []=(a, b) {}", "}"])); | 17202 Source source = addSource(EngineTestCase.createSource(["class A {", " int o
perator []=(a, b) {}", "}"])); |
| 15460 resolve(source); | 17203 resolve(source); |
| 15461 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]); | 17204 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]); |
| 15462 verify([source]); | 17205 verify([source]); |
| 15463 } | 17206 } |
| 17207 |
| 15464 void test_nonVoidReturnForSetter_function() { | 17208 void test_nonVoidReturnForSetter_function() { |
| 15465 Source source = addSource(EngineTestCase.createSource(["int set x(int v) {",
" return 42;", "}"])); | 17209 Source source = addSource(EngineTestCase.createSource(["int set x(int v) {",
" return 42;", "}"])); |
| 15466 resolve(source); | 17210 resolve(source); |
| 15467 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]); | 17211 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]); |
| 15468 verify([source]); | 17212 verify([source]); |
| 15469 } | 17213 } |
| 17214 |
| 15470 void test_nonVoidReturnForSetter_method() { | 17215 void test_nonVoidReturnForSetter_method() { |
| 15471 Source source = addSource(EngineTestCase.createSource([ | 17216 Source source = addSource(EngineTestCase.createSource([ |
| 15472 "class A {", | 17217 "class A {", |
| 15473 " int set x(int v) {", | 17218 " int set x(int v) {", |
| 15474 " return 42;", | 17219 " return 42;", |
| 15475 " }", | 17220 " }", |
| 15476 "}"])); | 17221 "}"])); |
| 15477 resolve(source); | 17222 resolve(source); |
| 15478 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]); | 17223 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]); |
| 15479 verify([source]); | 17224 verify([source]); |
| 15480 } | 17225 } |
| 17226 |
| 15481 void test_notAType() { | 17227 void test_notAType() { |
| 15482 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" f v = null;", "}"])); | 17228 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" f v = null;", "}"])); |
| 15483 resolve(source); | 17229 resolve(source); |
| 15484 assertErrors(source, [StaticWarningCode.NOT_A_TYPE]); | 17230 assertErrors(source, [StaticWarningCode.NOT_A_TYPE]); |
| 15485 verify([source]); | 17231 verify([source]); |
| 15486 } | 17232 } |
| 17233 |
| 15487 void test_notEnoughRequiredArguments() { | 17234 void test_notEnoughRequiredArguments() { |
| 15488 Source source = addSource(EngineTestCase.createSource(["f(int a, String b) {
}", "main() {", " f();", "}"])); | 17235 Source source = addSource(EngineTestCase.createSource(["f(int a, String b) {
}", "main() {", " f();", "}"])); |
| 15489 resolve(source); | 17236 resolve(source); |
| 15490 assertErrors(source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); | 17237 assertErrors(source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); |
| 15491 verify([source]); | 17238 verify([source]); |
| 15492 } | 17239 } |
| 17240 |
| 15493 void test_notEnoughRequiredArguments_functionExpression() { | 17241 void test_notEnoughRequiredArguments_functionExpression() { |
| 15494 Source source = addSource(EngineTestCase.createSource(["main() {", " (int x
) {} ();", "}"])); | 17242 Source source = addSource(EngineTestCase.createSource(["main() {", " (int x
) {} ();", "}"])); |
| 15495 resolve(source); | 17243 resolve(source); |
| 15496 assertErrors(source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); | 17244 assertErrors(source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); |
| 15497 verify([source]); | 17245 verify([source]); |
| 15498 } | 17246 } |
| 17247 |
| 15499 void test_partOfDifferentLibrary() { | 17248 void test_partOfDifferentLibrary() { |
| 15500 Source source = addSource(EngineTestCase.createSource(["library lib;", "part
'part.dart';"])); | 17249 Source source = addSource(EngineTestCase.createSource(["library lib;", "part
'part.dart';"])); |
| 15501 addSource2("/part.dart", EngineTestCase.createSource(["part of lub;"])); | 17250 addSource2("/part.dart", EngineTestCase.createSource(["part of lub;"])); |
| 15502 resolve(source); | 17251 resolve(source); |
| 15503 assertErrors(source, [StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]); | 17252 assertErrors(source, [StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]); |
| 15504 verify([source]); | 17253 verify([source]); |
| 15505 } | 17254 } |
| 17255 |
| 15506 void test_redirectToInvalidFunctionType() { | 17256 void test_redirectToInvalidFunctionType() { |
| 15507 Source source = addSource(EngineTestCase.createSource([ | 17257 Source source = addSource(EngineTestCase.createSource([ |
| 15508 "class A implements B {", | 17258 "class A implements B {", |
| 15509 " A(int p) {}", | 17259 " A(int p) {}", |
| 15510 "}", | 17260 "}", |
| 15511 "class B {", | 17261 "class B {", |
| 15512 " factory B() = A;", | 17262 " factory B() = A;", |
| 15513 "}"])); | 17263 "}"])); |
| 15514 resolve(source); | 17264 resolve(source); |
| 15515 assertErrors(source, [StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE]); | 17265 assertErrors(source, [StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE]); |
| 15516 verify([source]); | 17266 verify([source]); |
| 15517 } | 17267 } |
| 17268 |
| 15518 void test_redirectToInvalidReturnType() { | 17269 void test_redirectToInvalidReturnType() { |
| 15519 Source source = addSource(EngineTestCase.createSource([ | 17270 Source source = addSource(EngineTestCase.createSource([ |
| 15520 "class A {", | 17271 "class A {", |
| 15521 " A() {}", | 17272 " A() {}", |
| 15522 "}", | 17273 "}", |
| 15523 "class B {", | 17274 "class B {", |
| 15524 " factory B() = A;", | 17275 " factory B() = A;", |
| 15525 "}"])); | 17276 "}"])); |
| 15526 resolve(source); | 17277 resolve(source); |
| 15527 assertErrors(source, [StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]); | 17278 assertErrors(source, [StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]); |
| 15528 verify([source]); | 17279 verify([source]); |
| 15529 } | 17280 } |
| 17281 |
| 15530 void test_redirectToMissingConstructor_named() { | 17282 void test_redirectToMissingConstructor_named() { |
| 15531 Source source = addSource(EngineTestCase.createSource([ | 17283 Source source = addSource(EngineTestCase.createSource([ |
| 15532 "class A implements B{", | 17284 "class A implements B{", |
| 15533 " A() {}", | 17285 " A() {}", |
| 15534 "}", | 17286 "}", |
| 15535 "class B {", | 17287 "class B {", |
| 15536 " factory B() = A.name;", | 17288 " factory B() = A.name;", |
| 15537 "}"])); | 17289 "}"])); |
| 15538 resolve(source); | 17290 resolve(source); |
| 15539 assertErrors(source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); | 17291 assertErrors(source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); |
| 15540 } | 17292 } |
| 17293 |
| 15541 void test_redirectToMissingConstructor_unnamed() { | 17294 void test_redirectToMissingConstructor_unnamed() { |
| 15542 Source source = addSource(EngineTestCase.createSource([ | 17295 Source source = addSource(EngineTestCase.createSource([ |
| 15543 "class A implements B{", | 17296 "class A implements B{", |
| 15544 " A.name() {}", | 17297 " A.name() {}", |
| 15545 "}", | 17298 "}", |
| 15546 "class B {", | 17299 "class B {", |
| 15547 " factory B() = A;", | 17300 " factory B() = A;", |
| 15548 "}"])); | 17301 "}"])); |
| 15549 resolve(source); | 17302 resolve(source); |
| 15550 assertErrors(source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); | 17303 assertErrors(source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); |
| 15551 } | 17304 } |
| 17305 |
| 15552 void test_redirectToNonClass_notAType() { | 17306 void test_redirectToNonClass_notAType() { |
| 15553 Source source = addSource(EngineTestCase.createSource(["class B {", " int A
;", " factory B() = A;", "}"])); | 17307 Source source = addSource(EngineTestCase.createSource(["class B {", " int A
;", " factory B() = A;", "}"])); |
| 15554 resolve(source); | 17308 resolve(source); |
| 15555 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); | 17309 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); |
| 15556 verify([source]); | 17310 verify([source]); |
| 15557 } | 17311 } |
| 17312 |
| 15558 void test_redirectToNonClass_undefinedIdentifier() { | 17313 void test_redirectToNonClass_undefinedIdentifier() { |
| 15559 Source source = addSource(EngineTestCase.createSource(["class B {", " facto
ry B() = A;", "}"])); | 17314 Source source = addSource(EngineTestCase.createSource(["class B {", " facto
ry B() = A;", "}"])); |
| 15560 resolve(source); | 17315 resolve(source); |
| 15561 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); | 17316 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); |
| 15562 verify([source]); | 17317 verify([source]); |
| 15563 } | 17318 } |
| 17319 |
| 15564 void test_returnWithoutValue() { | 17320 void test_returnWithoutValue() { |
| 15565 Source source = addSource(EngineTestCase.createSource(["int f() { return; }"
])); | 17321 Source source = addSource(EngineTestCase.createSource(["int f() { return; }"
])); |
| 15566 resolve(source); | 17322 resolve(source); |
| 15567 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); | 17323 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); |
| 15568 verify([source]); | 17324 verify([source]); |
| 15569 } | 17325 } |
| 17326 |
| 15570 void test_staticAccessToInstanceMember_method_invocation() { | 17327 void test_staticAccessToInstanceMember_method_invocation() { |
| 15571 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", "}", "main() {", " A.m();", "}"])); | 17328 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", "}", "main() {", " A.m();", "}"])); |
| 15572 resolve(source); | 17329 resolve(source); |
| 15573 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); | 17330 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); |
| 15574 verify([source]); | 17331 verify([source]); |
| 15575 } | 17332 } |
| 17333 |
| 15576 void test_staticAccessToInstanceMember_method_reference() { | 17334 void test_staticAccessToInstanceMember_method_reference() { |
| 15577 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", "}", "main() {", " A.m;", "}"])); | 17335 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", "}", "main() {", " A.m;", "}"])); |
| 15578 resolve(source); | 17336 resolve(source); |
| 15579 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); | 17337 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); |
| 15580 verify([source]); | 17338 verify([source]); |
| 15581 } | 17339 } |
| 17340 |
| 15582 void test_staticAccessToInstanceMember_propertyAccess_field() { | 17341 void test_staticAccessToInstanceMember_propertyAccess_field() { |
| 15583 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
;", "}", "main() {", " A.f;", "}"])); | 17342 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
;", "}", "main() {", " A.f;", "}"])); |
| 15584 resolve(source); | 17343 resolve(source); |
| 15585 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); | 17344 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); |
| 15586 verify([source]); | 17345 verify([source]); |
| 15587 } | 17346 } |
| 17347 |
| 15588 void test_staticAccessToInstanceMember_propertyAccess_getter() { | 17348 void test_staticAccessToInstanceMember_propertyAccess_getter() { |
| 15589 Source source = addSource(EngineTestCase.createSource([ | 17349 Source source = addSource(EngineTestCase.createSource([ |
| 15590 "class A {", | 17350 "class A {", |
| 15591 " get f => 42;", | 17351 " get f => 42;", |
| 15592 "}", | 17352 "}", |
| 15593 "main() {", | 17353 "main() {", |
| 15594 " A.f;", | 17354 " A.f;", |
| 15595 "}"])); | 17355 "}"])); |
| 15596 resolve(source); | 17356 resolve(source); |
| 15597 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); | 17357 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); |
| 15598 verify([source]); | 17358 verify([source]); |
| 15599 } | 17359 } |
| 17360 |
| 15600 void test_staticAccessToInstanceMember_propertyAccess_setter() { | 17361 void test_staticAccessToInstanceMember_propertyAccess_setter() { |
| 15601 Source source = addSource(EngineTestCase.createSource([ | 17362 Source source = addSource(EngineTestCase.createSource([ |
| 15602 "class A {", | 17363 "class A {", |
| 15603 " set f(x) {}", | 17364 " set f(x) {}", |
| 15604 "}", | 17365 "}", |
| 15605 "main() {", | 17366 "main() {", |
| 15606 " A.f = 42;", | 17367 " A.f = 42;", |
| 15607 "}"])); | 17368 "}"])); |
| 15608 resolve(source); | 17369 resolve(source); |
| 15609 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); | 17370 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); |
| 15610 verify([source]); | 17371 verify([source]); |
| 15611 } | 17372 } |
| 17373 |
| 15612 void test_switchExpressionNotAssignable() { | 17374 void test_switchExpressionNotAssignable() { |
| 15613 Source source = addSource(EngineTestCase.createSource([ | 17375 Source source = addSource(EngineTestCase.createSource([ |
| 15614 "f(int p) {", | 17376 "f(int p) {", |
| 15615 " switch (p) {", | 17377 " switch (p) {", |
| 15616 " case 'a': break;", | 17378 " case 'a': break;", |
| 15617 " }", | 17379 " }", |
| 15618 "}"])); | 17380 "}"])); |
| 15619 resolve(source); | 17381 resolve(source); |
| 15620 assertErrors(source, [StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]); | 17382 assertErrors(source, [StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]); |
| 15621 verify([source]); | 17383 verify([source]); |
| 15622 } | 17384 } |
| 17385 |
| 15623 void test_typeParameterReferencedByStatic_field() { | 17386 void test_typeParameterReferencedByStatic_field() { |
| 15624 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K k;", "}"])); | 17387 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K k;", "}"])); |
| 15625 resolve(source); | 17388 resolve(source); |
| 15626 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); | 17389 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 15627 verify([source]); | 17390 verify([source]); |
| 15628 } | 17391 } |
| 17392 |
| 15629 void test_typeParameterReferencedByStatic_getter() { | 17393 void test_typeParameterReferencedByStatic_getter() { |
| 15630 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K get k => 0;", "}"])); | 17394 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K get k => 0;", "}"])); |
| 15631 resolve(source); | 17395 resolve(source); |
| 15632 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); | 17396 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 15633 verify([source]); | 17397 verify([source]); |
| 15634 } | 17398 } |
| 17399 |
| 15635 void test_typeParameterReferencedByStatic_methodBodyReference() { | 17400 void test_typeParameterReferencedByStatic_methodBodyReference() { |
| 15636 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic m() {", " K k;", " }", "}"])); | 17401 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic m() {", " K k;", " }", "}"])); |
| 15637 resolve(source); | 17402 resolve(source); |
| 15638 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); | 17403 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 15639 verify([source]); | 17404 verify([source]); |
| 15640 } | 17405 } |
| 17406 |
| 15641 void test_typeParameterReferencedByStatic_methodParameter() { | 17407 void test_typeParameterReferencedByStatic_methodParameter() { |
| 15642 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic m(K k) {}", "}"])); | 17408 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic m(K k) {}", "}"])); |
| 15643 resolve(source); | 17409 resolve(source); |
| 15644 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); | 17410 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 15645 verify([source]); | 17411 verify([source]); |
| 15646 } | 17412 } |
| 17413 |
| 15647 void test_typeParameterReferencedByStatic_methodReturn() { | 17414 void test_typeParameterReferencedByStatic_methodReturn() { |
| 15648 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K m() {}", "}"])); | 17415 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K m() {}", "}"])); |
| 15649 resolve(source); | 17416 resolve(source); |
| 15650 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); | 17417 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 15651 verify([source]); | 17418 verify([source]); |
| 15652 } | 17419 } |
| 17420 |
| 15653 void test_typeParameterReferencedByStatic_setter() { | 17421 void test_typeParameterReferencedByStatic_setter() { |
| 15654 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic set s(K k) {}", "}"])); | 17422 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic set s(K k) {}", "}"])); |
| 15655 resolve(source); | 17423 resolve(source); |
| 15656 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); | 17424 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 15657 verify([source]); | 17425 verify([source]); |
| 15658 } | 17426 } |
| 17427 |
| 15659 void test_typePromotion_functionType_arg_InterToDyn() { | 17428 void test_typePromotion_functionType_arg_InterToDyn() { |
| 15660 Source source = addSource(EngineTestCase.createSource([ | 17429 Source source = addSource(EngineTestCase.createSource([ |
| 15661 "typedef FuncDyn(x);", | 17430 "typedef FuncDyn(x);", |
| 15662 "typedef FuncA(A a);", | 17431 "typedef FuncA(A a);", |
| 15663 "class A {}", | 17432 "class A {}", |
| 15664 "class B {}", | 17433 "class B {}", |
| 15665 "main(FuncA f) {", | 17434 "main(FuncA f) {", |
| 15666 " if (f is FuncDyn) {", | 17435 " if (f is FuncDyn) {", |
| 15667 " f(new B());", | 17436 " f(new B());", |
| 15668 " }", | 17437 " }", |
| 15669 "}"])); | 17438 "}"])); |
| 15670 resolve(source); | 17439 resolve(source); |
| 15671 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 17440 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 15672 } | 17441 } |
| 17442 |
| 15673 void test_typeTestNonType() { | 17443 void test_typeTestNonType() { |
| 15674 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(var
p) {", " if (p is A) {", " }", "}"])); | 17444 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(var
p) {", " if (p is A) {", " }", "}"])); |
| 15675 resolve(source); | 17445 resolve(source); |
| 15676 assertErrors(source, [StaticWarningCode.TYPE_TEST_NON_TYPE]); | 17446 assertErrors(source, [StaticWarningCode.TYPE_TEST_NON_TYPE]); |
| 15677 verify([source]); | 17447 verify([source]); |
| 15678 } | 17448 } |
| 17449 |
| 15679 void test_undefinedClass_instanceCreation() { | 17450 void test_undefinedClass_instanceCreation() { |
| 15680 Source source = addSource(EngineTestCase.createSource(["f() { new C(); }"]))
; | 17451 Source source = addSource(EngineTestCase.createSource(["f() { new C(); }"]))
; |
| 15681 resolve(source); | 17452 resolve(source); |
| 15682 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]); | 17453 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]); |
| 15683 } | 17454 } |
| 17455 |
| 15684 void test_undefinedClass_variableDeclaration() { | 17456 void test_undefinedClass_variableDeclaration() { |
| 15685 Source source = addSource(EngineTestCase.createSource(["f() { C c; }"])); | 17457 Source source = addSource(EngineTestCase.createSource(["f() { C c; }"])); |
| 15686 resolve(source); | 17458 resolve(source); |
| 15687 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]); | 17459 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]); |
| 15688 } | 17460 } |
| 17461 |
| 15689 void test_undefinedClassBoolean_variableDeclaration() { | 17462 void test_undefinedClassBoolean_variableDeclaration() { |
| 15690 Source source = addSource(EngineTestCase.createSource(["f() { boolean v; }"]
)); | 17463 Source source = addSource(EngineTestCase.createSource(["f() { boolean v; }"]
)); |
| 15691 resolve(source); | 17464 resolve(source); |
| 15692 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]); | 17465 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]); |
| 15693 } | 17466 } |
| 17467 |
| 15694 void test_undefinedGetter_fromLibrary() { | 17468 void test_undefinedGetter_fromLibrary() { |
| 15695 Source source1 = addSource2("lib.dart", ""); | 17469 Source source1 = addSource2("lib.dart", ""); |
| 15696 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ | 17470 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ |
| 15697 "import 'lib.dart' as lib;", | 17471 "import 'lib.dart' as lib;", |
| 15698 "void f() {", | 17472 "void f() {", |
| 15699 " var g = lib.gg;", | 17473 " var g = lib.gg;", |
| 15700 "}"])); | 17474 "}"])); |
| 15701 resolve(source1); | 17475 resolve(source1); |
| 15702 resolve(source2); | 17476 resolve(source2); |
| 15703 assertErrors(source2, [StaticWarningCode.UNDEFINED_GETTER]); | 17477 assertErrors(source2, [StaticWarningCode.UNDEFINED_GETTER]); |
| 15704 verify([source1]); | 17478 verify([source1]); |
| 15705 } | 17479 } |
| 17480 |
| 15706 void test_undefinedIdentifier_for() { | 17481 void test_undefinedIdentifier_for() { |
| 15707 Source source = addSource(EngineTestCase.createSource(["f(var l) {", " for
(e in l) {", " }", "}"])); | 17482 Source source = addSource(EngineTestCase.createSource(["f(var l) {", " for
(e in l) {", " }", "}"])); |
| 15708 resolve(source); | 17483 resolve(source); |
| 15709 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 17484 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 15710 } | 17485 } |
| 17486 |
| 15711 void test_undefinedIdentifier_function() { | 17487 void test_undefinedIdentifier_function() { |
| 15712 Source source = addSource(EngineTestCase.createSource(["int a() => b;"])); | 17488 Source source = addSource(EngineTestCase.createSource(["int a() => b;"])); |
| 15713 resolve(source); | 17489 resolve(source); |
| 15714 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 17490 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 15715 } | 17491 } |
| 17492 |
| 15716 void test_undefinedIdentifier_function_prefix() { | 17493 void test_undefinedIdentifier_function_prefix() { |
| 15717 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
C {}"])); | 17494 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
C {}"])); |
| 15718 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
b;", "", "int a() => b;", "b.C c;"])); | 17495 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
b;", "", "int a() => b;", "b.C c;"])); |
| 15719 resolve(source); | 17496 resolve(source); |
| 15720 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 17497 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 15721 verify([source]); | 17498 verify([source]); |
| 15722 } | 17499 } |
| 17500 |
| 15723 void test_undefinedIdentifier_initializer() { | 17501 void test_undefinedIdentifier_initializer() { |
| 15724 Source source = addSource(EngineTestCase.createSource(["var a = b;"])); | 17502 Source source = addSource(EngineTestCase.createSource(["var a = b;"])); |
| 15725 resolve(source); | 17503 resolve(source); |
| 15726 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 17504 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 15727 } | 17505 } |
| 17506 |
| 15728 void test_undefinedIdentifier_initializer_prefix() { | 17507 void test_undefinedIdentifier_initializer_prefix() { |
| 15729 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
C {}"])); | 17508 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
C {}"])); |
| 15730 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
b;", "", "var a = b;", "b.C c;"])); | 17509 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
b;", "", "var a = b;", "b.C c;"])); |
| 15731 resolve(source); | 17510 resolve(source); |
| 15732 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 17511 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 15733 } | 17512 } |
| 17513 |
| 15734 void test_undefinedIdentifier_methodInvocation() { | 17514 void test_undefinedIdentifier_methodInvocation() { |
| 15735 Source source = addSource(EngineTestCase.createSource(["f() { C.m(); }"])); | 17515 Source source = addSource(EngineTestCase.createSource(["f() { C.m(); }"])); |
| 15736 resolve(source); | 17516 resolve(source); |
| 15737 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 17517 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 15738 } | 17518 } |
| 17519 |
| 15739 void test_undefinedIdentifier_private_getter() { | 17520 void test_undefinedIdentifier_private_getter() { |
| 15740 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {", " var _foo;", "}"])); | 17521 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {", " var _foo;", "}"])); |
| 15741 Source source = addSource(EngineTestCase.createSource([ | 17522 Source source = addSource(EngineTestCase.createSource([ |
| 15742 "import 'lib.dart';", | 17523 "import 'lib.dart';", |
| 15743 "class B extends A {", | 17524 "class B extends A {", |
| 15744 " test() {", | 17525 " test() {", |
| 15745 " var v = _foo;", | 17526 " var v = _foo;", |
| 15746 " }", | 17527 " }", |
| 15747 "}"])); | 17528 "}"])); |
| 15748 resolve(source); | 17529 resolve(source); |
| 15749 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 17530 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 15750 } | 17531 } |
| 17532 |
| 15751 void test_undefinedIdentifier_private_setter() { | 17533 void test_undefinedIdentifier_private_setter() { |
| 15752 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {", " var _foo;", "}"])); | 17534 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {", " var _foo;", "}"])); |
| 15753 Source source = addSource(EngineTestCase.createSource([ | 17535 Source source = addSource(EngineTestCase.createSource([ |
| 15754 "import 'lib.dart';", | 17536 "import 'lib.dart';", |
| 15755 "class B extends A {", | 17537 "class B extends A {", |
| 15756 " test() {", | 17538 " test() {", |
| 15757 " _foo = 42;", | 17539 " _foo = 42;", |
| 15758 " }", | 17540 " }", |
| 15759 "}"])); | 17541 "}"])); |
| 15760 resolve(source); | 17542 resolve(source); |
| 15761 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 17543 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 15762 } | 17544 } |
| 17545 |
| 15763 void test_undefinedNamedParameter() { | 17546 void test_undefinedNamedParameter() { |
| 15764 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main
() {", " f(c: 1);", "}"])); | 17547 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main
() {", " f(c: 1);", "}"])); |
| 15765 resolve(source); | 17548 resolve(source); |
| 15766 assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]); | 17549 assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]); |
| 15767 } | 17550 } |
| 17551 |
| 15768 void test_undefinedSetter() { | 17552 void test_undefinedSetter() { |
| 15769 Source source1 = addSource2("lib.dart", ""); | 17553 Source source1 = addSource2("lib.dart", ""); |
| 15770 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ | 17554 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ |
| 15771 "import 'lib.dart' as lib;", | 17555 "import 'lib.dart' as lib;", |
| 15772 "void f() {", | 17556 "void f() {", |
| 15773 " lib.gg = null;", | 17557 " lib.gg = null;", |
| 15774 "}"])); | 17558 "}"])); |
| 15775 resolve(source1); | 17559 resolve(source1); |
| 15776 resolve(source2); | 17560 resolve(source2); |
| 15777 assertErrors(source2, [StaticWarningCode.UNDEFINED_SETTER]); | 17561 assertErrors(source2, [StaticWarningCode.UNDEFINED_SETTER]); |
| 15778 } | 17562 } |
| 17563 |
| 17564 void test_undefinedStaticMethodOrGetter_getter() { |
| 17565 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " f(C.m);", "}"])); |
| 17566 resolve(source); |
| 17567 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 17568 } |
| 17569 |
| 17570 void test_undefinedStaticMethodOrGetter_getter_inSuperclass() { |
| 17571 Source source = addSource(EngineTestCase.createSource([ |
| 17572 "class S {", |
| 17573 " static int get g => 0;", |
| 17574 "}", |
| 17575 "class C extends S {}", |
| 17576 "f(var p) {", |
| 17577 " f(C.g);", |
| 17578 "}"])); |
| 17579 resolve(source); |
| 17580 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 17581 } |
| 17582 |
| 17583 void test_undefinedStaticMethodOrGetter_method() { |
| 17584 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " f(C.m());", "}"])); |
| 17585 resolve(source); |
| 17586 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); |
| 17587 } |
| 17588 |
| 17589 void test_undefinedStaticMethodOrGetter_method_inSuperclass() { |
| 17590 Source source = addSource(EngineTestCase.createSource([ |
| 17591 "class S {", |
| 17592 " static m() {}", |
| 17593 "}", |
| 17594 "class C extends S {}", |
| 17595 "f(var p) {", |
| 17596 " f(C.m());", |
| 17597 "}"])); |
| 17598 resolve(source); |
| 17599 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); |
| 17600 } |
| 17601 |
| 17602 void test_undefinedStaticMethodOrGetter_setter_inSuperclass() { |
| 17603 Source source = addSource(EngineTestCase.createSource([ |
| 17604 "class S {", |
| 17605 " static set s(int i) {}", |
| 17606 "}", |
| 17607 "class C extends S {}", |
| 17608 "f(var p) {", |
| 17609 " f(C.s = 1);", |
| 17610 "}"])); |
| 17611 resolve(source); |
| 17612 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]); |
| 17613 } |
| 17614 |
| 15779 static dartSuite() { | 17615 static dartSuite() { |
| 15780 _ut.group('StaticWarningCodeTest', () { | 17616 _ut.group('StaticWarningCodeTest', () { |
| 15781 _ut.test('test_ambiguousImport_as', () { | 17617 _ut.test('test_ambiguousImport_as', () { |
| 15782 final __test = new StaticWarningCodeTest(); | 17618 final __test = new StaticWarningCodeTest(); |
| 15783 runJUnitTest(__test, __test.test_ambiguousImport_as); | 17619 runJUnitTest(__test, __test.test_ambiguousImport_as); |
| 15784 }); | 17620 }); |
| 15785 _ut.test('test_ambiguousImport_extends', () { | 17621 _ut.test('test_ambiguousImport_extends', () { |
| 15786 final __test = new StaticWarningCodeTest(); | 17622 final __test = new StaticWarningCodeTest(); |
| 15787 runJUnitTest(__test, __test.test_ambiguousImport_extends); | 17623 runJUnitTest(__test, __test.test_ambiguousImport_extends); |
| 15788 }); | 17624 }); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15971 runJUnitTest(__test, __test.test_castToNonType); | 17807 runJUnitTest(__test, __test.test_castToNonType); |
| 15972 }); | 17808 }); |
| 15973 _ut.test('test_concreteClassWithAbstractMember', () { | 17809 _ut.test('test_concreteClassWithAbstractMember', () { |
| 15974 final __test = new StaticWarningCodeTest(); | 17810 final __test = new StaticWarningCodeTest(); |
| 15975 runJUnitTest(__test, __test.test_concreteClassWithAbstractMember); | 17811 runJUnitTest(__test, __test.test_concreteClassWithAbstractMember); |
| 15976 }); | 17812 }); |
| 15977 _ut.test('test_conflictingDartImport', () { | 17813 _ut.test('test_conflictingDartImport', () { |
| 15978 final __test = new StaticWarningCodeTest(); | 17814 final __test = new StaticWarningCodeTest(); |
| 15979 runJUnitTest(__test, __test.test_conflictingDartImport); | 17815 runJUnitTest(__test, __test.test_conflictingDartImport); |
| 15980 }); | 17816 }); |
| 17817 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_declField_dire
ct_setter', () { |
| 17818 final __test = new StaticWarningCodeTest(); |
| 17819 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_declField_direct_setter); |
| 17820 }); |
| 17821 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_declGetter_dir
ect_getter', () { |
| 17822 final __test = new StaticWarningCodeTest(); |
| 17823 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_declGetter_direct_getter); |
| 17824 }); |
| 17825 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_declGetter_dir
ect_method', () { |
| 17826 final __test = new StaticWarningCodeTest(); |
| 17827 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_declGetter_direct_method); |
| 17828 }); |
| 17829 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_declGetter_dir
ect_setter', () { |
| 17830 final __test = new StaticWarningCodeTest(); |
| 17831 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_declGetter_direct_setter); |
| 17832 }); |
| 17833 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_declGetter_ind
irect', () { |
| 17834 final __test = new StaticWarningCodeTest(); |
| 17835 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_declGetter_indirect); |
| 17836 }); |
| 17837 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_declGetter_mix
in', () { |
| 17838 final __test = new StaticWarningCodeTest(); |
| 17839 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_declGetter_mixin); |
| 17840 }); |
| 15981 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_field',
() { | 17841 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_field',
() { |
| 15982 final __test = new StaticWarningCodeTest(); | 17842 final __test = new StaticWarningCodeTest(); |
| 15983 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_direct_field); | 17843 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_direct_field); |
| 15984 }); | 17844 }); |
| 15985 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_getter'
, () { | 17845 _ut.test('test_conflictingInstanceMethodSetter_sameClass', () { |
| 15986 final __test = new StaticWarningCodeTest(); | 17846 final __test = new StaticWarningCodeTest(); |
| 15987 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_direct_getter); | 17847 runJUnitTest(__test, __test.test_conflictingInstanceMethodSetter_sameCla
ss); |
| 15988 }); | 17848 }); |
| 15989 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_method'
, () { | 17849 _ut.test('test_conflictingInstanceMethodSetter_setterInInterface', () { |
| 15990 final __test = new StaticWarningCodeTest(); | 17850 final __test = new StaticWarningCodeTest(); |
| 15991 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_direct_method); | 17851 runJUnitTest(__test, __test.test_conflictingInstanceMethodSetter_setterI
nInterface); |
| 15992 }); | 17852 }); |
| 15993 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_setter'
, () { | 17853 _ut.test('test_conflictingInstanceMethodSetter_setterInSuper', () { |
| 15994 final __test = new StaticWarningCodeTest(); | 17854 final __test = new StaticWarningCodeTest(); |
| 15995 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_direct_setter); | 17855 runJUnitTest(__test, __test.test_conflictingInstanceMethodSetter_setterI
nSuper); |
| 15996 }); | |
| 15997 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_indirect', ()
{ | |
| 15998 final __test = new StaticWarningCodeTest(); | |
| 15999 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_indirect); | |
| 16000 }); | |
| 16001 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_mixin', () { | |
| 16002 final __test = new StaticWarningCodeTest(); | |
| 16003 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM
ember_mixin); | |
| 16004 }); | 17856 }); |
| 16005 _ut.test('test_conflictingInstanceSetterAndSuperclassMember', () { | 17857 _ut.test('test_conflictingInstanceSetterAndSuperclassMember', () { |
| 16006 final __test = new StaticWarningCodeTest(); | 17858 final __test = new StaticWarningCodeTest(); |
| 16007 runJUnitTest(__test, __test.test_conflictingInstanceSetterAndSuperclassM
ember); | 17859 runJUnitTest(__test, __test.test_conflictingInstanceSetterAndSuperclassM
ember); |
| 16008 }); | 17860 }); |
| 16009 _ut.test('test_conflictingStaticGetterAndInstanceSetter_mixin', () { | 17861 _ut.test('test_conflictingStaticGetterAndInstanceSetter_mixin', () { |
| 16010 final __test = new StaticWarningCodeTest(); | 17862 final __test = new StaticWarningCodeTest(); |
| 16011 runJUnitTest(__test, __test.test_conflictingStaticGetterAndInstanceSette
r_mixin); | 17863 runJUnitTest(__test, __test.test_conflictingStaticGetterAndInstanceSette
r_mixin); |
| 16012 }); | 17864 }); |
| 16013 _ut.test('test_conflictingStaticGetterAndInstanceSetter_superClass', () { | 17865 _ut.test('test_conflictingStaticGetterAndInstanceSetter_superClass', () { |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16507 runJUnitTest(__test, __test.test_undefinedIdentifier_private_setter); | 18359 runJUnitTest(__test, __test.test_undefinedIdentifier_private_setter); |
| 16508 }); | 18360 }); |
| 16509 _ut.test('test_undefinedNamedParameter', () { | 18361 _ut.test('test_undefinedNamedParameter', () { |
| 16510 final __test = new StaticWarningCodeTest(); | 18362 final __test = new StaticWarningCodeTest(); |
| 16511 runJUnitTest(__test, __test.test_undefinedNamedParameter); | 18363 runJUnitTest(__test, __test.test_undefinedNamedParameter); |
| 16512 }); | 18364 }); |
| 16513 _ut.test('test_undefinedSetter', () { | 18365 _ut.test('test_undefinedSetter', () { |
| 16514 final __test = new StaticWarningCodeTest(); | 18366 final __test = new StaticWarningCodeTest(); |
| 16515 runJUnitTest(__test, __test.test_undefinedSetter); | 18367 runJUnitTest(__test, __test.test_undefinedSetter); |
| 16516 }); | 18368 }); |
| 18369 _ut.test('test_undefinedStaticMethodOrGetter_getter', () { |
| 18370 final __test = new StaticWarningCodeTest(); |
| 18371 runJUnitTest(__test, __test.test_undefinedStaticMethodOrGetter_getter); |
| 18372 }); |
| 18373 _ut.test('test_undefinedStaticMethodOrGetter_getter_inSuperclass', () { |
| 18374 final __test = new StaticWarningCodeTest(); |
| 18375 runJUnitTest(__test, __test.test_undefinedStaticMethodOrGetter_getter_in
Superclass); |
| 18376 }); |
| 18377 _ut.test('test_undefinedStaticMethodOrGetter_method', () { |
| 18378 final __test = new StaticWarningCodeTest(); |
| 18379 runJUnitTest(__test, __test.test_undefinedStaticMethodOrGetter_method); |
| 18380 }); |
| 18381 _ut.test('test_undefinedStaticMethodOrGetter_method_inSuperclass', () { |
| 18382 final __test = new StaticWarningCodeTest(); |
| 18383 runJUnitTest(__test, __test.test_undefinedStaticMethodOrGetter_method_in
Superclass); |
| 18384 }); |
| 18385 _ut.test('test_undefinedStaticMethodOrGetter_setter_inSuperclass', () { |
| 18386 final __test = new StaticWarningCodeTest(); |
| 18387 runJUnitTest(__test, __test.test_undefinedStaticMethodOrGetter_setter_in
Superclass); |
| 18388 }); |
| 16517 }); | 18389 }); |
| 16518 } | 18390 } |
| 16519 } | 18391 } |
| 18392 |
| 16520 class ErrorResolverTest extends ResolverTestCase { | 18393 class ErrorResolverTest extends ResolverTestCase { |
| 16521 void test_breakLabelOnSwitchMember() { | 18394 void test_breakLabelOnSwitchMember() { |
| 16522 Source source = addSource(EngineTestCase.createSource([ | 18395 Source source = addSource(EngineTestCase.createSource([ |
| 16523 "class A {", | 18396 "class A {", |
| 16524 " void m(int i) {", | 18397 " void m(int i) {", |
| 16525 " switch (i) {", | 18398 " switch (i) {", |
| 16526 " l: case 0:", | 18399 " l: case 0:", |
| 16527 " break;", | 18400 " break;", |
| 16528 " case 1:", | 18401 " case 1:", |
| 16529 " break l;", | 18402 " break l;", |
| 16530 " }", | 18403 " }", |
| 16531 " }", | 18404 " }", |
| 16532 "}"])); | 18405 "}"])); |
| 16533 resolve(source); | 18406 resolve(source); |
| 16534 assertErrors(source, [ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]); | 18407 assertErrors(source, [ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]); |
| 16535 verify([source]); | 18408 verify([source]); |
| 16536 } | 18409 } |
| 18410 |
| 16537 void test_continueLabelOnSwitch() { | 18411 void test_continueLabelOnSwitch() { |
| 16538 Source source = addSource(EngineTestCase.createSource([ | 18412 Source source = addSource(EngineTestCase.createSource([ |
| 16539 "class A {", | 18413 "class A {", |
| 16540 " void m(int i) {", | 18414 " void m(int i) {", |
| 16541 " l: switch (i) {", | 18415 " l: switch (i) {", |
| 16542 " case 0:", | 18416 " case 0:", |
| 16543 " continue l;", | 18417 " continue l;", |
| 16544 " }", | 18418 " }", |
| 16545 " }", | 18419 " }", |
| 16546 "}"])); | 18420 "}"])); |
| 16547 resolve(source); | 18421 resolve(source); |
| 16548 assertErrors(source, [ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]); | 18422 assertErrors(source, [ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]); |
| 16549 verify([source]); | 18423 verify([source]); |
| 16550 } | 18424 } |
| 18425 |
| 16551 static dartSuite() { | 18426 static dartSuite() { |
| 16552 _ut.group('ErrorResolverTest', () { | 18427 _ut.group('ErrorResolverTest', () { |
| 16553 _ut.test('test_breakLabelOnSwitchMember', () { | 18428 _ut.test('test_breakLabelOnSwitchMember', () { |
| 16554 final __test = new ErrorResolverTest(); | 18429 final __test = new ErrorResolverTest(); |
| 16555 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember); | 18430 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember); |
| 16556 }); | 18431 }); |
| 16557 _ut.test('test_continueLabelOnSwitch', () { | 18432 _ut.test('test_continueLabelOnSwitch', () { |
| 16558 final __test = new ErrorResolverTest(); | 18433 final __test = new ErrorResolverTest(); |
| 16559 runJUnitTest(__test, __test.test_continueLabelOnSwitch); | 18434 runJUnitTest(__test, __test.test_continueLabelOnSwitch); |
| 16560 }); | 18435 }); |
| 16561 }); | 18436 }); |
| 16562 } | 18437 } |
| 16563 } | 18438 } |
| 18439 |
| 16564 /** | 18440 /** |
| 16565 * Instances of the class `TestTypeProvider` implement a type provider that can
be used by | 18441 * Instances of the class `TestTypeProvider` implement a type provider that can
be used by |
| 16566 * tests without creating the element model for the core library. | 18442 * tests without creating the element model for the core library. |
| 16567 */ | 18443 */ |
| 16568 class TestTypeProvider implements TypeProvider { | 18444 class TestTypeProvider implements TypeProvider { |
| 16569 | |
| 16570 /** | 18445 /** |
| 16571 * The type representing the built-in type 'bool'. | 18446 * The type representing the built-in type 'bool'. |
| 16572 */ | 18447 */ |
| 16573 InterfaceType _boolType; | 18448 InterfaceType _boolType; |
| 16574 | 18449 |
| 16575 /** | 18450 /** |
| 16576 * The type representing the type 'bottom'. | 18451 * The type representing the type 'bottom'. |
| 16577 */ | 18452 */ |
| 16578 Type2 _bottomType; | 18453 Type2 _bottomType; |
| 16579 | 18454 |
| 16580 /** | 18455 /** |
| 16581 * The type representing the built-in type 'double'. | 18456 * The type representing the built-in type 'double'. |
| 16582 */ | 18457 */ |
| 16583 InterfaceType _doubleType; | 18458 InterfaceType _doubleType; |
| 16584 | 18459 |
| 16585 /** | 18460 /** |
| 18461 * The type representing the built-in type 'deprecated'. |
| 18462 */ |
| 18463 InterfaceType _deprecatedType; |
| 18464 |
| 18465 /** |
| 16586 * The type representing the built-in type 'dynamic'. | 18466 * The type representing the built-in type 'dynamic'. |
| 16587 */ | 18467 */ |
| 16588 Type2 _dynamicType; | 18468 Type2 _dynamicType; |
| 16589 | 18469 |
| 16590 /** | 18470 /** |
| 16591 * The type representing the built-in type 'Function'. | 18471 * The type representing the built-in type 'Function'. |
| 16592 */ | 18472 */ |
| 16593 InterfaceType _functionType; | 18473 InterfaceType _functionType; |
| 16594 | 18474 |
| 16595 /** | 18475 /** |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16644 | 18524 |
| 16645 /** | 18525 /** |
| 16646 * The type representing the built-in type 'Symbol'. | 18526 * The type representing the built-in type 'Symbol'. |
| 16647 */ | 18527 */ |
| 16648 InterfaceType _symbolType; | 18528 InterfaceType _symbolType; |
| 16649 | 18529 |
| 16650 /** | 18530 /** |
| 16651 * The type representing the built-in type 'Type'. | 18531 * The type representing the built-in type 'Type'. |
| 16652 */ | 18532 */ |
| 16653 InterfaceType _typeType; | 18533 InterfaceType _typeType; |
| 18534 |
| 16654 InterfaceType get boolType { | 18535 InterfaceType get boolType { |
| 16655 if (_boolType == null) { | 18536 if (_boolType == null) { |
| 16656 _boolType = ElementFactory.classElement2("bool", []).type; | 18537 _boolType = ElementFactory.classElement2("bool", []).type; |
| 16657 } | 18538 } |
| 16658 return _boolType; | 18539 return _boolType; |
| 16659 } | 18540 } |
| 18541 |
| 16660 Type2 get bottomType { | 18542 Type2 get bottomType { |
| 16661 if (_bottomType == null) { | 18543 if (_bottomType == null) { |
| 16662 _bottomType = BottomTypeImpl.instance; | 18544 _bottomType = BottomTypeImpl.instance; |
| 16663 } | 18545 } |
| 16664 return _bottomType; | 18546 return _bottomType; |
| 16665 } | 18547 } |
| 18548 |
| 18549 InterfaceType get deprecatedType { |
| 18550 if (_deprecatedType == null) { |
| 18551 ClassElementImpl deprecatedElement = ElementFactory.classElement2("Depreca
ted", []); |
| 18552 deprecatedElement.constructors = <ConstructorElement> [ElementFactory.cons
tructorElement(deprecatedElement, null, true, [stringType])]; |
| 18553 _deprecatedType = deprecatedElement.type; |
| 18554 } |
| 18555 return _deprecatedType; |
| 18556 } |
| 18557 |
| 16666 InterfaceType get doubleType { | 18558 InterfaceType get doubleType { |
| 16667 if (_doubleType == null) { | 18559 if (_doubleType == null) { |
| 16668 initializeNumericTypes(); | 18560 initializeNumericTypes(); |
| 16669 } | 18561 } |
| 16670 return _doubleType; | 18562 return _doubleType; |
| 16671 } | 18563 } |
| 18564 |
| 16672 Type2 get dynamicType { | 18565 Type2 get dynamicType { |
| 16673 if (_dynamicType == null) { | 18566 if (_dynamicType == null) { |
| 16674 _dynamicType = DynamicTypeImpl.instance; | 18567 _dynamicType = DynamicTypeImpl.instance; |
| 16675 } | 18568 } |
| 16676 return _dynamicType; | 18569 return _dynamicType; |
| 16677 } | 18570 } |
| 18571 |
| 16678 InterfaceType get functionType { | 18572 InterfaceType get functionType { |
| 16679 if (_functionType == null) { | 18573 if (_functionType == null) { |
| 16680 _functionType = ElementFactory.classElement2("Function", []).type; | 18574 _functionType = ElementFactory.classElement2("Function", []).type; |
| 16681 } | 18575 } |
| 16682 return _functionType; | 18576 return _functionType; |
| 16683 } | 18577 } |
| 18578 |
| 16684 InterfaceType get intType { | 18579 InterfaceType get intType { |
| 16685 if (_intType == null) { | 18580 if (_intType == null) { |
| 16686 initializeNumericTypes(); | 18581 initializeNumericTypes(); |
| 16687 } | 18582 } |
| 16688 return _intType; | 18583 return _intType; |
| 16689 } | 18584 } |
| 18585 |
| 16690 InterfaceType get iterableType { | 18586 InterfaceType get iterableType { |
| 16691 if (_iterableType == null) { | 18587 if (_iterableType == null) { |
| 16692 ClassElementImpl iterableElement = ElementFactory.classElement2("Iterable"
, ["E"]); | 18588 ClassElementImpl iterableElement = ElementFactory.classElement2("Iterable"
, ["E"]); |
| 16693 _iterableType = iterableElement.type; | 18589 _iterableType = iterableElement.type; |
| 16694 Type2 eType = iterableElement.typeParameters[0].type; | 18590 Type2 eType = iterableElement.typeParameters[0].type; |
| 16695 iterableElement.accessors = <PropertyAccessorElement> [ | 18591 iterableElement.accessors = <PropertyAccessorElement> [ |
| 16696 ElementFactory.getterElement("iterator", false, iteratorType.substitut
e4(<Type2> [eType])), | 18592 ElementFactory.getterElement("iterator", false, iteratorType.substitut
e4(<Type2> [eType])), |
| 16697 ElementFactory.getterElement("last", false, eType)]; | 18593 ElementFactory.getterElement("last", false, eType)]; |
| 16698 propagateTypeArguments(iterableElement); | 18594 propagateTypeArguments(iterableElement); |
| 16699 } | 18595 } |
| 16700 return _iterableType; | 18596 return _iterableType; |
| 16701 } | 18597 } |
| 18598 |
| 16702 InterfaceType get iteratorType { | 18599 InterfaceType get iteratorType { |
| 16703 if (_iteratorType == null) { | 18600 if (_iteratorType == null) { |
| 16704 ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator"
, ["E"]); | 18601 ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator"
, ["E"]); |
| 16705 _iteratorType = iteratorElement.type; | 18602 _iteratorType = iteratorElement.type; |
| 16706 Type2 eType = iteratorElement.typeParameters[0].type; | 18603 Type2 eType = iteratorElement.typeParameters[0].type; |
| 16707 iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.gett
erElement("current", false, eType)]; | 18604 iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.gett
erElement("current", false, eType)]; |
| 16708 propagateTypeArguments(iteratorElement); | 18605 propagateTypeArguments(iteratorElement); |
| 16709 } | 18606 } |
| 16710 return _iteratorType; | 18607 return _iteratorType; |
| 16711 } | 18608 } |
| 18609 |
| 16712 InterfaceType get listType { | 18610 InterfaceType get listType { |
| 16713 if (_listType == null) { | 18611 if (_listType == null) { |
| 16714 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"])
; | 18612 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"])
; |
| 16715 listElement.constructors = <ConstructorElement> [ElementFactory.constructo
rElement(listElement, null)]; | 18613 listElement.constructors = <ConstructorElement> [ElementFactory.constructo
rElement2(listElement, null, [])]; |
| 16716 _listType = listElement.type; | 18614 _listType = listElement.type; |
| 16717 Type2 eType = listElement.typeParameters[0].type; | 18615 Type2 eType = listElement.typeParameters[0].type; |
| 16718 InterfaceType iterableType = this.iterableType.substitute4(<Type2> [eType]
); | 18616 InterfaceType iterableType = this.iterableType.substitute4(<Type2> [eType]
); |
| 16719 listElement.interfaces = <InterfaceType> [iterableType]; | 18617 listElement.interfaces = <InterfaceType> [iterableType]; |
| 16720 listElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEl
ement("length", false, intType)]; | 18618 listElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEl
ement("length", false, intType)]; |
| 16721 listElement.methods = <MethodElement> [ | 18619 listElement.methods = <MethodElement> [ |
| 16722 ElementFactory.methodElement("[]", eType, [intType]), | 18620 ElementFactory.methodElement("[]", eType, [intType]), |
| 16723 ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [intType, e
Type]), | 18621 ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [intType, e
Type]), |
| 16724 ElementFactory.methodElement("add", VoidTypeImpl.instance, [eType])]; | 18622 ElementFactory.methodElement("add", VoidTypeImpl.instance, [eType])]; |
| 16725 propagateTypeArguments(listElement); | 18623 propagateTypeArguments(listElement); |
| 16726 } | 18624 } |
| 16727 return _listType; | 18625 return _listType; |
| 16728 } | 18626 } |
| 18627 |
| 16729 InterfaceType get mapType { | 18628 InterfaceType get mapType { |
| 16730 if (_mapType == null) { | 18629 if (_mapType == null) { |
| 16731 ClassElementImpl mapElement = ElementFactory.classElement2("Map", ["K", "V
"]); | 18630 ClassElementImpl mapElement = ElementFactory.classElement2("Map", ["K", "V
"]); |
| 16732 _mapType = mapElement.type; | 18631 _mapType = mapElement.type; |
| 16733 mapElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEle
ment("length", false, intType)]; | 18632 mapElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEle
ment("length", false, intType)]; |
| 16734 propagateTypeArguments(mapElement); | 18633 propagateTypeArguments(mapElement); |
| 16735 } | 18634 } |
| 16736 return _mapType; | 18635 return _mapType; |
| 16737 } | 18636 } |
| 18637 |
| 16738 InterfaceType get nullType { | 18638 InterfaceType get nullType { |
| 16739 if (_nullType == null) { | 18639 if (_nullType == null) { |
| 16740 _nullType = ElementFactory.classElement2("Null", []).type; | 18640 _nullType = ElementFactory.classElement2("Null", []).type; |
| 16741 } | 18641 } |
| 16742 return _nullType; | 18642 return _nullType; |
| 16743 } | 18643 } |
| 18644 |
| 16744 InterfaceType get numType { | 18645 InterfaceType get numType { |
| 16745 if (_numType == null) { | 18646 if (_numType == null) { |
| 16746 initializeNumericTypes(); | 18647 initializeNumericTypes(); |
| 16747 } | 18648 } |
| 16748 return _numType; | 18649 return _numType; |
| 16749 } | 18650 } |
| 18651 |
| 16750 InterfaceType get objectType { | 18652 InterfaceType get objectType { |
| 16751 if (_objectType == null) { | 18653 if (_objectType == null) { |
| 16752 ClassElementImpl objectElement = ElementFactory.object; | 18654 ClassElementImpl objectElement = ElementFactory.object; |
| 16753 _objectType = objectElement.type; | 18655 _objectType = objectElement.type; |
| 16754 objectElement.constructors = <ConstructorElement> [ElementFactory.construc
torElement(objectElement, null)]; | 18656 objectElement.constructors = <ConstructorElement> [ElementFactory.construc
torElement2(objectElement, null, [])]; |
| 16755 objectElement.methods = <MethodElement> [ | 18657 objectElement.methods = <MethodElement> [ |
| 16756 ElementFactory.methodElement("toString", stringType, []), | 18658 ElementFactory.methodElement("toString", stringType, []), |
| 16757 ElementFactory.methodElement("==", boolType, [_objectType]), | 18659 ElementFactory.methodElement("==", boolType, [_objectType]), |
| 16758 ElementFactory.methodElement("noSuchMethod", dynamicType, [dynamicType
])]; | 18660 ElementFactory.methodElement("noSuchMethod", dynamicType, [dynamicType
])]; |
| 16759 objectElement.accessors = <PropertyAccessorElement> [ | 18661 objectElement.accessors = <PropertyAccessorElement> [ |
| 16760 ElementFactory.getterElement("hashCode", false, intType), | 18662 ElementFactory.getterElement("hashCode", false, intType), |
| 16761 ElementFactory.getterElement("runtimeType", false, typeType)]; | 18663 ElementFactory.getterElement("runtimeType", false, typeType)]; |
| 16762 } | 18664 } |
| 16763 return _objectType; | 18665 return _objectType; |
| 16764 } | 18666 } |
| 18667 |
| 16765 InterfaceType get stackTraceType { | 18668 InterfaceType get stackTraceType { |
| 16766 if (_stackTraceType == null) { | 18669 if (_stackTraceType == null) { |
| 16767 _stackTraceType = ElementFactory.classElement2("StackTrace", []).type; | 18670 _stackTraceType = ElementFactory.classElement2("StackTrace", []).type; |
| 16768 } | 18671 } |
| 16769 return _stackTraceType; | 18672 return _stackTraceType; |
| 16770 } | 18673 } |
| 18674 |
| 16771 InterfaceType get stringType { | 18675 InterfaceType get stringType { |
| 16772 if (_stringType == null) { | 18676 if (_stringType == null) { |
| 16773 _stringType = ElementFactory.classElement2("String", []).type; | 18677 _stringType = ElementFactory.classElement2("String", []).type; |
| 16774 ClassElementImpl stringElement = _stringType.element as ClassElementImpl; | 18678 ClassElementImpl stringElement = _stringType.element as ClassElementImpl; |
| 16775 stringElement.accessors = <PropertyAccessorElement> [ | 18679 stringElement.accessors = <PropertyAccessorElement> [ |
| 16776 ElementFactory.getterElement("isEmpty", false, boolType), | 18680 ElementFactory.getterElement("isEmpty", false, boolType), |
| 16777 ElementFactory.getterElement("length", false, intType), | 18681 ElementFactory.getterElement("length", false, intType), |
| 16778 ElementFactory.getterElement("codeUnits", false, listType.substitute4(
<Type2> [intType]))]; | 18682 ElementFactory.getterElement("codeUnits", false, listType.substitute4(
<Type2> [intType]))]; |
| 16779 stringElement.methods = <MethodElement> [ | 18683 stringElement.methods = <MethodElement> [ |
| 16780 ElementFactory.methodElement("+", _stringType, [_stringType]), | 18684 ElementFactory.methodElement("+", _stringType, [_stringType]), |
| 16781 ElementFactory.methodElement("toLowerCase", _stringType, []), | 18685 ElementFactory.methodElement("toLowerCase", _stringType, []), |
| 16782 ElementFactory.methodElement("toUpperCase", _stringType, [])]; | 18686 ElementFactory.methodElement("toUpperCase", _stringType, [])]; |
| 16783 } | 18687 } |
| 16784 return _stringType; | 18688 return _stringType; |
| 16785 } | 18689 } |
| 18690 |
| 16786 InterfaceType get symbolType { | 18691 InterfaceType get symbolType { |
| 16787 if (_symbolType == null) { | 18692 if (_symbolType == null) { |
| 16788 _symbolType = ElementFactory.classElement2("Symbol", []).type; | 18693 _symbolType = ElementFactory.classElement2("Symbol", []).type; |
| 16789 } | 18694 } |
| 16790 return _symbolType; | 18695 return _symbolType; |
| 16791 } | 18696 } |
| 18697 |
| 16792 InterfaceType get typeType { | 18698 InterfaceType get typeType { |
| 16793 if (_typeType == null) { | 18699 if (_typeType == null) { |
| 16794 _typeType = ElementFactory.classElement2("Type", []).type; | 18700 _typeType = ElementFactory.classElement2("Type", []).type; |
| 16795 } | 18701 } |
| 16796 return _typeType; | 18702 return _typeType; |
| 16797 } | 18703 } |
| 16798 | 18704 |
| 16799 /** | 18705 /** |
| 16800 * Initialize the numeric types. They are created as a group so that we can (a
) create the right | 18706 * Initialize the numeric types. They are created as a group so that we can (a
) create the right |
| 16801 * hierarchy and (b) add members to them. | 18707 * hierarchy and (b) add members to them. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16895 for (MethodElement method in classElement.methods) { | 18801 for (MethodElement method in classElement.methods) { |
| 16896 FunctionTypeImpl functionType = method.type as FunctionTypeImpl; | 18802 FunctionTypeImpl functionType = method.type as FunctionTypeImpl; |
| 16897 functionType.typeArguments = typeArguments; | 18803 functionType.typeArguments = typeArguments; |
| 16898 } | 18804 } |
| 16899 for (ConstructorElement constructor in classElement.constructors) { | 18805 for (ConstructorElement constructor in classElement.constructors) { |
| 16900 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl; | 18806 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl; |
| 16901 functionType.typeArguments = typeArguments; | 18807 functionType.typeArguments = typeArguments; |
| 16902 } | 18808 } |
| 16903 } | 18809 } |
| 16904 } | 18810 } |
| 18811 |
| 16905 /** | 18812 /** |
| 16906 * The class `AnalysisContextFactory` defines utility methods used to create ana
lysis contexts | 18813 * The class `AnalysisContextFactory` defines utility methods used to create ana
lysis contexts |
| 16907 * for testing purposes. | 18814 * for testing purposes. |
| 16908 */ | 18815 */ |
| 16909 class AnalysisContextFactory { | 18816 class AnalysisContextFactory { |
| 16910 | |
| 16911 /** | 18817 /** |
| 16912 * Create an analysis context that has a fake core library already resolved. | 18818 * Create an analysis context that has a fake core library already resolved. |
| 16913 * | 18819 * |
| 16914 * @return the analysis context that was created | 18820 * @return the analysis context that was created |
| 16915 */ | 18821 */ |
| 16916 static AnalysisContextImpl contextWithCore() { | 18822 static AnalysisContextImpl contextWithCore() { |
| 16917 AnalysisContext sdkContext = DirectoryBasedDartSdk.defaultSdk.context; | 18823 AnalysisContext sdkContext = DirectoryBasedDartSdk.defaultSdk.context; |
| 16918 SourceFactory sourceFactory = sdkContext.sourceFactory; | 18824 SourceFactory sourceFactory = sdkContext.sourceFactory; |
| 16919 TestTypeProvider provider = new TestTypeProvider(); | 18825 TestTypeProvider provider = new TestTypeProvider(); |
| 16920 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d
art"); | 18826 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d
art"); |
| 16921 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); | 18827 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
| 16922 sdkContext.setContents(coreSource, ""); | 18828 sdkContext.setContents(coreSource, ""); |
| 16923 coreUnit.source = coreSource; | 18829 coreUnit.source = coreSource; |
| 16924 coreUnit.types = <ClassElement> [ | 18830 coreUnit.types = <ClassElement> [ |
| 16925 provider.boolType.element, | 18831 provider.boolType.element, |
| 18832 provider.deprecatedType.element, |
| 16926 provider.doubleType.element, | 18833 provider.doubleType.element, |
| 16927 provider.functionType.element, | 18834 provider.functionType.element, |
| 16928 provider.intType.element, | 18835 provider.intType.element, |
| 16929 provider.listType.element, | 18836 provider.listType.element, |
| 16930 provider.mapType.element, | 18837 provider.mapType.element, |
| 16931 provider.nullType.element, | 18838 provider.nullType.element, |
| 16932 provider.numType.element, | 18839 provider.numType.element, |
| 16933 provider.objectType.element, | 18840 provider.objectType.element, |
| 16934 provider.stackTraceType.element, | 18841 provider.stackTraceType.element, |
| 16935 provider.stringType.element, | 18842 provider.stringType.element, |
| 16936 provider.symbolType.element, | 18843 provider.symbolType.element, |
| 16937 provider.typeType.element]; | 18844 provider.typeType.element]; |
| 16938 coreUnit.functions = <FunctionElement> [ElementFactory.functionElement3("ide
ntical", provider.boolType.element, <ClassElement> [provider.objectType.element,
provider.objectType.element], null)]; | 18845 coreUnit.functions = <FunctionElement> [ElementFactory.functionElement3("ide
ntical", provider.boolType.element, <ClassElement> [provider.objectType.element,
provider.objectType.element], null)]; |
| 18846 TopLevelVariableElement proxyTopLevelVariableElt = ElementFactory.topLevelVa
riableElement3("proxy", true, false, ElementFactory.classElement2("_Proxy", []).
type); |
| 18847 TopLevelVariableElement deprecatedTopLevelVariableElt = ElementFactory.topLe
velVariableElement3("deprecated", true, false, provider.deprecatedType); |
| 18848 coreUnit.accessors = <PropertyAccessorElement> [ |
| 18849 proxyTopLevelVariableElt.getter, |
| 18850 proxyTopLevelVariableElt.setter, |
| 18851 deprecatedTopLevelVariableElt.getter, |
| 18852 deprecatedTopLevelVariableElt.setter]; |
| 18853 coreUnit.topLevelVariables = <TopLevelVariableElement> [proxyTopLevelVariabl
eElt, deprecatedTopLevelVariableElt]; |
| 16939 LibraryElementImpl coreLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "core"])); | 18854 LibraryElementImpl coreLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "core"])); |
| 16940 coreLibrary.definingCompilationUnit = coreUnit; | 18855 coreLibrary.definingCompilationUnit = coreUnit; |
| 16941 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d
artium.dart"); | 18856 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d
artium.dart"); |
| 16942 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 18857 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
| 16943 sdkContext.setContents(htmlSource, ""); | 18858 sdkContext.setContents(htmlSource, ""); |
| 16944 htmlUnit.source = htmlSource; | 18859 htmlUnit.source = htmlSource; |
| 16945 ClassElementImpl elementElement = ElementFactory.classElement2("Element", []
); | 18860 ClassElementImpl elementElement = ElementFactory.classElement2("Element", []
); |
| 16946 InterfaceType elementType = elementElement.type; | 18861 InterfaceType elementType = elementElement.type; |
| 16947 ClassElementImpl documentElement = ElementFactory.classElement("Document", e
lementType, []); | 18862 ClassElementImpl documentElement = ElementFactory.classElement("Document", e
lementType, []); |
| 16948 ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocu
ment", documentElement.type, []); | 18863 ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocu
ment", documentElement.type, []); |
| 16949 htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement(
"query", elementType, <Type2> [provider.stringType])]; | 18864 htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement(
"query", elementType, <Type2> [provider.stringType])]; |
| 16950 htmlUnit.types = <ClassElement> [ | 18865 htmlUnit.types = <ClassElement> [ |
| 16951 ElementFactory.classElement("AnchorElement", elementType, []), | 18866 ElementFactory.classElement("AnchorElement", elementType, []), |
| 16952 ElementFactory.classElement("BodyElement", elementType, []), | 18867 ElementFactory.classElement("BodyElement", elementType, []), |
| 16953 ElementFactory.classElement("ButtonElement", elementType, []), | 18868 ElementFactory.classElement("ButtonElement", elementType, []), |
| 16954 ElementFactory.classElement("DivElement", elementType, []), | 18869 ElementFactory.classElement("DivElement", elementType, []), |
| 16955 documentElement, | 18870 documentElement, |
| 16956 elementElement, | 18871 elementElement, |
| 16957 htmlDocumentElement, | 18872 htmlDocumentElement, |
| 16958 ElementFactory.classElement("InputElement", elementType, []), | 18873 ElementFactory.classElement("InputElement", elementType, []), |
| 16959 ElementFactory.classElement("SelectElement", elementType, [])]; | 18874 ElementFactory.classElement("SelectElement", elementType, [])]; |
| 16960 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que
ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI
mpl.EMPTY_ARRAY)]; | 18875 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que
ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI
mpl.EMPTY_ARRAY)]; |
| 16961 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen
t3("document", true, htmlDocumentElement.type); | 18876 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen
t3("document", false, true, htmlDocumentElement.type); |
| 16962 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document]; | 18877 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document]; |
| 16963 htmlUnit.accessors = <PropertyAccessorElement> [document.getter]; | 18878 htmlUnit.accessors = <PropertyAccessorElement> [document.getter]; |
| 16964 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "dom", "html"])); | 18879 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "dom", "html"])); |
| 16965 htmlLibrary.definingCompilationUnit = htmlUnit; | 18880 htmlLibrary.definingCompilationUnit = htmlUnit; |
| 16966 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); | 18881 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); |
| 16967 elementMap[coreSource] = coreLibrary; | 18882 elementMap[coreSource] = coreLibrary; |
| 16968 elementMap[htmlSource] = htmlLibrary; | 18883 elementMap[htmlSource] = htmlLibrary; |
| 16969 ((sdkContext as AnalysisContextImpl)).recordLibraryElements(elementMap); | 18884 (sdkContext as AnalysisContextImpl).recordLibraryElements(elementMap); |
| 16970 AnalysisContextImpl context = new DelegatingAnalysisContextImpl(); | 18885 AnalysisContextImpl context = new DelegatingAnalysisContextImpl(); |
| 16971 sourceFactory = new SourceFactory.con2([ | 18886 sourceFactory = new SourceFactory.con2([ |
| 16972 new DartUriResolver(sdkContext.sourceFactory.dartSdk), | 18887 new DartUriResolver(sdkContext.sourceFactory.dartSdk), |
| 16973 new FileUriResolver()]); | 18888 new FileUriResolver()]); |
| 16974 context.sourceFactory = sourceFactory; | 18889 context.sourceFactory = sourceFactory; |
| 16975 return context; | 18890 return context; |
| 16976 } | 18891 } |
| 16977 } | 18892 } |
| 18893 |
| 16978 class LibraryImportScopeTest extends ResolverTestCase { | 18894 class LibraryImportScopeTest extends ResolverTestCase { |
| 16979 void test_conflictingImports() { | 18895 void test_conflictingImports() { |
| 16980 AnalysisContext context = new AnalysisContextImpl(); | 18896 AnalysisContext context = new AnalysisContextImpl(); |
| 16981 String typeNameA = "A"; | 18897 String typeNameA = "A"; |
| 16982 String typeNameB = "B"; | 18898 String typeNameB = "B"; |
| 16983 String typeNameC = "C"; | 18899 String typeNameC = "C"; |
| 16984 ClassElement typeA = ElementFactory.classElement2(typeNameA, []); | 18900 ClassElement typeA = ElementFactory.classElement2(typeNameA, []); |
| 16985 ClassElement typeB1 = ElementFactory.classElement2(typeNameB, []); | 18901 ClassElement typeB1 = ElementFactory.classElement2(typeNameB, []); |
| 16986 ClassElement typeB2 = ElementFactory.classElement2(typeNameB, []); | 18902 ClassElement typeB2 = ElementFactory.classElement2(typeNameB, []); |
| 16987 ClassElement typeC = ElementFactory.classElement2(typeNameC, []); | 18903 ClassElement typeC = ElementFactory.classElement2(typeNameC, []); |
| 16988 LibraryElement importedLibrary1 = createTestLibrary2(context, "imported1", [
]); | 18904 LibraryElement importedLibrary1 = createTestLibrary2(context, "imported1", [
]); |
| 16989 ((importedLibrary1.definingCompilationUnit as CompilationUnitElementImpl)).t
ypes = <ClassElement> [typeA, typeB1]; | 18905 (importedLibrary1.definingCompilationUnit as CompilationUnitElementImpl).typ
es = <ClassElement> [typeA, typeB1]; |
| 16990 ImportElementImpl import1 = ElementFactory.importFor(importedLibrary1, null,
[]); | 18906 ImportElementImpl import1 = ElementFactory.importFor(importedLibrary1, null,
[]); |
| 16991 LibraryElement importedLibrary2 = createTestLibrary2(context, "imported2", [
]); | 18907 LibraryElement importedLibrary2 = createTestLibrary2(context, "imported2", [
]); |
| 16992 ((importedLibrary2.definingCompilationUnit as CompilationUnitElementImpl)).t
ypes = <ClassElement> [typeB2, typeC]; | 18908 (importedLibrary2.definingCompilationUnit as CompilationUnitElementImpl).typ
es = <ClassElement> [typeB2, typeC]; |
| 16993 ImportElementImpl import2 = ElementFactory.importFor(importedLibrary2, null,
[]); | 18909 ImportElementImpl import2 = ElementFactory.importFor(importedLibrary2, null,
[]); |
| 16994 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing
", []); | 18910 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing
", []); |
| 16995 importingLibrary.imports = <ImportElement> [import1, import2]; | 18911 importingLibrary.imports = <ImportElement> [import1, import2]; |
| 16996 { | 18912 { |
| 16997 GatheringErrorListener errorListener = new GatheringErrorListener(); | 18913 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 16998 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | 18914 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
| 16999 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(type
NameA), importingLibrary)); | 18915 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(type
NameA), importingLibrary)); |
| 17000 errorListener.assertNoErrors(); | 18916 errorListener.assertNoErrors(); |
| 17001 JUnitTestCase.assertEquals(typeC, scope.lookup(ASTFactory.identifier3(type
NameC), importingLibrary)); | 18917 JUnitTestCase.assertEquals(typeC, scope.lookup(ASTFactory.identifier3(type
NameC), importingLibrary)); |
| 17002 errorListener.assertNoErrors(); | 18918 errorListener.assertNoErrors(); |
| 17003 Element element = scope.lookup(ASTFactory.identifier3(typeNameB), importin
gLibrary); | 18919 Element element = scope.lookup(ASTFactory.identifier3(typeNameB), importin
gLibrary); |
| 17004 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]); | 18920 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 17005 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); | 18921 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); |
| 17006 List<Element> conflictingElements = ((element as MultiplyDefinedElement)).
conflictingElements; | 18922 List<Element> conflictingElements = (element as MultiplyDefinedElement).co
nflictingElements; |
| 17007 EngineTestCase.assertLength(2, conflictingElements); | 18923 EngineTestCase.assertLength(2, conflictingElements); |
| 17008 if (identical(conflictingElements[0], typeB1)) { | 18924 if (identical(conflictingElements[0], typeB1)) { |
| 17009 JUnitTestCase.assertSame(typeB2, conflictingElements[1]); | 18925 JUnitTestCase.assertSame(typeB2, conflictingElements[1]); |
| 17010 } else if (identical(conflictingElements[0], typeB2)) { | 18926 } else if (identical(conflictingElements[0], typeB2)) { |
| 17011 JUnitTestCase.assertSame(typeB1, conflictingElements[1]); | 18927 JUnitTestCase.assertSame(typeB1, conflictingElements[1]); |
| 17012 } else { | 18928 } else { |
| 17013 JUnitTestCase.assertSame(typeB1, conflictingElements[0]); | 18929 JUnitTestCase.assertSame(typeB1, conflictingElements[0]); |
| 17014 } | 18930 } |
| 17015 } | 18931 } |
| 17016 { | 18932 { |
| 17017 GatheringErrorListener errorListener = new GatheringErrorListener(); | 18933 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 17018 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | 18934 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
| 17019 Identifier identifier = ASTFactory.identifier3(typeNameB); | 18935 Identifier identifier = ASTFactory.identifier3(typeNameB); |
| 17020 ASTFactory.methodDeclaration(null, ASTFactory.typeName3(identifier, []), n
ull, null, ASTFactory.identifier3("foo"), null); | 18936 ASTFactory.methodDeclaration(null, ASTFactory.typeName3(identifier, []), n
ull, null, ASTFactory.identifier3("foo"), null); |
| 17021 Element element = scope.lookup(identifier, importingLibrary); | 18937 Element element = scope.lookup(identifier, importingLibrary); |
| 17022 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]); | 18938 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 17023 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); | 18939 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); |
| 17024 } | 18940 } |
| 17025 } | 18941 } |
| 18942 |
| 17026 void test_creation_empty() { | 18943 void test_creation_empty() { |
| 17027 LibraryElement definingLibrary = createTestLibrary(); | 18944 LibraryElement definingLibrary = createTestLibrary(); |
| 17028 GatheringErrorListener errorListener = new GatheringErrorListener(); | 18945 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 17029 new LibraryImportScope(definingLibrary, errorListener); | 18946 new LibraryImportScope(definingLibrary, errorListener); |
| 17030 } | 18947 } |
| 18948 |
| 17031 void test_creation_nonEmpty() { | 18949 void test_creation_nonEmpty() { |
| 17032 AnalysisContext context = new AnalysisContextImpl(); | 18950 AnalysisContext context = new AnalysisContextImpl(); |
| 17033 String importedTypeName = "A"; | 18951 String importedTypeName = "A"; |
| 17034 ClassElement importedType = new ClassElementImpl(ASTFactory.identifier3(impo
rtedTypeName)); | 18952 ClassElement importedType = new ClassElementImpl(ASTFactory.identifier3(impo
rtedTypeName)); |
| 17035 LibraryElement importedLibrary = createTestLibrary2(context, "imported", [])
; | 18953 LibraryElement importedLibrary = createTestLibrary2(context, "imported", [])
; |
| 17036 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty
pes = <ClassElement> [importedType]; | 18954 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).type
s = <ClassElement> [importedType]; |
| 17037 LibraryElementImpl definingLibrary = createTestLibrary2(context, "importing"
, []); | 18955 LibraryElementImpl definingLibrary = createTestLibrary2(context, "importing"
, []); |
| 17038 ImportElementImpl importElement = new ImportElementImpl(); | 18956 ImportElementImpl importElement = new ImportElementImpl(); |
| 17039 importElement.importedLibrary = importedLibrary; | 18957 importElement.importedLibrary = importedLibrary; |
| 17040 definingLibrary.imports = <ImportElement> [importElement]; | 18958 definingLibrary.imports = <ImportElement> [importElement]; |
| 17041 GatheringErrorListener errorListener = new GatheringErrorListener(); | 18959 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 17042 Scope scope = new LibraryImportScope(definingLibrary, errorListener); | 18960 Scope scope = new LibraryImportScope(definingLibrary, errorListener); |
| 17043 JUnitTestCase.assertEquals(importedType, scope.lookup(ASTFactory.identifier3
(importedTypeName), definingLibrary)); | 18961 JUnitTestCase.assertEquals(importedType, scope.lookup(ASTFactory.identifier3
(importedTypeName), definingLibrary)); |
| 17044 } | 18962 } |
| 18963 |
| 17045 void test_getErrorListener() { | 18964 void test_getErrorListener() { |
| 17046 LibraryElement definingLibrary = createTestLibrary(); | 18965 LibraryElement definingLibrary = createTestLibrary(); |
| 17047 GatheringErrorListener errorListener = new GatheringErrorListener(); | 18966 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 17048 LibraryImportScope scope = new LibraryImportScope(definingLibrary, errorList
ener); | 18967 LibraryImportScope scope = new LibraryImportScope(definingLibrary, errorList
ener); |
| 17049 JUnitTestCase.assertEquals(errorListener, scope.errorListener); | 18968 JUnitTestCase.assertEquals(errorListener, scope.errorListener); |
| 17050 } | 18969 } |
| 18970 |
| 17051 void test_nonConflictingImports_fromSdk() { | 18971 void test_nonConflictingImports_fromSdk() { |
| 17052 AnalysisContext context = AnalysisContextFactory.contextWithCore(); | 18972 AnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 17053 String typeName = "List"; | 18973 String typeName = "List"; |
| 17054 ClassElement type = ElementFactory.classElement2(typeName, []); | 18974 ClassElement type = ElementFactory.classElement2(typeName, []); |
| 17055 LibraryElement importedLibrary = createTestLibrary2(context, "lib", []); | 18975 LibraryElement importedLibrary = createTestLibrary2(context, "lib", []); |
| 17056 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty
pes = <ClassElement> [type]; | 18976 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).type
s = <ClassElement> [type]; |
| 17057 ImportElementImpl importCore = ElementFactory.importFor(context.getLibraryEl
ement(context.sourceFactory.forUri("dart:core")), null, []); | 18977 ImportElementImpl importCore = ElementFactory.importFor(context.getLibraryEl
ement(context.sourceFactory.forUri("dart:core")), null, []); |
| 17058 ImportElementImpl importLib = ElementFactory.importFor(importedLibrary, null
, []); | 18978 ImportElementImpl importLib = ElementFactory.importFor(importedLibrary, null
, []); |
| 17059 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing
", []); | 18979 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing
", []); |
| 17060 importingLibrary.imports = <ImportElement> [importCore, importLib]; | 18980 importingLibrary.imports = <ImportElement> [importCore, importLib]; |
| 17061 GatheringErrorListener errorListener = new GatheringErrorListener(); | 18981 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 17062 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | 18982 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
| 17063 JUnitTestCase.assertEquals(type, scope.lookup(ASTFactory.identifier3(typeNam
e), importingLibrary)); | 18983 JUnitTestCase.assertEquals(type, scope.lookup(ASTFactory.identifier3(typeNam
e), importingLibrary)); |
| 17064 errorListener.assertErrors2([StaticWarningCode.CONFLICTING_DART_IMPORT]); | 18984 errorListener.assertErrors2([StaticWarningCode.CONFLICTING_DART_IMPORT]); |
| 17065 } | 18985 } |
| 18986 |
| 17066 void test_nonConflictingImports_sameElement() { | 18987 void test_nonConflictingImports_sameElement() { |
| 17067 AnalysisContext context = new AnalysisContextImpl(); | 18988 AnalysisContext context = new AnalysisContextImpl(); |
| 17068 String typeNameA = "A"; | 18989 String typeNameA = "A"; |
| 17069 String typeNameB = "B"; | 18990 String typeNameB = "B"; |
| 17070 ClassElement typeA = ElementFactory.classElement2(typeNameA, []); | 18991 ClassElement typeA = ElementFactory.classElement2(typeNameA, []); |
| 17071 ClassElement typeB = ElementFactory.classElement2(typeNameB, []); | 18992 ClassElement typeB = ElementFactory.classElement2(typeNameB, []); |
| 17072 LibraryElement importedLibrary = createTestLibrary2(context, "imported", [])
; | 18993 LibraryElement importedLibrary = createTestLibrary2(context, "imported", [])
; |
| 17073 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty
pes = <ClassElement> [typeA, typeB]; | 18994 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).type
s = <ClassElement> [typeA, typeB]; |
| 17074 ImportElementImpl import1 = ElementFactory.importFor(importedLibrary, null,
[]); | 18995 ImportElementImpl import1 = ElementFactory.importFor(importedLibrary, null,
[]); |
| 17075 ImportElementImpl import2 = ElementFactory.importFor(importedLibrary, null,
[]); | 18996 ImportElementImpl import2 = ElementFactory.importFor(importedLibrary, null,
[]); |
| 17076 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing
", []); | 18997 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing
", []); |
| 17077 importingLibrary.imports = <ImportElement> [import1, import2]; | 18998 importingLibrary.imports = <ImportElement> [import1, import2]; |
| 17078 GatheringErrorListener errorListener = new GatheringErrorListener(); | 18999 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 17079 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | 19000 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
| 17080 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(typeNa
meA), importingLibrary)); | 19001 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(typeNa
meA), importingLibrary)); |
| 17081 errorListener.assertNoErrors(); | 19002 errorListener.assertNoErrors(); |
| 17082 JUnitTestCase.assertEquals(typeB, scope.lookup(ASTFactory.identifier3(typeNa
meB), importingLibrary)); | 19003 JUnitTestCase.assertEquals(typeB, scope.lookup(ASTFactory.identifier3(typeNa
meB), importingLibrary)); |
| 17083 errorListener.assertNoErrors(); | 19004 errorListener.assertNoErrors(); |
| 17084 } | 19005 } |
| 19006 |
| 17085 void test_prefixedAndNonPrefixed() { | 19007 void test_prefixedAndNonPrefixed() { |
| 17086 AnalysisContext context = new AnalysisContextImpl(); | 19008 AnalysisContext context = new AnalysisContextImpl(); |
| 17087 String typeName = "C"; | 19009 String typeName = "C"; |
| 17088 String prefixName = "p"; | 19010 String prefixName = "p"; |
| 17089 ClassElement prefixedType = ElementFactory.classElement2(typeName, []); | 19011 ClassElement prefixedType = ElementFactory.classElement2(typeName, []); |
| 17090 ClassElement nonPrefixedType = ElementFactory.classElement2(typeName, []); | 19012 ClassElement nonPrefixedType = ElementFactory.classElement2(typeName, []); |
| 17091 LibraryElement prefixedLibrary = createTestLibrary2(context, "import.prefixe
d", []); | 19013 LibraryElement prefixedLibrary = createTestLibrary2(context, "import.prefixe
d", []); |
| 17092 ((prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty
pes = <ClassElement> [prefixedType]; | 19014 (prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl).type
s = <ClassElement> [prefixedType]; |
| 17093 ImportElementImpl prefixedImport = ElementFactory.importFor(prefixedLibrary,
ElementFactory.prefix(prefixName), []); | 19015 ImportElementImpl prefixedImport = ElementFactory.importFor(prefixedLibrary,
ElementFactory.prefix(prefixName), []); |
| 17094 LibraryElement nonPrefixedLibrary = createTestLibrary2(context, "import.nonP
refixed", []); | 19016 LibraryElement nonPrefixedLibrary = createTestLibrary2(context, "import.nonP
refixed", []); |
| 17095 ((nonPrefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl))
.types = <ClassElement> [nonPrefixedType]; | 19017 (nonPrefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl).t
ypes = <ClassElement> [nonPrefixedType]; |
| 17096 ImportElementImpl nonPrefixedImport = ElementFactory.importFor(nonPrefixedLi
brary, null, []); | 19018 ImportElementImpl nonPrefixedImport = ElementFactory.importFor(nonPrefixedLi
brary, null, []); |
| 17097 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing
", []); | 19019 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing
", []); |
| 17098 importingLibrary.imports = <ImportElement> [prefixedImport, nonPrefixedImpor
t]; | 19020 importingLibrary.imports = <ImportElement> [prefixedImport, nonPrefixedImpor
t]; |
| 17099 GatheringErrorListener errorListener = new GatheringErrorListener(); | 19021 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 17100 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | 19022 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
| 17101 Element prefixedElement = scope.lookup(ASTFactory.identifier5(prefixName, ty
peName), importingLibrary); | 19023 Element prefixedElement = scope.lookup(ASTFactory.identifier5(prefixName, ty
peName), importingLibrary); |
| 17102 errorListener.assertNoErrors(); | 19024 errorListener.assertNoErrors(); |
| 17103 JUnitTestCase.assertSame(prefixedType, prefixedElement); | 19025 JUnitTestCase.assertSame(prefixedType, prefixedElement); |
| 17104 Element nonPrefixedElement = scope.lookup(ASTFactory.identifier3(typeName),
importingLibrary); | 19026 Element nonPrefixedElement = scope.lookup(ASTFactory.identifier3(typeName),
importingLibrary); |
| 17105 errorListener.assertNoErrors(); | 19027 errorListener.assertNoErrors(); |
| 17106 JUnitTestCase.assertSame(nonPrefixedType, nonPrefixedElement); | 19028 JUnitTestCase.assertSame(nonPrefixedType, nonPrefixedElement); |
| 17107 } | 19029 } |
| 19030 |
| 17108 static dartSuite() { | 19031 static dartSuite() { |
| 17109 _ut.group('LibraryImportScopeTest', () { | 19032 _ut.group('LibraryImportScopeTest', () { |
| 17110 _ut.test('test_conflictingImports', () { | 19033 _ut.test('test_conflictingImports', () { |
| 17111 final __test = new LibraryImportScopeTest(); | 19034 final __test = new LibraryImportScopeTest(); |
| 17112 runJUnitTest(__test, __test.test_conflictingImports); | 19035 runJUnitTest(__test, __test.test_conflictingImports); |
| 17113 }); | 19036 }); |
| 17114 _ut.test('test_creation_empty', () { | 19037 _ut.test('test_creation_empty', () { |
| 17115 final __test = new LibraryImportScopeTest(); | 19038 final __test = new LibraryImportScopeTest(); |
| 17116 runJUnitTest(__test, __test.test_creation_empty); | 19039 runJUnitTest(__test, __test.test_creation_empty); |
| 17117 }); | 19040 }); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 17131 final __test = new LibraryImportScopeTest(); | 19054 final __test = new LibraryImportScopeTest(); |
| 17132 runJUnitTest(__test, __test.test_nonConflictingImports_sameElement); | 19055 runJUnitTest(__test, __test.test_nonConflictingImports_sameElement); |
| 17133 }); | 19056 }); |
| 17134 _ut.test('test_prefixedAndNonPrefixed', () { | 19057 _ut.test('test_prefixedAndNonPrefixed', () { |
| 17135 final __test = new LibraryImportScopeTest(); | 19058 final __test = new LibraryImportScopeTest(); |
| 17136 runJUnitTest(__test, __test.test_prefixedAndNonPrefixed); | 19059 runJUnitTest(__test, __test.test_prefixedAndNonPrefixed); |
| 17137 }); | 19060 }); |
| 17138 }); | 19061 }); |
| 17139 } | 19062 } |
| 17140 } | 19063 } |
| 19064 |
| 19065 class IncrementalResolverTest extends ResolverTestCase { |
| 19066 void test_resolve() { |
| 19067 MethodDeclaration method = resolveMethod(EngineTestCase.createSource([ |
| 19068 "class C {", |
| 19069 " int m(int a) {", |
| 19070 " return a + a;", |
| 19071 " }", |
| 19072 "}"])); |
| 19073 BlockFunctionBody body = method.body as BlockFunctionBody; |
| 19074 ReturnStatement statement = body.block.statements[0] as ReturnStatement; |
| 19075 BinaryExpression expression = statement.expression as BinaryExpression; |
| 19076 SimpleIdentifier left = expression.leftOperand as SimpleIdentifier; |
| 19077 Element leftElement = left.staticElement; |
| 19078 SimpleIdentifier right = expression.rightOperand as SimpleIdentifier; |
| 19079 Element rightElement = right.staticElement; |
| 19080 JUnitTestCase.assertNotNull(leftElement); |
| 19081 JUnitTestCase.assertSame(leftElement, rightElement); |
| 19082 } |
| 19083 |
| 19084 MethodDeclaration resolveMethod(String content) { |
| 19085 Source source = addSource(content); |
| 19086 LibraryElement library = resolve(source); |
| 19087 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 19088 ClassDeclaration classNode = unit.declarations[0] as ClassDeclaration; |
| 19089 MethodDeclaration method = classNode.members[0] as MethodDeclaration; |
| 19090 method.body.accept(new ResolutionEraser()); |
| 19091 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 19092 IncrementalResolver resolver = new IncrementalResolver(library, source, type
Provider, errorListener); |
| 19093 resolver.resolve(method.body); |
| 19094 return method; |
| 19095 } |
| 19096 |
| 19097 static dartSuite() { |
| 19098 _ut.group('IncrementalResolverTest', () { |
| 19099 _ut.test('test_resolve', () { |
| 19100 final __test = new IncrementalResolverTest(); |
| 19101 runJUnitTest(__test, __test.test_resolve); |
| 19102 }); |
| 19103 }); |
| 19104 } |
| 19105 } |
| 19106 |
| 17141 /** | 19107 /** |
| 17142 * Instances of the class `ResolutionVerifier` verify that all of the nodes in a
n AST | 19108 * Instances of the class `ResolutionVerifier` verify that all of the nodes in a
n AST |
| 17143 * structure that should have been resolved were resolved. | 19109 * structure that should have been resolved were resolved. |
| 17144 */ | 19110 */ |
| 17145 class ResolutionVerifier extends RecursiveASTVisitor<Object> { | 19111 class ResolutionVerifier extends RecursiveASTVisitor<Object> { |
| 17146 | |
| 17147 /** | 19112 /** |
| 17148 * A set containing nodes that are known to not be resolvable and should there
fore not cause the | 19113 * A set containing nodes that are known to not be resolvable and should there
fore not cause the |
| 17149 * test to fail. | 19114 * test to fail. |
| 17150 */ | 19115 */ |
| 17151 Set<ASTNode> _knownExceptions; | 19116 Set<ASTNode> _knownExceptions; |
| 17152 | 19117 |
| 17153 /** | 19118 /** |
| 17154 * A list containing all of the AST nodes that were not resolved. | 19119 * A list containing all of the AST nodes that were not resolved. |
| 17155 */ | 19120 */ |
| 17156 List<ASTNode> _unresolvedNodes = new List<ASTNode>(); | 19121 List<ASTNode> _unresolvedNodes = new List<ASTNode>(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17193 } | 19158 } |
| 17194 if (!_wrongTypedNodes.isEmpty) { | 19159 if (!_wrongTypedNodes.isEmpty) { |
| 17195 writer.print("Resolved "); | 19160 writer.print("Resolved "); |
| 17196 writer.print(_wrongTypedNodes.length); | 19161 writer.print(_wrongTypedNodes.length); |
| 17197 writer.println(" to the wrong type of element:"); | 19162 writer.println(" to the wrong type of element:"); |
| 17198 printNodes(writer, _wrongTypedNodes); | 19163 printNodes(writer, _wrongTypedNodes); |
| 17199 } | 19164 } |
| 17200 JUnitTestCase.fail(writer.toString()); | 19165 JUnitTestCase.fail(writer.toString()); |
| 17201 } | 19166 } |
| 17202 } | 19167 } |
| 19168 |
| 17203 Object visitBinaryExpression(BinaryExpression node) { | 19169 Object visitBinaryExpression(BinaryExpression node) { |
| 17204 node.visitChildren(this); | 19170 node.visitChildren(this); |
| 17205 if (!node.operator.isUserDefinableOperator) { | 19171 if (!node.operator.isUserDefinableOperator) { |
| 17206 return null; | 19172 return null; |
| 17207 } | 19173 } |
| 17208 Type2 operandType = node.leftOperand.staticType; | 19174 Type2 operandType = node.leftOperand.staticType; |
| 17209 if (operandType == null || operandType.isDynamic) { | 19175 if (operandType == null || operandType.isDynamic) { |
| 17210 return null; | 19176 return null; |
| 17211 } | 19177 } |
| 17212 return checkResolved2(node, node.staticElement, MethodElement); | 19178 return checkResolved2(node, node.staticElement, MethodElement); |
| 17213 } | 19179 } |
| 19180 |
| 17214 Object visitCommentReference(CommentReference node) => null; | 19181 Object visitCommentReference(CommentReference node) => null; |
| 19182 |
| 17215 Object visitCompilationUnit(CompilationUnit node) { | 19183 Object visitCompilationUnit(CompilationUnit node) { |
| 17216 node.visitChildren(this); | 19184 node.visitChildren(this); |
| 17217 return checkResolved2(node, node.element, CompilationUnitElement); | 19185 return checkResolved2(node, node.element, CompilationUnitElement); |
| 17218 } | 19186 } |
| 19187 |
| 17219 Object visitExportDirective(ExportDirective node) => checkResolved2(node, node
.element, ExportElement); | 19188 Object visitExportDirective(ExportDirective node) => checkResolved2(node, node
.element, ExportElement); |
| 19189 |
| 17220 Object visitFunctionDeclaration(FunctionDeclaration node) { | 19190 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 17221 node.visitChildren(this); | 19191 node.visitChildren(this); |
| 17222 if (node.element is LibraryElement) { | 19192 if (node.element is LibraryElement) { |
| 17223 _wrongTypedNodes.add(node); | 19193 _wrongTypedNodes.add(node); |
| 17224 } | 19194 } |
| 17225 return null; | 19195 return null; |
| 17226 } | 19196 } |
| 19197 |
| 17227 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 19198 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 17228 node.visitChildren(this); | 19199 node.visitChildren(this); |
| 17229 return null; | 19200 return null; |
| 17230 } | 19201 } |
| 19202 |
| 17231 Object visitImportDirective(ImportDirective node) { | 19203 Object visitImportDirective(ImportDirective node) { |
| 17232 checkResolved2(node, node.element, ImportElement); | 19204 checkResolved2(node, node.element, ImportElement); |
| 17233 SimpleIdentifier prefix = node.prefix; | 19205 SimpleIdentifier prefix = node.prefix; |
| 17234 if (prefix == null) { | 19206 if (prefix == null) { |
| 17235 return null; | 19207 return null; |
| 17236 } | 19208 } |
| 17237 return checkResolved2(prefix, prefix.staticElement, PrefixElement); | 19209 return checkResolved2(prefix, prefix.staticElement, PrefixElement); |
| 17238 } | 19210 } |
| 19211 |
| 17239 Object visitIndexExpression(IndexExpression node) { | 19212 Object visitIndexExpression(IndexExpression node) { |
| 17240 node.visitChildren(this); | 19213 node.visitChildren(this); |
| 17241 Type2 targetType = node.realTarget.staticType; | 19214 Type2 targetType = node.realTarget.staticType; |
| 17242 if (targetType == null || targetType.isDynamic) { | 19215 if (targetType == null || targetType.isDynamic) { |
| 17243 return null; | 19216 return null; |
| 17244 } | 19217 } |
| 17245 return checkResolved2(node, node.staticElement, MethodElement); | 19218 return checkResolved2(node, node.staticElement, MethodElement); |
| 17246 } | 19219 } |
| 19220 |
| 17247 Object visitLibraryDirective(LibraryDirective node) => checkResolved2(node, no
de.element, LibraryElement); | 19221 Object visitLibraryDirective(LibraryDirective node) => checkResolved2(node, no
de.element, LibraryElement); |
| 19222 |
| 17248 Object visitNamedExpression(NamedExpression node) => node.expression.accept(th
is); | 19223 Object visitNamedExpression(NamedExpression node) => node.expression.accept(th
is); |
| 19224 |
| 17249 Object visitPartDirective(PartDirective node) => checkResolved2(node, node.ele
ment, CompilationUnitElement); | 19225 Object visitPartDirective(PartDirective node) => checkResolved2(node, node.ele
ment, CompilationUnitElement); |
| 19226 |
| 17250 Object visitPartOfDirective(PartOfDirective node) => checkResolved2(node, node
.element, LibraryElement); | 19227 Object visitPartOfDirective(PartOfDirective node) => checkResolved2(node, node
.element, LibraryElement); |
| 19228 |
| 17251 Object visitPostfixExpression(PostfixExpression node) { | 19229 Object visitPostfixExpression(PostfixExpression node) { |
| 17252 node.visitChildren(this); | 19230 node.visitChildren(this); |
| 17253 if (!node.operator.isUserDefinableOperator) { | 19231 if (!node.operator.isUserDefinableOperator) { |
| 17254 return null; | 19232 return null; |
| 17255 } | 19233 } |
| 17256 Type2 operandType = node.operand.staticType; | 19234 Type2 operandType = node.operand.staticType; |
| 17257 if (operandType == null || operandType.isDynamic) { | 19235 if (operandType == null || operandType.isDynamic) { |
| 17258 return null; | 19236 return null; |
| 17259 } | 19237 } |
| 17260 return checkResolved2(node, node.staticElement, MethodElement); | 19238 return checkResolved2(node, node.staticElement, MethodElement); |
| 17261 } | 19239 } |
| 19240 |
| 17262 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 19241 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 17263 SimpleIdentifier prefix = node.prefix; | 19242 SimpleIdentifier prefix = node.prefix; |
| 17264 prefix.accept(this); | 19243 prefix.accept(this); |
| 17265 Type2 prefixType = prefix.staticType; | 19244 Type2 prefixType = prefix.staticType; |
| 17266 if (prefixType == null || prefixType.isDynamic) { | 19245 if (prefixType == null || prefixType.isDynamic) { |
| 17267 return null; | 19246 return null; |
| 17268 } | 19247 } |
| 17269 return checkResolved(node, node.staticElement); | 19248 return checkResolved(node, node.staticElement); |
| 17270 } | 19249 } |
| 19250 |
| 17271 Object visitPrefixExpression(PrefixExpression node) { | 19251 Object visitPrefixExpression(PrefixExpression node) { |
| 17272 node.visitChildren(this); | 19252 node.visitChildren(this); |
| 17273 if (!node.operator.isUserDefinableOperator) { | 19253 if (!node.operator.isUserDefinableOperator) { |
| 17274 return null; | 19254 return null; |
| 17275 } | 19255 } |
| 17276 Type2 operandType = node.operand.staticType; | 19256 Type2 operandType = node.operand.staticType; |
| 17277 if (operandType == null || operandType.isDynamic) { | 19257 if (operandType == null || operandType.isDynamic) { |
| 17278 return null; | 19258 return null; |
| 17279 } | 19259 } |
| 17280 return checkResolved2(node, node.staticElement, MethodElement); | 19260 return checkResolved2(node, node.staticElement, MethodElement); |
| 17281 } | 19261 } |
| 19262 |
| 17282 Object visitPropertyAccess(PropertyAccess node) { | 19263 Object visitPropertyAccess(PropertyAccess node) { |
| 17283 Expression target = node.realTarget; | 19264 Expression target = node.realTarget; |
| 17284 target.accept(this); | 19265 target.accept(this); |
| 17285 Type2 targetType = target.staticType; | 19266 Type2 targetType = target.staticType; |
| 17286 if (targetType == null || targetType.isDynamic) { | 19267 if (targetType == null || targetType.isDynamic) { |
| 17287 return null; | 19268 return null; |
| 17288 } | 19269 } |
| 17289 return node.propertyName.accept(this); | 19270 return node.propertyName.accept(this); |
| 17290 } | 19271 } |
| 19272 |
| 17291 Object visitSimpleIdentifier(SimpleIdentifier node) { | 19273 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 17292 if (node.name == "void") { | 19274 if (node.name == "void") { |
| 17293 return null; | 19275 return null; |
| 17294 } | 19276 } |
| 17295 ASTNode parent = node.parent; | 19277 ASTNode parent = node.parent; |
| 17296 if (parent is MethodInvocation) { | 19278 if (parent is MethodInvocation) { |
| 17297 MethodInvocation invocation = parent as MethodInvocation; | 19279 MethodInvocation invocation = parent as MethodInvocation; |
| 17298 if (identical(invocation.methodName, node)) { | 19280 if (identical(invocation.methodName, node)) { |
| 17299 Expression target = invocation.realTarget; | 19281 Expression target = invocation.realTarget; |
| 17300 Type2 targetType = target == null ? null : target.staticType; | 19282 Type2 targetType = target == null ? null : target.staticType; |
| 17301 if (targetType == null || targetType.isDynamic) { | 19283 if (targetType == null || targetType.isDynamic) { |
| 17302 return null; | 19284 return null; |
| 17303 } | 19285 } |
| 17304 } | 19286 } |
| 17305 } | 19287 } |
| 17306 return checkResolved(node, node.staticElement); | 19288 return checkResolved(node, node.staticElement); |
| 17307 } | 19289 } |
| 19290 |
| 17308 Object checkResolved(ASTNode node, Element element) => checkResolved2(node, el
ement, null); | 19291 Object checkResolved(ASTNode node, Element element) => checkResolved2(node, el
ement, null); |
| 19292 |
| 17309 Object checkResolved2(ASTNode node, Element element, Type expectedClass) { | 19293 Object checkResolved2(ASTNode node, Element element, Type expectedClass) { |
| 17310 if (element == null) { | 19294 if (element == null) { |
| 17311 if (_knownExceptions == null || !_knownExceptions.contains(node)) { | 19295 if (_knownExceptions == null || !_knownExceptions.contains(node)) { |
| 17312 _unresolvedNodes.add(node); | 19296 _unresolvedNodes.add(node); |
| 17313 } | 19297 } |
| 17314 } else if (expectedClass != null) { | 19298 } else if (expectedClass != null) { |
| 17315 if (!isInstanceOf(element, expectedClass)) { | 19299 if (!isInstanceOf(element, expectedClass)) { |
| 17316 _wrongTypedNodes.add(node); | 19300 _wrongTypedNodes.add(node); |
| 17317 } | 19301 } |
| 17318 } | 19302 } |
| 17319 return null; | 19303 return null; |
| 17320 } | 19304 } |
| 19305 |
| 17321 String getFileName(ASTNode node) { | 19306 String getFileName(ASTNode node) { |
| 17322 if (node != null) { | 19307 if (node != null) { |
| 17323 ASTNode root = node.root; | 19308 ASTNode root = node.root; |
| 17324 if (root is CompilationUnit) { | 19309 if (root is CompilationUnit) { |
| 17325 CompilationUnit rootCU = root as CompilationUnit; | 19310 CompilationUnit rootCU = root as CompilationUnit; |
| 17326 if (rootCU.element != null) { | 19311 if (rootCU.element != null) { |
| 17327 return rootCU.element.source.fullName; | 19312 return rootCU.element.source.fullName; |
| 17328 } else { | 19313 } else { |
| 17329 return "<unknown file- CompilationUnit.getElement() returned null>"; | 19314 return "<unknown file- CompilationUnit.getElement() returned null>"; |
| 17330 } | 19315 } |
| 17331 } else { | 19316 } else { |
| 17332 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni
t>"; | 19317 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni
t>"; |
| 17333 } | 19318 } |
| 17334 } | 19319 } |
| 17335 return "<unknown file- ASTNode is null>"; | 19320 return "<unknown file- ASTNode is null>"; |
| 17336 } | 19321 } |
| 19322 |
| 17337 void printNodes(PrintStringWriter writer, List<ASTNode> nodes) { | 19323 void printNodes(PrintStringWriter writer, List<ASTNode> nodes) { |
| 17338 for (ASTNode identifier in nodes) { | 19324 for (ASTNode identifier in nodes) { |
| 17339 writer.print(" "); | 19325 writer.print(" "); |
| 17340 writer.print(identifier.toString()); | 19326 writer.print(identifier.toString()); |
| 17341 writer.print(" ("); | 19327 writer.print(" ("); |
| 17342 writer.print(getFileName(identifier)); | 19328 writer.print(getFileName(identifier)); |
| 17343 writer.print(" : "); | 19329 writer.print(" : "); |
| 17344 writer.print(identifier.offset); | 19330 writer.print(identifier.offset); |
| 17345 writer.println(")"); | 19331 writer.println(")"); |
| 17346 } | 19332 } |
| 17347 } | 19333 } |
| 17348 } | 19334 } |
| 19335 |
| 17349 class MemberMapTest extends JUnitTestCase { | 19336 class MemberMapTest extends JUnitTestCase { |
| 17350 | |
| 17351 /** | 19337 /** |
| 17352 * The null type. | 19338 * The null type. |
| 17353 */ | 19339 */ |
| 17354 InterfaceType _nullType; | 19340 InterfaceType _nullType; |
| 19341 |
| 17355 void setUp() { | 19342 void setUp() { |
| 17356 _nullType = new TestTypeProvider().nullType; | 19343 _nullType = new TestTypeProvider().nullType; |
| 17357 } | 19344 } |
| 19345 |
| 17358 void test_MemberMap_copyConstructor() { | 19346 void test_MemberMap_copyConstructor() { |
| 17359 MethodElement m1 = ElementFactory.methodElement("m1", _nullType, []); | 19347 MethodElement m1 = ElementFactory.methodElement("m1", _nullType, []); |
| 17360 MethodElement m2 = ElementFactory.methodElement("m2", _nullType, []); | 19348 MethodElement m2 = ElementFactory.methodElement("m2", _nullType, []); |
| 17361 MethodElement m3 = ElementFactory.methodElement("m3", _nullType, []); | 19349 MethodElement m3 = ElementFactory.methodElement("m3", _nullType, []); |
| 17362 MemberMap map = new MemberMap(); | 19350 MemberMap map = new MemberMap(); |
| 17363 map.put(m1.name, m1); | 19351 map.put(m1.name, m1); |
| 17364 map.put(m2.name, m2); | 19352 map.put(m2.name, m2); |
| 17365 map.put(m3.name, m3); | 19353 map.put(m3.name, m3); |
| 17366 MemberMap copy = new MemberMap.con2(map); | 19354 MemberMap copy = new MemberMap.con2(map); |
| 17367 JUnitTestCase.assertEquals(map.size, copy.size); | 19355 JUnitTestCase.assertEquals(map.size, copy.size); |
| 17368 JUnitTestCase.assertEquals(m1, copy.get(m1.name)); | 19356 JUnitTestCase.assertEquals(m1, copy.get(m1.name)); |
| 17369 JUnitTestCase.assertEquals(m2, copy.get(m2.name)); | 19357 JUnitTestCase.assertEquals(m2, copy.get(m2.name)); |
| 17370 JUnitTestCase.assertEquals(m3, copy.get(m3.name)); | 19358 JUnitTestCase.assertEquals(m3, copy.get(m3.name)); |
| 17371 } | 19359 } |
| 19360 |
| 17372 void test_MemberMap_override() { | 19361 void test_MemberMap_override() { |
| 17373 MethodElement m1 = ElementFactory.methodElement("m", _nullType, []); | 19362 MethodElement m1 = ElementFactory.methodElement("m", _nullType, []); |
| 17374 MethodElement m2 = ElementFactory.methodElement("m", _nullType, []); | 19363 MethodElement m2 = ElementFactory.methodElement("m", _nullType, []); |
| 17375 MemberMap map = new MemberMap(); | 19364 MemberMap map = new MemberMap(); |
| 17376 map.put(m1.name, m1); | 19365 map.put(m1.name, m1); |
| 17377 map.put(m2.name, m2); | 19366 map.put(m2.name, m2); |
| 17378 JUnitTestCase.assertEquals(1, map.size); | 19367 JUnitTestCase.assertEquals(1, map.size); |
| 17379 JUnitTestCase.assertEquals(m2, map.get("m")); | 19368 JUnitTestCase.assertEquals(m2, map.get("m")); |
| 17380 } | 19369 } |
| 19370 |
| 17381 void test_MemberMap_put() { | 19371 void test_MemberMap_put() { |
| 17382 MethodElement m1 = ElementFactory.methodElement("m1", _nullType, []); | 19372 MethodElement m1 = ElementFactory.methodElement("m1", _nullType, []); |
| 17383 MemberMap map = new MemberMap(); | 19373 MemberMap map = new MemberMap(); |
| 17384 JUnitTestCase.assertEquals(0, map.size); | 19374 JUnitTestCase.assertEquals(0, map.size); |
| 17385 map.put(m1.name, m1); | 19375 map.put(m1.name, m1); |
| 17386 JUnitTestCase.assertEquals(1, map.size); | 19376 JUnitTestCase.assertEquals(1, map.size); |
| 17387 JUnitTestCase.assertEquals(m1, map.get("m1")); | 19377 JUnitTestCase.assertEquals(m1, map.get("m1")); |
| 17388 } | 19378 } |
| 19379 |
| 17389 static dartSuite() { | 19380 static dartSuite() { |
| 17390 _ut.group('MemberMapTest', () { | 19381 _ut.group('MemberMapTest', () { |
| 17391 _ut.test('test_MemberMap_copyConstructor', () { | 19382 _ut.test('test_MemberMap_copyConstructor', () { |
| 17392 final __test = new MemberMapTest(); | 19383 final __test = new MemberMapTest(); |
| 17393 runJUnitTest(__test, __test.test_MemberMap_copyConstructor); | 19384 runJUnitTest(__test, __test.test_MemberMap_copyConstructor); |
| 17394 }); | 19385 }); |
| 17395 _ut.test('test_MemberMap_override', () { | 19386 _ut.test('test_MemberMap_override', () { |
| 17396 final __test = new MemberMapTest(); | 19387 final __test = new MemberMapTest(); |
| 17397 runJUnitTest(__test, __test.test_MemberMap_override); | 19388 runJUnitTest(__test, __test.test_MemberMap_override); |
| 17398 }); | 19389 }); |
| 17399 _ut.test('test_MemberMap_put', () { | 19390 _ut.test('test_MemberMap_put', () { |
| 17400 final __test = new MemberMapTest(); | 19391 final __test = new MemberMapTest(); |
| 17401 runJUnitTest(__test, __test.test_MemberMap_put); | 19392 runJUnitTest(__test, __test.test_MemberMap_put); |
| 17402 }); | 19393 }); |
| 17403 }); | 19394 }); |
| 17404 } | 19395 } |
| 17405 } | 19396 } |
| 19397 |
| 17406 class LibraryScopeTest extends ResolverTestCase { | 19398 class LibraryScopeTest extends ResolverTestCase { |
| 17407 void test_creation_empty() { | 19399 void test_creation_empty() { |
| 17408 LibraryElement definingLibrary = createTestLibrary(); | 19400 LibraryElement definingLibrary = createTestLibrary(); |
| 17409 GatheringErrorListener errorListener = new GatheringErrorListener(); | 19401 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 17410 new LibraryScope(definingLibrary, errorListener); | 19402 new LibraryScope(definingLibrary, errorListener); |
| 17411 } | 19403 } |
| 19404 |
| 17412 void test_creation_nonEmpty() { | 19405 void test_creation_nonEmpty() { |
| 17413 AnalysisContext context = new AnalysisContextImpl(); | 19406 AnalysisContext context = new AnalysisContextImpl(); |
| 17414 String importedTypeName = "A"; | 19407 String importedTypeName = "A"; |
| 17415 ClassElement importedType = new ClassElementImpl(ASTFactory.identifier3(impo
rtedTypeName)); | 19408 ClassElement importedType = new ClassElementImpl(ASTFactory.identifier3(impo
rtedTypeName)); |
| 17416 LibraryElement importedLibrary = createTestLibrary2(context, "imported", [])
; | 19409 LibraryElement importedLibrary = createTestLibrary2(context, "imported", [])
; |
| 17417 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty
pes = <ClassElement> [importedType]; | 19410 (importedLibrary.definingCompilationUnit as CompilationUnitElementImpl).type
s = <ClassElement> [importedType]; |
| 17418 LibraryElementImpl definingLibrary = createTestLibrary2(context, "importing"
, []); | 19411 LibraryElementImpl definingLibrary = createTestLibrary2(context, "importing"
, []); |
| 17419 ImportElementImpl importElement = new ImportElementImpl(); | 19412 ImportElementImpl importElement = new ImportElementImpl(); |
| 17420 importElement.importedLibrary = importedLibrary; | 19413 importElement.importedLibrary = importedLibrary; |
| 17421 definingLibrary.imports = <ImportElement> [importElement]; | 19414 definingLibrary.imports = <ImportElement> [importElement]; |
| 17422 GatheringErrorListener errorListener = new GatheringErrorListener(); | 19415 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 17423 Scope scope = new LibraryScope(definingLibrary, errorListener); | 19416 Scope scope = new LibraryScope(definingLibrary, errorListener); |
| 17424 JUnitTestCase.assertEquals(importedType, scope.lookup(ASTFactory.identifier3
(importedTypeName), definingLibrary)); | 19417 JUnitTestCase.assertEquals(importedType, scope.lookup(ASTFactory.identifier3
(importedTypeName), definingLibrary)); |
| 17425 } | 19418 } |
| 19419 |
| 17426 void test_getErrorListener() { | 19420 void test_getErrorListener() { |
| 17427 LibraryElement definingLibrary = createTestLibrary(); | 19421 LibraryElement definingLibrary = createTestLibrary(); |
| 17428 GatheringErrorListener errorListener = new GatheringErrorListener(); | 19422 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 17429 LibraryScope scope = new LibraryScope(definingLibrary, errorListener); | 19423 LibraryScope scope = new LibraryScope(definingLibrary, errorListener); |
| 17430 JUnitTestCase.assertEquals(errorListener, scope.errorListener); | 19424 JUnitTestCase.assertEquals(errorListener, scope.errorListener); |
| 17431 } | 19425 } |
| 19426 |
| 17432 static dartSuite() { | 19427 static dartSuite() { |
| 17433 _ut.group('LibraryScopeTest', () { | 19428 _ut.group('LibraryScopeTest', () { |
| 17434 _ut.test('test_creation_empty', () { | 19429 _ut.test('test_creation_empty', () { |
| 17435 final __test = new LibraryScopeTest(); | 19430 final __test = new LibraryScopeTest(); |
| 17436 runJUnitTest(__test, __test.test_creation_empty); | 19431 runJUnitTest(__test, __test.test_creation_empty); |
| 17437 }); | 19432 }); |
| 17438 _ut.test('test_creation_nonEmpty', () { | 19433 _ut.test('test_creation_nonEmpty', () { |
| 17439 final __test = new LibraryScopeTest(); | 19434 final __test = new LibraryScopeTest(); |
| 17440 runJUnitTest(__test, __test.test_creation_nonEmpty); | 19435 runJUnitTest(__test, __test.test_creation_nonEmpty); |
| 17441 }); | 19436 }); |
| 17442 _ut.test('test_getErrorListener', () { | 19437 _ut.test('test_getErrorListener', () { |
| 17443 final __test = new LibraryScopeTest(); | 19438 final __test = new LibraryScopeTest(); |
| 17444 runJUnitTest(__test, __test.test_getErrorListener); | 19439 runJUnitTest(__test, __test.test_getErrorListener); |
| 17445 }); | 19440 }); |
| 17446 }); | 19441 }); |
| 17447 } | 19442 } |
| 17448 } | 19443 } |
| 19444 |
| 17449 class StaticTypeAnalyzerTest extends EngineTestCase { | 19445 class StaticTypeAnalyzerTest extends EngineTestCase { |
| 17450 | |
| 17451 /** | 19446 /** |
| 17452 * The error listener to which errors will be reported. | 19447 * The error listener to which errors will be reported. |
| 17453 */ | 19448 */ |
| 17454 GatheringErrorListener _listener; | 19449 GatheringErrorListener _listener; |
| 17455 | 19450 |
| 17456 /** | 19451 /** |
| 17457 * The resolver visitor used to create the analyzer. | 19452 * The resolver visitor used to create the analyzer. |
| 17458 */ | 19453 */ |
| 17459 ResolverVisitor _visitor; | 19454 ResolverVisitor _visitor; |
| 17460 | 19455 |
| 17461 /** | 19456 /** |
| 17462 * The analyzer being used to analyze the test cases. | 19457 * The analyzer being used to analyze the test cases. |
| 17463 */ | 19458 */ |
| 17464 StaticTypeAnalyzer _analyzer; | 19459 StaticTypeAnalyzer _analyzer; |
| 17465 | 19460 |
| 17466 /** | 19461 /** |
| 17467 * The type provider used to access the types. | 19462 * The type provider used to access the types. |
| 17468 */ | 19463 */ |
| 17469 TestTypeProvider _typeProvider; | 19464 TestTypeProvider _typeProvider; |
| 19465 |
| 17470 void fail_visitFunctionExpressionInvocation() { | 19466 void fail_visitFunctionExpressionInvocation() { |
| 17471 JUnitTestCase.fail("Not yet tested"); | 19467 JUnitTestCase.fail("Not yet tested"); |
| 17472 _listener.assertNoErrors(); | 19468 _listener.assertNoErrors(); |
| 17473 } | 19469 } |
| 19470 |
| 17474 void fail_visitMethodInvocation() { | 19471 void fail_visitMethodInvocation() { |
| 17475 JUnitTestCase.fail("Not yet tested"); | 19472 JUnitTestCase.fail("Not yet tested"); |
| 17476 _listener.assertNoErrors(); | 19473 _listener.assertNoErrors(); |
| 17477 } | 19474 } |
| 19475 |
| 17478 void fail_visitSimpleIdentifier() { | 19476 void fail_visitSimpleIdentifier() { |
| 17479 JUnitTestCase.fail("Not yet tested"); | 19477 JUnitTestCase.fail("Not yet tested"); |
| 17480 _listener.assertNoErrors(); | 19478 _listener.assertNoErrors(); |
| 17481 } | 19479 } |
| 19480 |
| 17482 void setUp() { | 19481 void setUp() { |
| 17483 _listener = new GatheringErrorListener(); | 19482 _listener = new GatheringErrorListener(); |
| 17484 _typeProvider = new TestTypeProvider(); | 19483 _typeProvider = new TestTypeProvider(); |
| 17485 _analyzer = createAnalyzer(); | 19484 _analyzer = createAnalyzer(); |
| 17486 } | 19485 } |
| 19486 |
| 17487 void test_visitAdjacentStrings() { | 19487 void test_visitAdjacentStrings() { |
| 17488 Expression node = ASTFactory.adjacentStrings([resolvedString("a"), resolvedS
tring("b")]); | 19488 Expression node = ASTFactory.adjacentStrings([resolvedString("a"), resolvedS
tring("b")]); |
| 17489 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); | 19489 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); |
| 17490 _listener.assertNoErrors(); | 19490 _listener.assertNoErrors(); |
| 17491 } | 19491 } |
| 19492 |
| 17492 void test_visitArgumentDefinitionTest() { | 19493 void test_visitArgumentDefinitionTest() { |
| 17493 Expression node = ASTFactory.argumentDefinitionTest("p"); | 19494 Expression node = ASTFactory.argumentDefinitionTest("p"); |
| 17494 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19495 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17495 _listener.assertNoErrors(); | 19496 _listener.assertNoErrors(); |
| 17496 } | 19497 } |
| 19498 |
| 17497 void test_visitAsExpression() { | 19499 void test_visitAsExpression() { |
| 17498 ClassElement superclass = ElementFactory.classElement2("A", []); | 19500 ClassElement superclass = ElementFactory.classElement2("A", []); |
| 17499 InterfaceType superclassType = superclass.type; | 19501 InterfaceType superclassType = superclass.type; |
| 17500 ClassElement subclass = ElementFactory.classElement("B", superclassType, [])
; | 19502 ClassElement subclass = ElementFactory.classElement("B", superclassType, [])
; |
| 17501 Expression node = ASTFactory.asExpression(ASTFactory.thisExpression(), ASTFa
ctory.typeName(subclass, [])); | 19503 Expression node = ASTFactory.asExpression(ASTFactory.thisExpression(), ASTFa
ctory.typeName(subclass, [])); |
| 17502 JUnitTestCase.assertSame(subclass.type, analyze2(node, superclassType)); | 19504 JUnitTestCase.assertSame(subclass.type, analyze2(node, superclassType)); |
| 17503 _listener.assertNoErrors(); | 19505 _listener.assertNoErrors(); |
| 17504 } | 19506 } |
| 19507 |
| 17505 void test_visitAssignmentExpression_compound() { | 19508 void test_visitAssignmentExpression_compound() { |
| 17506 InterfaceType numType = _typeProvider.numType; | 19509 InterfaceType numType = _typeProvider.numType; |
| 17507 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i"); | 19510 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i"); |
| 17508 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke
nType.PLUS_EQ, resolvedInteger(1)); | 19511 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke
nType.PLUS_EQ, resolvedInteger(1)); |
| 17509 MethodElement plusMethod = getMethod(numType, "+"); | 19512 MethodElement plusMethod = getMethod(numType, "+"); |
| 17510 node.staticElement = plusMethod; | 19513 node.staticElement = plusMethod; |
| 17511 JUnitTestCase.assertSame(numType, analyze(node)); | 19514 JUnitTestCase.assertSame(numType, analyze(node)); |
| 17512 _listener.assertNoErrors(); | 19515 _listener.assertNoErrors(); |
| 17513 } | 19516 } |
| 19517 |
| 17514 void test_visitAssignmentExpression_simple() { | 19518 void test_visitAssignmentExpression_simple() { |
| 17515 InterfaceType intType = _typeProvider.intType; | 19519 InterfaceType intType = _typeProvider.intType; |
| 17516 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType,
"i"), TokenType.EQ, resolvedInteger(0)); | 19520 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType,
"i"), TokenType.EQ, resolvedInteger(0)); |
| 17517 JUnitTestCase.assertSame(intType, analyze(node)); | 19521 JUnitTestCase.assertSame(intType, analyze(node)); |
| 17518 _listener.assertNoErrors(); | 19522 _listener.assertNoErrors(); |
| 17519 } | 19523 } |
| 19524 |
| 17520 void test_visitBinaryExpression_equals() { | 19525 void test_visitBinaryExpression_equals() { |
| 17521 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType.
EQ_EQ, resolvedInteger(3)); | 19526 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType.
EQ_EQ, resolvedInteger(3)); |
| 17522 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19527 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17523 _listener.assertNoErrors(); | 19528 _listener.assertNoErrors(); |
| 17524 } | 19529 } |
| 19530 |
| 17525 void test_visitBinaryExpression_logicalAnd() { | 19531 void test_visitBinaryExpression_logicalAnd() { |
| 17526 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals
e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true)); | 19532 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals
e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true)); |
| 17527 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19533 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17528 _listener.assertNoErrors(); | 19534 _listener.assertNoErrors(); |
| 17529 } | 19535 } |
| 19536 |
| 17530 void test_visitBinaryExpression_logicalOr() { | 19537 void test_visitBinaryExpression_logicalOr() { |
| 17531 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals
e), TokenType.BAR_BAR, ASTFactory.booleanLiteral(true)); | 19538 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals
e), TokenType.BAR_BAR, ASTFactory.booleanLiteral(true)); |
| 17532 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19539 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17533 _listener.assertNoErrors(); | 19540 _listener.assertNoErrors(); |
| 17534 } | 19541 } |
| 19542 |
| 17535 void test_visitBinaryExpression_notEquals() { | 19543 void test_visitBinaryExpression_notEquals() { |
| 17536 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType.
BANG_EQ, resolvedInteger(3)); | 19544 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType.
BANG_EQ, resolvedInteger(3)); |
| 17537 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19545 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17538 _listener.assertNoErrors(); | 19546 _listener.assertNoErrors(); |
| 17539 } | 19547 } |
| 19548 |
| 17540 void test_visitBinaryExpression_plusID() { | 19549 void test_visitBinaryExpression_plusID() { |
| 17541 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke
nType.PLUS, resolvedDouble(2.0)); | 19550 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke
nType.PLUS, resolvedDouble(2.0)); |
| 17542 node.staticElement = getMethod(_typeProvider.numType, "+"); | 19551 node.staticElement = getMethod(_typeProvider.numType, "+"); |
| 17543 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); | 19552 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); |
| 17544 _listener.assertNoErrors(); | 19553 _listener.assertNoErrors(); |
| 17545 } | 19554 } |
| 19555 |
| 17546 void test_visitBinaryExpression_plusII() { | 19556 void test_visitBinaryExpression_plusII() { |
| 17547 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke
nType.PLUS, resolvedInteger(2)); | 19557 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke
nType.PLUS, resolvedInteger(2)); |
| 17548 node.staticElement = getMethod(_typeProvider.numType, "+"); | 19558 node.staticElement = getMethod(_typeProvider.numType, "+"); |
| 17549 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 19559 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
| 17550 _listener.assertNoErrors(); | 19560 _listener.assertNoErrors(); |
| 17551 } | 19561 } |
| 19562 |
| 17552 void test_visitBinaryExpression_slash() { | 19563 void test_visitBinaryExpression_slash() { |
| 17553 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(2), Toke
nType.SLASH, resolvedInteger(2)); | 19564 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(2), Toke
nType.SLASH, resolvedInteger(2)); |
| 17554 node.staticElement = getMethod(_typeProvider.numType, "/"); | 19565 node.staticElement = getMethod(_typeProvider.numType, "/"); |
| 17555 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); | 19566 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); |
| 17556 _listener.assertNoErrors(); | 19567 _listener.assertNoErrors(); |
| 17557 } | 19568 } |
| 19569 |
| 17558 void test_visitBinaryExpression_star_notSpecial() { | 19570 void test_visitBinaryExpression_star_notSpecial() { |
| 17559 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 19571 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 17560 InterfaceType typeA = classA.type; | 19572 InterfaceType typeA = classA.type; |
| 17561 MethodElement operator = ElementFactory.methodElement("*", typeA, [_typeProv
ider.doubleType]); | 19573 MethodElement operator = ElementFactory.methodElement("*", typeA, [_typeProv
ider.doubleType]); |
| 17562 classA.methods = <MethodElement> [operator]; | 19574 classA.methods = <MethodElement> [operator]; |
| 17563 BinaryExpression node = ASTFactory.binaryExpression(ASTFactory.asExpression(
ASTFactory.identifier3("a"), ASTFactory.typeName(classA, [])), TokenType.PLUS, r
esolvedDouble(2.0)); | 19575 BinaryExpression node = ASTFactory.binaryExpression(ASTFactory.asExpression(
ASTFactory.identifier3("a"), ASTFactory.typeName(classA, [])), TokenType.PLUS, r
esolvedDouble(2.0)); |
| 17564 node.staticElement = operator; | 19576 node.staticElement = operator; |
| 17565 JUnitTestCase.assertSame(typeA, analyze(node)); | 19577 JUnitTestCase.assertSame(typeA, analyze(node)); |
| 17566 _listener.assertNoErrors(); | 19578 _listener.assertNoErrors(); |
| 17567 } | 19579 } |
| 19580 |
| 17568 void test_visitBinaryExpression_starID() { | 19581 void test_visitBinaryExpression_starID() { |
| 17569 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke
nType.PLUS, resolvedDouble(2.0)); | 19582 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke
nType.PLUS, resolvedDouble(2.0)); |
| 17570 node.staticElement = getMethod(_typeProvider.numType, "*"); | 19583 node.staticElement = getMethod(_typeProvider.numType, "*"); |
| 17571 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); | 19584 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); |
| 17572 _listener.assertNoErrors(); | 19585 _listener.assertNoErrors(); |
| 17573 } | 19586 } |
| 19587 |
| 17574 void test_visitBooleanLiteral_false() { | 19588 void test_visitBooleanLiteral_false() { |
| 17575 Expression node = ASTFactory.booleanLiteral(false); | 19589 Expression node = ASTFactory.booleanLiteral(false); |
| 17576 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19590 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17577 _listener.assertNoErrors(); | 19591 _listener.assertNoErrors(); |
| 17578 } | 19592 } |
| 19593 |
| 17579 void test_visitBooleanLiteral_true() { | 19594 void test_visitBooleanLiteral_true() { |
| 17580 Expression node = ASTFactory.booleanLiteral(true); | 19595 Expression node = ASTFactory.booleanLiteral(true); |
| 17581 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19596 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17582 _listener.assertNoErrors(); | 19597 _listener.assertNoErrors(); |
| 17583 } | 19598 } |
| 19599 |
| 17584 void test_visitCascadeExpression() { | 19600 void test_visitCascadeExpression() { |
| 17585 Expression node = ASTFactory.cascadeExpression(resolvedString("a"), [ASTFact
ory.propertyAccess2(null, "length")]); | 19601 Expression node = ASTFactory.cascadeExpression(resolvedString("a"), [ASTFact
ory.propertyAccess2(null, "length")]); |
| 17586 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); | 19602 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); |
| 17587 _listener.assertNoErrors(); | 19603 _listener.assertNoErrors(); |
| 17588 } | 19604 } |
| 19605 |
| 17589 void test_visitConditionalExpression_differentTypes() { | 19606 void test_visitConditionalExpression_differentTypes() { |
| 17590 Expression node = ASTFactory.conditionalExpression(ASTFactory.booleanLiteral
(true), resolvedDouble(1.0), resolvedInteger(0)); | 19607 Expression node = ASTFactory.conditionalExpression(ASTFactory.booleanLiteral
(true), resolvedDouble(1.0), resolvedInteger(0)); |
| 17591 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node)); | 19608 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node)); |
| 17592 _listener.assertNoErrors(); | 19609 _listener.assertNoErrors(); |
| 17593 } | 19610 } |
| 19611 |
| 17594 void test_visitConditionalExpression_sameTypes() { | 19612 void test_visitConditionalExpression_sameTypes() { |
| 17595 Expression node = ASTFactory.conditionalExpression(ASTFactory.booleanLiteral
(true), resolvedInteger(1), resolvedInteger(0)); | 19613 Expression node = ASTFactory.conditionalExpression(ASTFactory.booleanLiteral
(true), resolvedInteger(1), resolvedInteger(0)); |
| 17596 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 19614 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
| 17597 _listener.assertNoErrors(); | 19615 _listener.assertNoErrors(); |
| 17598 } | 19616 } |
| 19617 |
| 17599 void test_visitDoubleLiteral() { | 19618 void test_visitDoubleLiteral() { |
| 17600 Expression node = ASTFactory.doubleLiteral(4.33); | 19619 Expression node = ASTFactory.doubleLiteral(4.33); |
| 17601 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); | 19620 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); |
| 17602 _listener.assertNoErrors(); | 19621 _listener.assertNoErrors(); |
| 17603 } | 19622 } |
| 19623 |
| 17604 void test_visitFunctionExpression_named_block() { | 19624 void test_visitFunctionExpression_named_block() { |
| 17605 Type2 dynamicType = _typeProvider.dynamicType; | 19625 Type2 dynamicType = _typeProvider.dynamicType; |
| 17606 FormalParameter p1 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p1"), resolvedInteger(0)); | 19626 FormalParameter p1 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p1"), resolvedInteger(0)); |
| 17607 setType(p1, dynamicType); | 19627 setType(p1, dynamicType); |
| 17608 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); | 19628 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); |
| 17609 setType(p2, dynamicType); | 19629 setType(p2, dynamicType); |
| 17610 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); | 19630 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); |
| 17611 analyze3(p1); | 19631 analyze3(p1); |
| 17612 analyze3(p2); | 19632 analyze3(p2); |
| 17613 Type2 resultType = analyze(node); | 19633 Type2 resultType = analyze(node); |
| 17614 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 19634 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
| 17615 expectedNamedTypes["p1"] = dynamicType; | 19635 expectedNamedTypes["p1"] = dynamicType; |
| 17616 expectedNamedTypes["p2"] = dynamicType; | 19636 expectedNamedTypes["p2"] = dynamicType; |
| 17617 assertFunctionType(dynamicType, null, null, expectedNamedTypes, resultType); | 19637 assertFunctionType(dynamicType, null, null, expectedNamedTypes, resultType); |
| 17618 _listener.assertNoErrors(); | 19638 _listener.assertNoErrors(); |
| 17619 } | 19639 } |
| 19640 |
| 17620 void test_visitFunctionExpression_named_expression() { | 19641 void test_visitFunctionExpression_named_expression() { |
| 17621 Type2 dynamicType = _typeProvider.dynamicType; | 19642 Type2 dynamicType = _typeProvider.dynamicType; |
| 17622 FormalParameter p = ASTFactory.namedFormalParameter(ASTFactory.simpleFormalP
arameter3("p"), resolvedInteger(0)); | 19643 FormalParameter p = ASTFactory.namedFormalParameter(ASTFactory.simpleFormalP
arameter3("p"), resolvedInteger(0)); |
| 17623 setType(p, dynamicType); | 19644 setType(p, dynamicType); |
| 17624 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 19645 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
| 17625 analyze3(p); | 19646 analyze3(p); |
| 17626 Type2 resultType = analyze(node); | 19647 Type2 resultType = analyze(node); |
| 17627 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 19648 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
| 17628 expectedNamedTypes["p"] = dynamicType; | 19649 expectedNamedTypes["p"] = dynamicType; |
| 17629 assertFunctionType(_typeProvider.intType, null, null, expectedNamedTypes, re
sultType); | 19650 assertFunctionType(_typeProvider.intType, null, null, expectedNamedTypes, re
sultType); |
| 17630 _listener.assertNoErrors(); | 19651 _listener.assertNoErrors(); |
| 17631 } | 19652 } |
| 19653 |
| 17632 void test_visitFunctionExpression_normal_block() { | 19654 void test_visitFunctionExpression_normal_block() { |
| 17633 Type2 dynamicType = _typeProvider.dynamicType; | 19655 Type2 dynamicType = _typeProvider.dynamicType; |
| 17634 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 19656 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
| 17635 setType(p1, dynamicType); | 19657 setType(p1, dynamicType); |
| 17636 FormalParameter p2 = ASTFactory.simpleFormalParameter3("p2"); | 19658 FormalParameter p2 = ASTFactory.simpleFormalParameter3("p2"); |
| 17637 setType(p2, dynamicType); | 19659 setType(p2, dynamicType); |
| 17638 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); | 19660 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); |
| 17639 analyze3(p1); | 19661 analyze3(p1); |
| 17640 analyze3(p2); | 19662 analyze3(p2); |
| 17641 Type2 resultType = analyze(node); | 19663 Type2 resultType = analyze(node); |
| 17642 assertFunctionType(dynamicType, <Type2> [dynamicType, dynamicType], null, nu
ll, resultType); | 19664 assertFunctionType(dynamicType, <Type2> [dynamicType, dynamicType], null, nu
ll, resultType); |
| 17643 _listener.assertNoErrors(); | 19665 _listener.assertNoErrors(); |
| 17644 } | 19666 } |
| 19667 |
| 17645 void test_visitFunctionExpression_normal_expression() { | 19668 void test_visitFunctionExpression_normal_expression() { |
| 17646 Type2 dynamicType = _typeProvider.dynamicType; | 19669 Type2 dynamicType = _typeProvider.dynamicType; |
| 17647 FormalParameter p = ASTFactory.simpleFormalParameter3("p"); | 19670 FormalParameter p = ASTFactory.simpleFormalParameter3("p"); |
| 17648 setType(p, dynamicType); | 19671 setType(p, dynamicType); |
| 17649 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 19672 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
| 17650 analyze3(p); | 19673 analyze3(p); |
| 17651 Type2 resultType = analyze(node); | 19674 Type2 resultType = analyze(node); |
| 17652 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, null,
resultType); | 19675 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, null,
resultType); |
| 17653 _listener.assertNoErrors(); | 19676 _listener.assertNoErrors(); |
| 17654 } | 19677 } |
| 19678 |
| 17655 void test_visitFunctionExpression_normalAndNamed_block() { | 19679 void test_visitFunctionExpression_normalAndNamed_block() { |
| 17656 Type2 dynamicType = _typeProvider.dynamicType; | 19680 Type2 dynamicType = _typeProvider.dynamicType; |
| 17657 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 19681 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
| 17658 setType(p1, dynamicType); | 19682 setType(p1, dynamicType); |
| 17659 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); | 19683 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); |
| 17660 setType(p2, dynamicType); | 19684 setType(p2, dynamicType); |
| 17661 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); | 19685 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); |
| 17662 analyze3(p2); | 19686 analyze3(p2); |
| 17663 Type2 resultType = analyze(node); | 19687 Type2 resultType = analyze(node); |
| 17664 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 19688 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
| 17665 expectedNamedTypes["p2"] = dynamicType; | 19689 expectedNamedTypes["p2"] = dynamicType; |
| 17666 assertFunctionType(dynamicType, <Type2> [dynamicType], null, expectedNamedTy
pes, resultType); | 19690 assertFunctionType(dynamicType, <Type2> [dynamicType], null, expectedNamedTy
pes, resultType); |
| 17667 _listener.assertNoErrors(); | 19691 _listener.assertNoErrors(); |
| 17668 } | 19692 } |
| 19693 |
| 17669 void test_visitFunctionExpression_normalAndNamed_expression() { | 19694 void test_visitFunctionExpression_normalAndNamed_expression() { |
| 17670 Type2 dynamicType = _typeProvider.dynamicType; | 19695 Type2 dynamicType = _typeProvider.dynamicType; |
| 17671 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 19696 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
| 17672 setType(p1, dynamicType); | 19697 setType(p1, dynamicType); |
| 17673 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); | 19698 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); |
| 17674 setType(p2, dynamicType); | 19699 setType(p2, dynamicType); |
| 17675 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 19700 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
| 17676 analyze3(p2); | 19701 analyze3(p2); |
| 17677 Type2 resultType = analyze(node); | 19702 Type2 resultType = analyze(node); |
| 17678 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 19703 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
| 17679 expectedNamedTypes["p2"] = dynamicType; | 19704 expectedNamedTypes["p2"] = dynamicType; |
| 17680 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, expec
tedNamedTypes, resultType); | 19705 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, expec
tedNamedTypes, resultType); |
| 17681 _listener.assertNoErrors(); | 19706 _listener.assertNoErrors(); |
| 17682 } | 19707 } |
| 19708 |
| 17683 void test_visitFunctionExpression_normalAndPositional_block() { | 19709 void test_visitFunctionExpression_normalAndPositional_block() { |
| 17684 Type2 dynamicType = _typeProvider.dynamicType; | 19710 Type2 dynamicType = _typeProvider.dynamicType; |
| 17685 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 19711 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
| 17686 setType(p1, dynamicType); | 19712 setType(p1, dynamicType); |
| 17687 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); | 19713 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); |
| 17688 setType(p2, dynamicType); | 19714 setType(p2, dynamicType); |
| 17689 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); | 19715 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); |
| 17690 analyze3(p1); | 19716 analyze3(p1); |
| 17691 analyze3(p2); | 19717 analyze3(p2); |
| 17692 Type2 resultType = analyze(node); | 19718 Type2 resultType = analyze(node); |
| 17693 assertFunctionType(dynamicType, <Type2> [dynamicType], <Type2> [dynamicType]
, null, resultType); | 19719 assertFunctionType(dynamicType, <Type2> [dynamicType], <Type2> [dynamicType]
, null, resultType); |
| 17694 _listener.assertNoErrors(); | 19720 _listener.assertNoErrors(); |
| 17695 } | 19721 } |
| 19722 |
| 17696 void test_visitFunctionExpression_normalAndPositional_expression() { | 19723 void test_visitFunctionExpression_normalAndPositional_expression() { |
| 17697 Type2 dynamicType = _typeProvider.dynamicType; | 19724 Type2 dynamicType = _typeProvider.dynamicType; |
| 17698 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 19725 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
| 17699 setType(p1, dynamicType); | 19726 setType(p1, dynamicType); |
| 17700 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); | 19727 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); |
| 17701 setType(p2, dynamicType); | 19728 setType(p2, dynamicType); |
| 17702 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 19729 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
| 17703 analyze3(p1); | 19730 analyze3(p1); |
| 17704 analyze3(p2); | 19731 analyze3(p2); |
| 17705 Type2 resultType = analyze(node); | 19732 Type2 resultType = analyze(node); |
| 17706 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], <Type2> [dy
namicType], null, resultType); | 19733 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], <Type2> [dy
namicType], null, resultType); |
| 17707 _listener.assertNoErrors(); | 19734 _listener.assertNoErrors(); |
| 17708 } | 19735 } |
| 19736 |
| 17709 void test_visitFunctionExpression_positional_block() { | 19737 void test_visitFunctionExpression_positional_block() { |
| 17710 Type2 dynamicType = _typeProvider.dynamicType; | 19738 Type2 dynamicType = _typeProvider.dynamicType; |
| 17711 FormalParameter p1 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p1"), resolvedInteger(0)); | 19739 FormalParameter p1 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p1"), resolvedInteger(0)); |
| 17712 setType(p1, dynamicType); | 19740 setType(p1, dynamicType); |
| 17713 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); | 19741 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); |
| 17714 setType(p2, dynamicType); | 19742 setType(p2, dynamicType); |
| 17715 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); | 19743 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); |
| 17716 analyze3(p1); | 19744 analyze3(p1); |
| 17717 analyze3(p2); | 19745 analyze3(p2); |
| 17718 Type2 resultType = analyze(node); | 19746 Type2 resultType = analyze(node); |
| 17719 assertFunctionType(dynamicType, null, <Type2> [dynamicType, dynamicType], nu
ll, resultType); | 19747 assertFunctionType(dynamicType, null, <Type2> [dynamicType, dynamicType], nu
ll, resultType); |
| 17720 _listener.assertNoErrors(); | 19748 _listener.assertNoErrors(); |
| 17721 } | 19749 } |
| 19750 |
| 17722 void test_visitFunctionExpression_positional_expression() { | 19751 void test_visitFunctionExpression_positional_expression() { |
| 17723 Type2 dynamicType = _typeProvider.dynamicType; | 19752 Type2 dynamicType = _typeProvider.dynamicType; |
| 17724 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo
rmalParameter3("p"), resolvedInteger(0)); | 19753 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo
rmalParameter3("p"), resolvedInteger(0)); |
| 17725 setType(p, dynamicType); | 19754 setType(p, dynamicType); |
| 17726 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 19755 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
| 17727 analyze3(p); | 19756 analyze3(p); |
| 17728 Type2 resultType = analyze(node); | 19757 Type2 resultType = analyze(node); |
| 17729 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType], null,
resultType); | 19758 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType], null,
resultType); |
| 17730 _listener.assertNoErrors(); | 19759 _listener.assertNoErrors(); |
| 17731 } | 19760 } |
| 19761 |
| 17732 void test_visitIndexExpression_getter() { | 19762 void test_visitIndexExpression_getter() { |
| 17733 InterfaceType listType = _typeProvider.listType; | 19763 InterfaceType listType = _typeProvider.listType; |
| 17734 SimpleIdentifier identifier = resolvedVariable(listType, "a"); | 19764 SimpleIdentifier identifier = resolvedVariable(listType, "a"); |
| 17735 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege
r(2)); | 19765 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege
r(2)); |
| 17736 MethodElement indexMethod = listType.element.methods[0]; | 19766 MethodElement indexMethod = listType.element.methods[0]; |
| 17737 node.staticElement = indexMethod; | 19767 node.staticElement = indexMethod; |
| 17738 JUnitTestCase.assertSame(listType.typeArguments[0], analyze(node)); | 19768 JUnitTestCase.assertSame(listType.typeArguments[0], analyze(node)); |
| 17739 _listener.assertNoErrors(); | 19769 _listener.assertNoErrors(); |
| 17740 } | 19770 } |
| 19771 |
| 17741 void test_visitIndexExpression_setter() { | 19772 void test_visitIndexExpression_setter() { |
| 17742 InterfaceType listType = _typeProvider.listType; | 19773 InterfaceType listType = _typeProvider.listType; |
| 17743 SimpleIdentifier identifier = resolvedVariable(listType, "a"); | 19774 SimpleIdentifier identifier = resolvedVariable(listType, "a"); |
| 17744 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege
r(2)); | 19775 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege
r(2)); |
| 17745 MethodElement indexMethod = listType.element.methods[1]; | 19776 MethodElement indexMethod = listType.element.methods[1]; |
| 17746 node.staticElement = indexMethod; | 19777 node.staticElement = indexMethod; |
| 17747 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); | 19778 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); |
| 17748 JUnitTestCase.assertSame(listType.typeArguments[0], analyze(node)); | 19779 JUnitTestCase.assertSame(listType.typeArguments[0], analyze(node)); |
| 17749 _listener.assertNoErrors(); | 19780 _listener.assertNoErrors(); |
| 17750 } | 19781 } |
| 19782 |
| 17751 void test_visitIndexExpression_typeParameters() { | 19783 void test_visitIndexExpression_typeParameters() { |
| 17752 InterfaceType intType = _typeProvider.intType; | 19784 InterfaceType intType = _typeProvider.intType; |
| 17753 InterfaceType listType = _typeProvider.listType; | 19785 InterfaceType listType = _typeProvider.listType; |
| 17754 MethodElement methodElement = getMethod(listType, "[]"); | 19786 MethodElement methodElement = getMethod(listType, "[]"); |
| 17755 SimpleIdentifier identifier = ASTFactory.identifier3("list"); | 19787 SimpleIdentifier identifier = ASTFactory.identifier3("list"); |
| 17756 InterfaceType listOfIntType = listType.substitute4(<Type2> [intType]); | 19788 InterfaceType listOfIntType = listType.substitute4(<Type2> [intType]); |
| 17757 identifier.staticType = listOfIntType; | 19789 identifier.staticType = listOfIntType; |
| 17758 IndexExpression indexExpression = ASTFactory.indexExpression(identifier, AST
Factory.integer(0)); | 19790 IndexExpression indexExpression = ASTFactory.indexExpression(identifier, AST
Factory.integer(0)); |
| 17759 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType); | 19791 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType); |
| 17760 indexExpression.staticElement = indexMethod; | 19792 indexExpression.staticElement = indexMethod; |
| 17761 JUnitTestCase.assertSame(intType, analyze(indexExpression)); | 19793 JUnitTestCase.assertSame(intType, analyze(indexExpression)); |
| 17762 _listener.assertNoErrors(); | 19794 _listener.assertNoErrors(); |
| 17763 } | 19795 } |
| 19796 |
| 17764 void test_visitIndexExpression_typeParameters_inSetterContext() { | 19797 void test_visitIndexExpression_typeParameters_inSetterContext() { |
| 17765 InterfaceType intType = _typeProvider.intType; | 19798 InterfaceType intType = _typeProvider.intType; |
| 17766 InterfaceType listType = _typeProvider.listType; | 19799 InterfaceType listType = _typeProvider.listType; |
| 17767 MethodElement methodElement = getMethod(listType, "[]="); | 19800 MethodElement methodElement = getMethod(listType, "[]="); |
| 17768 SimpleIdentifier identifier = ASTFactory.identifier3("list"); | 19801 SimpleIdentifier identifier = ASTFactory.identifier3("list"); |
| 17769 InterfaceType listOfIntType = listType.substitute4(<Type2> [intType]); | 19802 InterfaceType listOfIntType = listType.substitute4(<Type2> [intType]); |
| 17770 identifier.staticType = listOfIntType; | 19803 identifier.staticType = listOfIntType; |
| 17771 IndexExpression indexExpression = ASTFactory.indexExpression(identifier, AST
Factory.integer(0)); | 19804 IndexExpression indexExpression = ASTFactory.indexExpression(identifier, AST
Factory.integer(0)); |
| 17772 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType); | 19805 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType); |
| 17773 indexExpression.staticElement = indexMethod; | 19806 indexExpression.staticElement = indexMethod; |
| 17774 ASTFactory.assignmentExpression(indexExpression, TokenType.EQ, ASTFactory.in
teger(0)); | 19807 ASTFactory.assignmentExpression(indexExpression, TokenType.EQ, ASTFactory.in
teger(0)); |
| 17775 JUnitTestCase.assertSame(intType, analyze(indexExpression)); | 19808 JUnitTestCase.assertSame(intType, analyze(indexExpression)); |
| 17776 _listener.assertNoErrors(); | 19809 _listener.assertNoErrors(); |
| 17777 } | 19810 } |
| 19811 |
| 17778 void test_visitInstanceCreationExpression_named() { | 19812 void test_visitInstanceCreationExpression_named() { |
| 17779 ClassElementImpl classElement = ElementFactory.classElement2("C", []); | 19813 ClassElementImpl classElement = ElementFactory.classElement2("C", []); |
| 17780 String constructorName = "m"; | 19814 String constructorName = "m"; |
| 17781 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
Element, constructorName); | 19815 ConstructorElementImpl constructor = ElementFactory.constructorElement2(clas
sElement, constructorName, []); |
| 17782 constructor.returnType = classElement.type; | 19816 constructor.returnType = classElement.type; |
| 17783 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); | 19817 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); |
| 17784 constructor.type = constructorType; | 19818 constructor.type = constructorType; |
| 17785 classElement.constructors = <ConstructorElement> [constructor]; | 19819 classElement.constructors = <ConstructorElement> [constructor]; |
| 17786 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam
e)]); | 19820 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam
e)]); |
| 17787 node.staticElement = constructor; | 19821 node.staticElement = constructor; |
| 17788 JUnitTestCase.assertSame(classElement.type, analyze(node)); | 19822 JUnitTestCase.assertSame(classElement.type, analyze(node)); |
| 17789 _listener.assertNoErrors(); | 19823 _listener.assertNoErrors(); |
| 17790 } | 19824 } |
| 19825 |
| 17791 void test_visitInstanceCreationExpression_typeParameters() { | 19826 void test_visitInstanceCreationExpression_typeParameters() { |
| 17792 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]); | 19827 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]); |
| 17793 ClassElementImpl elementI = ElementFactory.classElement2("I", []); | 19828 ClassElementImpl elementI = ElementFactory.classElement2("I", []); |
| 17794 ConstructorElementImpl constructor = ElementFactory.constructorElement(eleme
ntC, null); | 19829 ConstructorElementImpl constructor = ElementFactory.constructorElement2(elem
entC, null, []); |
| 17795 elementC.constructors = <ConstructorElement> [constructor]; | 19830 elementC.constructors = <ConstructorElement> [constructor]; |
| 17796 constructor.returnType = elementC.type; | 19831 constructor.returnType = elementC.type; |
| 17797 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); | 19832 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); |
| 17798 constructor.type = constructorType; | 19833 constructor.type = constructorType; |
| 17799 TypeName typeName = ASTFactory.typeName(elementC, [ASTFactory.typeName(eleme
ntI, [])]); | 19834 TypeName typeName = ASTFactory.typeName(elementC, [ASTFactory.typeName(eleme
ntI, [])]); |
| 17800 typeName.type = elementC.type.substitute4(<Type2> [elementI.type]); | 19835 typeName.type = elementC.type.substitute4(<Type2> [elementI.type]); |
| 17801 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, typeName, []); | 19836 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, typeName, []); |
| 17802 node.staticElement = constructor; | 19837 node.staticElement = constructor; |
| 17803 InterfaceType interfaceType = analyze(node) as InterfaceType; | 19838 InterfaceType interfaceType = analyze(node) as InterfaceType; |
| 17804 List<Type2> typeArgs = interfaceType.typeArguments; | 19839 List<Type2> typeArgs = interfaceType.typeArguments; |
| 17805 JUnitTestCase.assertEquals(1, typeArgs.length); | 19840 JUnitTestCase.assertEquals(1, typeArgs.length); |
| 17806 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]); | 19841 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]); |
| 17807 _listener.assertNoErrors(); | 19842 _listener.assertNoErrors(); |
| 17808 } | 19843 } |
| 19844 |
| 17809 void test_visitInstanceCreationExpression_unnamed() { | 19845 void test_visitInstanceCreationExpression_unnamed() { |
| 17810 ClassElementImpl classElement = ElementFactory.classElement2("C", []); | 19846 ClassElementImpl classElement = ElementFactory.classElement2("C", []); |
| 17811 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
Element, null); | 19847 ConstructorElementImpl constructor = ElementFactory.constructorElement2(clas
sElement, null, []); |
| 17812 constructor.returnType = classElement.type; | 19848 constructor.returnType = classElement.type; |
| 17813 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); | 19849 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); |
| 17814 constructor.type = constructorType; | 19850 constructor.type = constructorType; |
| 17815 classElement.constructors = <ConstructorElement> [constructor]; | 19851 classElement.constructors = <ConstructorElement> [constructor]; |
| 17816 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, ASTFactory.typeName(classElement, []), []); | 19852 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, ASTFactory.typeName(classElement, []), []); |
| 17817 node.staticElement = constructor; | 19853 node.staticElement = constructor; |
| 17818 JUnitTestCase.assertSame(classElement.type, analyze(node)); | 19854 JUnitTestCase.assertSame(classElement.type, analyze(node)); |
| 17819 _listener.assertNoErrors(); | 19855 _listener.assertNoErrors(); |
| 17820 } | 19856 } |
| 19857 |
| 17821 void test_visitIntegerLiteral() { | 19858 void test_visitIntegerLiteral() { |
| 17822 Expression node = resolvedInteger(42); | 19859 Expression node = resolvedInteger(42); |
| 17823 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 19860 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
| 17824 _listener.assertNoErrors(); | 19861 _listener.assertNoErrors(); |
| 17825 } | 19862 } |
| 19863 |
| 17826 void test_visitIsExpression_negated() { | 19864 void test_visitIsExpression_negated() { |
| 17827 Expression node = ASTFactory.isExpression(resolvedString("a"), true, ASTFact
ory.typeName4("String", [])); | 19865 Expression node = ASTFactory.isExpression(resolvedString("a"), true, ASTFact
ory.typeName4("String", [])); |
| 17828 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19866 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17829 _listener.assertNoErrors(); | 19867 _listener.assertNoErrors(); |
| 17830 } | 19868 } |
| 19869 |
| 17831 void test_visitIsExpression_notNegated() { | 19870 void test_visitIsExpression_notNegated() { |
| 17832 Expression node = ASTFactory.isExpression(resolvedString("a"), false, ASTFac
tory.typeName4("String", [])); | 19871 Expression node = ASTFactory.isExpression(resolvedString("a"), false, ASTFac
tory.typeName4("String", [])); |
| 17833 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19872 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17834 _listener.assertNoErrors(); | 19873 _listener.assertNoErrors(); |
| 17835 } | 19874 } |
| 19875 |
| 17836 void test_visitListLiteral_empty() { | 19876 void test_visitListLiteral_empty() { |
| 17837 Expression node = ASTFactory.listLiteral([]); | 19877 Expression node = ASTFactory.listLiteral([]); |
| 17838 Type2 resultType = analyze(node); | 19878 Type2 resultType = analyze(node); |
| 17839 assertType2(_typeProvider.listType.substitute4(<Type2> [_typeProvider.dynami
cType]), resultType); | 19879 assertType2(_typeProvider.listType.substitute4(<Type2> [_typeProvider.dynami
cType]), resultType); |
| 17840 _listener.assertNoErrors(); | 19880 _listener.assertNoErrors(); |
| 17841 } | 19881 } |
| 19882 |
| 17842 void test_visitListLiteral_nonEmpty() { | 19883 void test_visitListLiteral_nonEmpty() { |
| 17843 Expression node = ASTFactory.listLiteral([resolvedInteger(0)]); | 19884 Expression node = ASTFactory.listLiteral([resolvedInteger(0)]); |
| 17844 Type2 resultType = analyze(node); | 19885 Type2 resultType = analyze(node); |
| 17845 assertType2(_typeProvider.listType.substitute4(<Type2> [_typeProvider.dynami
cType]), resultType); | 19886 assertType2(_typeProvider.listType.substitute4(<Type2> [_typeProvider.dynami
cType]), resultType); |
| 17846 _listener.assertNoErrors(); | 19887 _listener.assertNoErrors(); |
| 17847 } | 19888 } |
| 19889 |
| 17848 void test_visitMapLiteral_empty() { | 19890 void test_visitMapLiteral_empty() { |
| 17849 Expression node = ASTFactory.mapLiteral2([]); | 19891 Expression node = ASTFactory.mapLiteral2([]); |
| 17850 Type2 resultType = analyze(node); | 19892 Type2 resultType = analyze(node); |
| 17851 assertType2(_typeProvider.mapType.substitute4(<Type2> [_typeProvider.dynamic
Type, _typeProvider.dynamicType]), resultType); | 19893 assertType2(_typeProvider.mapType.substitute4(<Type2> [_typeProvider.dynamic
Type, _typeProvider.dynamicType]), resultType); |
| 17852 _listener.assertNoErrors(); | 19894 _listener.assertNoErrors(); |
| 17853 } | 19895 } |
| 19896 |
| 17854 void test_visitMapLiteral_nonEmpty() { | 19897 void test_visitMapLiteral_nonEmpty() { |
| 17855 Expression node = ASTFactory.mapLiteral2([ASTFactory.mapLiteralEntry("k", re
solvedInteger(0))]); | 19898 Expression node = ASTFactory.mapLiteral2([ASTFactory.mapLiteralEntry("k", re
solvedInteger(0))]); |
| 17856 Type2 resultType = analyze(node); | 19899 Type2 resultType = analyze(node); |
| 17857 assertType2(_typeProvider.mapType.substitute4(<Type2> [_typeProvider.dynamic
Type, _typeProvider.dynamicType]), resultType); | 19900 assertType2(_typeProvider.mapType.substitute4(<Type2> [_typeProvider.dynamic
Type, _typeProvider.dynamicType]), resultType); |
| 17858 _listener.assertNoErrors(); | 19901 _listener.assertNoErrors(); |
| 17859 } | 19902 } |
| 19903 |
| 17860 void test_visitMethodInvocation_then() { | 19904 void test_visitMethodInvocation_then() { |
| 17861 Expression node = ASTFactory.methodInvocation(null, "then", []); | 19905 Expression node = ASTFactory.methodInvocation(null, "then", []); |
| 17862 analyze(node); | 19906 analyze(node); |
| 17863 _listener.assertNoErrors(); | 19907 _listener.assertNoErrors(); |
| 17864 } | 19908 } |
| 19909 |
| 17865 void test_visitNamedExpression() { | 19910 void test_visitNamedExpression() { |
| 17866 Expression node = ASTFactory.namedExpression2("n", resolvedString("a")); | 19911 Expression node = ASTFactory.namedExpression2("n", resolvedString("a")); |
| 17867 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); | 19912 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); |
| 17868 _listener.assertNoErrors(); | 19913 _listener.assertNoErrors(); |
| 17869 } | 19914 } |
| 19915 |
| 17870 void test_visitNullLiteral() { | 19916 void test_visitNullLiteral() { |
| 17871 Expression node = ASTFactory.nullLiteral(); | 19917 Expression node = ASTFactory.nullLiteral(); |
| 17872 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node)); | 19918 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node)); |
| 17873 _listener.assertNoErrors(); | 19919 _listener.assertNoErrors(); |
| 17874 } | 19920 } |
| 19921 |
| 17875 void test_visitParenthesizedExpression() { | 19922 void test_visitParenthesizedExpression() { |
| 17876 Expression node = ASTFactory.parenthesizedExpression(resolvedInteger(0)); | 19923 Expression node = ASTFactory.parenthesizedExpression(resolvedInteger(0)); |
| 17877 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 19924 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
| 17878 _listener.assertNoErrors(); | 19925 _listener.assertNoErrors(); |
| 17879 } | 19926 } |
| 19927 |
| 17880 void test_visitPostfixExpression_minusMinus() { | 19928 void test_visitPostfixExpression_minusMinus() { |
| 17881 PostfixExpression node = ASTFactory.postfixExpression(resolvedInteger(0), To
kenType.MINUS_MINUS); | 19929 PostfixExpression node = ASTFactory.postfixExpression(resolvedInteger(0), To
kenType.MINUS_MINUS); |
| 17882 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 19930 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
| 17883 _listener.assertNoErrors(); | 19931 _listener.assertNoErrors(); |
| 17884 } | 19932 } |
| 19933 |
| 17885 void test_visitPostfixExpression_plusPlus() { | 19934 void test_visitPostfixExpression_plusPlus() { |
| 17886 PostfixExpression node = ASTFactory.postfixExpression(resolvedInteger(0), To
kenType.PLUS_PLUS); | 19935 PostfixExpression node = ASTFactory.postfixExpression(resolvedInteger(0), To
kenType.PLUS_PLUS); |
| 17887 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 19936 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
| 17888 _listener.assertNoErrors(); | 19937 _listener.assertNoErrors(); |
| 17889 } | 19938 } |
| 19939 |
| 17890 void test_visitPrefixedIdentifier_getter() { | 19940 void test_visitPrefixedIdentifier_getter() { |
| 17891 Type2 boolType = _typeProvider.boolType; | 19941 Type2 boolType = _typeProvider.boolType; |
| 17892 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false
, boolType); | 19942 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false
, boolType); |
| 17893 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); | 19943 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); |
| 17894 node.identifier.staticElement = getter; | 19944 node.identifier.staticElement = getter; |
| 17895 JUnitTestCase.assertSame(boolType, analyze(node)); | 19945 JUnitTestCase.assertSame(boolType, analyze(node)); |
| 17896 _listener.assertNoErrors(); | 19946 _listener.assertNoErrors(); |
| 17897 } | 19947 } |
| 19948 |
| 17898 void test_visitPrefixedIdentifier_setter() { | 19949 void test_visitPrefixedIdentifier_setter() { |
| 17899 Type2 boolType = _typeProvider.boolType; | 19950 Type2 boolType = _typeProvider.boolType; |
| 17900 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals
e, boolType); | 19951 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals
e, boolType); |
| 17901 PropertyAccessorElement setter = field.setter; | 19952 PropertyAccessorElement setter = field.setter; |
| 17902 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); | 19953 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); |
| 17903 node.identifier.staticElement = setter; | 19954 node.identifier.staticElement = setter; |
| 17904 JUnitTestCase.assertSame(boolType, analyze(node)); | 19955 JUnitTestCase.assertSame(boolType, analyze(node)); |
| 17905 _listener.assertNoErrors(); | 19956 _listener.assertNoErrors(); |
| 17906 } | 19957 } |
| 19958 |
| 17907 void test_visitPrefixedIdentifier_variable() { | 19959 void test_visitPrefixedIdentifier_variable() { |
| 17908 VariableElementImpl variable = ElementFactory.localVariableElement2("b"); | 19960 VariableElementImpl variable = ElementFactory.localVariableElement2("b"); |
| 17909 variable.type = _typeProvider.boolType; | 19961 variable.type = _typeProvider.boolType; |
| 17910 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); | 19962 PrefixedIdentifier node = ASTFactory.identifier5("a", "b"); |
| 17911 node.identifier.staticElement = variable; | 19963 node.identifier.staticElement = variable; |
| 17912 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19964 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17913 _listener.assertNoErrors(); | 19965 _listener.assertNoErrors(); |
| 17914 } | 19966 } |
| 19967 |
| 17915 void test_visitPrefixExpression_bang() { | 19968 void test_visitPrefixExpression_bang() { |
| 17916 PrefixExpression node = ASTFactory.prefixExpression(TokenType.BANG, resolved
Integer(0)); | 19969 PrefixExpression node = ASTFactory.prefixExpression(TokenType.BANG, resolved
Integer(0)); |
| 17917 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19970 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17918 _listener.assertNoErrors(); | 19971 _listener.assertNoErrors(); |
| 17919 } | 19972 } |
| 19973 |
| 17920 void test_visitPrefixExpression_minus() { | 19974 void test_visitPrefixExpression_minus() { |
| 17921 PrefixExpression node = ASTFactory.prefixExpression(TokenType.MINUS, resolve
dInteger(0)); | 19975 PrefixExpression node = ASTFactory.prefixExpression(TokenType.MINUS, resolve
dInteger(0)); |
| 17922 MethodElement minusMethod = getMethod(_typeProvider.numType, "-"); | 19976 MethodElement minusMethod = getMethod(_typeProvider.numType, "-"); |
| 17923 node.staticElement = minusMethod; | 19977 node.staticElement = minusMethod; |
| 17924 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node)); | 19978 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node)); |
| 17925 _listener.assertNoErrors(); | 19979 _listener.assertNoErrors(); |
| 17926 } | 19980 } |
| 19981 |
| 17927 void test_visitPrefixExpression_minusMinus() { | 19982 void test_visitPrefixExpression_minusMinus() { |
| 17928 PrefixExpression node = ASTFactory.prefixExpression(TokenType.MINUS_MINUS, r
esolvedInteger(0)); | 19983 PrefixExpression node = ASTFactory.prefixExpression(TokenType.MINUS_MINUS, r
esolvedInteger(0)); |
| 17929 MethodElement minusMethod = getMethod(_typeProvider.numType, "-"); | 19984 MethodElement minusMethod = getMethod(_typeProvider.numType, "-"); |
| 17930 node.staticElement = minusMethod; | 19985 node.staticElement = minusMethod; |
| 17931 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 19986 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
| 17932 _listener.assertNoErrors(); | 19987 _listener.assertNoErrors(); |
| 17933 } | 19988 } |
| 19989 |
| 17934 void test_visitPrefixExpression_not() { | 19990 void test_visitPrefixExpression_not() { |
| 17935 Expression node = ASTFactory.prefixExpression(TokenType.BANG, ASTFactory.boo
leanLiteral(true)); | 19991 Expression node = ASTFactory.prefixExpression(TokenType.BANG, ASTFactory.boo
leanLiteral(true)); |
| 17936 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); | 19992 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); |
| 17937 _listener.assertNoErrors(); | 19993 _listener.assertNoErrors(); |
| 17938 } | 19994 } |
| 19995 |
| 17939 void test_visitPrefixExpression_plusPlus() { | 19996 void test_visitPrefixExpression_plusPlus() { |
| 17940 PrefixExpression node = ASTFactory.prefixExpression(TokenType.PLUS_PLUS, res
olvedInteger(0)); | 19997 PrefixExpression node = ASTFactory.prefixExpression(TokenType.PLUS_PLUS, res
olvedInteger(0)); |
| 17941 MethodElement plusMethod = getMethod(_typeProvider.numType, "+"); | 19998 MethodElement plusMethod = getMethod(_typeProvider.numType, "+"); |
| 17942 node.staticElement = plusMethod; | 19999 node.staticElement = plusMethod; |
| 17943 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 20000 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
| 17944 _listener.assertNoErrors(); | 20001 _listener.assertNoErrors(); |
| 17945 } | 20002 } |
| 20003 |
| 17946 void test_visitPrefixExpression_tilde() { | 20004 void test_visitPrefixExpression_tilde() { |
| 17947 PrefixExpression node = ASTFactory.prefixExpression(TokenType.TILDE, resolve
dInteger(0)); | 20005 PrefixExpression node = ASTFactory.prefixExpression(TokenType.TILDE, resolve
dInteger(0)); |
| 17948 MethodElement tildeMethod = getMethod(_typeProvider.intType, "~"); | 20006 MethodElement tildeMethod = getMethod(_typeProvider.intType, "~"); |
| 17949 node.staticElement = tildeMethod; | 20007 node.staticElement = tildeMethod; |
| 17950 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 20008 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
| 17951 _listener.assertNoErrors(); | 20009 _listener.assertNoErrors(); |
| 17952 } | 20010 } |
| 20011 |
| 17953 void test_visitPropertyAccess_getter() { | 20012 void test_visitPropertyAccess_getter() { |
| 17954 Type2 boolType = _typeProvider.boolType; | 20013 Type2 boolType = _typeProvider.boolType; |
| 17955 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false
, boolType); | 20014 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false
, boolType); |
| 17956 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a")
, "b"); | 20015 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a")
, "b"); |
| 17957 node.propertyName.staticElement = getter; | 20016 node.propertyName.staticElement = getter; |
| 17958 JUnitTestCase.assertSame(boolType, analyze(node)); | 20017 JUnitTestCase.assertSame(boolType, analyze(node)); |
| 17959 _listener.assertNoErrors(); | 20018 _listener.assertNoErrors(); |
| 17960 } | 20019 } |
| 20020 |
| 17961 void test_visitPropertyAccess_setter() { | 20021 void test_visitPropertyAccess_setter() { |
| 17962 Type2 boolType = _typeProvider.boolType; | 20022 Type2 boolType = _typeProvider.boolType; |
| 17963 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals
e, boolType); | 20023 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals
e, boolType); |
| 17964 PropertyAccessorElement setter = field.setter; | 20024 PropertyAccessorElement setter = field.setter; |
| 17965 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a")
, "b"); | 20025 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a")
, "b"); |
| 17966 node.propertyName.staticElement = setter; | 20026 node.propertyName.staticElement = setter; |
| 17967 JUnitTestCase.assertSame(boolType, analyze(node)); | 20027 JUnitTestCase.assertSame(boolType, analyze(node)); |
| 17968 _listener.assertNoErrors(); | 20028 _listener.assertNoErrors(); |
| 17969 } | 20029 } |
| 20030 |
| 17970 void test_visitSimpleStringLiteral() { | 20031 void test_visitSimpleStringLiteral() { |
| 17971 Expression node = resolvedString("a"); | 20032 Expression node = resolvedString("a"); |
| 17972 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); | 20033 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); |
| 17973 _listener.assertNoErrors(); | 20034 _listener.assertNoErrors(); |
| 17974 } | 20035 } |
| 20036 |
| 17975 void test_visitStringInterpolation() { | 20037 void test_visitStringInterpolation() { |
| 17976 Expression node = ASTFactory.string([ | 20038 Expression node = ASTFactory.string([ |
| 17977 ASTFactory.interpolationString("a", "a"), | 20039 ASTFactory.interpolationString("a", "a"), |
| 17978 ASTFactory.interpolationExpression(resolvedString("b")), | 20040 ASTFactory.interpolationExpression(resolvedString("b")), |
| 17979 ASTFactory.interpolationString("c", "c")]); | 20041 ASTFactory.interpolationString("c", "c")]); |
| 17980 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); | 20042 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); |
| 17981 _listener.assertNoErrors(); | 20043 _listener.assertNoErrors(); |
| 17982 } | 20044 } |
| 20045 |
| 17983 void test_visitSuperExpression() { | 20046 void test_visitSuperExpression() { |
| 17984 InterfaceType superType = ElementFactory.classElement2("A", []).type; | 20047 InterfaceType superType = ElementFactory.classElement2("A", []).type; |
| 17985 InterfaceType thisType = ElementFactory.classElement("B", superType, []).typ
e; | 20048 InterfaceType thisType = ElementFactory.classElement("B", superType, []).typ
e; |
| 17986 Expression node = ASTFactory.superExpression(); | 20049 Expression node = ASTFactory.superExpression(); |
| 17987 JUnitTestCase.assertSame(thisType, analyze2(node, thisType)); | 20050 JUnitTestCase.assertSame(thisType, analyze2(node, thisType)); |
| 17988 _listener.assertNoErrors(); | 20051 _listener.assertNoErrors(); |
| 17989 } | 20052 } |
| 20053 |
| 17990 void test_visitSymbolLiteral() { | 20054 void test_visitSymbolLiteral() { |
| 17991 JUnitTestCase.assertSame(_typeProvider.symbolType, analyze(ASTFactory.symbol
Literal(["a"]))); | 20055 JUnitTestCase.assertSame(_typeProvider.symbolType, analyze(ASTFactory.symbol
Literal(["a"]))); |
| 17992 } | 20056 } |
| 20057 |
| 17993 void test_visitThisExpression() { | 20058 void test_visitThisExpression() { |
| 17994 InterfaceType thisType = ElementFactory.classElement("B", ElementFactory.cla
ssElement2("A", []).type, []).type; | 20059 InterfaceType thisType = ElementFactory.classElement("B", ElementFactory.cla
ssElement2("A", []).type, []).type; |
| 17995 Expression node = ASTFactory.thisExpression(); | 20060 Expression node = ASTFactory.thisExpression(); |
| 17996 JUnitTestCase.assertSame(thisType, analyze2(node, thisType)); | 20061 JUnitTestCase.assertSame(thisType, analyze2(node, thisType)); |
| 17997 _listener.assertNoErrors(); | 20062 _listener.assertNoErrors(); |
| 17998 } | 20063 } |
| 20064 |
| 17999 void test_visitThrowExpression_withoutValue() { | 20065 void test_visitThrowExpression_withoutValue() { |
| 18000 Expression node = ASTFactory.throwExpression(); | 20066 Expression node = ASTFactory.throwExpression(); |
| 18001 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node)); | 20067 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node)); |
| 18002 _listener.assertNoErrors(); | 20068 _listener.assertNoErrors(); |
| 18003 } | 20069 } |
| 20070 |
| 18004 void test_visitThrowExpression_withValue() { | 20071 void test_visitThrowExpression_withValue() { |
| 18005 Expression node = ASTFactory.throwExpression2(resolvedInteger(0)); | 20072 Expression node = ASTFactory.throwExpression2(resolvedInteger(0)); |
| 18006 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node)); | 20073 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node)); |
| 18007 _listener.assertNoErrors(); | 20074 _listener.assertNoErrors(); |
| 18008 } | 20075 } |
| 18009 | 20076 |
| 18010 /** | 20077 /** |
| 18011 * Return the type associated with the given expression after the static type
analyzer has | 20078 * Return the type associated with the given expression after the static type
analyzer has |
| 18012 * computed a type for it. | 20079 * computed a type for it. |
| 18013 * | 20080 * |
| (...skipping 22 matching lines...) Expand all Loading... |
| 18036 | 20103 |
| 18037 /** | 20104 /** |
| 18038 * Return the type associated with the given parameter after the static type a
nalyzer has computed | 20105 * Return the type associated with the given parameter after the static type a
nalyzer has computed |
| 18039 * a type for it. | 20106 * a type for it. |
| 18040 * | 20107 * |
| 18041 * @param node the parameter with which the type is associated | 20108 * @param node the parameter with which the type is associated |
| 18042 * @return the type associated with the parameter | 20109 * @return the type associated with the parameter |
| 18043 */ | 20110 */ |
| 18044 Type2 analyze3(FormalParameter node) { | 20111 Type2 analyze3(FormalParameter node) { |
| 18045 node.accept(_analyzer); | 20112 node.accept(_analyzer); |
| 18046 return ((node.identifier.staticElement as ParameterElement)).type; | 20113 return (node.identifier.staticElement as ParameterElement).type; |
| 18047 } | 20114 } |
| 18048 | 20115 |
| 18049 /** | 20116 /** |
| 18050 * Assert that the actual type is a function type with the expected characteri
stics. | 20117 * Assert that the actual type is a function type with the expected characteri
stics. |
| 18051 * | 20118 * |
| 18052 * @param expectedReturnType the expected return type of the function | 20119 * @param expectedReturnType the expected return type of the function |
| 18053 * @param expectedNormalTypes the expected types of the normal parameters | 20120 * @param expectedNormalTypes the expected types of the normal parameters |
| 18054 * @param expectedOptionalTypes the expected types of the optional parameters | 20121 * @param expectedOptionalTypes the expected types of the optional parameters |
| 18055 * @param expectedNamedTypes the expected types of the named parameters | 20122 * @param expectedNamedTypes the expected types of the named parameters |
| 18056 * @param actualType the type being tested | 20123 * @param actualType the type being tested |
| (...skipping 25 matching lines...) Expand all Loading... |
| 18082 if (expectedNamedTypes == null) { | 20149 if (expectedNamedTypes == null) { |
| 18083 EngineTestCase.assertSize2(0, namedTypes); | 20150 EngineTestCase.assertSize2(0, namedTypes); |
| 18084 } else { | 20151 } else { |
| 18085 EngineTestCase.assertSize2(expectedNamedTypes.length, namedTypes); | 20152 EngineTestCase.assertSize2(expectedNamedTypes.length, namedTypes); |
| 18086 for (MapEntry<String, Type2> entry in getMapEntrySet(expectedNamedTypes))
{ | 20153 for (MapEntry<String, Type2> entry in getMapEntrySet(expectedNamedTypes))
{ |
| 18087 JUnitTestCase.assertSame(entry.getValue(), namedTypes[entry.getKey()]); | 20154 JUnitTestCase.assertSame(entry.getValue(), namedTypes[entry.getKey()]); |
| 18088 } | 20155 } |
| 18089 } | 20156 } |
| 18090 JUnitTestCase.assertSame(expectedReturnType, functionType.returnType); | 20157 JUnitTestCase.assertSame(expectedReturnType, functionType.returnType); |
| 18091 } | 20158 } |
| 20159 |
| 18092 void assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType)
{ | 20160 void assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType)
{ |
| 18093 JUnitTestCase.assertEquals(expectedType.displayName, actualType.displayName)
; | 20161 JUnitTestCase.assertEquals(expectedType.displayName, actualType.displayName)
; |
| 18094 JUnitTestCase.assertEquals(expectedType.element, actualType.element); | 20162 JUnitTestCase.assertEquals(expectedType.element, actualType.element); |
| 18095 List<Type2> expectedArguments = expectedType.typeArguments; | 20163 List<Type2> expectedArguments = expectedType.typeArguments; |
| 18096 int length = expectedArguments.length; | 20164 int length = expectedArguments.length; |
| 18097 List<Type2> actualArguments = actualType.typeArguments; | 20165 List<Type2> actualArguments = actualType.typeArguments; |
| 18098 EngineTestCase.assertLength(length, actualArguments); | 20166 EngineTestCase.assertLength(length, actualArguments); |
| 18099 for (int i = 0; i < length; i++) { | 20167 for (int i = 0; i < length; i++) { |
| 18100 assertType2(expectedArguments[i], actualArguments[i]); | 20168 assertType2(expectedArguments[i], actualArguments[i]); |
| 18101 } | 20169 } |
| 18102 } | 20170 } |
| 20171 |
| 18103 void assertType2(Type2 expectedType, Type2 actualType) { | 20172 void assertType2(Type2 expectedType, Type2 actualType) { |
| 18104 if (expectedType is InterfaceTypeImpl) { | 20173 if (expectedType is InterfaceTypeImpl) { |
| 18105 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType); | 20174 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType); |
| 18106 assertType(expectedType as InterfaceTypeImpl, actualType as InterfaceTypeI
mpl); | 20175 assertType(expectedType as InterfaceTypeImpl, actualType as InterfaceTypeI
mpl); |
| 18107 } | 20176 } |
| 18108 } | 20177 } |
| 18109 | 20178 |
| 18110 /** | 20179 /** |
| 18111 * Create the analyzer used by the tests. | 20180 * Create the analyzer used by the tests. |
| 18112 * | 20181 * |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18217 * @param parameter the parameter whose type is to be set | 20286 * @param parameter the parameter whose type is to be set |
| 18218 * @param type the new type of the given parameter | 20287 * @param type the new type of the given parameter |
| 18219 */ | 20288 */ |
| 18220 void setType(FormalParameter parameter, Type2 type) { | 20289 void setType(FormalParameter parameter, Type2 type) { |
| 18221 SimpleIdentifier identifier = parameter.identifier; | 20290 SimpleIdentifier identifier = parameter.identifier; |
| 18222 Element element = identifier.staticElement; | 20291 Element element = identifier.staticElement; |
| 18223 if (element is! ParameterElement) { | 20292 if (element is! ParameterElement) { |
| 18224 element = new ParameterElementImpl.con1(identifier); | 20293 element = new ParameterElementImpl.con1(identifier); |
| 18225 identifier.staticElement = element; | 20294 identifier.staticElement = element; |
| 18226 } | 20295 } |
| 18227 ((element as ParameterElementImpl)).type = type; | 20296 (element as ParameterElementImpl).type = type; |
| 18228 } | 20297 } |
| 20298 |
| 18229 static dartSuite() { | 20299 static dartSuite() { |
| 18230 _ut.group('StaticTypeAnalyzerTest', () { | 20300 _ut.group('StaticTypeAnalyzerTest', () { |
| 18231 _ut.test('test_visitAdjacentStrings', () { | 20301 _ut.test('test_visitAdjacentStrings', () { |
| 18232 final __test = new StaticTypeAnalyzerTest(); | 20302 final __test = new StaticTypeAnalyzerTest(); |
| 18233 runJUnitTest(__test, __test.test_visitAdjacentStrings); | 20303 runJUnitTest(__test, __test.test_visitAdjacentStrings); |
| 18234 }); | 20304 }); |
| 18235 _ut.test('test_visitArgumentDefinitionTest', () { | 20305 _ut.test('test_visitArgumentDefinitionTest', () { |
| 18236 final __test = new StaticTypeAnalyzerTest(); | 20306 final __test = new StaticTypeAnalyzerTest(); |
| 18237 runJUnitTest(__test, __test.test_visitArgumentDefinitionTest); | 20307 runJUnitTest(__test, __test.test_visitArgumentDefinitionTest); |
| 18238 }); | 20308 }); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18496 final __test = new StaticTypeAnalyzerTest(); | 20566 final __test = new StaticTypeAnalyzerTest(); |
| 18497 runJUnitTest(__test, __test.test_visitThrowExpression_withValue); | 20567 runJUnitTest(__test, __test.test_visitThrowExpression_withValue); |
| 18498 }); | 20568 }); |
| 18499 _ut.test('test_visitThrowExpression_withoutValue', () { | 20569 _ut.test('test_visitThrowExpression_withoutValue', () { |
| 18500 final __test = new StaticTypeAnalyzerTest(); | 20570 final __test = new StaticTypeAnalyzerTest(); |
| 18501 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue); | 20571 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue); |
| 18502 }); | 20572 }); |
| 18503 }); | 20573 }); |
| 18504 } | 20574 } |
| 18505 } | 20575 } |
| 20576 |
| 18506 class NonHintCodeTest extends ResolverTestCase { | 20577 class NonHintCodeTest extends ResolverTestCase { |
| 18507 void test_deadCode_deadBlock_conditionalElse_debugConst() { | 20578 void test_deadCode_deadBlock_conditionalElse_debugConst() { |
| 18508 Source source = addSource(EngineTestCase.createSource([ | 20579 Source source = addSource(EngineTestCase.createSource([ |
| 18509 "const bool DEBUG = true;", | 20580 "const bool DEBUG = true;", |
| 18510 "f() {", | 20581 "f() {", |
| 18511 " DEBUG ? 1 : 2;", | 20582 " DEBUG ? 1 : 2;", |
| 18512 "}"])); | 20583 "}"])); |
| 18513 resolve(source); | 20584 resolve(source); |
| 18514 assertNoErrors(source); | 20585 assertNoErrors(source); |
| 18515 verify([source]); | 20586 verify([source]); |
| 18516 } | 20587 } |
| 20588 |
| 18517 void test_deadCode_deadBlock_conditionalIf_debugConst() { | 20589 void test_deadCode_deadBlock_conditionalIf_debugConst() { |
| 18518 Source source = addSource(EngineTestCase.createSource([ | 20590 Source source = addSource(EngineTestCase.createSource([ |
| 18519 "const bool DEBUG = false;", | 20591 "const bool DEBUG = false;", |
| 18520 "f() {", | 20592 "f() {", |
| 18521 " DEBUG ? 1 : 2;", | 20593 " DEBUG ? 1 : 2;", |
| 18522 "}"])); | 20594 "}"])); |
| 18523 resolve(source); | 20595 resolve(source); |
| 18524 assertNoErrors(source); | 20596 assertNoErrors(source); |
| 18525 verify([source]); | 20597 verify([source]); |
| 18526 } | 20598 } |
| 20599 |
| 18527 void test_deadCode_deadBlock_else() { | 20600 void test_deadCode_deadBlock_else() { |
| 18528 Source source = addSource(EngineTestCase.createSource([ | 20601 Source source = addSource(EngineTestCase.createSource([ |
| 18529 "const bool DEBUG = true;", | 20602 "const bool DEBUG = true;", |
| 18530 "f() {", | 20603 "f() {", |
| 18531 " if(DEBUG) {} else {}", | 20604 " if(DEBUG) {} else {}", |
| 18532 "}"])); | 20605 "}"])); |
| 18533 resolve(source); | 20606 resolve(source); |
| 18534 assertNoErrors(source); | 20607 assertNoErrors(source); |
| 18535 verify([source]); | 20608 verify([source]); |
| 18536 } | 20609 } |
| 20610 |
| 18537 void test_deadCode_deadBlock_if_debugConst_prefixedIdentifier() { | 20611 void test_deadCode_deadBlock_if_debugConst_prefixedIdentifier() { |
| 18538 Source source = addSource(EngineTestCase.createSource([ | 20612 Source source = addSource(EngineTestCase.createSource([ |
| 18539 "class A {", | 20613 "class A {", |
| 18540 " static const bool DEBUG = false;", | 20614 " static const bool DEBUG = false;", |
| 18541 "}", | 20615 "}", |
| 18542 "f() {", | 20616 "f() {", |
| 18543 " if(A.DEBUG) {}", | 20617 " if(A.DEBUG) {}", |
| 18544 "}"])); | 20618 "}"])); |
| 18545 resolve(source); | 20619 resolve(source); |
| 18546 assertNoErrors(source); | 20620 assertNoErrors(source); |
| 18547 verify([source]); | 20621 verify([source]); |
| 18548 } | 20622 } |
| 20623 |
| 18549 void test_deadCode_deadBlock_if_debugConst_prefixedIdentifier2() { | 20624 void test_deadCode_deadBlock_if_debugConst_prefixedIdentifier2() { |
| 18550 Source source = addSource(EngineTestCase.createSource([ | 20625 Source source = addSource(EngineTestCase.createSource([ |
| 18551 "library L;", | 20626 "library L;", |
| 18552 "import 'lib2.dart';", | 20627 "import 'lib2.dart';", |
| 18553 "f() {", | 20628 "f() {", |
| 18554 " if(A.DEBUG) {}", | 20629 " if(A.DEBUG) {}", |
| 18555 "}"])); | 20630 "}"])); |
| 18556 addSource2("/lib2.dart", EngineTestCase.createSource([ | 20631 addSource2("/lib2.dart", EngineTestCase.createSource([ |
| 18557 "library lib2;", | 20632 "library lib2;", |
| 18558 "class A {", | 20633 "class A {", |
| 18559 " static const bool DEBUG = false;", | 20634 " static const bool DEBUG = false;", |
| 18560 "}"])); | 20635 "}"])); |
| 18561 resolve(source); | 20636 resolve(source); |
| 18562 assertNoErrors(source); | 20637 assertNoErrors(source); |
| 18563 verify([source]); | 20638 verify([source]); |
| 18564 } | 20639 } |
| 20640 |
| 18565 void test_deadCode_deadBlock_if_debugConst_propertyAccessor() { | 20641 void test_deadCode_deadBlock_if_debugConst_propertyAccessor() { |
| 18566 Source source = addSource(EngineTestCase.createSource([ | 20642 Source source = addSource(EngineTestCase.createSource([ |
| 18567 "library L;", | 20643 "library L;", |
| 18568 "import 'lib2.dart' as LIB;", | 20644 "import 'lib2.dart' as LIB;", |
| 18569 "f() {", | 20645 "f() {", |
| 18570 " if(LIB.A.DEBUG) {}", | 20646 " if(LIB.A.DEBUG) {}", |
| 18571 "}"])); | 20647 "}"])); |
| 18572 addSource2("/lib2.dart", EngineTestCase.createSource([ | 20648 addSource2("/lib2.dart", EngineTestCase.createSource([ |
| 18573 "library lib2;", | 20649 "library lib2;", |
| 18574 "class A {", | 20650 "class A {", |
| 18575 " static const bool DEBUG = false;", | 20651 " static const bool DEBUG = false;", |
| 18576 "}"])); | 20652 "}"])); |
| 18577 resolve(source); | 20653 resolve(source); |
| 18578 assertNoErrors(source); | 20654 assertNoErrors(source); |
| 18579 verify([source]); | 20655 verify([source]); |
| 18580 } | 20656 } |
| 20657 |
| 18581 void test_deadCode_deadBlock_if_debugConst_simpleIdentifier() { | 20658 void test_deadCode_deadBlock_if_debugConst_simpleIdentifier() { |
| 18582 Source source = addSource(EngineTestCase.createSource([ | 20659 Source source = addSource(EngineTestCase.createSource([ |
| 18583 "const bool DEBUG = false;", | 20660 "const bool DEBUG = false;", |
| 18584 "f() {", | 20661 "f() {", |
| 18585 " if(DEBUG) {}", | 20662 " if(DEBUG) {}", |
| 18586 "}"])); | 20663 "}"])); |
| 18587 resolve(source); | 20664 resolve(source); |
| 18588 assertNoErrors(source); | 20665 assertNoErrors(source); |
| 18589 verify([source]); | 20666 verify([source]); |
| 18590 } | 20667 } |
| 20668 |
| 18591 void test_deadCode_deadBlock_while_debugConst() { | 20669 void test_deadCode_deadBlock_while_debugConst() { |
| 18592 Source source = addSource(EngineTestCase.createSource([ | 20670 Source source = addSource(EngineTestCase.createSource([ |
| 18593 "const bool DEBUG = false;", | 20671 "const bool DEBUG = false;", |
| 18594 "f() {", | 20672 "f() {", |
| 18595 " while(DEBUG) {}", | 20673 " while(DEBUG) {}", |
| 18596 "}"])); | 20674 "}"])); |
| 18597 resolve(source); | 20675 resolve(source); |
| 18598 assertNoErrors(source); | 20676 assertNoErrors(source); |
| 18599 verify([source]); | 20677 verify([source]); |
| 18600 } | 20678 } |
| 20679 |
| 18601 void test_deadCode_deadCatch_onCatchSubtype() { | 20680 void test_deadCode_deadCatch_onCatchSubtype() { |
| 18602 Source source = addSource(EngineTestCase.createSource([ | 20681 Source source = addSource(EngineTestCase.createSource([ |
| 18603 "class A {}", | 20682 "class A {}", |
| 18604 "class B extends A {}", | 20683 "class B extends A {}", |
| 18605 "f() {", | 20684 "f() {", |
| 18606 " try {} on B catch (e) {} on A catch (e) {} catch (e) {}", | 20685 " try {} on B catch (e) {} on A catch (e) {} catch (e) {}", |
| 18607 "}"])); | 20686 "}"])); |
| 18608 resolve(source); | 20687 resolve(source); |
| 18609 assertNoErrors(source); | 20688 assertNoErrors(source); |
| 18610 verify([source]); | 20689 verify([source]); |
| 18611 } | 20690 } |
| 20691 |
| 18612 void test_deadCode_deadOperandLHS_and_debugConst() { | 20692 void test_deadCode_deadOperandLHS_and_debugConst() { |
| 18613 Source source = addSource(EngineTestCase.createSource([ | 20693 Source source = addSource(EngineTestCase.createSource([ |
| 18614 "const bool DEBUG = false;", | 20694 "const bool DEBUG = false;", |
| 18615 "f() {", | 20695 "f() {", |
| 18616 " bool b = DEBUG && false;", | 20696 " bool b = DEBUG && false;", |
| 18617 "}"])); | 20697 "}"])); |
| 18618 resolve(source); | 20698 resolve(source); |
| 18619 assertNoErrors(source); | 20699 assertNoErrors(source); |
| 18620 verify([source]); | 20700 verify([source]); |
| 18621 } | 20701 } |
| 20702 |
| 18622 void test_deadCode_deadOperandLHS_or_debugConst() { | 20703 void test_deadCode_deadOperandLHS_or_debugConst() { |
| 18623 Source source = addSource(EngineTestCase.createSource([ | 20704 Source source = addSource(EngineTestCase.createSource([ |
| 18624 "const bool DEBUG = true;", | 20705 "const bool DEBUG = true;", |
| 18625 "f() {", | 20706 "f() {", |
| 18626 " bool b = DEBUG || true;", | 20707 " bool b = DEBUG || true;", |
| 18627 "}"])); | 20708 "}"])); |
| 18628 resolve(source); | 20709 resolve(source); |
| 18629 assertNoErrors(source); | 20710 assertNoErrors(source); |
| 18630 verify([source]); | 20711 verify([source]); |
| 18631 } | 20712 } |
| 20713 |
| 18632 void test_divisionOptimization() { | 20714 void test_divisionOptimization() { |
| 18633 Source source = addSource(EngineTestCase.createSource(["f(int x, int y) {",
" var v = x / y.toInt();", "}"])); | 20715 Source source = addSource(EngineTestCase.createSource(["f(int x, int y) {",
" var v = x / y.toInt();", "}"])); |
| 18634 resolve(source); | 20716 resolve(source); |
| 18635 assertNoErrors(source); | 20717 assertNoErrors(source); |
| 18636 verify([source]); | 20718 verify([source]); |
| 18637 } | 20719 } |
| 20720 |
| 18638 void test_divisionOptimization_supressIfDivisionNotDefinedInCore() { | 20721 void test_divisionOptimization_supressIfDivisionNotDefinedInCore() { |
| 18639 Source source = addSource(EngineTestCase.createSource(["f(x, y) {", " var v
= (x / y).toInt();", "}"])); | 20722 Source source = addSource(EngineTestCase.createSource(["f(x, y) {", " var v
= (x / y).toInt();", "}"])); |
| 18640 resolve(source); | 20723 resolve(source); |
| 18641 assertNoErrors(source); | 20724 assertNoErrors(source); |
| 18642 verify([source]); | 20725 verify([source]); |
| 18643 } | 20726 } |
| 20727 |
| 18644 void test_divisionOptimization_supressIfDivisionOverridden() { | 20728 void test_divisionOptimization_supressIfDivisionOverridden() { |
| 18645 Source source = addSource(EngineTestCase.createSource([ | 20729 Source source = addSource(EngineTestCase.createSource([ |
| 18646 "class A {", | 20730 "class A {", |
| 18647 " num operator /(x) {}", | 20731 " num operator /(x) {}", |
| 18648 "}", | 20732 "}", |
| 18649 "f(A x, A y) {", | 20733 "f(A x, A y) {", |
| 18650 " var v = (x / y).toInt();", | 20734 " var v = (x / y).toInt();", |
| 18651 "}"])); | 20735 "}"])); |
| 18652 resolve(source); | 20736 resolve(source); |
| 18653 assertNoErrors(source); | 20737 assertNoErrors(source); |
| 18654 verify([source]); | 20738 verify([source]); |
| 18655 } | 20739 } |
| 20740 |
| 18656 void test_duplicateImport_as() { | 20741 void test_duplicateImport_as() { |
| 18657 Source source = addSource(EngineTestCase.createSource([ | 20742 Source source = addSource(EngineTestCase.createSource([ |
| 18658 "library L;", | 20743 "library L;", |
| 18659 "import 'lib1.dart';", | 20744 "import 'lib1.dart';", |
| 18660 "import 'lib1.dart' as one;", | 20745 "import 'lib1.dart' as one;", |
| 18661 "A a;", | 20746 "A a;", |
| 18662 "one.A a2;"])); | 20747 "one.A a2;"])); |
| 18663 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); | 20748 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); |
| 18664 resolve(source); | 20749 resolve(source); |
| 18665 assertNoErrors(source); | 20750 assertNoErrors(source); |
| 18666 verify([source]); | 20751 verify([source]); |
| 18667 } | 20752 } |
| 20753 |
| 18668 void test_duplicateImport_hide() { | 20754 void test_duplicateImport_hide() { |
| 18669 Source source = addSource(EngineTestCase.createSource([ | 20755 Source source = addSource(EngineTestCase.createSource([ |
| 18670 "library L;", | 20756 "library L;", |
| 18671 "import 'lib1.dart';", | 20757 "import 'lib1.dart';", |
| 18672 "import 'lib1.dart' hide A;", | 20758 "import 'lib1.dart' hide A;", |
| 18673 "A a;", | 20759 "A a;", |
| 18674 "B b;"])); | 20760 "B b;"])); |
| 18675 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}", "class B {}"])); | 20761 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}", "class B {}"])); |
| 18676 resolve(source); | 20762 resolve(source); |
| 18677 assertNoErrors(source); | 20763 assertNoErrors(source); |
| 18678 verify([source]); | 20764 verify([source]); |
| 18679 } | 20765 } |
| 20766 |
| 18680 void test_duplicateImport_show() { | 20767 void test_duplicateImport_show() { |
| 18681 Source source = addSource(EngineTestCase.createSource([ | 20768 Source source = addSource(EngineTestCase.createSource([ |
| 18682 "library L;", | 20769 "library L;", |
| 18683 "import 'lib1.dart';", | 20770 "import 'lib1.dart';", |
| 18684 "import 'lib1.dart' show A;", | 20771 "import 'lib1.dart' show A;", |
| 18685 "A a;", | 20772 "A a;", |
| 18686 "B b;"])); | 20773 "B b;"])); |
| 18687 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}", "class B {}"])); | 20774 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}", "class B {}"])); |
| 18688 resolve(source); | 20775 resolve(source); |
| 18689 assertNoErrors(source); | 20776 assertNoErrors(source); |
| 18690 verify([source]); | 20777 verify([source]); |
| 18691 } | 20778 } |
| 20779 |
| 18692 void test_overriddingPrivateMember_sameLibrary() { | 20780 void test_overriddingPrivateMember_sameLibrary() { |
| 18693 Source source = addSource(EngineTestCase.createSource([ | 20781 Source source = addSource(EngineTestCase.createSource([ |
| 18694 "class A {", | 20782 "class A {", |
| 18695 " _m(int x) => 0;", | 20783 " _m(int x) => 0;", |
| 18696 "}", | 20784 "}", |
| 18697 "class B extends A {", | 20785 "class B extends A {", |
| 18698 " _m(int x) => 0;", | 20786 " _m(int x) => 0;", |
| 18699 "}"])); | 20787 "}"])); |
| 18700 resolve(source); | 20788 resolve(source); |
| 18701 assertNoErrors(source); | 20789 assertNoErrors(source); |
| 18702 verify([source]); | 20790 verify([source]); |
| 18703 } | 20791 } |
| 20792 |
| 18704 void test_overrideEqualsButNotHashCode() { | 20793 void test_overrideEqualsButNotHashCode() { |
| 18705 Source source = addSource(EngineTestCase.createSource([ | 20794 Source source = addSource(EngineTestCase.createSource([ |
| 18706 "class A {", | 20795 "class A {", |
| 18707 " bool operator ==(x) {}", | 20796 " bool operator ==(x) {}", |
| 18708 " get hashCode => 0;", | 20797 " get hashCode => 0;", |
| 18709 "}"])); | 20798 "}"])); |
| 18710 resolve(source); | 20799 resolve(source); |
| 18711 assertNoErrors(source); | 20800 assertNoErrors(source); |
| 18712 verify([source]); | 20801 verify([source]); |
| 18713 } | 20802 } |
| 20803 |
| 18714 void test_proxy_annotation_prefixed() { | 20804 void test_proxy_annotation_prefixed() { |
| 18715 Source source = addSource(EngineTestCase.createSource([ | 20805 Source source = addSource(EngineTestCase.createSource([ |
| 18716 "library L;", | 20806 "library L;", |
| 18717 "import 'meta.dart';", | |
| 18718 "@proxy", | 20807 "@proxy", |
| 18719 "class A {}", | 20808 "class A {}", |
| 18720 "f(var a) {", | 20809 "f(var a) {", |
| 18721 " a = new A();", | 20810 " a = new A();", |
| 18722 " a.m();", | 20811 " a.m();", |
| 18723 " var x = a.g;", | 20812 " var x = a.g;", |
| 18724 " a.s = 1;", | 20813 " a.s = 1;", |
| 18725 " var y = a + a;", | 20814 " var y = a + a;", |
| 18726 " a++;", | 20815 " a++;", |
| 18727 " ++a;", | 20816 " ++a;", |
| 18728 "}"])); | 20817 "}"])); |
| 18729 addSource2("/meta.dart", EngineTestCase.createSource([ | |
| 18730 "library meta;", | |
| 18731 "const proxy = const _Proxy();", | |
| 18732 "class _Proxy { const _Proxy(); }"])); | |
| 18733 resolve(source); | 20818 resolve(source); |
| 18734 assertNoErrors(source); | 20819 assertNoErrors(source); |
| 18735 } | 20820 } |
| 20821 |
| 18736 void test_proxy_annotation_prefixed2() { | 20822 void test_proxy_annotation_prefixed2() { |
| 18737 Source source = addSource(EngineTestCase.createSource([ | 20823 Source source = addSource(EngineTestCase.createSource([ |
| 18738 "library L;", | 20824 "library L;", |
| 18739 "import 'meta.dart';", | |
| 18740 "@proxy", | 20825 "@proxy", |
| 18741 "class A {}", | 20826 "class A {}", |
| 18742 "class B {", | 20827 "class B {", |
| 18743 " f(var a) {", | 20828 " f(var a) {", |
| 18744 " a = new A();", | 20829 " a = new A();", |
| 18745 " a.m();", | 20830 " a.m();", |
| 18746 " var x = a.g;", | 20831 " var x = a.g;", |
| 18747 " a.s = 1;", | 20832 " a.s = 1;", |
| 18748 " var y = a + a;", | 20833 " var y = a + a;", |
| 18749 " a++;", | 20834 " a++;", |
| 18750 " ++a;", | 20835 " ++a;", |
| 18751 " }", | 20836 " }", |
| 18752 "}"])); | 20837 "}"])); |
| 18753 addSource2("/meta.dart", EngineTestCase.createSource([ | |
| 18754 "library meta;", | |
| 18755 "const proxy = const _Proxy();", | |
| 18756 "class _Proxy { const _Proxy(); }"])); | |
| 18757 resolve(source); | 20838 resolve(source); |
| 18758 assertNoErrors(source); | 20839 assertNoErrors(source); |
| 18759 } | 20840 } |
| 20841 |
| 18760 void test_proxy_annotation_prefixed3() { | 20842 void test_proxy_annotation_prefixed3() { |
| 18761 Source source = addSource(EngineTestCase.createSource([ | 20843 Source source = addSource(EngineTestCase.createSource([ |
| 18762 "library L;", | 20844 "library L;", |
| 18763 "import 'meta.dart';", | |
| 18764 "class B {", | 20845 "class B {", |
| 18765 " f(var a) {", | 20846 " f(var a) {", |
| 18766 " a = new A();", | 20847 " a = new A();", |
| 18767 " a.m();", | 20848 " a.m();", |
| 18768 " var x = a.g;", | 20849 " var x = a.g;", |
| 18769 " a.s = 1;", | 20850 " a.s = 1;", |
| 18770 " var y = a + a;", | 20851 " var y = a + a;", |
| 18771 " a++;", | 20852 " a++;", |
| 18772 " ++a;", | 20853 " ++a;", |
| 18773 " }", | 20854 " }", |
| 18774 "}", | 20855 "}", |
| 18775 "@proxy", | 20856 "@proxy", |
| 18776 "class A {}"])); | 20857 "class A {}"])); |
| 18777 addSource2("/meta.dart", EngineTestCase.createSource([ | |
| 18778 "library meta;", | |
| 18779 "const proxy = const _Proxy();", | |
| 18780 "class _Proxy { const _Proxy(); }"])); | |
| 18781 resolve(source); | 20858 resolve(source); |
| 18782 assertNoErrors(source); | 20859 assertNoErrors(source); |
| 18783 } | 20860 } |
| 20861 |
| 18784 void test_undefinedGetter_inSubtype() { | 20862 void test_undefinedGetter_inSubtype() { |
| 18785 Source source = addSource(EngineTestCase.createSource([ | 20863 Source source = addSource(EngineTestCase.createSource([ |
| 18786 "class A {}", | 20864 "class A {}", |
| 18787 "class B extends A {", | 20865 "class B extends A {", |
| 18788 " get b => 0;", | 20866 " get b => 0;", |
| 18789 "}", | 20867 "}", |
| 18790 "f(var a) {", | 20868 "f(var a) {", |
| 18791 " if(a is A) {", | 20869 " if(a is A) {", |
| 18792 " return a.b;", | 20870 " return a.b;", |
| 18793 " }", | 20871 " }", |
| 18794 "}"])); | 20872 "}"])); |
| 18795 resolve(source); | 20873 resolve(source); |
| 18796 assertNoErrors(source); | 20874 assertNoErrors(source); |
| 18797 } | 20875 } |
| 20876 |
| 18798 void test_undefinedMethod_assignmentExpression_inSubtype() { | 20877 void test_undefinedMethod_assignmentExpression_inSubtype() { |
| 18799 Source source = addSource(EngineTestCase.createSource([ | 20878 Source source = addSource(EngineTestCase.createSource([ |
| 18800 "class A {}", | 20879 "class A {}", |
| 18801 "class B extends A {", | 20880 "class B extends A {", |
| 18802 " operator +(B b) {return new B();}", | 20881 " operator +(B b) {return new B();}", |
| 18803 "}", | 20882 "}", |
| 18804 "f(var a, var a2) {", | 20883 "f(var a, var a2) {", |
| 18805 " a = new A();", | 20884 " a = new A();", |
| 18806 " a2 = new A();", | 20885 " a2 = new A();", |
| 18807 " a += a2;", | 20886 " a += a2;", |
| 18808 "}"])); | 20887 "}"])); |
| 18809 resolve(source); | 20888 resolve(source); |
| 18810 assertNoErrors(source); | 20889 assertNoErrors(source); |
| 18811 } | 20890 } |
| 20891 |
| 18812 void test_undefinedMethod_inSubtype() { | 20892 void test_undefinedMethod_inSubtype() { |
| 18813 Source source = addSource(EngineTestCase.createSource([ | 20893 Source source = addSource(EngineTestCase.createSource([ |
| 18814 "class A {}", | 20894 "class A {}", |
| 18815 "class B extends A {", | 20895 "class B extends A {", |
| 18816 " b() {}", | 20896 " b() {}", |
| 18817 "}", | 20897 "}", |
| 18818 "f() {", | 20898 "f() {", |
| 18819 " var a = new A();", | 20899 " var a = new A();", |
| 18820 " a.b();", | 20900 " a.b();", |
| 18821 "}"])); | 20901 "}"])); |
| 18822 resolve(source); | 20902 resolve(source); |
| 18823 assertNoErrors(source); | 20903 assertNoErrors(source); |
| 18824 } | 20904 } |
| 20905 |
| 18825 void test_undefinedOperator_binaryExpression_inSubtype() { | 20906 void test_undefinedOperator_binaryExpression_inSubtype() { |
| 18826 Source source = addSource(EngineTestCase.createSource([ | 20907 Source source = addSource(EngineTestCase.createSource([ |
| 18827 "class A {}", | 20908 "class A {}", |
| 18828 "class B extends A {", | 20909 "class B extends A {", |
| 18829 " operator +(B b) {}", | 20910 " operator +(B b) {}", |
| 18830 "}", | 20911 "}", |
| 18831 "f(var a) {", | 20912 "f(var a) {", |
| 18832 " if(a is A) {", | 20913 " if(a is A) {", |
| 18833 " a + 1;", | 20914 " a + 1;", |
| 18834 " }", | 20915 " }", |
| 18835 "}"])); | 20916 "}"])); |
| 18836 resolve(source); | 20917 resolve(source); |
| 18837 assertNoErrors(source); | 20918 assertNoErrors(source); |
| 18838 } | 20919 } |
| 20920 |
| 18839 void test_undefinedOperator_indexBoth_inSubtype() { | 20921 void test_undefinedOperator_indexBoth_inSubtype() { |
| 18840 Source source = addSource(EngineTestCase.createSource([ | 20922 Source source = addSource(EngineTestCase.createSource([ |
| 18841 "class A {}", | 20923 "class A {}", |
| 18842 "class B extends A {", | 20924 "class B extends A {", |
| 18843 " operator [](int index) {}", | 20925 " operator [](int index) {}", |
| 18844 "}", | 20926 "}", |
| 18845 "f(var a) {", | 20927 "f(var a) {", |
| 18846 " if(a is A) {", | 20928 " if(a is A) {", |
| 18847 " a[0]++;", | 20929 " a[0]++;", |
| 18848 " }", | 20930 " }", |
| 18849 "}"])); | 20931 "}"])); |
| 18850 resolve(source); | 20932 resolve(source); |
| 18851 assertNoErrors(source); | 20933 assertNoErrors(source); |
| 18852 } | 20934 } |
| 20935 |
| 18853 void test_undefinedOperator_indexGetter_inSubtype() { | 20936 void test_undefinedOperator_indexGetter_inSubtype() { |
| 18854 Source source = addSource(EngineTestCase.createSource([ | 20937 Source source = addSource(EngineTestCase.createSource([ |
| 18855 "class A {}", | 20938 "class A {}", |
| 18856 "class B extends A {", | 20939 "class B extends A {", |
| 18857 " operator [](int index) {}", | 20940 " operator [](int index) {}", |
| 18858 "}", | 20941 "}", |
| 18859 "f(var a) {", | 20942 "f(var a) {", |
| 18860 " if(a is A) {", | 20943 " if(a is A) {", |
| 18861 " a[0];", | 20944 " a[0];", |
| 18862 " }", | 20945 " }", |
| 18863 "}"])); | 20946 "}"])); |
| 18864 resolve(source); | 20947 resolve(source); |
| 18865 assertNoErrors(source); | 20948 assertNoErrors(source); |
| 18866 } | 20949 } |
| 20950 |
| 18867 void test_undefinedOperator_indexSetter_inSubtype() { | 20951 void test_undefinedOperator_indexSetter_inSubtype() { |
| 18868 Source source = addSource(EngineTestCase.createSource([ | 20952 Source source = addSource(EngineTestCase.createSource([ |
| 18869 "class A {}", | 20953 "class A {}", |
| 18870 "class B extends A {", | 20954 "class B extends A {", |
| 18871 " operator []=(i, v) {}", | 20955 " operator []=(i, v) {}", |
| 18872 "}", | 20956 "}", |
| 18873 "f(var a) {", | 20957 "f(var a) {", |
| 18874 " if(a is A) {", | 20958 " if(a is A) {", |
| 18875 " a[0] = 1;", | 20959 " a[0] = 1;", |
| 18876 " }", | 20960 " }", |
| 18877 "}"])); | 20961 "}"])); |
| 18878 resolve(source); | 20962 resolve(source); |
| 18879 assertNoErrors(source); | 20963 assertNoErrors(source); |
| 18880 } | 20964 } |
| 20965 |
| 18881 void test_undefinedOperator_postfixExpression() { | 20966 void test_undefinedOperator_postfixExpression() { |
| 18882 Source source = addSource(EngineTestCase.createSource([ | 20967 Source source = addSource(EngineTestCase.createSource([ |
| 18883 "class A {}", | 20968 "class A {}", |
| 18884 "class B extends A {", | 20969 "class B extends A {", |
| 18885 " operator +(B b) {return new B();}", | 20970 " operator +(B b) {return new B();}", |
| 18886 "}", | 20971 "}", |
| 18887 "f(var a) {", | 20972 "f(var a) {", |
| 18888 " if(a is A) {", | 20973 " if(a is A) {", |
| 18889 " a++;", | 20974 " a++;", |
| 18890 " }", | 20975 " }", |
| 18891 "}"])); | 20976 "}"])); |
| 18892 resolve(source); | 20977 resolve(source); |
| 18893 assertNoErrors(source); | 20978 assertNoErrors(source); |
| 18894 } | 20979 } |
| 20980 |
| 18895 void test_undefinedOperator_prefixExpression() { | 20981 void test_undefinedOperator_prefixExpression() { |
| 18896 Source source = addSource(EngineTestCase.createSource([ | 20982 Source source = addSource(EngineTestCase.createSource([ |
| 18897 "class A {}", | 20983 "class A {}", |
| 18898 "class B extends A {", | 20984 "class B extends A {", |
| 18899 " operator +(B b) {return new B();}", | 20985 " operator +(B b) {return new B();}", |
| 18900 "}", | 20986 "}", |
| 18901 "f(var a) {", | 20987 "f(var a) {", |
| 18902 " if(a is A) {", | 20988 " if(a is A) {", |
| 18903 " ++a;", | 20989 " ++a;", |
| 18904 " }", | 20990 " }", |
| 18905 "}"])); | 20991 "}"])); |
| 18906 resolve(source); | 20992 resolve(source); |
| 18907 assertNoErrors(source); | 20993 assertNoErrors(source); |
| 18908 } | 20994 } |
| 20995 |
| 18909 void test_undefinedSetter_inSubtype() { | 20996 void test_undefinedSetter_inSubtype() { |
| 18910 Source source = addSource(EngineTestCase.createSource([ | 20997 Source source = addSource(EngineTestCase.createSource([ |
| 18911 "class A {}", | 20998 "class A {}", |
| 18912 "class B extends A {", | 20999 "class B extends A {", |
| 18913 " set b(x) {}", | 21000 " set b(x) {}", |
| 18914 "}", | 21001 "}", |
| 18915 "f(var a) {", | 21002 "f(var a) {", |
| 18916 " if(a is A) {", | 21003 " if(a is A) {", |
| 18917 " a.b = 0;", | 21004 " a.b = 0;", |
| 18918 " }", | 21005 " }", |
| 18919 "}"])); | 21006 "}"])); |
| 18920 resolve(source); | 21007 resolve(source); |
| 18921 assertNoErrors(source); | 21008 assertNoErrors(source); |
| 18922 } | 21009 } |
| 21010 |
| 18923 void test_unnecessaryCast_13855_parameter_A() { | 21011 void test_unnecessaryCast_13855_parameter_A() { |
| 18924 Source source = addSource(EngineTestCase.createSource([ | 21012 Source source = addSource(EngineTestCase.createSource([ |
| 18925 "class A{", | 21013 "class A{", |
| 18926 " a() {}", | 21014 " a() {}", |
| 18927 "}", | 21015 "}", |
| 18928 "class B<E> {", | 21016 "class B<E> {", |
| 18929 " E e;", | 21017 " E e;", |
| 18930 " m() {", | 21018 " m() {", |
| 18931 " (e as A).a();", | 21019 " (e as A).a();", |
| 18932 " }", | 21020 " }", |
| 18933 "}"])); | 21021 "}"])); |
| 18934 resolve(source); | 21022 resolve(source); |
| 18935 assertNoErrors(source); | 21023 assertNoErrors(source); |
| 18936 verify([source]); | 21024 verify([source]); |
| 18937 } | 21025 } |
| 21026 |
| 18938 void test_unnecessaryCast_dynamic_type() { | 21027 void test_unnecessaryCast_dynamic_type() { |
| 18939 Source source = addSource(EngineTestCase.createSource(["m(v) {", " var b =
v as Object;", "}"])); | 21028 Source source = addSource(EngineTestCase.createSource(["m(v) {", " var b =
v as Object;", "}"])); |
| 18940 resolve(source); | 21029 resolve(source); |
| 18941 assertNoErrors(source); | 21030 assertNoErrors(source); |
| 18942 verify([source]); | 21031 verify([source]); |
| 18943 } | 21032 } |
| 21033 |
| 18944 void test_unnecessaryCast_type_dynamic() { | 21034 void test_unnecessaryCast_type_dynamic() { |
| 18945 Source source = addSource(EngineTestCase.createSource(["m(v) {", " var b =
Object as dynamic;", "}"])); | 21035 Source source = addSource(EngineTestCase.createSource(["m(v) {", " var b =
Object as dynamic;", "}"])); |
| 18946 resolve(source); | 21036 resolve(source); |
| 18947 assertNoErrors(source); | 21037 assertNoErrors(source); |
| 18948 verify([source]); | 21038 verify([source]); |
| 18949 } | 21039 } |
| 21040 |
| 18950 void test_unusedImport_annotationOnDirective() { | 21041 void test_unusedImport_annotationOnDirective() { |
| 18951 Source source = addSource(EngineTestCase.createSource(["library L;", "@A()",
"import 'lib1.dart';"])); | 21042 Source source = addSource(EngineTestCase.createSource(["library L;", "@A()",
"import 'lib1.dart';"])); |
| 18952 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " const A() {}", "}"])); | 21043 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " const A() {}", "}"])); |
| 18953 resolve(source); | 21044 resolve(source); |
| 18954 assertErrors(source, []); | 21045 assertErrors(source, []); |
| 18955 verify([source, source2]); | 21046 verify([source, source2]); |
| 18956 } | 21047 } |
| 21048 |
| 18957 void test_unusedImport_core_library() { | 21049 void test_unusedImport_core_library() { |
| 18958 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'dart:core';"])); | 21050 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'dart:core';"])); |
| 18959 resolve(source); | 21051 resolve(source); |
| 18960 assertNoErrors(source); | 21052 assertNoErrors(source); |
| 18961 verify([source]); | 21053 verify([source]); |
| 18962 } | 21054 } |
| 21055 |
| 18963 void test_unusedImport_export() { | 21056 void test_unusedImport_export() { |
| 18964 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Two two;"])); | 21057 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Two two;"])); |
| 18965 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); | 21058 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); |
| 18966 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s Two {}"])); | 21059 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s Two {}"])); |
| 18967 resolve(source); | 21060 resolve(source); |
| 18968 assertNoErrors(source); | 21061 assertNoErrors(source); |
| 18969 verify([source]); | 21062 verify([source]); |
| 18970 } | 21063 } |
| 21064 |
| 18971 void test_unusedImport_export_infiniteLoop() { | 21065 void test_unusedImport_export_infiniteLoop() { |
| 18972 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Two two;"])); | 21066 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Two two;"])); |
| 18973 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); | 21067 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); |
| 18974 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "expo
rt 'lib3.dart';", "class Two {}"])); | 21068 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "expo
rt 'lib3.dart';", "class Two {}"])); |
| 18975 addSource2("/lib3.dart", EngineTestCase.createSource(["library lib3;", "expo
rt 'lib2.dart';", "class Three {}"])); | 21069 addSource2("/lib3.dart", EngineTestCase.createSource(["library lib3;", "expo
rt 'lib2.dart';", "class Three {}"])); |
| 18976 resolve(source); | 21070 resolve(source); |
| 18977 assertNoErrors(source); | 21071 assertNoErrors(source); |
| 18978 verify([source]); | 21072 verify([source]); |
| 18979 } | 21073 } |
| 21074 |
| 18980 void test_unusedImport_export2() { | 21075 void test_unusedImport_export2() { |
| 18981 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Three three;"])); | 21076 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Three three;"])); |
| 18982 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); | 21077 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); |
| 18983 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "expo
rt 'lib3.dart';", "class Two {}"])); | 21078 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "expo
rt 'lib3.dart';", "class Two {}"])); |
| 18984 addSource2("/lib3.dart", EngineTestCase.createSource(["library lib3;", "clas
s Three {}"])); | 21079 addSource2("/lib3.dart", EngineTestCase.createSource(["library lib3;", "clas
s Three {}"])); |
| 18985 resolve(source); | 21080 resolve(source); |
| 18986 assertNoErrors(source); | 21081 assertNoErrors(source); |
| 18987 verify([source]); | 21082 verify([source]); |
| 18988 } | 21083 } |
| 21084 |
| 18989 void test_unusedImport_prefix_topLevelFunction() { | 21085 void test_unusedImport_prefix_topLevelFunction() { |
| 18990 Source source = addSource(EngineTestCase.createSource([ | 21086 Source source = addSource(EngineTestCase.createSource([ |
| 18991 "library L;", | 21087 "library L;", |
| 18992 "import 'lib1.dart' hide topLevelFunction;", | 21088 "import 'lib1.dart' hide topLevelFunction;", |
| 18993 "import 'lib1.dart' as one show topLevelFunction;", | 21089 "import 'lib1.dart' as one show topLevelFunction;", |
| 18994 "class A {", | 21090 "class A {", |
| 18995 " static void x() {", | 21091 " static void x() {", |
| 18996 " One o;", | 21092 " One o;", |
| 18997 " one.topLevelFunction();", | 21093 " one.topLevelFunction();", |
| 18998 " }", | 21094 " }", |
| 18999 "}"])); | 21095 "}"])); |
| 19000 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s One {}", "topLevelFunction() {}"])); | 21096 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s One {}", "topLevelFunction() {}"])); |
| 19001 resolve(source); | 21097 resolve(source); |
| 19002 assertNoErrors(source); | 21098 assertNoErrors(source); |
| 19003 verify([source]); | 21099 verify([source]); |
| 19004 } | 21100 } |
| 21101 |
| 19005 static dartSuite() { | 21102 static dartSuite() { |
| 19006 _ut.group('NonHintCodeTest', () { | 21103 _ut.group('NonHintCodeTest', () { |
| 19007 _ut.test('test_deadCode_deadBlock_conditionalElse_debugConst', () { | 21104 _ut.test('test_deadCode_deadBlock_conditionalElse_debugConst', () { |
| 19008 final __test = new NonHintCodeTest(); | 21105 final __test = new NonHintCodeTest(); |
| 19009 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse_debu
gConst); | 21106 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse_debu
gConst); |
| 19010 }); | 21107 }); |
| 19011 _ut.test('test_deadCode_deadBlock_conditionalIf_debugConst', () { | 21108 _ut.test('test_deadCode_deadBlock_conditionalIf_debugConst', () { |
| 19012 final __test = new NonHintCodeTest(); | 21109 final __test = new NonHintCodeTest(); |
| 19013 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalIf_debugC
onst); | 21110 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalIf_debugC
onst); |
| 19014 }); | 21111 }); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19164 final __test = new NonHintCodeTest(); | 21261 final __test = new NonHintCodeTest(); |
| 19165 runJUnitTest(__test, __test.test_unusedImport_export_infiniteLoop); | 21262 runJUnitTest(__test, __test.test_unusedImport_export_infiniteLoop); |
| 19166 }); | 21263 }); |
| 19167 _ut.test('test_unusedImport_prefix_topLevelFunction', () { | 21264 _ut.test('test_unusedImport_prefix_topLevelFunction', () { |
| 19168 final __test = new NonHintCodeTest(); | 21265 final __test = new NonHintCodeTest(); |
| 19169 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction); | 21266 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction); |
| 19170 }); | 21267 }); |
| 19171 }); | 21268 }); |
| 19172 } | 21269 } |
| 19173 } | 21270 } |
| 21271 |
| 19174 class EnclosedScopeTest extends ResolverTestCase { | 21272 class EnclosedScopeTest extends ResolverTestCase { |
| 19175 void test_define_duplicate() { | 21273 void test_define_duplicate() { |
| 19176 GatheringErrorListener errorListener2 = new GatheringErrorListener(); | 21274 GatheringErrorListener errorListener2 = new GatheringErrorListener(); |
| 19177 Scope rootScope = new Scope_21(errorListener2); | 21275 Scope rootScope = new Scope_22(errorListener2); |
| 19178 EnclosedScope scope = new EnclosedScope(rootScope); | 21276 EnclosedScope scope = new EnclosedScope(rootScope); |
| 19179 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); | 21277 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); |
| 19180 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); | 21278 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); |
| 19181 scope.define(element1); | 21279 scope.define(element1); |
| 19182 scope.define(element2); | 21280 scope.define(element2); |
| 19183 errorListener2.assertErrors3([ErrorSeverity.ERROR]); | 21281 errorListener2.assertErrors3([ErrorSeverity.ERROR]); |
| 19184 } | 21282 } |
| 21283 |
| 19185 void test_define_normal() { | 21284 void test_define_normal() { |
| 19186 GatheringErrorListener errorListener3 = new GatheringErrorListener(); | 21285 GatheringErrorListener errorListener3 = new GatheringErrorListener(); |
| 19187 Scope rootScope = new Scope_22(errorListener3); | 21286 Scope rootScope = new Scope_23(errorListener3); |
| 19188 EnclosedScope outerScope = new EnclosedScope(rootScope); | 21287 EnclosedScope outerScope = new EnclosedScope(rootScope); |
| 19189 EnclosedScope innerScope = new EnclosedScope(outerScope); | 21288 EnclosedScope innerScope = new EnclosedScope(outerScope); |
| 19190 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); | 21289 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); |
| 19191 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v2")); | 21290 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v2")); |
| 19192 outerScope.define(element1); | 21291 outerScope.define(element1); |
| 19193 innerScope.define(element2); | 21292 innerScope.define(element2); |
| 19194 errorListener3.assertNoErrors(); | 21293 errorListener3.assertNoErrors(); |
| 19195 } | 21294 } |
| 21295 |
| 19196 static dartSuite() { | 21296 static dartSuite() { |
| 19197 _ut.group('EnclosedScopeTest', () { | 21297 _ut.group('EnclosedScopeTest', () { |
| 19198 _ut.test('test_define_duplicate', () { | 21298 _ut.test('test_define_duplicate', () { |
| 19199 final __test = new EnclosedScopeTest(); | 21299 final __test = new EnclosedScopeTest(); |
| 19200 runJUnitTest(__test, __test.test_define_duplicate); | 21300 runJUnitTest(__test, __test.test_define_duplicate); |
| 19201 }); | 21301 }); |
| 19202 _ut.test('test_define_normal', () { | 21302 _ut.test('test_define_normal', () { |
| 19203 final __test = new EnclosedScopeTest(); | 21303 final __test = new EnclosedScopeTest(); |
| 19204 runJUnitTest(__test, __test.test_define_normal); | 21304 runJUnitTest(__test, __test.test_define_normal); |
| 19205 }); | 21305 }); |
| 19206 }); | 21306 }); |
| 19207 } | 21307 } |
| 19208 } | 21308 } |
| 19209 class Scope_21 extends Scope { | 21309 |
| 21310 class Scope_22 extends Scope { |
| 19210 GatheringErrorListener errorListener2; | 21311 GatheringErrorListener errorListener2; |
| 19211 Scope_21(this.errorListener2) : super(); | 21312 |
| 21313 Scope_22(this.errorListener2) : super(); |
| 21314 |
| 19212 AnalysisErrorListener get errorListener => errorListener2; | 21315 AnalysisErrorListener get errorListener => errorListener2; |
| 21316 |
| 19213 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) => null; | 21317 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) => null; |
| 19214 } | 21318 } |
| 19215 class Scope_22 extends Scope { | 21319 |
| 21320 class Scope_23 extends Scope { |
| 19216 GatheringErrorListener errorListener3; | 21321 GatheringErrorListener errorListener3; |
| 19217 Scope_22(this.errorListener3) : super(); | 21322 |
| 21323 Scope_23(this.errorListener3) : super(); |
| 21324 |
| 19218 AnalysisErrorListener get errorListener => errorListener3; | 21325 AnalysisErrorListener get errorListener => errorListener3; |
| 21326 |
| 19219 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) => null; | 21327 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) => null; |
| 19220 } | 21328 } |
| 21329 |
| 19221 class LibraryElementBuilderTest extends EngineTestCase { | 21330 class LibraryElementBuilderTest extends EngineTestCase { |
| 19222 | |
| 19223 /** | 21331 /** |
| 19224 * The source factory used to create [Source]. | 21332 * The source factory used to create [Source]. |
| 19225 */ | 21333 */ |
| 19226 SourceFactory _sourceFactory; | 21334 SourceFactory _sourceFactory; |
| 21335 |
| 19227 void setUp() { | 21336 void setUp() { |
| 19228 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); | 21337 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); |
| 19229 } | 21338 } |
| 21339 |
| 19230 void test_accessorsAcrossFiles() { | 21340 void test_accessorsAcrossFiles() { |
| 19231 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([ | 21341 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([ |
| 19232 "library lib;", | 21342 "library lib;", |
| 19233 "part 'first.dart';", | 21343 "part 'first.dart';", |
| 19234 "part 'second.dart';"])); | 21344 "part 'second.dart';"])); |
| 19235 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "int g
et V => 0;"])); | 21345 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "int g
et V => 0;"])); |
| 19236 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "void
set V(int v) {}"])); | 21346 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "void
set V(int v) {}"])); |
| 19237 LibraryElement element = buildLibrary(librarySource, []); | 21347 LibraryElement element = buildLibrary(librarySource, []); |
| 19238 JUnitTestCase.assertNotNull(element); | 21348 JUnitTestCase.assertNotNull(element); |
| 19239 List<CompilationUnitElement> sourcedUnits = element.parts; | 21349 List<CompilationUnitElement> sourcedUnits = element.parts; |
| 19240 EngineTestCase.assertLength(2, sourcedUnits); | 21350 EngineTestCase.assertLength(2, sourcedUnits); |
| 19241 List<PropertyAccessorElement> firstAccessors = sourcedUnits[0].accessors; | 21351 List<PropertyAccessorElement> firstAccessors = sourcedUnits[0].accessors; |
| 19242 EngineTestCase.assertLength(1, firstAccessors); | 21352 EngineTestCase.assertLength(1, firstAccessors); |
| 19243 List<PropertyAccessorElement> secondAccessors = sourcedUnits[1].accessors; | 21353 List<PropertyAccessorElement> secondAccessors = sourcedUnits[1].accessors; |
| 19244 EngineTestCase.assertLength(1, secondAccessors); | 21354 EngineTestCase.assertLength(1, secondAccessors); |
| 19245 JUnitTestCase.assertSame(firstAccessors[0].variable, secondAccessors[0].vari
able); | 21355 JUnitTestCase.assertSame(firstAccessors[0].variable, secondAccessors[0].vari
able); |
| 19246 } | 21356 } |
| 21357 |
| 19247 void test_empty() { | 21358 void test_empty() { |
| 19248 Source librarySource = addSource("/lib.dart", "library lib;"); | 21359 Source librarySource = addSource("/lib.dart", "library lib;"); |
| 19249 LibraryElement element = buildLibrary(librarySource, []); | 21360 LibraryElement element = buildLibrary(librarySource, []); |
| 19250 JUnitTestCase.assertNotNull(element); | 21361 JUnitTestCase.assertNotNull(element); |
| 19251 JUnitTestCase.assertEquals("lib", element.name); | 21362 JUnitTestCase.assertEquals("lib", element.name); |
| 19252 JUnitTestCase.assertNull(element.entryPoint); | 21363 JUnitTestCase.assertNull(element.entryPoint); |
| 19253 EngineTestCase.assertLength(0, element.importedLibraries); | 21364 EngineTestCase.assertLength(0, element.importedLibraries); |
| 19254 EngineTestCase.assertLength(0, element.imports); | 21365 EngineTestCase.assertLength(0, element.imports); |
| 19255 JUnitTestCase.assertSame(element, element.library); | 21366 JUnitTestCase.assertSame(element, element.library); |
| 19256 EngineTestCase.assertLength(0, element.prefixes); | 21367 EngineTestCase.assertLength(0, element.prefixes); |
| 19257 EngineTestCase.assertLength(0, element.parts); | 21368 EngineTestCase.assertLength(0, element.parts); |
| 19258 CompilationUnitElement unit = element.definingCompilationUnit; | 21369 CompilationUnitElement unit = element.definingCompilationUnit; |
| 19259 JUnitTestCase.assertNotNull(unit); | 21370 JUnitTestCase.assertNotNull(unit); |
| 19260 JUnitTestCase.assertEquals("lib.dart", unit.name); | 21371 JUnitTestCase.assertEquals("lib.dart", unit.name); |
| 19261 JUnitTestCase.assertEquals(element, unit.library); | 21372 JUnitTestCase.assertEquals(element, unit.library); |
| 19262 EngineTestCase.assertLength(0, unit.accessors); | 21373 EngineTestCase.assertLength(0, unit.accessors); |
| 19263 EngineTestCase.assertLength(0, unit.functions); | 21374 EngineTestCase.assertLength(0, unit.functions); |
| 19264 EngineTestCase.assertLength(0, unit.functionTypeAliases); | 21375 EngineTestCase.assertLength(0, unit.functionTypeAliases); |
| 19265 EngineTestCase.assertLength(0, unit.types); | 21376 EngineTestCase.assertLength(0, unit.types); |
| 19266 EngineTestCase.assertLength(0, unit.topLevelVariables); | 21377 EngineTestCase.assertLength(0, unit.topLevelVariables); |
| 19267 } | 21378 } |
| 21379 |
| 19268 void test_invalidUri_part() { | 21380 void test_invalidUri_part() { |
| 19269 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource(["
library lib;", "", "part '\${'a'}.dart';"])); | 21381 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource(["
library lib;", "", "part '\${'a'}.dart';"])); |
| 19270 LibraryElement element = buildLibrary(librarySource, [CompileTimeErrorCode.U
RI_WITH_INTERPOLATION]); | 21382 LibraryElement element = buildLibrary(librarySource, [CompileTimeErrorCode.U
RI_WITH_INTERPOLATION]); |
| 19271 JUnitTestCase.assertNotNull(element); | 21383 JUnitTestCase.assertNotNull(element); |
| 19272 } | 21384 } |
| 21385 |
| 19273 void test_missingLibraryDirectiveWithPart() { | 21386 void test_missingLibraryDirectiveWithPart() { |
| 19274 addSource("/a.dart", EngineTestCase.createSource(["part of lib;"])); | 21387 addSource("/a.dart", EngineTestCase.createSource(["part of lib;"])); |
| 19275 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource(["
part 'a.dart';"])); | 21388 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource(["
part 'a.dart';"])); |
| 19276 LibraryElement element = buildLibrary(librarySource, [ResolverErrorCode.MISS
ING_LIBRARY_DIRECTIVE_WITH_PART]); | 21389 LibraryElement element = buildLibrary(librarySource, [ResolverErrorCode.MISS
ING_LIBRARY_DIRECTIVE_WITH_PART]); |
| 19277 JUnitTestCase.assertNotNull(element); | 21390 JUnitTestCase.assertNotNull(element); |
| 19278 } | 21391 } |
| 21392 |
| 19279 void test_missingPartOfDirective() { | 21393 void test_missingPartOfDirective() { |
| 19280 addSource("/a.dart", "class A {}"); | 21394 addSource("/a.dart", "class A {}"); |
| 19281 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource(["
library lib;", "", "part 'a.dart';"])); | 21395 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource(["
library lib;", "", "part 'a.dart';"])); |
| 19282 LibraryElement element = buildLibrary(librarySource, [CompileTimeErrorCode.P
ART_OF_NON_PART]); | 21396 LibraryElement element = buildLibrary(librarySource, [CompileTimeErrorCode.P
ART_OF_NON_PART]); |
| 19283 JUnitTestCase.assertNotNull(element); | 21397 JUnitTestCase.assertNotNull(element); |
| 19284 } | 21398 } |
| 21399 |
| 19285 void test_multipleFiles() { | 21400 void test_multipleFiles() { |
| 19286 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([ | 21401 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([ |
| 19287 "library lib;", | 21402 "library lib;", |
| 19288 "part 'first.dart';", | 21403 "part 'first.dart';", |
| 19289 "part 'second.dart';", | 21404 "part 'second.dart';", |
| 19290 "", | 21405 "", |
| 19291 "class A {}"])); | 21406 "class A {}"])); |
| 19292 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "class
B {}"])); | 21407 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "class
B {}"])); |
| 19293 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "clas
s C {}"])); | 21408 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "clas
s C {}"])); |
| 19294 LibraryElement element = buildLibrary(librarySource, []); | 21409 LibraryElement element = buildLibrary(librarySource, []); |
| 19295 JUnitTestCase.assertNotNull(element); | 21410 JUnitTestCase.assertNotNull(element); |
| 19296 List<CompilationUnitElement> sourcedUnits = element.parts; | 21411 List<CompilationUnitElement> sourcedUnits = element.parts; |
| 19297 EngineTestCase.assertLength(2, sourcedUnits); | 21412 EngineTestCase.assertLength(2, sourcedUnits); |
| 19298 assertTypes(element.definingCompilationUnit, ["A"]); | 21413 assertTypes(element.definingCompilationUnit, ["A"]); |
| 19299 if (sourcedUnits[0].name == "first.dart") { | 21414 if (sourcedUnits[0].name == "first.dart") { |
| 19300 assertTypes(sourcedUnits[0], ["B"]); | 21415 assertTypes(sourcedUnits[0], ["B"]); |
| 19301 assertTypes(sourcedUnits[1], ["C"]); | 21416 assertTypes(sourcedUnits[1], ["C"]); |
| 19302 } else { | 21417 } else { |
| 19303 assertTypes(sourcedUnits[0], ["C"]); | 21418 assertTypes(sourcedUnits[0], ["C"]); |
| 19304 assertTypes(sourcedUnits[1], ["B"]); | 21419 assertTypes(sourcedUnits[1], ["B"]); |
| 19305 } | 21420 } |
| 19306 } | 21421 } |
| 21422 |
| 19307 void test_singleFile() { | 21423 void test_singleFile() { |
| 19308 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource(["
library lib;", "", "class A {}"])); | 21424 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource(["
library lib;", "", "class A {}"])); |
| 19309 LibraryElement element = buildLibrary(librarySource, []); | 21425 LibraryElement element = buildLibrary(librarySource, []); |
| 19310 JUnitTestCase.assertNotNull(element); | 21426 JUnitTestCase.assertNotNull(element); |
| 19311 assertTypes(element.definingCompilationUnit, ["A"]); | 21427 assertTypes(element.definingCompilationUnit, ["A"]); |
| 19312 } | 21428 } |
| 19313 | 21429 |
| 19314 /** | 21430 /** |
| 19315 * Add a source file to the content provider. The file path should be absolute
. | 21431 * Add a source file to the content provider. The file path should be absolute
. |
| 19316 * | 21432 * |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19365 new FileUriResolver()]); | 21481 new FileUriResolver()]); |
| 19366 LibraryResolver resolver = new LibraryResolver(context); | 21482 LibraryResolver resolver = new LibraryResolver(context); |
| 19367 LibraryElementBuilder builder = new LibraryElementBuilder(resolver); | 21483 LibraryElementBuilder builder = new LibraryElementBuilder(resolver); |
| 19368 Library library = resolver.createLibrary(librarySource) as Library; | 21484 Library library = resolver.createLibrary(librarySource) as Library; |
| 19369 LibraryElement element = builder.buildLibrary(library); | 21485 LibraryElement element = builder.buildLibrary(library); |
| 19370 GatheringErrorListener listener = new GatheringErrorListener(); | 21486 GatheringErrorListener listener = new GatheringErrorListener(); |
| 19371 listener.addAll(resolver.errorListener); | 21487 listener.addAll(resolver.errorListener); |
| 19372 listener.assertErrors2(expectedErrorCodes); | 21488 listener.assertErrors2(expectedErrorCodes); |
| 19373 return element; | 21489 return element; |
| 19374 } | 21490 } |
| 21491 |
| 19375 static dartSuite() { | 21492 static dartSuite() { |
| 19376 _ut.group('LibraryElementBuilderTest', () { | 21493 _ut.group('LibraryElementBuilderTest', () { |
| 19377 _ut.test('test_accessorsAcrossFiles', () { | 21494 _ut.test('test_accessorsAcrossFiles', () { |
| 19378 final __test = new LibraryElementBuilderTest(); | 21495 final __test = new LibraryElementBuilderTest(); |
| 19379 runJUnitTest(__test, __test.test_accessorsAcrossFiles); | 21496 runJUnitTest(__test, __test.test_accessorsAcrossFiles); |
| 19380 }); | 21497 }); |
| 19381 _ut.test('test_empty', () { | 21498 _ut.test('test_empty', () { |
| 19382 final __test = new LibraryElementBuilderTest(); | 21499 final __test = new LibraryElementBuilderTest(); |
| 19383 runJUnitTest(__test, __test.test_empty); | 21500 runJUnitTest(__test, __test.test_empty); |
| 19384 }); | 21501 }); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 19398 final __test = new LibraryElementBuilderTest(); | 21515 final __test = new LibraryElementBuilderTest(); |
| 19399 runJUnitTest(__test, __test.test_multipleFiles); | 21516 runJUnitTest(__test, __test.test_multipleFiles); |
| 19400 }); | 21517 }); |
| 19401 _ut.test('test_singleFile', () { | 21518 _ut.test('test_singleFile', () { |
| 19402 final __test = new LibraryElementBuilderTest(); | 21519 final __test = new LibraryElementBuilderTest(); |
| 19403 runJUnitTest(__test, __test.test_singleFile); | 21520 runJUnitTest(__test, __test.test_singleFile); |
| 19404 }); | 21521 }); |
| 19405 }); | 21522 }); |
| 19406 } | 21523 } |
| 19407 } | 21524 } |
| 21525 |
| 19408 class ScopeTest extends ResolverTestCase { | 21526 class ScopeTest extends ResolverTestCase { |
| 19409 void test_define_duplicate() { | 21527 void test_define_duplicate() { |
| 19410 GatheringErrorListener errorListener = new GatheringErrorListener(); | 21528 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 19411 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); | 21529 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); |
| 19412 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); | 21530 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); |
| 19413 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); | 21531 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); |
| 19414 scope.define(element1); | 21532 scope.define(element1); |
| 19415 scope.define(element2); | 21533 scope.define(element2); |
| 19416 errorListener.assertErrors3([ErrorSeverity.ERROR]); | 21534 errorListener.assertErrors3([ErrorSeverity.ERROR]); |
| 19417 } | 21535 } |
| 21536 |
| 19418 void test_define_normal() { | 21537 void test_define_normal() { |
| 19419 GatheringErrorListener errorListener = new GatheringErrorListener(); | 21538 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 19420 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); | 21539 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); |
| 19421 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); | 21540 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); |
| 19422 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v2")); | 21541 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v2")); |
| 19423 scope.define(element1); | 21542 scope.define(element1); |
| 19424 scope.define(element2); | 21543 scope.define(element2); |
| 19425 errorListener.assertNoErrors(); | 21544 errorListener.assertNoErrors(); |
| 19426 } | 21545 } |
| 21546 |
| 19427 void test_getErrorListener() { | 21547 void test_getErrorListener() { |
| 19428 GatheringErrorListener errorListener = new GatheringErrorListener(); | 21548 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 19429 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); | 21549 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); |
| 19430 JUnitTestCase.assertEquals(errorListener, scope.errorListener); | 21550 JUnitTestCase.assertEquals(errorListener, scope.errorListener); |
| 19431 } | 21551 } |
| 21552 |
| 19432 void test_isPrivateName_nonPrivate() { | 21553 void test_isPrivateName_nonPrivate() { |
| 19433 JUnitTestCase.assertFalse(Scope.isPrivateName("Public")); | 21554 JUnitTestCase.assertFalse(Scope.isPrivateName("Public")); |
| 19434 } | 21555 } |
| 21556 |
| 19435 void test_isPrivateName_private() { | 21557 void test_isPrivateName_private() { |
| 19436 JUnitTestCase.assertTrue(Scope.isPrivateName("_Private")); | 21558 JUnitTestCase.assertTrue(Scope.isPrivateName("_Private")); |
| 19437 } | 21559 } |
| 21560 |
| 19438 static dartSuite() { | 21561 static dartSuite() { |
| 19439 _ut.group('ScopeTest', () { | 21562 _ut.group('ScopeTest', () { |
| 19440 _ut.test('test_define_duplicate', () { | 21563 _ut.test('test_define_duplicate', () { |
| 19441 final __test = new ScopeTest(); | 21564 final __test = new ScopeTest(); |
| 19442 runJUnitTest(__test, __test.test_define_duplicate); | 21565 runJUnitTest(__test, __test.test_define_duplicate); |
| 19443 }); | 21566 }); |
| 19444 _ut.test('test_define_normal', () { | 21567 _ut.test('test_define_normal', () { |
| 19445 final __test = new ScopeTest(); | 21568 final __test = new ScopeTest(); |
| 19446 runJUnitTest(__test, __test.test_define_normal); | 21569 runJUnitTest(__test, __test.test_define_normal); |
| 19447 }); | 21570 }); |
| 19448 _ut.test('test_getErrorListener', () { | 21571 _ut.test('test_getErrorListener', () { |
| 19449 final __test = new ScopeTest(); | 21572 final __test = new ScopeTest(); |
| 19450 runJUnitTest(__test, __test.test_getErrorListener); | 21573 runJUnitTest(__test, __test.test_getErrorListener); |
| 19451 }); | 21574 }); |
| 19452 _ut.test('test_isPrivateName_nonPrivate', () { | 21575 _ut.test('test_isPrivateName_nonPrivate', () { |
| 19453 final __test = new ScopeTest(); | 21576 final __test = new ScopeTest(); |
| 19454 runJUnitTest(__test, __test.test_isPrivateName_nonPrivate); | 21577 runJUnitTest(__test, __test.test_isPrivateName_nonPrivate); |
| 19455 }); | 21578 }); |
| 19456 _ut.test('test_isPrivateName_private', () { | 21579 _ut.test('test_isPrivateName_private', () { |
| 19457 final __test = new ScopeTest(); | 21580 final __test = new ScopeTest(); |
| 19458 runJUnitTest(__test, __test.test_isPrivateName_private); | 21581 runJUnitTest(__test, __test.test_isPrivateName_private); |
| 19459 }); | 21582 }); |
| 19460 }); | 21583 }); |
| 19461 } | 21584 } |
| 19462 } | 21585 } |
| 21586 |
| 19463 /** | 21587 /** |
| 19464 * A non-abstract subclass that can be used for testing purposes. | 21588 * A non-abstract subclass that can be used for testing purposes. |
| 19465 */ | 21589 */ |
| 19466 class ScopeTest_TestScope extends Scope { | 21590 class ScopeTest_TestScope extends Scope { |
| 19467 | |
| 19468 /** | 21591 /** |
| 19469 * The listener that is to be informed when an error is encountered. | 21592 * The listener that is to be informed when an error is encountered. |
| 19470 */ | 21593 */ |
| 19471 AnalysisErrorListener _errorListener; | 21594 AnalysisErrorListener _errorListener; |
| 21595 |
| 19472 ScopeTest_TestScope(AnalysisErrorListener errorListener) { | 21596 ScopeTest_TestScope(AnalysisErrorListener errorListener) { |
| 19473 this._errorListener = errorListener; | 21597 this._errorListener = errorListener; |
| 19474 } | 21598 } |
| 21599 |
| 19475 AnalysisErrorListener get errorListener => _errorListener; | 21600 AnalysisErrorListener get errorListener => _errorListener; |
| 21601 |
| 19476 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) => localLookup(name, referencingLibrary); | 21602 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) => localLookup(name, referencingLibrary); |
| 19477 } | 21603 } |
| 21604 |
| 19478 class SimpleResolverTest extends ResolverTestCase { | 21605 class SimpleResolverTest extends ResolverTestCase { |
| 19479 void fail_staticInvocation() { | 21606 void fail_staticInvocation() { |
| 19480 Source source = addSource(EngineTestCase.createSource([ | 21607 Source source = addSource(EngineTestCase.createSource([ |
| 19481 "class A {", | 21608 "class A {", |
| 19482 " static int get g => (a,b) => 0;", | 21609 " static int get g => (a,b) => 0;", |
| 19483 "}", | 21610 "}", |
| 19484 "class B {", | 21611 "class B {", |
| 19485 " f() {", | 21612 " f() {", |
| 19486 " A.g(1,0);", | 21613 " A.g(1,0);", |
| 19487 " }", | 21614 " }", |
| 19488 "}"])); | 21615 "}"])); |
| 19489 resolve(source); | 21616 resolve(source); |
| 19490 assertNoErrors(source); | 21617 assertNoErrors(source); |
| 19491 verify([source]); | 21618 verify([source]); |
| 19492 } | 21619 } |
| 21620 |
| 19493 void test_argumentResolution_required_matching() { | 21621 void test_argumentResolution_required_matching() { |
| 19494 Source source = addSource(EngineTestCase.createSource([ | 21622 Source source = addSource(EngineTestCase.createSource([ |
| 19495 "class A {", | 21623 "class A {", |
| 19496 " void f() {", | 21624 " void f() {", |
| 19497 " g(1, 2, 3);", | 21625 " g(1, 2, 3);", |
| 19498 " }", | 21626 " }", |
| 19499 " void g(a, b, c) {}", | 21627 " void g(a, b, c) {}", |
| 19500 "}"])); | 21628 "}"])); |
| 19501 validateArgumentResolution(source, [0, 1, 2]); | 21629 validateArgumentResolution(source, [0, 1, 2]); |
| 19502 } | 21630 } |
| 21631 |
| 19503 void test_argumentResolution_required_tooFew() { | 21632 void test_argumentResolution_required_tooFew() { |
| 19504 Source source = addSource(EngineTestCase.createSource([ | 21633 Source source = addSource(EngineTestCase.createSource([ |
| 19505 "class A {", | 21634 "class A {", |
| 19506 " void f() {", | 21635 " void f() {", |
| 19507 " g(1, 2);", | 21636 " g(1, 2);", |
| 19508 " }", | 21637 " }", |
| 19509 " void g(a, b, c) {}", | 21638 " void g(a, b, c) {}", |
| 19510 "}"])); | 21639 "}"])); |
| 19511 validateArgumentResolution(source, [0, 1]); | 21640 validateArgumentResolution(source, [0, 1]); |
| 19512 } | 21641 } |
| 21642 |
| 19513 void test_argumentResolution_required_tooMany() { | 21643 void test_argumentResolution_required_tooMany() { |
| 19514 Source source = addSource(EngineTestCase.createSource([ | 21644 Source source = addSource(EngineTestCase.createSource([ |
| 19515 "class A {", | 21645 "class A {", |
| 19516 " void f() {", | 21646 " void f() {", |
| 19517 " g(1, 2, 3);", | 21647 " g(1, 2, 3);", |
| 19518 " }", | 21648 " }", |
| 19519 " void g(a, b) {}", | 21649 " void g(a, b) {}", |
| 19520 "}"])); | 21650 "}"])); |
| 19521 validateArgumentResolution(source, [0, 1, -1]); | 21651 validateArgumentResolution(source, [0, 1, -1]); |
| 19522 } | 21652 } |
| 21653 |
| 19523 void test_argumentResolution_requiredAndNamed_extra() { | 21654 void test_argumentResolution_requiredAndNamed_extra() { |
| 19524 Source source = addSource(EngineTestCase.createSource([ | 21655 Source source = addSource(EngineTestCase.createSource([ |
| 19525 "class A {", | 21656 "class A {", |
| 19526 " void f() {", | 21657 " void f() {", |
| 19527 " g(1, 2, c: 3, d: 4);", | 21658 " g(1, 2, c: 3, d: 4);", |
| 19528 " }", | 21659 " }", |
| 19529 " void g(a, b, {c}) {}", | 21660 " void g(a, b, {c}) {}", |
| 19530 "}"])); | 21661 "}"])); |
| 19531 validateArgumentResolution(source, [0, 1, 2, -1]); | 21662 validateArgumentResolution(source, [0, 1, 2, -1]); |
| 19532 } | 21663 } |
| 21664 |
| 19533 void test_argumentResolution_requiredAndNamed_matching() { | 21665 void test_argumentResolution_requiredAndNamed_matching() { |
| 19534 Source source = addSource(EngineTestCase.createSource([ | 21666 Source source = addSource(EngineTestCase.createSource([ |
| 19535 "class A {", | 21667 "class A {", |
| 19536 " void f() {", | 21668 " void f() {", |
| 19537 " g(1, 2, c: 3);", | 21669 " g(1, 2, c: 3);", |
| 19538 " }", | 21670 " }", |
| 19539 " void g(a, b, {c}) {}", | 21671 " void g(a, b, {c}) {}", |
| 19540 "}"])); | 21672 "}"])); |
| 19541 validateArgumentResolution(source, [0, 1, 2]); | 21673 validateArgumentResolution(source, [0, 1, 2]); |
| 19542 } | 21674 } |
| 21675 |
| 19543 void test_argumentResolution_requiredAndNamed_missing() { | 21676 void test_argumentResolution_requiredAndNamed_missing() { |
| 19544 Source source = addSource(EngineTestCase.createSource([ | 21677 Source source = addSource(EngineTestCase.createSource([ |
| 19545 "class A {", | 21678 "class A {", |
| 19546 " void f() {", | 21679 " void f() {", |
| 19547 " g(1, 2, d: 3);", | 21680 " g(1, 2, d: 3);", |
| 19548 " }", | 21681 " }", |
| 19549 " void g(a, b, {c, d}) {}", | 21682 " void g(a, b, {c, d}) {}", |
| 19550 "}"])); | 21683 "}"])); |
| 19551 validateArgumentResolution(source, [0, 1, 3]); | 21684 validateArgumentResolution(source, [0, 1, 3]); |
| 19552 } | 21685 } |
| 21686 |
| 19553 void test_argumentResolution_requiredAndPositional_fewer() { | 21687 void test_argumentResolution_requiredAndPositional_fewer() { |
| 19554 Source source = addSource(EngineTestCase.createSource([ | 21688 Source source = addSource(EngineTestCase.createSource([ |
| 19555 "class A {", | 21689 "class A {", |
| 19556 " void f() {", | 21690 " void f() {", |
| 19557 " g(1, 2, 3);", | 21691 " g(1, 2, 3);", |
| 19558 " }", | 21692 " }", |
| 19559 " void g(a, b, [c, d]) {}", | 21693 " void g(a, b, [c, d]) {}", |
| 19560 "}"])); | 21694 "}"])); |
| 19561 validateArgumentResolution(source, [0, 1, 2]); | 21695 validateArgumentResolution(source, [0, 1, 2]); |
| 19562 } | 21696 } |
| 21697 |
| 19563 void test_argumentResolution_requiredAndPositional_matching() { | 21698 void test_argumentResolution_requiredAndPositional_matching() { |
| 19564 Source source = addSource(EngineTestCase.createSource([ | 21699 Source source = addSource(EngineTestCase.createSource([ |
| 19565 "class A {", | 21700 "class A {", |
| 19566 " void f() {", | 21701 " void f() {", |
| 19567 " g(1, 2, 3, 4);", | 21702 " g(1, 2, 3, 4);", |
| 19568 " }", | 21703 " }", |
| 19569 " void g(a, b, [c, d]) {}", | 21704 " void g(a, b, [c, d]) {}", |
| 19570 "}"])); | 21705 "}"])); |
| 19571 validateArgumentResolution(source, [0, 1, 2, 3]); | 21706 validateArgumentResolution(source, [0, 1, 2, 3]); |
| 19572 } | 21707 } |
| 21708 |
| 19573 void test_argumentResolution_requiredAndPositional_more() { | 21709 void test_argumentResolution_requiredAndPositional_more() { |
| 19574 Source source = addSource(EngineTestCase.createSource([ | 21710 Source source = addSource(EngineTestCase.createSource([ |
| 19575 "class A {", | 21711 "class A {", |
| 19576 " void f() {", | 21712 " void f() {", |
| 19577 " g(1, 2, 3, 4);", | 21713 " g(1, 2, 3, 4);", |
| 19578 " }", | 21714 " }", |
| 19579 " void g(a, b, [c]) {}", | 21715 " void g(a, b, [c]) {}", |
| 19580 "}"])); | 21716 "}"])); |
| 19581 validateArgumentResolution(source, [0, 1, 2, -1]); | 21717 validateArgumentResolution(source, [0, 1, 2, -1]); |
| 19582 } | 21718 } |
| 21719 |
| 19583 void test_class_definesCall() { | 21720 void test_class_definesCall() { |
| 19584 Source source = addSource(EngineTestCase.createSource([ | 21721 Source source = addSource(EngineTestCase.createSource([ |
| 19585 "class A {", | 21722 "class A {", |
| 19586 " int call(int x) { return x; }", | 21723 " int call(int x) { return x; }", |
| 19587 "}", | 21724 "}", |
| 19588 "int f(A a) {", | 21725 "int f(A a) {", |
| 19589 " return a(0);", | 21726 " return a(0);", |
| 19590 "}"])); | 21727 "}"])); |
| 19591 resolve(source); | 21728 resolve(source); |
| 19592 assertNoErrors(source); | 21729 assertNoErrors(source); |
| 19593 verify([source]); | 21730 verify([source]); |
| 19594 } | 21731 } |
| 21732 |
| 19595 void test_class_extends_implements() { | 21733 void test_class_extends_implements() { |
| 19596 Source source = addSource(EngineTestCase.createSource([ | 21734 Source source = addSource(EngineTestCase.createSource([ |
| 19597 "class A extends B implements C {}", | 21735 "class A extends B implements C {}", |
| 19598 "class B {}", | 21736 "class B {}", |
| 19599 "class C {}"])); | 21737 "class C {}"])); |
| 19600 resolve(source); | 21738 resolve(source); |
| 19601 assertNoErrors(source); | 21739 assertNoErrors(source); |
| 19602 verify([source]); | 21740 verify([source]); |
| 19603 } | 21741 } |
| 21742 |
| 19604 void test_commentReference_class() { | 21743 void test_commentReference_class() { |
| 19605 Source source = addSource(EngineTestCase.createSource([ | 21744 Source source = addSource(EngineTestCase.createSource([ |
| 19606 "f() {}", | 21745 "f() {}", |
| 19607 "/** [A] [new A] [A.n] [new A.n] [m] [f] */", | 21746 "/** [A] [new A] [A.n] [new A.n] [m] [f] */", |
| 19608 "class A {", | 21747 "class A {", |
| 19609 " A() {}", | 21748 " A() {}", |
| 19610 " A.n() {}", | 21749 " A.n() {}", |
| 19611 " m() {}", | 21750 " m() {}", |
| 19612 "}"])); | 21751 "}"])); |
| 19613 resolve(source); | 21752 resolve(source); |
| 19614 assertNoErrors(source); | 21753 assertNoErrors(source); |
| 19615 verify([source]); | 21754 verify([source]); |
| 19616 } | 21755 } |
| 21756 |
| 19617 void test_commentReference_parameter() { | 21757 void test_commentReference_parameter() { |
| 19618 Source source = addSource(EngineTestCase.createSource([ | 21758 Source source = addSource(EngineTestCase.createSource([ |
| 19619 "class A {", | 21759 "class A {", |
| 19620 " A() {}", | 21760 " A() {}", |
| 19621 " A.n() {}", | 21761 " A.n() {}", |
| 19622 " /** [e] [f] */", | 21762 " /** [e] [f] */", |
| 19623 " m(e, f()) {}", | 21763 " m(e, f()) {}", |
| 19624 "}"])); | 21764 "}"])); |
| 19625 resolve(source); | 21765 resolve(source); |
| 19626 assertNoErrors(source); | 21766 assertNoErrors(source); |
| 19627 verify([source]); | 21767 verify([source]); |
| 19628 } | 21768 } |
| 21769 |
| 19629 void test_commentReference_singleLine() { | 21770 void test_commentReference_singleLine() { |
| 19630 Source source = addSource(EngineTestCase.createSource(["/// [A]", "class A {
}"])); | 21771 Source source = addSource(EngineTestCase.createSource(["/// [A]", "class A {
}"])); |
| 19631 resolve(source); | 21772 resolve(source); |
| 19632 assertNoErrors(source); | 21773 assertNoErrors(source); |
| 19633 verify([source]); | 21774 verify([source]); |
| 19634 } | 21775 } |
| 21776 |
| 19635 void test_empty() { | 21777 void test_empty() { |
| 19636 Source source = addSource(""); | 21778 Source source = addSource(""); |
| 19637 resolve(source); | 21779 resolve(source); |
| 19638 assertNoErrors(source); | 21780 assertNoErrors(source); |
| 19639 verify([source]); | 21781 verify([source]); |
| 19640 } | 21782 } |
| 21783 |
| 19641 void test_extractedMethodAsConstant() { | 21784 void test_extractedMethodAsConstant() { |
| 19642 Source source = addSource(EngineTestCase.createSource([ | 21785 Source source = addSource(EngineTestCase.createSource([ |
| 19643 "abstract class Comparable<T> {", | 21786 "abstract class Comparable<T> {", |
| 19644 " int compareTo(T other);", | 21787 " int compareTo(T other);", |
| 19645 " static int compare(Comparable a, Comparable b) => a.compareTo(b);", | 21788 " static int compare(Comparable a, Comparable b) => a.compareTo(b);", |
| 19646 "}", | 21789 "}", |
| 19647 "class A {", | 21790 "class A {", |
| 19648 " void sort([compare = Comparable.compare]) {}", | 21791 " void sort([compare = Comparable.compare]) {}", |
| 19649 "}"])); | 21792 "}"])); |
| 19650 resolve(source); | 21793 resolve(source); |
| 19651 assertNoErrors(source); | 21794 assertNoErrors(source); |
| 19652 verify([source]); | 21795 verify([source]); |
| 19653 } | 21796 } |
| 21797 |
| 19654 void test_fieldFormalParameter() { | 21798 void test_fieldFormalParameter() { |
| 19655 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); | 21799 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); |
| 19656 resolve(source); | 21800 resolve(source); |
| 19657 assertNoErrors(source); | 21801 assertNoErrors(source); |
| 19658 verify([source]); | 21802 verify([source]); |
| 19659 } | 21803 } |
| 21804 |
| 19660 void test_forEachLoops_nonConflicting() { | 21805 void test_forEachLoops_nonConflicting() { |
| 19661 Source source = addSource(EngineTestCase.createSource([ | 21806 Source source = addSource(EngineTestCase.createSource([ |
| 19662 "f() {", | 21807 "f() {", |
| 19663 " List list = [1,2,3];", | 21808 " List list = [1,2,3];", |
| 19664 " for (int x in list) {}", | 21809 " for (int x in list) {}", |
| 19665 " for (int x in list) {}", | 21810 " for (int x in list) {}", |
| 19666 "}"])); | 21811 "}"])); |
| 19667 resolve(source); | 21812 resolve(source); |
| 19668 assertNoErrors(source); | 21813 assertNoErrors(source); |
| 19669 verify([source]); | 21814 verify([source]); |
| 19670 } | 21815 } |
| 21816 |
| 19671 void test_forLoops_nonConflicting() { | 21817 void test_forLoops_nonConflicting() { |
| 19672 Source source = addSource(EngineTestCase.createSource([ | 21818 Source source = addSource(EngineTestCase.createSource([ |
| 19673 "f() {", | 21819 "f() {", |
| 19674 " for (int i = 0; i < 3; i++) {", | 21820 " for (int i = 0; i < 3; i++) {", |
| 19675 " }", | 21821 " }", |
| 19676 " for (int i = 0; i < 3; i++) {", | 21822 " for (int i = 0; i < 3; i++) {", |
| 19677 " }", | 21823 " }", |
| 19678 "}"])); | 21824 "}"])); |
| 19679 resolve(source); | 21825 resolve(source); |
| 19680 assertNoErrors(source); | 21826 assertNoErrors(source); |
| 19681 verify([source]); | 21827 verify([source]); |
| 19682 } | 21828 } |
| 21829 |
| 19683 void test_functionTypeAlias() { | 21830 void test_functionTypeAlias() { |
| 19684 Source source = addSource(EngineTestCase.createSource([ | 21831 Source source = addSource(EngineTestCase.createSource([ |
| 19685 "typedef bool P(e);", | 21832 "typedef bool P(e);", |
| 19686 "class A {", | 21833 "class A {", |
| 19687 " P p;", | 21834 " P p;", |
| 19688 " m(e) {", | 21835 " m(e) {", |
| 19689 " if (p(e)) {}", | 21836 " if (p(e)) {}", |
| 19690 " }", | 21837 " }", |
| 19691 "}"])); | 21838 "}"])); |
| 19692 resolve(source); | 21839 resolve(source); |
| 19693 assertNoErrors(source); | 21840 assertNoErrors(source); |
| 19694 verify([source]); | 21841 verify([source]); |
| 19695 } | 21842 } |
| 21843 |
| 19696 void test_getterAndSetterWithDifferentTypes() { | 21844 void test_getterAndSetterWithDifferentTypes() { |
| 19697 Source source = addSource(EngineTestCase.createSource([ | 21845 Source source = addSource(EngineTestCase.createSource([ |
| 19698 "class A {", | 21846 "class A {", |
| 19699 " int get f => 0;", | 21847 " int get f => 0;", |
| 19700 " void set f(String s) {}", | 21848 " void set f(String s) {}", |
| 19701 "}", | 21849 "}", |
| 19702 "g (A a) {", | 21850 "g (A a) {", |
| 19703 " a.f = a.f.toString();", | 21851 " a.f = a.f.toString();", |
| 19704 "}"])); | 21852 "}"])); |
| 19705 resolve(source); | 21853 resolve(source); |
| 19706 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; | 21854 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; |
| 19707 verify([source]); | 21855 verify([source]); |
| 19708 } | 21856 } |
| 21857 |
| 19709 void test_hasReferenceToSuper() { | 21858 void test_hasReferenceToSuper() { |
| 19710 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B {toString() => super.toString();}"])); | 21859 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B {toString() => super.toString();}"])); |
| 19711 LibraryElement library = resolve(source); | 21860 LibraryElement library = resolve(source); |
| 19712 JUnitTestCase.assertNotNull(library); | 21861 JUnitTestCase.assertNotNull(library); |
| 19713 CompilationUnitElement unit = library.definingCompilationUnit; | 21862 CompilationUnitElement unit = library.definingCompilationUnit; |
| 19714 JUnitTestCase.assertNotNull(unit); | 21863 JUnitTestCase.assertNotNull(unit); |
| 19715 List<ClassElement> classes = unit.types; | 21864 List<ClassElement> classes = unit.types; |
| 19716 EngineTestCase.assertLength(2, classes); | 21865 EngineTestCase.assertLength(2, classes); |
| 19717 JUnitTestCase.assertFalse(classes[0].hasReferenceToSuper()); | 21866 JUnitTestCase.assertFalse(classes[0].hasReferenceToSuper()); |
| 19718 JUnitTestCase.assertTrue(classes[1].hasReferenceToSuper()); | 21867 JUnitTestCase.assertTrue(classes[1].hasReferenceToSuper()); |
| 19719 assertNoErrors(source); | 21868 assertNoErrors(source); |
| 19720 verify([source]); | 21869 verify([source]); |
| 19721 } | 21870 } |
| 21871 |
| 19722 void test_import_hide() { | 21872 void test_import_hide() { |
| 19723 addSource2("lib1.dart", EngineTestCase.createSource(["library lib1;", "set f
oo(value) {}", "class A {}"])); | 21873 addSource2("lib1.dart", EngineTestCase.createSource(["library lib1;", "set f
oo(value) {}", "class A {}"])); |
| 19724 addSource2("lib2.dart", EngineTestCase.createSource(["library lib2;", "set f
oo(value) {}"])); | 21874 addSource2("lib2.dart", EngineTestCase.createSource(["library lib2;", "set f
oo(value) {}"])); |
| 19725 Source source = addSource2("lib3.dart", EngineTestCase.createSource([ | 21875 Source source = addSource2("lib3.dart", EngineTestCase.createSource([ |
| 19726 "import 'lib1.dart' hide foo;", | 21876 "import 'lib1.dart' hide foo;", |
| 19727 "import 'lib2.dart';", | 21877 "import 'lib2.dart';", |
| 19728 "", | 21878 "", |
| 19729 "main() {", | 21879 "main() {", |
| 19730 " foo = 0;", | 21880 " foo = 0;", |
| 19731 "}", | 21881 "}", |
| 19732 "A a;"])); | 21882 "A a;"])); |
| 19733 resolve(source); | 21883 resolve(source); |
| 19734 assertNoErrors(source); | 21884 assertNoErrors(source); |
| 19735 verify([source]); | 21885 verify([source]); |
| 19736 } | 21886 } |
| 21887 |
| 19737 void test_import_prefix() { | 21888 void test_import_prefix() { |
| 19738 addSource2("/two.dart", EngineTestCase.createSource(["library two;", "f(int
x) {", " return x * x;", "}"])); | 21889 addSource2("/two.dart", EngineTestCase.createSource(["library two;", "f(int
x) {", " return x * x;", "}"])); |
| 19739 Source source = addSource2("/one.dart", EngineTestCase.createSource([ | 21890 Source source = addSource2("/one.dart", EngineTestCase.createSource([ |
| 19740 "library one;", | 21891 "library one;", |
| 19741 "import 'two.dart' as _two;", | 21892 "import 'two.dart' as _two;", |
| 19742 "main() {", | 21893 "main() {", |
| 19743 " _two.f(0);", | 21894 " _two.f(0);", |
| 19744 "}"])); | 21895 "}"])); |
| 19745 resolve(source); | 21896 resolve(source); |
| 19746 assertNoErrors(source); | 21897 assertNoErrors(source); |
| 19747 verify([source]); | 21898 verify([source]); |
| 19748 } | 21899 } |
| 21900 |
| 19749 void test_import_spaceInUri() { | 21901 void test_import_spaceInUri() { |
| 19750 addSource2("sub folder/lib.dart", EngineTestCase.createSource(["library lib;
", "foo() {}"])); | 21902 addSource2("sub folder/lib.dart", EngineTestCase.createSource(["library lib;
", "foo() {}"])); |
| 19751 Source source = addSource2("app.dart", EngineTestCase.createSource([ | 21903 Source source = addSource2("app.dart", EngineTestCase.createSource([ |
| 19752 "import 'sub folder/lib.dart';", | 21904 "import 'sub folder/lib.dart';", |
| 19753 "", | 21905 "", |
| 19754 "main() {", | 21906 "main() {", |
| 19755 " foo();", | 21907 " foo();", |
| 19756 "}"])); | 21908 "}"])); |
| 19757 resolve(source); | 21909 resolve(source); |
| 19758 assertNoErrors(source); | 21910 assertNoErrors(source); |
| 19759 verify([source]); | 21911 verify([source]); |
| 19760 } | 21912 } |
| 21913 |
| 19761 void test_indexExpression_typeParameters() { | 21914 void test_indexExpression_typeParameters() { |
| 19762 Source source = addSource(EngineTestCase.createSource([ | 21915 Source source = addSource(EngineTestCase.createSource([ |
| 19763 "f() {", | 21916 "f() {", |
| 19764 " List<int> a;", | 21917 " List<int> a;", |
| 19765 " a[0];", | 21918 " a[0];", |
| 19766 " List<List<int>> b;", | 21919 " List<List<int>> b;", |
| 19767 " b[0][0];", | 21920 " b[0][0];", |
| 19768 " List<List<List<int>>> c;", | 21921 " List<List<List<int>>> c;", |
| 19769 " c[0][0][0];", | 21922 " c[0][0][0];", |
| 19770 "}"])); | 21923 "}"])); |
| 19771 resolve(source); | 21924 resolve(source); |
| 19772 assertNoErrors(source); | 21925 assertNoErrors(source); |
| 19773 verify([source]); | 21926 verify([source]); |
| 19774 } | 21927 } |
| 21928 |
| 19775 void test_indexExpression_typeParameters_invalidAssignmentWarning() { | 21929 void test_indexExpression_typeParameters_invalidAssignmentWarning() { |
| 19776 Source source = addSource(EngineTestCase.createSource(["f() {", " List<List
<int>> b;", " b[0][0] = 'hi';", "}"])); | 21930 Source source = addSource(EngineTestCase.createSource(["f() {", " List<List
<int>> b;", " b[0][0] = 'hi';", "}"])); |
| 19777 resolve(source); | 21931 resolve(source); |
| 19778 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 21932 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 19779 verify([source]); | 21933 verify([source]); |
| 19780 } | 21934 } |
| 21935 |
| 19781 void test_indirectOperatorThroughCall() { | 21936 void test_indirectOperatorThroughCall() { |
| 19782 Source source = addSource(EngineTestCase.createSource([ | 21937 Source source = addSource(EngineTestCase.createSource([ |
| 19783 "class A {", | 21938 "class A {", |
| 19784 " B call() { return new B(); }", | 21939 " B call() { return new B(); }", |
| 19785 "}", | 21940 "}", |
| 19786 "", | 21941 "", |
| 19787 "class B {", | 21942 "class B {", |
| 19788 " int operator [](int i) { return i; }", | 21943 " int operator [](int i) { return i; }", |
| 19789 "}", | 21944 "}", |
| 19790 "", | 21945 "", |
| 19791 "A f = new A();", | 21946 "A f = new A();", |
| 19792 "", | 21947 "", |
| 19793 "g(int x) {}", | 21948 "g(int x) {}", |
| 19794 "", | 21949 "", |
| 19795 "main() {", | 21950 "main() {", |
| 19796 " g(f()[0]);", | 21951 " g(f()[0]);", |
| 19797 "}"])); | 21952 "}"])); |
| 19798 resolve(source); | 21953 resolve(source); |
| 19799 assertNoErrors(source); | 21954 assertNoErrors(source); |
| 19800 verify([source]); | 21955 verify([source]); |
| 19801 } | 21956 } |
| 21957 |
| 19802 void test_invoke_dynamicThroughGetter() { | 21958 void test_invoke_dynamicThroughGetter() { |
| 19803 Source source = addSource(EngineTestCase.createSource([ | 21959 Source source = addSource(EngineTestCase.createSource([ |
| 19804 "class A {", | 21960 "class A {", |
| 19805 " List get X => [() => 0];", | 21961 " List get X => [() => 0];", |
| 19806 " m(A a) {", | 21962 " m(A a) {", |
| 19807 " X.last;", | 21963 " X.last;", |
| 19808 " }", | 21964 " }", |
| 19809 "}"])); | 21965 "}"])); |
| 19810 resolve(source); | 21966 resolve(source); |
| 19811 assertNoErrors(source); | 21967 assertNoErrors(source); |
| 19812 verify([source]); | 21968 verify([source]); |
| 19813 } | 21969 } |
| 21970 |
| 19814 void test_isValidMixin_badSuperclass() { | 21971 void test_isValidMixin_badSuperclass() { |
| 19815 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B {}"])); | 21972 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B {}"])); |
| 19816 LibraryElement library = resolve(source); | 21973 LibraryElement library = resolve(source); |
| 19817 JUnitTestCase.assertNotNull(library); | 21974 JUnitTestCase.assertNotNull(library); |
| 19818 CompilationUnitElement unit = library.definingCompilationUnit; | 21975 CompilationUnitElement unit = library.definingCompilationUnit; |
| 19819 JUnitTestCase.assertNotNull(unit); | 21976 JUnitTestCase.assertNotNull(unit); |
| 19820 List<ClassElement> classes = unit.types; | 21977 List<ClassElement> classes = unit.types; |
| 19821 EngineTestCase.assertLength(2, classes); | 21978 EngineTestCase.assertLength(2, classes); |
| 19822 JUnitTestCase.assertFalse(classes[0].isValidMixin); | 21979 JUnitTestCase.assertFalse(classes[0].isValidMixin); |
| 19823 assertNoErrors(source); | 21980 assertNoErrors(source); |
| 19824 verify([source]); | 21981 verify([source]); |
| 19825 } | 21982 } |
| 21983 |
| 19826 void test_isValidMixin_constructor() { | 21984 void test_isValidMixin_constructor() { |
| 19827 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}"])); | 21985 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}"])); |
| 19828 LibraryElement library = resolve(source); | 21986 LibraryElement library = resolve(source); |
| 19829 JUnitTestCase.assertNotNull(library); | 21987 JUnitTestCase.assertNotNull(library); |
| 19830 CompilationUnitElement unit = library.definingCompilationUnit; | 21988 CompilationUnitElement unit = library.definingCompilationUnit; |
| 19831 JUnitTestCase.assertNotNull(unit); | 21989 JUnitTestCase.assertNotNull(unit); |
| 19832 List<ClassElement> classes = unit.types; | 21990 List<ClassElement> classes = unit.types; |
| 19833 EngineTestCase.assertLength(1, classes); | 21991 EngineTestCase.assertLength(1, classes); |
| 19834 JUnitTestCase.assertFalse(classes[0].isValidMixin); | 21992 JUnitTestCase.assertFalse(classes[0].isValidMixin); |
| 19835 assertNoErrors(source); | 21993 assertNoErrors(source); |
| 19836 verify([source]); | 21994 verify([source]); |
| 19837 } | 21995 } |
| 21996 |
| 19838 void test_isValidMixin_super() { | 21997 void test_isValidMixin_super() { |
| 19839 Source source = addSource(EngineTestCase.createSource([ | 21998 Source source = addSource(EngineTestCase.createSource([ |
| 19840 "class A {", | 21999 "class A {", |
| 19841 " toString() {", | 22000 " toString() {", |
| 19842 " return super.toString();", | 22001 " return super.toString();", |
| 19843 " }", | 22002 " }", |
| 19844 "}"])); | 22003 "}"])); |
| 19845 LibraryElement library = resolve(source); | 22004 LibraryElement library = resolve(source); |
| 19846 JUnitTestCase.assertNotNull(library); | 22005 JUnitTestCase.assertNotNull(library); |
| 19847 CompilationUnitElement unit = library.definingCompilationUnit; | 22006 CompilationUnitElement unit = library.definingCompilationUnit; |
| 19848 JUnitTestCase.assertNotNull(unit); | 22007 JUnitTestCase.assertNotNull(unit); |
| 19849 List<ClassElement> classes = unit.types; | 22008 List<ClassElement> classes = unit.types; |
| 19850 EngineTestCase.assertLength(1, classes); | 22009 EngineTestCase.assertLength(1, classes); |
| 19851 JUnitTestCase.assertFalse(classes[0].isValidMixin); | 22010 JUnitTestCase.assertFalse(classes[0].isValidMixin); |
| 19852 assertNoErrors(source); | 22011 assertNoErrors(source); |
| 19853 verify([source]); | 22012 verify([source]); |
| 19854 } | 22013 } |
| 22014 |
| 19855 void test_isValidMixin_valid() { | 22015 void test_isValidMixin_valid() { |
| 19856 Source source = addSource(EngineTestCase.createSource(["class A {}"])); | 22016 Source source = addSource(EngineTestCase.createSource(["class A {}"])); |
| 19857 LibraryElement library = resolve(source); | 22017 LibraryElement library = resolve(source); |
| 19858 JUnitTestCase.assertNotNull(library); | 22018 JUnitTestCase.assertNotNull(library); |
| 19859 CompilationUnitElement unit = library.definingCompilationUnit; | 22019 CompilationUnitElement unit = library.definingCompilationUnit; |
| 19860 JUnitTestCase.assertNotNull(unit); | 22020 JUnitTestCase.assertNotNull(unit); |
| 19861 List<ClassElement> classes = unit.types; | 22021 List<ClassElement> classes = unit.types; |
| 19862 EngineTestCase.assertLength(1, classes); | 22022 EngineTestCase.assertLength(1, classes); |
| 19863 JUnitTestCase.assertTrue(classes[0].isValidMixin); | 22023 JUnitTestCase.assertTrue(classes[0].isValidMixin); |
| 19864 assertNoErrors(source); | 22024 assertNoErrors(source); |
| 19865 verify([source]); | 22025 verify([source]); |
| 19866 } | 22026 } |
| 22027 |
| 19867 void test_labels_switch() { | 22028 void test_labels_switch() { |
| 19868 Source source = addSource(EngineTestCase.createSource([ | 22029 Source source = addSource(EngineTestCase.createSource([ |
| 19869 "void doSwitch(int target) {", | 22030 "void doSwitch(int target) {", |
| 19870 " switch (target) {", | 22031 " switch (target) {", |
| 19871 " l0: case 0:", | 22032 " l0: case 0:", |
| 19872 " continue l1;", | 22033 " continue l1;", |
| 19873 " l1: case 1:", | 22034 " l1: case 1:", |
| 19874 " continue l0;", | 22035 " continue l0;", |
| 19875 " default:", | 22036 " default:", |
| 19876 " continue l1;", | 22037 " continue l1;", |
| 19877 " }", | 22038 " }", |
| 19878 "}"])); | 22039 "}"])); |
| 19879 LibraryElement library = resolve(source); | 22040 LibraryElement library = resolve(source); |
| 19880 JUnitTestCase.assertNotNull(library); | 22041 JUnitTestCase.assertNotNull(library); |
| 19881 assertNoErrors(source); | 22042 assertNoErrors(source); |
| 19882 verify([source]); | 22043 verify([source]); |
| 19883 } | 22044 } |
| 22045 |
| 19884 void test_metadata_class() { | 22046 void test_metadata_class() { |
| 19885 Source source = addSource(EngineTestCase.createSource(["const A = null;", "@
A class C {}"])); | 22047 Source source = addSource(EngineTestCase.createSource(["const A = null;", "@
A class C {}"])); |
| 19886 LibraryElement library = resolve(source); | 22048 LibraryElement library = resolve(source); |
| 19887 JUnitTestCase.assertNotNull(library); | 22049 JUnitTestCase.assertNotNull(library); |
| 19888 CompilationUnitElement unit = library.definingCompilationUnit; | 22050 CompilationUnitElement unit = library.definingCompilationUnit; |
| 19889 JUnitTestCase.assertNotNull(unit); | 22051 JUnitTestCase.assertNotNull(unit); |
| 19890 List<ClassElement> classes = unit.types; | 22052 List<ClassElement> classes = unit.types; |
| 19891 EngineTestCase.assertLength(1, classes); | 22053 EngineTestCase.assertLength(1, classes); |
| 19892 List<ElementAnnotation> annotations = classes[0].metadata; | 22054 List<ElementAnnotation> annotations = classes[0].metadata; |
| 19893 EngineTestCase.assertLength(1, annotations); | 22055 EngineTestCase.assertLength(1, annotations); |
| 19894 assertNoErrors(source); | 22056 assertNoErrors(source); |
| 19895 verify([source]); | 22057 verify([source]); |
| 19896 } | 22058 } |
| 22059 |
| 19897 void test_metadata_field() { | 22060 void test_metadata_field() { |
| 19898 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c
lass C {", " @A int f;", "}"])); | 22061 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c
lass C {", " @A int f;", "}"])); |
| 19899 LibraryElement library = resolve(source); | 22062 LibraryElement library = resolve(source); |
| 19900 JUnitTestCase.assertNotNull(library); | 22063 JUnitTestCase.assertNotNull(library); |
| 19901 CompilationUnitElement unit = library.definingCompilationUnit; | 22064 CompilationUnitElement unit = library.definingCompilationUnit; |
| 19902 JUnitTestCase.assertNotNull(unit); | 22065 JUnitTestCase.assertNotNull(unit); |
| 19903 List<ClassElement> classes = unit.types; | 22066 List<ClassElement> classes = unit.types; |
| 19904 EngineTestCase.assertLength(1, classes); | 22067 EngineTestCase.assertLength(1, classes); |
| 19905 FieldElement field = classes[0].fields[0]; | 22068 FieldElement field = classes[0].fields[0]; |
| 19906 List<ElementAnnotation> annotations = field.metadata; | 22069 List<ElementAnnotation> annotations = field.metadata; |
| 19907 EngineTestCase.assertLength(1, annotations); | 22070 EngineTestCase.assertLength(1, annotations); |
| 19908 assertNoErrors(source); | 22071 assertNoErrors(source); |
| 19909 verify([source]); | 22072 verify([source]); |
| 19910 } | 22073 } |
| 22074 |
| 19911 void test_metadata_libraryDirective() { | 22075 void test_metadata_libraryDirective() { |
| 19912 Source source = addSource(EngineTestCase.createSource(["@A library lib;", "c
onst A = null;"])); | 22076 Source source = addSource(EngineTestCase.createSource(["@A library lib;", "c
onst A = null;"])); |
| 19913 LibraryElement library = resolve(source); | 22077 LibraryElement library = resolve(source); |
| 19914 JUnitTestCase.assertNotNull(library); | 22078 JUnitTestCase.assertNotNull(library); |
| 19915 List<ElementAnnotation> annotations = library.metadata; | 22079 List<ElementAnnotation> annotations = library.metadata; |
| 19916 EngineTestCase.assertLength(1, annotations); | 22080 EngineTestCase.assertLength(1, annotations); |
| 19917 assertNoErrors(source); | 22081 assertNoErrors(source); |
| 19918 verify([source]); | 22082 verify([source]); |
| 19919 } | 22083 } |
| 22084 |
| 19920 void test_metadata_method() { | 22085 void test_metadata_method() { |
| 19921 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c
lass C {", " @A void m() {}", "}"])); | 22086 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c
lass C {", " @A void m() {}", "}"])); |
| 19922 LibraryElement library = resolve(source); | 22087 LibraryElement library = resolve(source); |
| 19923 JUnitTestCase.assertNotNull(library); | 22088 JUnitTestCase.assertNotNull(library); |
| 19924 CompilationUnitElement unit = library.definingCompilationUnit; | 22089 CompilationUnitElement unit = library.definingCompilationUnit; |
| 19925 JUnitTestCase.assertNotNull(unit); | 22090 JUnitTestCase.assertNotNull(unit); |
| 19926 List<ClassElement> classes = unit.types; | 22091 List<ClassElement> classes = unit.types; |
| 19927 EngineTestCase.assertLength(1, classes); | 22092 EngineTestCase.assertLength(1, classes); |
| 19928 MethodElement method = classes[0].methods[0]; | 22093 MethodElement method = classes[0].methods[0]; |
| 19929 List<ElementAnnotation> annotations = method.metadata; | 22094 List<ElementAnnotation> annotations = method.metadata; |
| 19930 EngineTestCase.assertLength(1, annotations); | 22095 EngineTestCase.assertLength(1, annotations); |
| 19931 assertNoErrors(source); | 22096 assertNoErrors(source); |
| 19932 verify([source]); | 22097 verify([source]); |
| 19933 } | 22098 } |
| 22099 |
| 19934 void test_method_fromMixin() { | 22100 void test_method_fromMixin() { |
| 19935 Source source = addSource(EngineTestCase.createSource([ | 22101 Source source = addSource(EngineTestCase.createSource([ |
| 19936 "class B {", | 22102 "class B {", |
| 19937 " bar() => 1;", | 22103 " bar() => 1;", |
| 19938 "}", | 22104 "}", |
| 19939 "class A {", | 22105 "class A {", |
| 19940 " foo() => 2;", | 22106 " foo() => 2;", |
| 19941 "}", | 22107 "}", |
| 19942 "", | 22108 "", |
| 19943 "class C extends B with A {", | 22109 "class C extends B with A {", |
| 19944 " bar() => super.bar();", | 22110 " bar() => super.bar();", |
| 19945 " foo() => super.foo();", | 22111 " foo() => super.foo();", |
| 19946 "}"])); | 22112 "}"])); |
| 19947 resolve(source); | 22113 resolve(source); |
| 19948 assertNoErrors(source); | 22114 assertNoErrors(source); |
| 19949 verify([source]); | 22115 verify([source]); |
| 19950 } | 22116 } |
| 22117 |
| 19951 void test_method_fromSuperclassMixin() { | 22118 void test_method_fromSuperclassMixin() { |
| 19952 Source source = addSource(EngineTestCase.createSource([ | 22119 Source source = addSource(EngineTestCase.createSource([ |
| 19953 "class A {", | 22120 "class A {", |
| 19954 " void m1() {}", | 22121 " void m1() {}", |
| 19955 "}", | 22122 "}", |
| 19956 "class B extends Object with A {", | 22123 "class B extends Object with A {", |
| 19957 "}", | 22124 "}", |
| 19958 "class C extends B {", | 22125 "class C extends B {", |
| 19959 "}", | 22126 "}", |
| 19960 "f(C c) {", | 22127 "f(C c) {", |
| 19961 " c.m1();", | 22128 " c.m1();", |
| 19962 "}"])); | 22129 "}"])); |
| 19963 resolve(source); | 22130 resolve(source); |
| 19964 assertNoErrors(source); | 22131 assertNoErrors(source); |
| 19965 verify([source]); | 22132 verify([source]); |
| 19966 } | 22133 } |
| 22134 |
| 19967 void test_methodCascades() { | 22135 void test_methodCascades() { |
| 19968 Source source = addSource(EngineTestCase.createSource([ | 22136 Source source = addSource(EngineTestCase.createSource([ |
| 19969 "class A {", | 22137 "class A {", |
| 19970 " void m1() {}", | 22138 " void m1() {}", |
| 19971 " void m2() {}", | 22139 " void m2() {}", |
| 19972 " void m() {", | 22140 " void m() {", |
| 19973 " A a = new A();", | 22141 " A a = new A();", |
| 19974 " a..m1()", | 22142 " a..m1()", |
| 19975 " ..m2();", | 22143 " ..m2();", |
| 19976 " }", | 22144 " }", |
| 19977 "}"])); | 22145 "}"])); |
| 19978 resolve(source); | 22146 resolve(source); |
| 19979 assertNoErrors(source); | 22147 assertNoErrors(source); |
| 19980 verify([source]); | 22148 verify([source]); |
| 19981 } | 22149 } |
| 22150 |
| 19982 void test_methodCascades_withSetter() { | 22151 void test_methodCascades_withSetter() { |
| 19983 Source source = addSource(EngineTestCase.createSource([ | 22152 Source source = addSource(EngineTestCase.createSource([ |
| 19984 "class A {", | 22153 "class A {", |
| 19985 " String name;", | 22154 " String name;", |
| 19986 " void m1() {}", | 22155 " void m1() {}", |
| 19987 " void m2() {}", | 22156 " void m2() {}", |
| 19988 " void m() {", | 22157 " void m() {", |
| 19989 " A a = new A();", | 22158 " A a = new A();", |
| 19990 " a..m1()", | 22159 " a..m1()", |
| 19991 " ..name = 'name'", | 22160 " ..name = 'name'", |
| 19992 " ..m2();", | 22161 " ..m2();", |
| 19993 " }", | 22162 " }", |
| 19994 "}"])); | 22163 "}"])); |
| 19995 resolve(source); | 22164 resolve(source); |
| 19996 assertNoErrors(source); | 22165 assertNoErrors(source); |
| 19997 verify([source]); | 22166 verify([source]); |
| 19998 } | 22167 } |
| 22168 |
| 19999 void test_resolveAgainstNull() { | 22169 void test_resolveAgainstNull() { |
| 20000 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " retu
rn null == p;", "}"])); | 22170 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " retu
rn null == p;", "}"])); |
| 20001 resolve(source); | 22171 resolve(source); |
| 20002 assertNoErrors(source); | 22172 assertNoErrors(source); |
| 20003 } | 22173 } |
| 22174 |
| 20004 void test_setter_inherited() { | 22175 void test_setter_inherited() { |
| 20005 Source source = addSource(EngineTestCase.createSource([ | 22176 Source source = addSource(EngineTestCase.createSource([ |
| 20006 "class A {", | 22177 "class A {", |
| 20007 " int get x => 0;", | 22178 " int get x => 0;", |
| 20008 " set x(int p) {}", | 22179 " set x(int p) {}", |
| 20009 "}", | 22180 "}", |
| 20010 "class B extends A {", | 22181 "class B extends A {", |
| 20011 " int get x => super.x == null ? 0 : super.x;", | 22182 " int get x => super.x == null ? 0 : super.x;", |
| 20012 " int f() => x = 1;", | 22183 " int f() => x = 1;", |
| 20013 "}"])); | 22184 "}"])); |
| 20014 resolve(source); | 22185 resolve(source); |
| 20015 assertNoErrors(source); | 22186 assertNoErrors(source); |
| 20016 verify([source]); | 22187 verify([source]); |
| 20017 } | 22188 } |
| 22189 |
| 20018 void test_setter_static() { | 22190 void test_setter_static() { |
| 20019 Source source = addSource(EngineTestCase.createSource(["set s(x) {", "}", ""
, "main() {", " s = 123;", "}"])); | 22191 Source source = addSource(EngineTestCase.createSource(["set s(x) {", "}", ""
, "main() {", " s = 123;", "}"])); |
| 20020 resolve(source); | 22192 resolve(source); |
| 20021 assertNoErrors(source); | 22193 assertNoErrors(source); |
| 20022 verify([source]); | 22194 verify([source]); |
| 20023 } | 22195 } |
| 20024 | 22196 |
| 20025 /** | 22197 /** |
| 20026 * Resolve the given source and verify that the arguments in a specific method
invocation were | 22198 * Resolve the given source and verify that the arguments in a specific method
invocation were |
| 20027 * correctly resolved. | 22199 * correctly resolved. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 20045 */ | 22217 */ |
| 20046 void validateArgumentResolution(Source source, List<int> indices) { | 22218 void validateArgumentResolution(Source source, List<int> indices) { |
| 20047 LibraryElement library = resolve(source); | 22219 LibraryElement library = resolve(source); |
| 20048 JUnitTestCase.assertNotNull(library); | 22220 JUnitTestCase.assertNotNull(library); |
| 20049 ClassElement classElement = library.definingCompilationUnit.types[0]; | 22221 ClassElement classElement = library.definingCompilationUnit.types[0]; |
| 20050 List<ParameterElement> parameters = classElement.methods[1].parameters; | 22222 List<ParameterElement> parameters = classElement.methods[1].parameters; |
| 20051 CompilationUnit unit = resolveCompilationUnit(source, library); | 22223 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 20052 JUnitTestCase.assertNotNull(unit); | 22224 JUnitTestCase.assertNotNull(unit); |
| 20053 ClassDeclaration classDeclaration = unit.declarations[0] as ClassDeclaration
; | 22225 ClassDeclaration classDeclaration = unit.declarations[0] as ClassDeclaration
; |
| 20054 MethodDeclaration methodDeclaration = classDeclaration.members[0] as MethodD
eclaration; | 22226 MethodDeclaration methodDeclaration = classDeclaration.members[0] as MethodD
eclaration; |
| 20055 Block block = ((methodDeclaration.body as BlockFunctionBody)).block; | 22227 Block block = (methodDeclaration.body as BlockFunctionBody).block; |
| 20056 ExpressionStatement statement = block.statements[0] as ExpressionStatement; | 22228 ExpressionStatement statement = block.statements[0] as ExpressionStatement; |
| 20057 MethodInvocation invocation = statement.expression as MethodInvocation; | 22229 MethodInvocation invocation = statement.expression as MethodInvocation; |
| 20058 NodeList<Expression> arguments = invocation.argumentList.arguments; | 22230 NodeList<Expression> arguments = invocation.argumentList.arguments; |
| 20059 int argumentCount = arguments.length; | 22231 int argumentCount = arguments.length; |
| 20060 JUnitTestCase.assertEquals(indices.length, argumentCount); | 22232 JUnitTestCase.assertEquals(indices.length, argumentCount); |
| 20061 for (int i = 0; i < argumentCount; i++) { | 22233 for (int i = 0; i < argumentCount; i++) { |
| 20062 Expression argument = arguments[i]; | 22234 Expression argument = arguments[i]; |
| 20063 ParameterElement element = argument.staticParameterElement; | 22235 ParameterElement element = argument.staticParameterElement; |
| 20064 int index = indices[i]; | 22236 int index = indices[i]; |
| 20065 if (index < 0) { | 22237 if (index < 0) { |
| 20066 JUnitTestCase.assertNull(element); | 22238 JUnitTestCase.assertNull(element); |
| 20067 } else { | 22239 } else { |
| 20068 JUnitTestCase.assertSame(parameters[index], element); | 22240 JUnitTestCase.assertSame(parameters[index], element); |
| 20069 } | 22241 } |
| 20070 } | 22242 } |
| 20071 } | 22243 } |
| 22244 |
| 20072 static dartSuite() { | 22245 static dartSuite() { |
| 20073 _ut.group('SimpleResolverTest', () { | 22246 _ut.group('SimpleResolverTest', () { |
| 20074 _ut.test('test_argumentResolution_requiredAndNamed_extra', () { | 22247 _ut.test('test_argumentResolution_requiredAndNamed_extra', () { |
| 20075 final __test = new SimpleResolverTest(); | 22248 final __test = new SimpleResolverTest(); |
| 20076 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_ext
ra); | 22249 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_ext
ra); |
| 20077 }); | 22250 }); |
| 20078 _ut.test('test_argumentResolution_requiredAndNamed_matching', () { | 22251 _ut.test('test_argumentResolution_requiredAndNamed_matching', () { |
| 20079 final __test = new SimpleResolverTest(); | 22252 final __test = new SimpleResolverTest(); |
| 20080 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_mat
ching); | 22253 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_mat
ching); |
| 20081 }); | 22254 }); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20247 final __test = new SimpleResolverTest(); | 22420 final __test = new SimpleResolverTest(); |
| 20248 runJUnitTest(__test, __test.test_setter_inherited); | 22421 runJUnitTest(__test, __test.test_setter_inherited); |
| 20249 }); | 22422 }); |
| 20250 _ut.test('test_setter_static', () { | 22423 _ut.test('test_setter_static', () { |
| 20251 final __test = new SimpleResolverTest(); | 22424 final __test = new SimpleResolverTest(); |
| 20252 runJUnitTest(__test, __test.test_setter_static); | 22425 runJUnitTest(__test, __test.test_setter_static); |
| 20253 }); | 22426 }); |
| 20254 }); | 22427 }); |
| 20255 } | 22428 } |
| 20256 } | 22429 } |
| 22430 |
| 20257 class SubtypeManagerTest extends EngineTestCase { | 22431 class SubtypeManagerTest extends EngineTestCase { |
| 20258 | |
| 20259 /** | 22432 /** |
| 20260 * The inheritance manager being tested. | 22433 * The inheritance manager being tested. |
| 20261 */ | 22434 */ |
| 20262 SubtypeManager _subtypeManager; | 22435 SubtypeManager _subtypeManager; |
| 20263 | 22436 |
| 20264 /** | 22437 /** |
| 20265 * The compilation unit element containing all of the types setup in each test
. | 22438 * The compilation unit element containing all of the types setup in each test
. |
| 20266 */ | 22439 */ |
| 20267 CompilationUnitElementImpl _definingCompilationUnit; | 22440 CompilationUnitElementImpl _definingCompilationUnit; |
| 22441 |
| 20268 void test_computeAllSubtypes_infiniteLoop() { | 22442 void test_computeAllSubtypes_infiniteLoop() { |
| 20269 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 22443 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 20270 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 22444 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 20271 classA.supertype = classB.type; | 22445 classA.supertype = classB.type; |
| 20272 _definingCompilationUnit.types = <ClassElement> [classA, classB]; | 22446 _definingCompilationUnit.types = <ClassElement> [classA, classB]; |
| 20273 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA); | 22447 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA); |
| 20274 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA); | 22448 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA); |
| 20275 EngineTestCase.assertSize3(2, subtypesOfA); | 22449 EngineTestCase.assertSize3(2, subtypesOfA); |
| 20276 EngineTestCase.assertContains(arraySubtypesOfA, [classA, classB]); | 22450 EngineTestCase.assertContains(arraySubtypesOfA, [classA, classB]); |
| 20277 } | 22451 } |
| 22452 |
| 20278 void test_computeAllSubtypes_manyRecursiveSubtypes() { | 22453 void test_computeAllSubtypes_manyRecursiveSubtypes() { |
| 20279 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 22454 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 20280 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 22455 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 20281 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); | 22456 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []); |
| 20282 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []); | 22457 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []); |
| 20283 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []); | 22458 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []); |
| 20284 _definingCompilationUnit.types = <ClassElement> [classA, classB, classC, cla
ssD, classE]; | 22459 _definingCompilationUnit.types = <ClassElement> [classA, classB, classC, cla
ssD, classE]; |
| 20285 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA); | 22460 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA); |
| 20286 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA); | 22461 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA); |
| 20287 Set<ClassElement> subtypesOfB = _subtypeManager.computeAllSubtypes(classB); | 22462 Set<ClassElement> subtypesOfB = _subtypeManager.computeAllSubtypes(classB); |
| 20288 List<ClassElement> arraySubtypesOfB = new List.from(subtypesOfB); | 22463 List<ClassElement> arraySubtypesOfB = new List.from(subtypesOfB); |
| 20289 EngineTestCase.assertSize3(4, subtypesOfA); | 22464 EngineTestCase.assertSize3(4, subtypesOfA); |
| 20290 EngineTestCase.assertContains(arraySubtypesOfA, [classB, classC, classD, cla
ssE]); | 22465 EngineTestCase.assertContains(arraySubtypesOfA, [classB, classC, classD, cla
ssE]); |
| 20291 EngineTestCase.assertSize3(3, subtypesOfB); | 22466 EngineTestCase.assertSize3(3, subtypesOfB); |
| 20292 EngineTestCase.assertContains(arraySubtypesOfB, [classC, classD, classE]); | 22467 EngineTestCase.assertContains(arraySubtypesOfB, [classC, classD, classE]); |
| 20293 } | 22468 } |
| 22469 |
| 20294 void test_computeAllSubtypes_noSubtypes() { | 22470 void test_computeAllSubtypes_noSubtypes() { |
| 20295 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 22471 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 20296 _definingCompilationUnit.types = <ClassElement> [classA]; | 22472 _definingCompilationUnit.types = <ClassElement> [classA]; |
| 20297 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA); | 22473 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA); |
| 20298 EngineTestCase.assertSize3(0, subtypesOfA); | 22474 EngineTestCase.assertSize3(0, subtypesOfA); |
| 20299 } | 22475 } |
| 22476 |
| 20300 void test_computeAllSubtypes_oneSubtype() { | 22477 void test_computeAllSubtypes_oneSubtype() { |
| 20301 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 22478 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 20302 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); | 22479 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); |
| 20303 _definingCompilationUnit.types = <ClassElement> [classA, classB]; | 22480 _definingCompilationUnit.types = <ClassElement> [classA, classB]; |
| 20304 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA); | 22481 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA); |
| 20305 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA); | 22482 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA); |
| 20306 EngineTestCase.assertSize3(1, subtypesOfA); | 22483 EngineTestCase.assertSize3(1, subtypesOfA); |
| 20307 EngineTestCase.assertContains(arraySubtypesOfA, [classB]); | 22484 EngineTestCase.assertContains(arraySubtypesOfA, [classB]); |
| 20308 } | 22485 } |
| 22486 |
| 20309 void setUp() { | 22487 void setUp() { |
| 20310 super.setUp(); | 22488 super.setUp(); |
| 20311 AnalysisContextImpl context = AnalysisContextFactory.contextWithCore(); | 22489 AnalysisContextImpl context = AnalysisContextFactory.contextWithCore(); |
| 20312 FileBasedSource source = new FileBasedSource.con1(new ContentCache(), FileUt
ilities2.createFile("/test.dart")); | 22490 FileBasedSource source = new FileBasedSource.con1(new ContentCache(), FileUt
ilities2.createFile("/test.dart")); |
| 20313 _definingCompilationUnit = new CompilationUnitElementImpl("test.dart"); | 22491 _definingCompilationUnit = new CompilationUnitElementImpl("test.dart"); |
| 20314 _definingCompilationUnit.source = source; | 22492 _definingCompilationUnit.source = source; |
| 20315 LibraryElementImpl definingLibrary = ElementFactory.library(context, "test")
; | 22493 LibraryElementImpl definingLibrary = ElementFactory.library(context, "test")
; |
| 20316 definingLibrary.definingCompilationUnit = _definingCompilationUnit; | 22494 definingLibrary.definingCompilationUnit = _definingCompilationUnit; |
| 20317 _subtypeManager = new SubtypeManager(); | 22495 _subtypeManager = new SubtypeManager(); |
| 20318 } | 22496 } |
| 22497 |
| 20319 static dartSuite() { | 22498 static dartSuite() { |
| 20320 _ut.group('SubtypeManagerTest', () { | 22499 _ut.group('SubtypeManagerTest', () { |
| 20321 _ut.test('test_computeAllSubtypes_infiniteLoop', () { | 22500 _ut.test('test_computeAllSubtypes_infiniteLoop', () { |
| 20322 final __test = new SubtypeManagerTest(); | 22501 final __test = new SubtypeManagerTest(); |
| 20323 runJUnitTest(__test, __test.test_computeAllSubtypes_infiniteLoop); | 22502 runJUnitTest(__test, __test.test_computeAllSubtypes_infiniteLoop); |
| 20324 }); | 22503 }); |
| 20325 _ut.test('test_computeAllSubtypes_manyRecursiveSubtypes', () { | 22504 _ut.test('test_computeAllSubtypes_manyRecursiveSubtypes', () { |
| 20326 final __test = new SubtypeManagerTest(); | 22505 final __test = new SubtypeManagerTest(); |
| 20327 runJUnitTest(__test, __test.test_computeAllSubtypes_manyRecursiveSubtype
s); | 22506 runJUnitTest(__test, __test.test_computeAllSubtypes_manyRecursiveSubtype
s); |
| 20328 }); | 22507 }); |
| 20329 _ut.test('test_computeAllSubtypes_noSubtypes', () { | 22508 _ut.test('test_computeAllSubtypes_noSubtypes', () { |
| 20330 final __test = new SubtypeManagerTest(); | 22509 final __test = new SubtypeManagerTest(); |
| 20331 runJUnitTest(__test, __test.test_computeAllSubtypes_noSubtypes); | 22510 runJUnitTest(__test, __test.test_computeAllSubtypes_noSubtypes); |
| 20332 }); | 22511 }); |
| 20333 _ut.test('test_computeAllSubtypes_oneSubtype', () { | 22512 _ut.test('test_computeAllSubtypes_oneSubtype', () { |
| 20334 final __test = new SubtypeManagerTest(); | 22513 final __test = new SubtypeManagerTest(); |
| 20335 runJUnitTest(__test, __test.test_computeAllSubtypes_oneSubtype); | 22514 runJUnitTest(__test, __test.test_computeAllSubtypes_oneSubtype); |
| 20336 }); | 22515 }); |
| 20337 }); | 22516 }); |
| 20338 } | 22517 } |
| 20339 } | 22518 } |
| 22519 |
| 22520 class ScopeBuilderTest extends EngineTestCase { |
| 22521 void test_scopeFor_ClassDeclaration() { |
| 22522 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22523 Scope scope = ScopeBuilder.scopeFor(createResolvedClassDeclaration(), listen
er); |
| 22524 EngineTestCase.assertInstanceOf(LibraryScope, scope); |
| 22525 } |
| 22526 |
| 22527 void test_scopeFor_ClassTypeAlias() { |
| 22528 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22529 Scope scope = ScopeBuilder.scopeFor(createResolvedClassTypeAlias(), listener
); |
| 22530 EngineTestCase.assertInstanceOf(LibraryScope, scope); |
| 22531 } |
| 22532 |
| 22533 void test_scopeFor_CompilationUnit() { |
| 22534 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22535 Scope scope = ScopeBuilder.scopeFor(createResolvedCompilationUnit(), listene
r); |
| 22536 EngineTestCase.assertInstanceOf(LibraryScope, scope); |
| 22537 } |
| 22538 |
| 22539 void test_scopeFor_ConstructorDeclaration() { |
| 22540 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22541 Scope scope = ScopeBuilder.scopeFor(createResolvedConstructorDeclaration(),
listener); |
| 22542 EngineTestCase.assertInstanceOf(ClassScope, scope); |
| 22543 } |
| 22544 |
| 22545 void test_scopeFor_ConstructorDeclaration_parameters() { |
| 22546 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22547 Scope scope = ScopeBuilder.scopeFor(createResolvedConstructorDeclaration().p
arameters, listener); |
| 22548 EngineTestCase.assertInstanceOf(FunctionScope, scope); |
| 22549 } |
| 22550 |
| 22551 void test_scopeFor_FunctionDeclaration() { |
| 22552 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22553 Scope scope = ScopeBuilder.scopeFor(createResolvedFunctionDeclaration(), lis
tener); |
| 22554 EngineTestCase.assertInstanceOf(LibraryScope, scope); |
| 22555 } |
| 22556 |
| 22557 void test_scopeFor_FunctionDeclaration_parameters() { |
| 22558 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22559 Scope scope = ScopeBuilder.scopeFor(createResolvedFunctionDeclaration().func
tionExpression.parameters, listener); |
| 22560 EngineTestCase.assertInstanceOf(FunctionScope, scope); |
| 22561 } |
| 22562 |
| 22563 void test_scopeFor_FunctionTypeAlias() { |
| 22564 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22565 Scope scope = ScopeBuilder.scopeFor(createResolvedFunctionTypeAlias(), liste
ner); |
| 22566 EngineTestCase.assertInstanceOf(LibraryScope, scope); |
| 22567 } |
| 22568 |
| 22569 void test_scopeFor_FunctionTypeAlias_parameters() { |
| 22570 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22571 Scope scope = ScopeBuilder.scopeFor(createResolvedFunctionTypeAlias().parame
ters, listener); |
| 22572 EngineTestCase.assertInstanceOf(FunctionTypeScope, scope); |
| 22573 } |
| 22574 |
| 22575 void test_scopeFor_MethodDeclaration() { |
| 22576 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22577 Scope scope = ScopeBuilder.scopeFor(createResolvedMethodDeclaration(), liste
ner); |
| 22578 EngineTestCase.assertInstanceOf(ClassScope, scope); |
| 22579 } |
| 22580 |
| 22581 void test_scopeFor_MethodDeclaration_body() { |
| 22582 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22583 Scope scope = ScopeBuilder.scopeFor(createResolvedMethodDeclaration().body,
listener); |
| 22584 EngineTestCase.assertInstanceOf(FunctionScope, scope); |
| 22585 } |
| 22586 |
| 22587 void test_scopeFor_notInCompilationUnit() { |
| 22588 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22589 try { |
| 22590 ScopeBuilder.scopeFor(ASTFactory.identifier3("x"), listener); |
| 22591 JUnitTestCase.fail("Expected AnalysisException"); |
| 22592 } on AnalysisException catch (exception) { |
| 22593 } |
| 22594 } |
| 22595 |
| 22596 void test_scopeFor_null() { |
| 22597 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22598 try { |
| 22599 ScopeBuilder.scopeFor(null, listener); |
| 22600 JUnitTestCase.fail("Expected AnalysisException"); |
| 22601 } on AnalysisException catch (exception) { |
| 22602 } |
| 22603 } |
| 22604 |
| 22605 void test_scopeFor_unresolved() { |
| 22606 GatheringErrorListener listener = new GatheringErrorListener(); |
| 22607 try { |
| 22608 ScopeBuilder.scopeFor(ASTFactory.compilationUnit(), listener); |
| 22609 JUnitTestCase.fail("Expected AnalysisException"); |
| 22610 } on AnalysisException catch (exception) { |
| 22611 } |
| 22612 } |
| 22613 |
| 22614 ClassDeclaration createResolvedClassDeclaration() { |
| 22615 CompilationUnit unit = createResolvedCompilationUnit(); |
| 22616 String className = "C"; |
| 22617 ClassDeclaration classNode = ASTFactory.classDeclaration(null, className, AS
TFactory.typeParameterList([]), null, null, null, []); |
| 22618 unit.declarations.add(classNode); |
| 22619 ClassElement classElement = ElementFactory.classElement2(className, []); |
| 22620 classNode.name.staticElement = classElement; |
| 22621 (unit.element as CompilationUnitElementImpl).types = <ClassElement> [classEl
ement]; |
| 22622 return classNode; |
| 22623 } |
| 22624 |
| 22625 ClassTypeAlias createResolvedClassTypeAlias() { |
| 22626 CompilationUnit unit = createResolvedCompilationUnit(); |
| 22627 String className = "C"; |
| 22628 ClassTypeAlias classNode = ASTFactory.classTypeAlias(className, ASTFactory.t
ypeParameterList([]), null, null, null, null); |
| 22629 unit.declarations.add(classNode); |
| 22630 ClassElement classElement = ElementFactory.classElement2(className, []); |
| 22631 classNode.name.staticElement = classElement; |
| 22632 (unit.element as CompilationUnitElementImpl).types = <ClassElement> [classEl
ement]; |
| 22633 return classNode; |
| 22634 } |
| 22635 |
| 22636 CompilationUnit createResolvedCompilationUnit() { |
| 22637 CompilationUnit unit = ASTFactory.compilationUnit(); |
| 22638 LibraryElementImpl library = ElementFactory.library(AnalysisContextFactory.c
ontextWithCore(), "lib"); |
| 22639 unit.element = library.definingCompilationUnit; |
| 22640 return unit; |
| 22641 } |
| 22642 |
| 22643 ConstructorDeclaration createResolvedConstructorDeclaration() { |
| 22644 ClassDeclaration classNode = createResolvedClassDeclaration(); |
| 22645 String constructorName = "f"; |
| 22646 ConstructorDeclaration constructorNode = ASTFactory.constructorDeclaration(A
STFactory.identifier3(constructorName), null, ASTFactory.formalParameterList([])
, null); |
| 22647 classNode.members.add(constructorNode); |
| 22648 ConstructorElement constructorElement = ElementFactory.constructorElement2(c
lassNode.element, null, []); |
| 22649 constructorNode.element = constructorElement; |
| 22650 (classNode.element as ClassElementImpl).constructors = <ConstructorElement>
[constructorElement]; |
| 22651 return constructorNode; |
| 22652 } |
| 22653 |
| 22654 FunctionDeclaration createResolvedFunctionDeclaration() { |
| 22655 CompilationUnit unit = createResolvedCompilationUnit(); |
| 22656 String functionName = "f"; |
| 22657 FunctionDeclaration functionNode = ASTFactory.functionDeclaration(null, null
, functionName, ASTFactory.functionExpression()); |
| 22658 unit.declarations.add(functionNode); |
| 22659 FunctionElement functionElement = ElementFactory.functionElement(functionNam
e); |
| 22660 functionNode.name.staticElement = functionElement; |
| 22661 (unit.element as CompilationUnitElementImpl).functions = <FunctionElement> [
functionElement]; |
| 22662 return functionNode; |
| 22663 } |
| 22664 |
| 22665 FunctionTypeAlias createResolvedFunctionTypeAlias() { |
| 22666 CompilationUnit unit = createResolvedCompilationUnit(); |
| 22667 FunctionTypeAlias aliasNode = ASTFactory.typeAlias(ASTFactory.typeName4("A",
[]), "F", ASTFactory.typeParameterList([]), ASTFactory.formalParameterList([]))
; |
| 22668 unit.declarations.add(aliasNode); |
| 22669 SimpleIdentifier aliasName = aliasNode.name; |
| 22670 FunctionTypeAliasElement aliasElement = new FunctionTypeAliasElementImpl(ali
asName); |
| 22671 aliasName.staticElement = aliasElement; |
| 22672 (unit.element as CompilationUnitElementImpl).typeAliases = <FunctionTypeAlia
sElement> [aliasElement]; |
| 22673 return aliasNode; |
| 22674 } |
| 22675 |
| 22676 MethodDeclaration createResolvedMethodDeclaration() { |
| 22677 ClassDeclaration classNode = createResolvedClassDeclaration(); |
| 22678 String methodName = "f"; |
| 22679 MethodDeclaration methodNode = ASTFactory.methodDeclaration(null, null, null
, null, ASTFactory.identifier3(methodName), ASTFactory.formalParameterList([])); |
| 22680 classNode.members.add(methodNode); |
| 22681 MethodElement methodElement = ElementFactory.methodElement(methodName, null,
[]); |
| 22682 methodNode.name.staticElement = methodElement; |
| 22683 (classNode.element as ClassElementImpl).methods = <MethodElement> [methodEle
ment]; |
| 22684 return methodNode; |
| 22685 } |
| 22686 |
| 22687 static dartSuite() { |
| 22688 _ut.group('ScopeBuilderTest', () { |
| 22689 _ut.test('test_scopeFor_ClassDeclaration', () { |
| 22690 final __test = new ScopeBuilderTest(); |
| 22691 runJUnitTest(__test, __test.test_scopeFor_ClassDeclaration); |
| 22692 }); |
| 22693 _ut.test('test_scopeFor_ClassTypeAlias', () { |
| 22694 final __test = new ScopeBuilderTest(); |
| 22695 runJUnitTest(__test, __test.test_scopeFor_ClassTypeAlias); |
| 22696 }); |
| 22697 _ut.test('test_scopeFor_CompilationUnit', () { |
| 22698 final __test = new ScopeBuilderTest(); |
| 22699 runJUnitTest(__test, __test.test_scopeFor_CompilationUnit); |
| 22700 }); |
| 22701 _ut.test('test_scopeFor_ConstructorDeclaration', () { |
| 22702 final __test = new ScopeBuilderTest(); |
| 22703 runJUnitTest(__test, __test.test_scopeFor_ConstructorDeclaration); |
| 22704 }); |
| 22705 _ut.test('test_scopeFor_ConstructorDeclaration_parameters', () { |
| 22706 final __test = new ScopeBuilderTest(); |
| 22707 runJUnitTest(__test, __test.test_scopeFor_ConstructorDeclaration_paramet
ers); |
| 22708 }); |
| 22709 _ut.test('test_scopeFor_FunctionDeclaration', () { |
| 22710 final __test = new ScopeBuilderTest(); |
| 22711 runJUnitTest(__test, __test.test_scopeFor_FunctionDeclaration); |
| 22712 }); |
| 22713 _ut.test('test_scopeFor_FunctionDeclaration_parameters', () { |
| 22714 final __test = new ScopeBuilderTest(); |
| 22715 runJUnitTest(__test, __test.test_scopeFor_FunctionDeclaration_parameters
); |
| 22716 }); |
| 22717 _ut.test('test_scopeFor_FunctionTypeAlias', () { |
| 22718 final __test = new ScopeBuilderTest(); |
| 22719 runJUnitTest(__test, __test.test_scopeFor_FunctionTypeAlias); |
| 22720 }); |
| 22721 _ut.test('test_scopeFor_FunctionTypeAlias_parameters', () { |
| 22722 final __test = new ScopeBuilderTest(); |
| 22723 runJUnitTest(__test, __test.test_scopeFor_FunctionTypeAlias_parameters); |
| 22724 }); |
| 22725 _ut.test('test_scopeFor_MethodDeclaration', () { |
| 22726 final __test = new ScopeBuilderTest(); |
| 22727 runJUnitTest(__test, __test.test_scopeFor_MethodDeclaration); |
| 22728 }); |
| 22729 _ut.test('test_scopeFor_MethodDeclaration_body', () { |
| 22730 final __test = new ScopeBuilderTest(); |
| 22731 runJUnitTest(__test, __test.test_scopeFor_MethodDeclaration_body); |
| 22732 }); |
| 22733 _ut.test('test_scopeFor_notInCompilationUnit', () { |
| 22734 final __test = new ScopeBuilderTest(); |
| 22735 runJUnitTest(__test, __test.test_scopeFor_notInCompilationUnit); |
| 22736 }); |
| 22737 _ut.test('test_scopeFor_null', () { |
| 22738 final __test = new ScopeBuilderTest(); |
| 22739 runJUnitTest(__test, __test.test_scopeFor_null); |
| 22740 }); |
| 22741 _ut.test('test_scopeFor_unresolved', () { |
| 22742 final __test = new ScopeBuilderTest(); |
| 22743 runJUnitTest(__test, __test.test_scopeFor_unresolved); |
| 22744 }); |
| 22745 }); |
| 22746 } |
| 22747 } |
| 22748 |
| 20340 main() { | 22749 main() { |
| 20341 // ElementResolverTest.dartSuite(); | 22750 DeclarationMatcherTest.dartSuite(); |
| 20342 // InheritanceManagerTest.dartSuite(); | 22751 ElementResolverTest.dartSuite(); |
| 20343 // LibraryElementBuilderTest.dartSuite(); | 22752 IncrementalResolverTest.dartSuite(); |
| 20344 // LibraryTest.dartSuite(); | 22753 InheritanceManagerTest.dartSuite(); |
| 20345 // StaticTypeAnalyzerTest.dartSuite(); | 22754 LibraryElementBuilderTest.dartSuite(); |
| 20346 // SubtypeManagerTest.dartSuite(); | 22755 LibraryTest.dartSuite(); |
| 20347 // TypeOverrideManagerTest.dartSuite(); | 22756 StaticTypeAnalyzerTest.dartSuite(); |
| 20348 // TypeProviderImplTest.dartSuite(); | 22757 SubtypeManagerTest.dartSuite(); |
| 20349 // TypeResolverVisitorTest.dartSuite(); | 22758 TypeOverrideManagerTest.dartSuite(); |
| 20350 // EnclosedScopeTest.dartSuite(); | 22759 TypeProviderImplTest.dartSuite(); |
| 20351 // LibraryImportScopeTest.dartSuite(); | 22760 TypeResolverVisitorTest.dartSuite(); |
| 20352 // LibraryScopeTest.dartSuite(); | 22761 EnclosedScopeTest.dartSuite(); |
| 20353 // ScopeTest.dartSuite(); | 22762 LibraryImportScopeTest.dartSuite(); |
| 20354 // CompileTimeErrorCodeTest.dartSuite(); | 22763 LibraryScopeTest.dartSuite(); |
| 20355 // ErrorResolverTest.dartSuite(); | 22764 ScopeBuilderTest.dartSuite(); |
| 20356 // HintCodeTest.dartSuite(); | 22765 ScopeTest.dartSuite(); |
| 20357 // MemberMapTest.dartSuite(); | 22766 CompileTimeErrorCodeTest.dartSuite(); |
| 20358 // NonHintCodeTest.dartSuite(); | 22767 ErrorResolverTest.dartSuite(); |
| 20359 // NonErrorResolverTest.dartSuite(); | 22768 HintCodeTest.dartSuite(); |
| 20360 // SimpleResolverTest.dartSuite(); | 22769 MemberMapTest.dartSuite(); |
| 20361 // StaticTypeWarningCodeTest.dartSuite(); | 22770 NonHintCodeTest.dartSuite(); |
| 20362 // StaticWarningCodeTest.dartSuite(); | 22771 NonErrorResolverTest.dartSuite(); |
| 20363 // StrictModeTest.dartSuite(); | 22772 SimpleResolverTest.dartSuite(); |
| 20364 // TypePropagationTest.dartSuite(); | 22773 StaticTypeWarningCodeTest.dartSuite(); |
| 22774 StaticWarningCodeTest.dartSuite(); |
| 22775 StrictModeTest.dartSuite(); |
| 22776 TypePropagationTest.dartSuite(); |
| 20365 } | 22777 } |
| OLD | NEW |