| 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 library engine.resolver_test; | 3 library engine.resolver_test; |
| 4 import 'package:analyzer_experimental/src/generated/java_core.dart'; | 4 import 'package:analyzer_experimental/src/generated/java_core.dart'; |
| 5 import 'package:analyzer_experimental/src/generated/java_junit.dart'; | 5 import 'package:analyzer_experimental/src/generated/java_junit.dart'; |
| 6 import 'package:analyzer_experimental/src/generated/source_io.dart'; | 6 import 'package:analyzer_experimental/src/generated/source_io.dart'; |
| 7 import 'package:analyzer_experimental/src/generated/error.dart'; | 7 import 'package:analyzer_experimental/src/generated/error.dart'; |
| 8 import 'package:analyzer_experimental/src/generated/scanner.dart'; | 8 import 'package:analyzer_experimental/src/generated/scanner.dart'; |
| 9 import 'package:analyzer_experimental/src/generated/ast.dart'; | 9 import 'package:analyzer_experimental/src/generated/ast.dart'; |
| 10 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro
rCode; | 10 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro
rCode; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class TypePropagationTest extends ResolverTestCase { | 21 class TypePropagationTest extends ResolverTestCase { |
| 22 void fail_functionExpression_asInvocationArgument_functionExpressionInvocation
() { | 22 void fail_functionExpression_asInvocationArgument_functionExpressionInvocation
() { |
| 23 String code = EngineTestCase.createSource([ | 23 String code = EngineTestCase.createSource([ |
| 24 "main() {", | 24 "main() {", |
| 25 " (f(String value)) {} ((v) {", | 25 " (f(String value)) {} ((v) {", |
| 26 " v;", | 26 " v;", |
| 27 " });", | 27 " });", |
| 28 "}"]); | 28 "}"]); |
| 29 Source source = addSource(code); | 29 Source source = addSource(code); |
| 30 LibraryElement library = resolve(source); | 30 LibraryElement library = resolve(source); |
| 31 assertNoErrors(); | 31 assertNoErrors(source); |
| 32 verify([source]); | 32 verify([source]); |
| 33 CompilationUnit unit = resolveCompilationUnit(source, library); | 33 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 34 Type2 dynamicType = typeProvider.dynamicType; | 34 Type2 dynamicType = typeProvider.dynamicType; |
| 35 Type2 stringType = typeProvider.stringType; | 35 Type2 stringType = typeProvider.stringType; |
| 36 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Forma
lParameter); | 36 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Forma
lParameter); |
| 37 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); | 37 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); |
| 38 JUnitTestCase.assertSame(dynamicType, vParameter.identifier.staticType); | 38 JUnitTestCase.assertSame(dynamicType, vParameter.identifier.staticType); |
| 39 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); | 39 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); |
| 40 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); | 40 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); |
| 41 JUnitTestCase.assertSame(dynamicType, vIdentifier.staticType); | 41 JUnitTestCase.assertSame(dynamicType, vIdentifier.staticType); |
| 42 } | 42 } |
| 43 void fail_propagatedReturnType_functionExpression() { | 43 void fail_propagatedReturnType_functionExpression() { |
| 44 String code = EngineTestCase.createSource(["main() {", " var v = (() {retur
n 42;})();", "}"]); | 44 String code = EngineTestCase.createSource(["main() {", " var v = (() {retur
n 42;})();", "}"]); |
| 45 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); | 45 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); |
| 46 } | 46 } |
| 47 void test_as() { | 47 void test_as() { |
| 48 Source source = addSource(EngineTestCase.createSource([ | 48 Source source = addSource(EngineTestCase.createSource([ |
| 49 "class A {", | 49 "class A {", |
| 50 " bool get g => true;", | 50 " bool get g => true;", |
| 51 "}", | 51 "}", |
| 52 "A f(var p) {", | 52 "A f(var p) {", |
| 53 " if ((p as A).g) {", | 53 " if ((p as A).g) {", |
| 54 " return p;", | 54 " return p;", |
| 55 " } else {", | 55 " } else {", |
| 56 " return null;", | 56 " return null;", |
| 57 " }", | 57 " }", |
| 58 "}"])); | 58 "}"])); |
| 59 LibraryElement library = resolve(source); | 59 LibraryElement library = resolve(source); |
| 60 assertNoErrors(); | 60 assertNoErrors(source); |
| 61 verify([source]); | 61 verify([source]); |
| 62 CompilationUnit unit = resolveCompilationUnit(source, library); | 62 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 63 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 63 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 64 InterfaceType typeA = classA.element.type; | 64 InterfaceType typeA = classA.element.type; |
| 65 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 65 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 66 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 66 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 67 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 67 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 68 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 68 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; |
| 69 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 69 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 70 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 70 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 71 } | 71 } |
| 72 void test_assert() { | 72 void test_assert() { |
| 73 Source source = addSource(EngineTestCase.createSource([ | 73 Source source = addSource(EngineTestCase.createSource([ |
| 74 "class A {}", | 74 "class A {}", |
| 75 "A f(var p) {", | 75 "A f(var p) {", |
| 76 " assert (p is A);", | 76 " assert (p is A);", |
| 77 " return p;", | 77 " return p;", |
| 78 "}"])); | 78 "}"])); |
| 79 LibraryElement library = resolve(source); | 79 LibraryElement library = resolve(source); |
| 80 assertNoErrors(); | 80 assertNoErrors(source); |
| 81 verify([source]); | 81 verify([source]); |
| 82 CompilationUnit unit = resolveCompilationUnit(source, library); | 82 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 83 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 83 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 84 InterfaceType typeA = classA.element.type; | 84 InterfaceType typeA = classA.element.type; |
| 85 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 85 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 86 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 86 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 87 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 87 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 88 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 88 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 89 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 89 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 90 } | 90 } |
| 91 void test_assignment() { | 91 void test_assignment() { |
| 92 Source source = addSource(EngineTestCase.createSource(["f() {", " var v;",
" v = 0;", " return v;", "}"])); | 92 Source source = addSource(EngineTestCase.createSource(["f() {", " var v;",
" v = 0;", " return v;", "}"])); |
| 93 LibraryElement library = resolve(source); | 93 LibraryElement library = resolve(source); |
| 94 assertNoErrors(); | 94 assertNoErrors(source); |
| 95 verify([source]); | 95 verify([source]); |
| 96 CompilationUnit unit = resolveCompilationUnit(source, library); | 96 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 97 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 97 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 98 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 98 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 99 ReturnStatement statement = body.block.statements[2] as ReturnStatement; | 99 ReturnStatement statement = body.block.statements[2] as ReturnStatement; |
| 100 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 100 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 101 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType); | 101 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType); |
| 102 } | 102 } |
| 103 void test_assignment_afterInitializer() { | 103 void test_assignment_afterInitializer() { |
| 104 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " v = 1.0;", " return v;", "}"])); | 104 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " v = 1.0;", " return v;", "}"])); |
| 105 LibraryElement library = resolve(source); | 105 LibraryElement library = resolve(source); |
| 106 assertNoErrors(); | 106 assertNoErrors(source); |
| 107 verify([source]); | 107 verify([source]); |
| 108 CompilationUnit unit = resolveCompilationUnit(source, library); | 108 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 109 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 109 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 110 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 110 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 111 ReturnStatement statement = body.block.statements[2] as ReturnStatement; | 111 ReturnStatement statement = body.block.statements[2] as ReturnStatement; |
| 112 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 112 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 113 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.propagatedTyp
e); | 113 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.propagatedTyp
e); |
| 114 } | 114 } |
| 115 void test_forEach() { | 115 void test_forEach() { |
| 116 String code = EngineTestCase.createSource([ | 116 String code = EngineTestCase.createSource([ |
| 117 "f(List<String> p) {", | 117 "f(List<String> p) {", |
| 118 " for (var e in p) {", | 118 " for (var e in p) {", |
| 119 " e;", | 119 " e;", |
| 120 " }", | 120 " }", |
| 121 "}"]); | 121 "}"]); |
| 122 Source source = addSource(code); | 122 Source source = addSource(code); |
| 123 LibraryElement library = resolve(source); | 123 LibraryElement library = resolve(source); |
| 124 assertNoErrors(); | 124 assertNoErrors(source); |
| 125 verify([source]); | 125 verify([source]); |
| 126 CompilationUnit unit = resolveCompilationUnit(source, library); | 126 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 127 InterfaceType stringType = typeProvider.stringType; | 127 InterfaceType stringType = typeProvider.stringType; |
| 128 { | 128 { |
| 129 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e in",
SimpleIdentifier); | 129 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e in",
SimpleIdentifier); |
| 130 JUnitTestCase.assertSame(stringType, identifier.propagatedType); | 130 JUnitTestCase.assertSame(stringType, identifier.propagatedType); |
| 131 } | 131 } |
| 132 { | 132 { |
| 133 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e;", Si
mpleIdentifier); | 133 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e;", Si
mpleIdentifier); |
| 134 JUnitTestCase.assertSame(stringType, identifier.propagatedType); | 134 JUnitTestCase.assertSame(stringType, identifier.propagatedType); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 void test_functionExpression_asInvocationArgument() { | 137 void test_functionExpression_asInvocationArgument() { |
| 138 String code = EngineTestCase.createSource([ | 138 String code = EngineTestCase.createSource([ |
| 139 "class MyMap<K, V> {", | 139 "class MyMap<K, V> {", |
| 140 " forEach(f(K key, V value)) {}", | 140 " forEach(f(K key, V value)) {}", |
| 141 "}", | 141 "}", |
| 142 "f(MyMap<int, String> m) {", | 142 "f(MyMap<int, String> m) {", |
| 143 " m.forEach((k, v) {", | 143 " m.forEach((k, v) {", |
| 144 " k;", | 144 " k;", |
| 145 " v;", | 145 " v;", |
| 146 " });", | 146 " });", |
| 147 "}"]); | 147 "}"]); |
| 148 Source source = addSource(code); | 148 Source source = addSource(code); |
| 149 LibraryElement library = resolve(source); | 149 LibraryElement library = resolve(source); |
| 150 assertNoErrors(); | 150 assertNoErrors(source); |
| 151 verify([source]); | 151 verify([source]); |
| 152 CompilationUnit unit = resolveCompilationUnit(source, library); | 152 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 153 Type2 intType = typeProvider.intType; | 153 Type2 intType = typeProvider.intType; |
| 154 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp
leFormalParameter); | 154 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp
leFormalParameter); |
| 155 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType); | 155 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType); |
| 156 SimpleIdentifier kIdentifier = EngineTestCase.findNode(unit, code, "k;", Sim
pleIdentifier); | 156 SimpleIdentifier kIdentifier = EngineTestCase.findNode(unit, code, "k;", Sim
pleIdentifier); |
| 157 JUnitTestCase.assertSame(intType, kIdentifier.propagatedType); | 157 JUnitTestCase.assertSame(intType, kIdentifier.propagatedType); |
| 158 JUnitTestCase.assertSame(typeProvider.dynamicType, kIdentifier.staticType); | 158 JUnitTestCase.assertSame(typeProvider.dynamicType, kIdentifier.staticType); |
| 159 Type2 stringType = typeProvider.stringType; | 159 Type2 stringType = typeProvider.stringType; |
| 160 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); | 160 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); |
| 161 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); | 161 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); |
| 162 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); | 162 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); |
| 163 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); | 163 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); |
| 164 JUnitTestCase.assertSame(typeProvider.dynamicType, vIdentifier.staticType); | 164 JUnitTestCase.assertSame(typeProvider.dynamicType, vIdentifier.staticType); |
| 165 } | 165 } |
| 166 void test_functionExpression_asInvocationArgument_fromInferredInvocation() { | 166 void test_functionExpression_asInvocationArgument_fromInferredInvocation() { |
| 167 String code = EngineTestCase.createSource([ | 167 String code = EngineTestCase.createSource([ |
| 168 "class MyMap<K, V> {", | 168 "class MyMap<K, V> {", |
| 169 " forEach(f(K key, V value)) {}", | 169 " forEach(f(K key, V value)) {}", |
| 170 "}", | 170 "}", |
| 171 "f(MyMap<int, String> m) {", | 171 "f(MyMap<int, String> m) {", |
| 172 " var m2 = m;", | 172 " var m2 = m;", |
| 173 " m2.forEach((k, v) {});", | 173 " m2.forEach((k, v) {});", |
| 174 "}"]); | 174 "}"]); |
| 175 Source source = addSource(code); | 175 Source source = addSource(code); |
| 176 LibraryElement library = resolve(source); | 176 LibraryElement library = resolve(source); |
| 177 assertNoErrors(); | 177 assertNoErrors(source); |
| 178 verify([source]); | 178 verify([source]); |
| 179 CompilationUnit unit = resolveCompilationUnit(source, library); | 179 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 180 Type2 intType = typeProvider.intType; | 180 Type2 intType = typeProvider.intType; |
| 181 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp
leFormalParameter); | 181 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp
leFormalParameter); |
| 182 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType); | 182 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType); |
| 183 Type2 stringType = typeProvider.stringType; | 183 Type2 stringType = typeProvider.stringType; |
| 184 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); | 184 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); |
| 185 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); | 185 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); |
| 186 } | 186 } |
| 187 void test_functionExpression_asInvocationArgument_keepIfLessSpecific() { | 187 void test_functionExpression_asInvocationArgument_keepIfLessSpecific() { |
| 188 String code = EngineTestCase.createSource([ | 188 String code = EngineTestCase.createSource([ |
| 189 "class MyList {", | 189 "class MyList {", |
| 190 " forEach(f(Object value)) {}", | 190 " forEach(f(Object value)) {}", |
| 191 "}", | 191 "}", |
| 192 "f(MyList list) {", | 192 "f(MyList list) {", |
| 193 " list.forEach((int v) {", | 193 " list.forEach((int v) {", |
| 194 " v;", | 194 " v;", |
| 195 " });", | 195 " });", |
| 196 "}"]); | 196 "}"]); |
| 197 Source source = addSource(code); | 197 Source source = addSource(code); |
| 198 LibraryElement library = resolve(source); | 198 LibraryElement library = resolve(source); |
| 199 assertNoErrors(); | 199 assertNoErrors(source); |
| 200 verify([source]); | 200 verify([source]); |
| 201 CompilationUnit unit = resolveCompilationUnit(source, library); | 201 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 202 Type2 intType = typeProvider.intType; | 202 Type2 intType = typeProvider.intType; |
| 203 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); | 203 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); |
| 204 JUnitTestCase.assertSame(null, vParameter.identifier.propagatedType); | 204 JUnitTestCase.assertSame(null, vParameter.identifier.propagatedType); |
| 205 JUnitTestCase.assertSame(intType, vParameter.identifier.staticType); | 205 JUnitTestCase.assertSame(intType, vParameter.identifier.staticType); |
| 206 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); | 206 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); |
| 207 JUnitTestCase.assertSame(intType, vIdentifier.staticType); | 207 JUnitTestCase.assertSame(intType, vIdentifier.staticType); |
| 208 JUnitTestCase.assertSame(null, vIdentifier.propagatedType); | 208 JUnitTestCase.assertSame(null, vIdentifier.propagatedType); |
| 209 } | 209 } |
| 210 void test_functionExpression_asInvocationArgument_replaceIfMoreSpecific() { | 210 void test_functionExpression_asInvocationArgument_replaceIfMoreSpecific() { |
| 211 String code = EngineTestCase.createSource([ | 211 String code = EngineTestCase.createSource([ |
| 212 "class MyList<E> {", | 212 "class MyList<E> {", |
| 213 " forEach(f(E value)) {}", | 213 " forEach(f(E value)) {}", |
| 214 "}", | 214 "}", |
| 215 "f(MyList<String> list) {", | 215 "f(MyList<String> list) {", |
| 216 " list.forEach((Object v) {", | 216 " list.forEach((Object v) {", |
| 217 " v;", | 217 " v;", |
| 218 " });", | 218 " });", |
| 219 "}"]); | 219 "}"]); |
| 220 Source source = addSource(code); | 220 Source source = addSource(code); |
| 221 LibraryElement library = resolve(source); | 221 LibraryElement library = resolve(source); |
| 222 assertNoErrors(); | 222 assertNoErrors(source); |
| 223 verify([source]); | 223 verify([source]); |
| 224 CompilationUnit unit = resolveCompilationUnit(source, library); | 224 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 225 Type2 stringType = typeProvider.stringType; | 225 Type2 stringType = typeProvider.stringType; |
| 226 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); | 226 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl
eFormalParameter); |
| 227 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); | 227 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType); |
| 228 JUnitTestCase.assertSame(typeProvider.objectType, vParameter.identifier.stat
icType); | 228 JUnitTestCase.assertSame(typeProvider.objectType, vParameter.identifier.stat
icType); |
| 229 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); | 229 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim
pleIdentifier); |
| 230 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); | 230 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType); |
| 231 } | 231 } |
| 232 void test_Future_then() { | 232 void test_Future_then() { |
| 233 String code = EngineTestCase.createSource([ | 233 String code = EngineTestCase.createSource([ |
| 234 "import 'dart:async';", | 234 "import 'dart:async';", |
| 235 "main(Future<int> firstFuture) {", | 235 "main(Future<int> firstFuture) {", |
| 236 " firstFuture.then((p1) {", | 236 " firstFuture.then((p1) {", |
| 237 " return 1.0;", | 237 " return 1.0;", |
| 238 " }).then((p2) {", | 238 " }).then((p2) {", |
| 239 " return new Future<String>.value('str');", | 239 " return new Future<String>.value('str');", |
| 240 " }).then((p3) {", | 240 " }).then((p3) {", |
| 241 " });", | 241 " });", |
| 242 "}"]); | 242 "}"]); |
| 243 Source source = addSource(code); | 243 Source source = addSource(code); |
| 244 LibraryElement library = resolve(source); | 244 LibraryElement library = resolve(source); |
| 245 assertNoErrors(); | 245 assertNoErrors(source); |
| 246 verify([source]); | 246 verify([source]); |
| 247 CompilationUnit unit = resolveCompilationUnit(source, library); | 247 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 248 FormalParameter p1 = EngineTestCase.findNode(unit, code, "p1) {", SimpleForm
alParameter); | 248 FormalParameter p1 = EngineTestCase.findNode(unit, code, "p1) {", SimpleForm
alParameter); |
| 249 JUnitTestCase.assertSame(typeProvider.intType, p1.identifier.propagatedType)
; | 249 JUnitTestCase.assertSame(typeProvider.intType, p1.identifier.propagatedType)
; |
| 250 FormalParameter p2 = EngineTestCase.findNode(unit, code, "p2) {", SimpleForm
alParameter); | 250 FormalParameter p2 = EngineTestCase.findNode(unit, code, "p2) {", SimpleForm
alParameter); |
| 251 JUnitTestCase.assertSame(typeProvider.doubleType, p2.identifier.propagatedTy
pe); | 251 JUnitTestCase.assertSame(typeProvider.doubleType, p2.identifier.propagatedTy
pe); |
| 252 FormalParameter p3 = EngineTestCase.findNode(unit, code, "p3) {", SimpleForm
alParameter); | 252 FormalParameter p3 = EngineTestCase.findNode(unit, code, "p3) {", SimpleForm
alParameter); |
| 253 JUnitTestCase.assertSame(typeProvider.stringType, p3.identifier.propagatedTy
pe); | 253 JUnitTestCase.assertSame(typeProvider.stringType, p3.identifier.propagatedTy
pe); |
| 254 } | 254 } |
| 255 void test_initializer() { | 255 void test_initializer() { |
| 256 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " return v;", "}"])); | 256 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0
;", " return v;", "}"])); |
| 257 LibraryElement library = resolve(source); | 257 LibraryElement library = resolve(source); |
| 258 assertNoErrors(); | 258 assertNoErrors(source); |
| 259 verify([source]); | 259 verify([source]); |
| 260 CompilationUnit unit = resolveCompilationUnit(source, library); | 260 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 261 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 261 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 262 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 262 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 263 NodeList<Statement> statements = body.block.statements; | 263 NodeList<Statement> statements = body.block.statements; |
| 264 { | 264 { |
| 265 VariableDeclarationStatement statement = statements[0] as VariableDeclarat
ionStatement; | 265 VariableDeclarationStatement statement = statements[0] as VariableDeclarat
ionStatement; |
| 266 SimpleIdentifier variableName = statement.variables.variables[0].name; | 266 SimpleIdentifier variableName = statement.variables.variables[0].name; |
| 267 JUnitTestCase.assertSame(typeProvider.dynamicType, variableName.staticType
); | 267 JUnitTestCase.assertSame(typeProvider.dynamicType, variableName.staticType
); |
| 268 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType
); | 268 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType
); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 284 SimpleIdentifier variableName = invocation.prefix; | 284 SimpleIdentifier variableName = invocation.prefix; |
| 285 JUnitTestCase.assertSame(typeProvider.stringType, variableName.propagatedTyp
e); | 285 JUnitTestCase.assertSame(typeProvider.stringType, variableName.propagatedTyp
e); |
| 286 } | 286 } |
| 287 void test_is_conditional() { | 287 void test_is_conditional() { |
| 288 Source source = addSource(EngineTestCase.createSource([ | 288 Source source = addSource(EngineTestCase.createSource([ |
| 289 "class A {}", | 289 "class A {}", |
| 290 "A f(var p) {", | 290 "A f(var p) {", |
| 291 " return (p is A) ? p : null;", | 291 " return (p is A) ? p : null;", |
| 292 "}"])); | 292 "}"])); |
| 293 LibraryElement library = resolve(source); | 293 LibraryElement library = resolve(source); |
| 294 assertNoErrors(); | 294 assertNoErrors(source); |
| 295 verify([source]); | 295 verify([source]); |
| 296 CompilationUnit unit = resolveCompilationUnit(source, library); | 296 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 297 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 297 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 298 InterfaceType typeA = classA.element.type; | 298 InterfaceType typeA = classA.element.type; |
| 299 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 299 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 300 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 300 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 301 ReturnStatement statement = body.block.statements[0] as ReturnStatement; | 301 ReturnStatement statement = body.block.statements[0] as ReturnStatement; |
| 302 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; | 302 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; |
| 303 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi
er; | 303 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi
er; |
| 304 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 304 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 305 } | 305 } |
| 306 void test_is_if() { | 306 void test_is_if() { |
| 307 Source source = addSource(EngineTestCase.createSource([ | 307 Source source = addSource(EngineTestCase.createSource([ |
| 308 "class A {}", | 308 "class A {}", |
| 309 "A f(var p) {", | 309 "A f(var p) {", |
| 310 " if (p is A) {", | 310 " if (p is A) {", |
| 311 " return p;", | 311 " return p;", |
| 312 " } else {", | 312 " } else {", |
| 313 " return null;", | 313 " return null;", |
| 314 " }", | 314 " }", |
| 315 "}"])); | 315 "}"])); |
| 316 LibraryElement library = resolve(source); | 316 LibraryElement library = resolve(source); |
| 317 assertNoErrors(); | 317 assertNoErrors(source); |
| 318 verify([source]); | 318 verify([source]); |
| 319 CompilationUnit unit = resolveCompilationUnit(source, library); | 319 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 320 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 320 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 321 InterfaceType typeA = classA.element.type; | 321 InterfaceType typeA = classA.element.type; |
| 322 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 322 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 323 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 323 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 324 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 324 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 325 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 325 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; |
| 326 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 326 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 327 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 327 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 328 } | 328 } |
| 329 void test_is_if_lessSpecific() { | 329 void test_is_if_lessSpecific() { |
| 330 Source source = addSource(EngineTestCase.createSource([ | 330 Source source = addSource(EngineTestCase.createSource([ |
| 331 "class A {}", | 331 "class A {}", |
| 332 "A f(A p) {", | 332 "A f(A p) {", |
| 333 " if (p is Object) {", | 333 " if (p is String) {", |
| 334 " return p;", | 334 " return p;", |
| 335 " } else {", | 335 " } else {", |
| 336 " return null;", | 336 " return null;", |
| 337 " }", | 337 " }", |
| 338 "}"])); | 338 "}"])); |
| 339 LibraryElement library = resolve(source); | 339 LibraryElement library = resolve(source); |
| 340 assertNoErrors(); | 340 assertNoErrors(source); |
| 341 verify([source]); | 341 verify([source]); |
| 342 CompilationUnit unit = resolveCompilationUnit(source, library); | 342 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 343 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 343 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 344 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 344 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 345 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 345 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 346 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 346 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; |
| 347 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 347 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 348 JUnitTestCase.assertSame(null, variableName.propagatedType); | 348 JUnitTestCase.assertSame(null, variableName.propagatedType); |
| 349 } | 349 } |
| 350 void test_is_if_logicalAnd() { | 350 void test_is_if_logicalAnd() { |
| 351 Source source = addSource(EngineTestCase.createSource([ | 351 Source source = addSource(EngineTestCase.createSource([ |
| 352 "class A {}", | 352 "class A {}", |
| 353 "A f(var p) {", | 353 "A f(var p) {", |
| 354 " if (p is A && p != null) {", | 354 " if (p is A && p != null) {", |
| 355 " return p;", | 355 " return p;", |
| 356 " } else {", | 356 " } else {", |
| 357 " return null;", | 357 " return null;", |
| 358 " }", | 358 " }", |
| 359 "}"])); | 359 "}"])); |
| 360 LibraryElement library = resolve(source); | 360 LibraryElement library = resolve(source); |
| 361 assertNoErrors(); | 361 assertNoErrors(source); |
| 362 verify([source]); | 362 verify([source]); |
| 363 CompilationUnit unit = resolveCompilationUnit(source, library); | 363 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 364 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 364 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 365 InterfaceType typeA = classA.element.type; | 365 InterfaceType typeA = classA.element.type; |
| 366 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 366 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 367 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 367 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 368 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 368 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 369 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 369 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; |
| 370 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 370 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 371 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 371 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 372 } | 372 } |
| 373 void test_is_postConditional() { | 373 void test_is_postConditional() { |
| 374 Source source = addSource(EngineTestCase.createSource([ | 374 Source source = addSource(EngineTestCase.createSource([ |
| 375 "class A {}", | 375 "class A {}", |
| 376 "A f(var p) {", | 376 "A f(var p) {", |
| 377 " A a = (p is A) ? p : throw null;", | 377 " A a = (p is A) ? p : throw null;", |
| 378 " return p;", | 378 " return p;", |
| 379 "}"])); | 379 "}"])); |
| 380 LibraryElement library = resolve(source); | 380 LibraryElement library = resolve(source); |
| 381 assertNoErrors(); | 381 assertNoErrors(source); |
| 382 verify([source]); | 382 verify([source]); |
| 383 CompilationUnit unit = resolveCompilationUnit(source, library); | 383 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 384 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 384 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 385 InterfaceType typeA = classA.element.type; | 385 InterfaceType typeA = classA.element.type; |
| 386 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 386 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 387 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 387 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 388 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 388 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 389 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 389 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 390 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 390 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 391 } | 391 } |
| 392 void test_is_postIf() { | 392 void test_is_postIf() { |
| 393 Source source = addSource(EngineTestCase.createSource([ | 393 Source source = addSource(EngineTestCase.createSource([ |
| 394 "class A {}", | 394 "class A {}", |
| 395 "A f(var p) {", | 395 "A f(var p) {", |
| 396 " if (p is A) {", | 396 " if (p is A) {", |
| 397 " A a = p;", | 397 " A a = p;", |
| 398 " } else {", | 398 " } else {", |
| 399 " return null;", | 399 " return null;", |
| 400 " }", | 400 " }", |
| 401 " return p;", | 401 " return p;", |
| 402 "}"])); | 402 "}"])); |
| 403 LibraryElement library = resolve(source); | 403 LibraryElement library = resolve(source); |
| 404 assertNoErrors(); | 404 assertNoErrors(source); |
| 405 verify([source]); | 405 verify([source]); |
| 406 CompilationUnit unit = resolveCompilationUnit(source, library); | 406 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 407 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 407 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 408 InterfaceType typeA = classA.element.type; | 408 InterfaceType typeA = classA.element.type; |
| 409 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 409 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 410 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 410 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 411 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 411 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 412 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 412 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 413 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 413 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 414 } | 414 } |
| 415 void test_is_subclass() { | 415 void test_is_subclass() { |
| 416 Source source = addSource(EngineTestCase.createSource([ | 416 Source source = addSource(EngineTestCase.createSource([ |
| 417 "class A {}", | 417 "class A {}", |
| 418 "class B extends A {", | 418 "class B extends A {", |
| 419 " B m() => this;", | 419 " B m() => this;", |
| 420 "}", | 420 "}", |
| 421 "A f(A p) {", | 421 "A f(A p) {", |
| 422 " if (p is B) {", | 422 " if (p is B) {", |
| 423 " return p.m();", | 423 " return p.m();", |
| 424 " }", | 424 " }", |
| 425 "}"])); | 425 "}"])); |
| 426 LibraryElement library = resolve(source); | 426 LibraryElement library = resolve(source); |
| 427 assertErrors([StaticTypeWarningCode.UNDEFINED_METHOD]); | 427 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); |
| 428 CompilationUnit unit = resolveCompilationUnit(source, library); | 428 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 429 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration; | 429 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration; |
| 430 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 430 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 431 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 431 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 432 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; | 432 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement
s[0] as ReturnStatement; |
| 433 MethodInvocation invocation = statement.expression as MethodInvocation; | 433 MethodInvocation invocation = statement.expression as MethodInvocation; |
| 434 JUnitTestCase.assertNotNull(invocation.methodName.propagatedElement); | 434 JUnitTestCase.assertNotNull(invocation.methodName.propagatedElement); |
| 435 } | 435 } |
| 436 void test_is_while() { | 436 void test_is_while() { |
| 437 Source source = addSource(EngineTestCase.createSource([ | 437 Source source = addSource(EngineTestCase.createSource([ |
| 438 "class A {}", | 438 "class A {}", |
| 439 "A f(var p) {", | 439 "A f(var p) {", |
| 440 " while (p is A) {", | 440 " while (p is A) {", |
| 441 " return p;", | 441 " return p;", |
| 442 " }", | 442 " }", |
| 443 "}"])); | 443 "}"])); |
| 444 LibraryElement library = resolve(source); | 444 LibraryElement library = resolve(source); |
| 445 assertNoErrors(); | 445 assertNoErrors(source); |
| 446 verify([source]); | 446 verify([source]); |
| 447 CompilationUnit unit = resolveCompilationUnit(source, library); | 447 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 448 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 448 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 449 InterfaceType typeA = classA.element.type; | 449 InterfaceType typeA = classA.element.type; |
| 450 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 450 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 451 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 451 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 452 WhileStatement whileStatement = body.block.statements[0] as WhileStatement; | 452 WhileStatement whileStatement = body.block.statements[0] as WhileStatement; |
| 453 ReturnStatement statement = ((whileStatement.body as Block)).statements[0] a
s ReturnStatement; | 453 ReturnStatement statement = ((whileStatement.body as Block)).statements[0] a
s ReturnStatement; |
| 454 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 454 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 455 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 455 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 456 } | 456 } |
| 457 void test_isNot_conditional() { | 457 void test_isNot_conditional() { |
| 458 Source source = addSource(EngineTestCase.createSource([ | 458 Source source = addSource(EngineTestCase.createSource([ |
| 459 "class A {}", | 459 "class A {}", |
| 460 "A f(var p) {", | 460 "A f(var p) {", |
| 461 " return (p is! A) ? null : p;", | 461 " return (p is! A) ? null : p;", |
| 462 "}"])); | 462 "}"])); |
| 463 LibraryElement library = resolve(source); | 463 LibraryElement library = resolve(source); |
| 464 assertNoErrors(); | 464 assertNoErrors(source); |
| 465 verify([source]); | 465 verify([source]); |
| 466 CompilationUnit unit = resolveCompilationUnit(source, library); | 466 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 467 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 467 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 468 InterfaceType typeA = classA.element.type; | 468 InterfaceType typeA = classA.element.type; |
| 469 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 469 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 470 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 470 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 471 ReturnStatement statement = body.block.statements[0] as ReturnStatement; | 471 ReturnStatement statement = body.block.statements[0] as ReturnStatement; |
| 472 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; | 472 ConditionalExpression conditional = statement.expression as ConditionalExpre
ssion; |
| 473 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi
er; | 473 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi
er; |
| 474 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 474 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 475 } | 475 } |
| 476 void test_isNot_if() { | 476 void test_isNot_if() { |
| 477 Source source = addSource(EngineTestCase.createSource([ | 477 Source source = addSource(EngineTestCase.createSource([ |
| 478 "class A {}", | 478 "class A {}", |
| 479 "A f(var p) {", | 479 "A f(var p) {", |
| 480 " if (p is! A) {", | 480 " if (p is! A) {", |
| 481 " return null;", | 481 " return null;", |
| 482 " } else {", | 482 " } else {", |
| 483 " return p;", | 483 " return p;", |
| 484 " }", | 484 " }", |
| 485 "}"])); | 485 "}"])); |
| 486 LibraryElement library = resolve(source); | 486 LibraryElement library = resolve(source); |
| 487 assertNoErrors(); | 487 assertNoErrors(source); |
| 488 verify([source]); | 488 verify([source]); |
| 489 CompilationUnit unit = resolveCompilationUnit(source, library); | 489 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 490 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 490 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 491 InterfaceType typeA = classA.element.type; | 491 InterfaceType typeA = classA.element.type; |
| 492 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 492 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 493 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 493 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 494 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 494 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 495 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement
s[0] as ReturnStatement; | 495 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement
s[0] as ReturnStatement; |
| 496 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 496 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 497 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 497 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 498 } | 498 } |
| 499 void test_isNot_if_logicalOr() { | 499 void test_isNot_if_logicalOr() { |
| 500 Source source = addSource(EngineTestCase.createSource([ | 500 Source source = addSource(EngineTestCase.createSource([ |
| 501 "class A {}", | 501 "class A {}", |
| 502 "A f(var p) {", | 502 "A f(var p) {", |
| 503 " if (p is! A || null == p) {", | 503 " if (p is! A || null == p) {", |
| 504 " return null;", | 504 " return null;", |
| 505 " } else {", | 505 " } else {", |
| 506 " return p;", | 506 " return p;", |
| 507 " }", | 507 " }", |
| 508 "}"])); | 508 "}"])); |
| 509 LibraryElement library = resolve(source); | 509 LibraryElement library = resolve(source); |
| 510 assertNoErrors(); | 510 assertNoErrors(source); |
| 511 verify([source]); | 511 verify([source]); |
| 512 CompilationUnit unit = resolveCompilationUnit(source, library); | 512 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 513 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 513 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 514 InterfaceType typeA = classA.element.type; | 514 InterfaceType typeA = classA.element.type; |
| 515 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 515 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 516 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 516 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 517 IfStatement ifStatement = body.block.statements[0] as IfStatement; | 517 IfStatement ifStatement = body.block.statements[0] as IfStatement; |
| 518 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement
s[0] as ReturnStatement; | 518 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement
s[0] as ReturnStatement; |
| 519 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 519 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 520 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 520 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 521 } | 521 } |
| 522 void test_isNot_postConditional() { | 522 void test_isNot_postConditional() { |
| 523 Source source = addSource(EngineTestCase.createSource([ | 523 Source source = addSource(EngineTestCase.createSource([ |
| 524 "class A {}", | 524 "class A {}", |
| 525 "A f(var p) {", | 525 "A f(var p) {", |
| 526 " A a = (p is! A) ? throw null : p;", | 526 " A a = (p is! A) ? throw null : p;", |
| 527 " return p;", | 527 " return p;", |
| 528 "}"])); | 528 "}"])); |
| 529 LibraryElement library = resolve(source); | 529 LibraryElement library = resolve(source); |
| 530 assertNoErrors(); | 530 assertNoErrors(source); |
| 531 verify([source]); | 531 verify([source]); |
| 532 CompilationUnit unit = resolveCompilationUnit(source, library); | 532 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 533 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 533 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 534 InterfaceType typeA = classA.element.type; | 534 InterfaceType typeA = classA.element.type; |
| 535 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 535 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 536 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 536 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 537 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 537 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 538 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 538 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 539 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 539 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 540 } | 540 } |
| 541 void test_isNot_postIf() { | 541 void test_isNot_postIf() { |
| 542 Source source = addSource(EngineTestCase.createSource([ | 542 Source source = addSource(EngineTestCase.createSource([ |
| 543 "class A {}", | 543 "class A {}", |
| 544 "A f(var p) {", | 544 "A f(var p) {", |
| 545 " if (p is! A) {", | 545 " if (p is! A) {", |
| 546 " return null;", | 546 " return null;", |
| 547 " }", | 547 " }", |
| 548 " return p;", | 548 " return p;", |
| 549 "}"])); | 549 "}"])); |
| 550 LibraryElement library = resolve(source); | 550 LibraryElement library = resolve(source); |
| 551 assertNoErrors(); | 551 assertNoErrors(source); |
| 552 verify([source]); | 552 verify([source]); |
| 553 CompilationUnit unit = resolveCompilationUnit(source, library); | 553 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 554 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; | 554 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; |
| 555 InterfaceType typeA = classA.element.type; | 555 InterfaceType typeA = classA.element.type; |
| 556 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; | 556 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; |
| 557 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 557 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 558 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 558 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 559 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; | 559 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 560 JUnitTestCase.assertSame(typeA, variableName.propagatedType); | 560 JUnitTestCase.assertSame(typeA, variableName.propagatedType); |
| 561 } | 561 } |
| 562 void test_listLiteral_different() { | 562 void test_listLiteral_different() { |
| 563 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, '1', 2];", " return v[2];", "}"])); | 563 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, '1', 2];", " return v[2];", "}"])); |
| 564 LibraryElement library = resolve(source); | 564 LibraryElement library = resolve(source); |
| 565 assertNoErrors(); | 565 assertNoErrors(source); |
| 566 verify([source]); | 566 verify([source]); |
| 567 CompilationUnit unit = resolveCompilationUnit(source, library); | 567 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 568 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 568 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 569 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 569 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 570 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 570 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 571 IndexExpression indexExpression = statement.expression as IndexExpression; | 571 IndexExpression indexExpression = statement.expression as IndexExpression; |
| 572 JUnitTestCase.assertNull(indexExpression.propagatedType); | 572 JUnitTestCase.assertNull(indexExpression.propagatedType); |
| 573 } | 573 } |
| 574 void test_listLiteral_same() { | 574 void test_listLiteral_same() { |
| 575 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, 1, 2];", " return v[2];", "}"])); | 575 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [
0, 1, 2];", " return v[2];", "}"])); |
| 576 LibraryElement library = resolve(source); | 576 LibraryElement library = resolve(source); |
| 577 assertNoErrors(); | 577 assertNoErrors(source); |
| 578 verify([source]); | 578 verify([source]); |
| 579 CompilationUnit unit = resolveCompilationUnit(source, library); | 579 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 580 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 580 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 581 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 581 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 582 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 582 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 583 IndexExpression indexExpression = statement.expression as IndexExpression; | 583 IndexExpression indexExpression = statement.expression as IndexExpression; |
| 584 JUnitTestCase.assertSame(typeProvider.intType, indexExpression.propagatedTyp
e); | 584 JUnitTestCase.assertSame(typeProvider.intType, indexExpression.propagatedTyp
e); |
| 585 } | 585 } |
| 586 void test_mapLiteral_different() { | 586 void test_mapLiteral_different() { |
| 587 Source source = addSource(EngineTestCase.createSource([ | 587 Source source = addSource(EngineTestCase.createSource([ |
| 588 "f() {", | 588 "f() {", |
| 589 " var v = {'0' : 0, 1 : '1', '2' : 2};", | 589 " var v = {'0' : 0, 1 : '1', '2' : 2};", |
| 590 " return v;", | 590 " return v;", |
| 591 "}"])); | 591 "}"])); |
| 592 LibraryElement library = resolve(source); | 592 LibraryElement library = resolve(source); |
| 593 assertNoErrors(); | 593 assertNoErrors(source); |
| 594 verify([source]); | 594 verify([source]); |
| 595 CompilationUnit unit = resolveCompilationUnit(source, library); | 595 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 596 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 596 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 597 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 597 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 598 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 598 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 599 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; | 599 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; |
| 600 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; | 600 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; |
| 601 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen
t); | 601 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen
t); |
| 602 List<Type2> typeArguments = propagatedType.typeArguments; | 602 List<Type2> typeArguments = propagatedType.typeArguments; |
| 603 EngineTestCase.assertLength(2, typeArguments); | 603 EngineTestCase.assertLength(2, typeArguments); |
| 604 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[0]); | 604 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[0]); |
| 605 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[1]); | 605 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[1]); |
| 606 } | 606 } |
| 607 void test_mapLiteral_same() { | 607 void test_mapLiteral_same() { |
| 608 Source source = addSource(EngineTestCase.createSource([ | 608 Source source = addSource(EngineTestCase.createSource([ |
| 609 "f() {", | 609 "f() {", |
| 610 " var v = {'a' : 0, 'b' : 1, 'c' : 2};", | 610 " var v = {'a' : 0, 'b' : 1, 'c' : 2};", |
| 611 " return v;", | 611 " return v;", |
| 612 "}"])); | 612 "}"])); |
| 613 LibraryElement library = resolve(source); | 613 LibraryElement library = resolve(source); |
| 614 assertNoErrors(); | 614 assertNoErrors(source); |
| 615 verify([source]); | 615 verify([source]); |
| 616 CompilationUnit unit = resolveCompilationUnit(source, library); | 616 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 617 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; | 617 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 618 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; | 618 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo
dy; |
| 619 ReturnStatement statement = body.block.statements[1] as ReturnStatement; | 619 ReturnStatement statement = body.block.statements[1] as ReturnStatement; |
| 620 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; | 620 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; |
| 621 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; | 621 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; |
| 622 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen
t); | 622 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen
t); |
| 623 List<Type2> typeArguments = propagatedType.typeArguments; | 623 List<Type2> typeArguments = propagatedType.typeArguments; |
| 624 EngineTestCase.assertLength(2, typeArguments); | 624 EngineTestCase.assertLength(2, typeArguments); |
| 625 JUnitTestCase.assertSame(typeProvider.stringType, typeArguments[0]); | 625 JUnitTestCase.assertSame(typeProvider.stringType, typeArguments[0]); |
| 626 JUnitTestCase.assertSame(typeProvider.intType, typeArguments[1]); | 626 JUnitTestCase.assertSame(typeProvider.intType, typeArguments[1]); |
| 627 } | 627 } |
| 628 void test_propagatedReturnType_function_hasReturnType_returnsNull() { | 628 void test_propagatedReturnType_function_hasReturnType_returnsNull() { |
| 629 String code = EngineTestCase.createSource(["String f() => null;", "main() {"
, " var v = f();", "}"]); | 629 String code = EngineTestCase.createSource(["String f() => null;", "main() {"
, " var v = f();", "}"]); |
| 630 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.stri
ngType); | 630 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.stri
ngType); |
| 631 } | 631 } |
| 632 void test_propagatedReturnType_function_lessSpecificStaticReturnType() { | 632 void test_propagatedReturnType_function_lessSpecificStaticReturnType() { |
| 633 String code = EngineTestCase.createSource(["Object f() => 42;", "main() {",
" var v = f();", "}"]); | 633 String code = EngineTestCase.createSource(["Object f() => 42;", "main() {",
" var v = f();", "}"]); |
| 634 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); | 634 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); |
| 635 } | 635 } |
| 636 void test_propagatedReturnType_function_moreSpecificStaticReturnType() { | 636 void test_propagatedReturnType_function_moreSpecificStaticReturnType() { |
| 637 String code = EngineTestCase.createSource([ | 637 String code = EngineTestCase.createSource([ |
| 638 "int f() => (42 as Object);", | 638 "int f(v) => (v as num);", |
| 639 "main() {", | 639 "main() {", |
| 640 " var v = f();", | 640 " var v = f(3);", |
| 641 "}"]); | 641 "}"]); |
| 642 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); | 642 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT
ype); |
| 643 } | 643 } |
| 644 void test_propagatedReturnType_function_noReturnTypeName_blockBody_multipleRet
urns() { | 644 void test_propagatedReturnType_function_noReturnTypeName_blockBody_multipleRet
urns() { |
| 645 String code = EngineTestCase.createSource([ | 645 String code = EngineTestCase.createSource([ |
| 646 "f() {", | 646 "f() {", |
| 647 " if (true) return 0;", | 647 " if (true) return 0;", |
| 648 " return 1.0;", | 648 " return 1.0;", |
| 649 "}", | 649 "}", |
| 650 "main() {", | 650 "main() {", |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 " var v7 = query('select#id');", | 685 " var v7 = query('select#id');", |
| 686 " // invocation of method", | 686 " // invocation of method", |
| 687 " var m1 = document.query('div');", | 687 " var m1 = document.query('div');", |
| 688 " // unsupported currently", | 688 " // unsupported currently", |
| 689 " var b1 = query('noSuchTag');", | 689 " var b1 = query('noSuchTag');", |
| 690 " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');", | 690 " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');", |
| 691 " var b3 = query('body div');", | 691 " var b3 = query('body div');", |
| 692 " return [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", | 692 " return [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", |
| 693 "}"])); | 693 "}"])); |
| 694 LibraryElement library = resolve(source); | 694 LibraryElement library = resolve(source); |
| 695 assertNoErrors(); | 695 assertNoErrors(source); |
| 696 verify([source]); | 696 verify([source]); |
| 697 CompilationUnit unit = resolveCompilationUnit(source, library); | 697 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 698 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration; | 698 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration; |
| 699 BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody; | 699 BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody; |
| 700 ReturnStatement statement = body.block.statements[11] as ReturnStatement; | 700 ReturnStatement statement = body.block.statements[11] as ReturnStatement; |
| 701 NodeList<Expression> elements = ((statement.expression as ListLiteral)).elem
ents; | 701 NodeList<Expression> elements = ((statement.expression as ListLiteral)).elem
ents; |
| 702 JUnitTestCase.assertEquals("AnchorElement", elements[0].propagatedType.name)
; | 702 JUnitTestCase.assertEquals("AnchorElement", elements[0].propagatedType.name)
; |
| 703 JUnitTestCase.assertEquals("AnchorElement", elements[1].propagatedType.name)
; | 703 JUnitTestCase.assertEquals("AnchorElement", elements[1].propagatedType.name)
; |
| 704 JUnitTestCase.assertEquals("BodyElement", elements[2].propagatedType.name); | 704 JUnitTestCase.assertEquals("BodyElement", elements[2].propagatedType.name); |
| 705 JUnitTestCase.assertEquals("ButtonElement", elements[3].propagatedType.name)
; | 705 JUnitTestCase.assertEquals("ButtonElement", elements[3].propagatedType.name)
; |
| 706 JUnitTestCase.assertEquals("DivElement", elements[4].propagatedType.name); | 706 JUnitTestCase.assertEquals("DivElement", elements[4].propagatedType.name); |
| 707 JUnitTestCase.assertEquals("InputElement", elements[5].propagatedType.name); | 707 JUnitTestCase.assertEquals("InputElement", elements[5].propagatedType.name); |
| 708 JUnitTestCase.assertEquals("SelectElement", elements[6].propagatedType.name)
; | 708 JUnitTestCase.assertEquals("SelectElement", elements[6].propagatedType.name)
; |
| 709 JUnitTestCase.assertEquals("DivElement", elements[7].propagatedType.name); | 709 JUnitTestCase.assertEquals("DivElement", elements[7].propagatedType.name); |
| 710 JUnitTestCase.assertEquals("Element", elements[8].propagatedType.name); | 710 JUnitTestCase.assertEquals("Element", elements[8].propagatedType.name); |
| 711 JUnitTestCase.assertEquals("Element", elements[9].propagatedType.name); | 711 JUnitTestCase.assertEquals("Element", elements[9].propagatedType.name); |
| 712 JUnitTestCase.assertEquals("Element", elements[10].propagatedType.name); | 712 JUnitTestCase.assertEquals("Element", elements[10].propagatedType.name); |
| 713 } | 713 } |
| 714 | 714 |
| 715 /** | 715 /** |
| 716 * @param code the code that assigns the value to the variable "v", no matter
how. We check that | 716 * @param code the code that assigns the value to the variable "v", no matter
how. We check that |
| 717 * "v" has expected static and propagated type. | 717 * "v" has expected static and propagated type. |
| 718 */ | 718 */ |
| 719 void check_propagatedReturnType(String code, Type2 expectedStaticType, Type2 e
xpectedPropagatedType) { | 719 void check_propagatedReturnType(String code, Type2 expectedStaticType, Type2 e
xpectedPropagatedType) { |
| 720 Source source = addSource(code); | 720 Source source = addSource(code); |
| 721 LibraryElement library = resolve(source); | 721 LibraryElement library = resolve(source); |
| 722 assertNoErrors(); | 722 assertNoErrors(source); |
| 723 verify([source]); | 723 verify([source]); |
| 724 CompilationUnit unit = resolveCompilationUnit(source, library); | 724 CompilationUnit unit = resolveCompilationUnit(source, library); |
| 725 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v = ", Si
mpleIdentifier); | 725 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v = ", Si
mpleIdentifier); |
| 726 JUnitTestCase.assertSame(expectedStaticType, identifier.staticType); | 726 JUnitTestCase.assertSame(expectedStaticType, identifier.staticType); |
| 727 JUnitTestCase.assertSame(expectedPropagatedType, identifier.propagatedType); | 727 JUnitTestCase.assertSame(expectedPropagatedType, identifier.propagatedType); |
| 728 } | 728 } |
| 729 static dartSuite() { | 729 static dartSuite() { |
| 730 _ut.group('TypePropagationTest', () { | 730 _ut.group('TypePropagationTest', () { |
| 731 _ut.test('test_Future_then', () { | 731 _ut.test('test_Future_then', () { |
| 732 final __test = new TypePropagationTest(); | 732 final __test = new TypePropagationTest(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 } | 881 } |
| 882 class NonErrorResolverTest extends ResolverTestCase { | 882 class NonErrorResolverTest extends ResolverTestCase { |
| 883 void test_ambiguousExport() { | 883 void test_ambiguousExport() { |
| 884 Source source = addSource(EngineTestCase.createSource([ | 884 Source source = addSource(EngineTestCase.createSource([ |
| 885 "library L;", | 885 "library L;", |
| 886 "export 'lib1.dart';", | 886 "export 'lib1.dart';", |
| 887 "export 'lib2.dart';"])); | 887 "export 'lib2.dart';"])); |
| 888 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s M {}"])); | 888 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s M {}"])); |
| 889 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 889 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 890 resolve(source); | 890 resolve(source); |
| 891 assertNoErrors(); | 891 assertNoErrors(source); |
| 892 verify([source]); | 892 verify([source]); |
| 893 } | 893 } |
| 894 void test_ambiguousExport_combinators_hide() { | 894 void test_ambiguousExport_combinators_hide() { |
| 895 Source source = addSource(EngineTestCase.createSource([ | 895 Source source = addSource(EngineTestCase.createSource([ |
| 896 "library L;", | 896 "library L;", |
| 897 "export 'lib1.dart';", | 897 "export 'lib1.dart';", |
| 898 "export 'lib2.dart' hide B;"])); | 898 "export 'lib2.dart' hide B;"])); |
| 899 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class
A {}", "class B {}"])); | 899 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class
A {}", "class B {}"])); |
| 900 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class
B {}", "class C {}"])); | 900 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class
B {}", "class C {}"])); |
| 901 resolve(source); | 901 resolve(source); |
| 902 assertNoErrors(); | 902 assertNoErrors(source); |
| 903 verify([source]); | 903 verify([source]); |
| 904 } | 904 } |
| 905 void test_ambiguousExport_combinators_show() { | 905 void test_ambiguousExport_combinators_show() { |
| 906 Source source = addSource(EngineTestCase.createSource([ | 906 Source source = addSource(EngineTestCase.createSource([ |
| 907 "library L;", | 907 "library L;", |
| 908 "export 'lib1.dart';", | 908 "export 'lib1.dart';", |
| 909 "export 'lib2.dart' show C;"])); | 909 "export 'lib2.dart' show C;"])); |
| 910 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class
A {}", "class B {}"])); | 910 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class
A {}", "class B {}"])); |
| 911 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class
B {}", "class C {}"])); | 911 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class
B {}", "class C {}"])); |
| 912 resolve(source); | 912 resolve(source); |
| 913 assertNoErrors(); | 913 assertNoErrors(source); |
| 914 verify([source]); | 914 verify([source]); |
| 915 } | 915 } |
| 916 void test_argumentDefinitionTestNonParameter_formalParameter() { | 916 void test_argumentDefinitionTestNonParameter_formalParameter() { |
| 917 Source source = addSource(EngineTestCase.createSource(["f(var v) {", " retu
rn ?v;", "}"])); | 917 Source source = addSource(EngineTestCase.createSource(["f(var v) {", " retu
rn ?v;", "}"])); |
| 918 resolve(source); | 918 resolve(source); |
| 919 assertErrors([ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); | 919 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); |
| 920 verify([source]); | 920 verify([source]); |
| 921 } | 921 } |
| 922 void test_argumentDefinitionTestNonParameter_namedParameter() { | 922 void test_argumentDefinitionTestNonParameter_namedParameter() { |
| 923 Source source = addSource(EngineTestCase.createSource(["f({var v : 0}) {", "
return ?v;", "}"])); | 923 Source source = addSource(EngineTestCase.createSource(["f({var v : 0}) {", "
return ?v;", "}"])); |
| 924 resolve(source); | 924 resolve(source); |
| 925 assertErrors([ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); | 925 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); |
| 926 verify([source]); | 926 verify([source]); |
| 927 } | 927 } |
| 928 void test_argumentDefinitionTestNonParameter_optionalParameter() { | 928 void test_argumentDefinitionTestNonParameter_optionalParameter() { |
| 929 Source source = addSource(EngineTestCase.createSource(["f([var v]) {", " re
turn ?v;", "}"])); | 929 Source source = addSource(EngineTestCase.createSource(["f([var v]) {", " re
turn ?v;", "}"])); |
| 930 resolve(source); | 930 resolve(source); |
| 931 assertErrors([ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); | 931 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]); |
| 932 verify([source]); | 932 verify([source]); |
| 933 } | 933 } |
| 934 void test_argumentTypeNotAssignable_classWithCall_Function() { | 934 void test_argumentTypeNotAssignable_classWithCall_Function() { |
| 935 Source source = addSource(EngineTestCase.createSource([ | 935 Source source = addSource(EngineTestCase.createSource([ |
| 936 " caller(Function callee) {", | 936 " caller(Function callee) {", |
| 937 " callee();", | 937 " callee();", |
| 938 " }", | 938 " }", |
| 939 "", | 939 "", |
| 940 " class CallMeBack {", | 940 " class CallMeBack {", |
| 941 " call() => 0;", | 941 " call() => 0;", |
| 942 " }", | 942 " }", |
| 943 "", | 943 "", |
| 944 " main() {", | 944 " main() {", |
| 945 " caller(new CallMeBack());", | 945 " caller(new CallMeBack());", |
| 946 " }"])); | 946 " }"])); |
| 947 resolve(source); | 947 resolve(source); |
| 948 assertNoErrors(); | 948 assertNoErrors(source); |
| 949 verify([source]); | 949 verify([source]); |
| 950 } | 950 } |
| 951 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() { | 951 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() { |
| 952 Source source = addSource(EngineTestCase.createSource([ | 952 Source source = addSource(EngineTestCase.createSource([ |
| 953 "class A<K> {", | 953 "class A<K> {", |
| 954 " m(f(K k), K v) {", | 954 " m(f(K k), K v) {", |
| 955 " f(v);", | 955 " f(v);", |
| 956 " }", | 956 " }", |
| 957 "}"])); | 957 "}"])); |
| 958 resolve(source); | 958 resolve(source); |
| 959 assertNoErrors(); | 959 assertNoErrors(source); |
| 960 verify([source]); | 960 verify([source]); |
| 961 } | 961 } |
| 962 void test_argumentTypeNotAssignable_invocation_typedef_generic() { | 962 void test_argumentTypeNotAssignable_invocation_typedef_generic() { |
| 963 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);",
"f(A<int> a) {", " a(1);", "}"])); | 963 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);",
"f(A<int> a) {", " a(1);", "}"])); |
| 964 resolve(source); | 964 resolve(source); |
| 965 assertNoErrors(); | 965 assertNoErrors(source); |
| 966 verify([source]); | 966 verify([source]); |
| 967 } | 967 } |
| 968 void test_argumentTypeNotAssignable_Object_Function() { | 968 void test_argumentTypeNotAssignable_Object_Function() { |
| 969 Source source = addSource(EngineTestCase.createSource([ | 969 Source source = addSource(EngineTestCase.createSource([ |
| 970 "main() {", | 970 "main() {", |
| 971 " process(() {});", | 971 " process(() {});", |
| 972 "}", | 972 "}", |
| 973 "process(Object x) {}"])); | 973 "process(Object x) {}"])); |
| 974 resolve(source); | 974 resolve(source); |
| 975 assertNoErrors(); | 975 assertNoErrors(source); |
| 976 verify([source]); | 976 verify([source]); |
| 977 } | 977 } |
| 978 void test_argumentTypeNotAssignable_typedef_local() { | 978 void test_argumentTypeNotAssignable_typedef_local() { |
| 979 Source source = addSource(EngineTestCase.createSource([ | 979 Source source = addSource(EngineTestCase.createSource([ |
| 980 "typedef A(int p1, String p2);", | 980 "typedef A(int p1, String p2);", |
| 981 "A getA() => null;", | 981 "A getA() => null;", |
| 982 "f() {", | 982 "f() {", |
| 983 " A a = getA();", | 983 " A a = getA();", |
| 984 " a(1, '2');", | 984 " a(1, '2');", |
| 985 "}"])); | 985 "}"])); |
| 986 resolve(source); | 986 resolve(source); |
| 987 assertNoErrors(); | 987 assertNoErrors(source); |
| 988 verify([source]); | 988 verify([source]); |
| 989 } | 989 } |
| 990 void test_argumentTypeNotAssignable_typedef_parameter() { | 990 void test_argumentTypeNotAssignable_typedef_parameter() { |
| 991 Source source = addSource(EngineTestCase.createSource([ | 991 Source source = addSource(EngineTestCase.createSource([ |
| 992 "typedef A(int p1, String p2);", | 992 "typedef A(int p1, String p2);", |
| 993 "f(A a) {", | 993 "f(A a) {", |
| 994 " a(1, '2');", | 994 " a(1, '2');", |
| 995 "}"])); | 995 "}"])); |
| 996 resolve(source); | 996 resolve(source); |
| 997 assertNoErrors(); | 997 assertNoErrors(source); |
| 998 verify([source]); | 998 verify([source]); |
| 999 } | 999 } |
| 1000 void test_assignmentToFinal_prefixNegate() { | 1000 void test_assignmentToFinal_prefixNegate() { |
| 1001 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " -x;", "}"])); | 1001 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " -x;", "}"])); |
| 1002 resolve(source); | 1002 resolve(source); |
| 1003 assertNoErrors(); | 1003 assertNoErrors(source); |
| 1004 verify([source]); | 1004 verify([source]); |
| 1005 } | 1005 } |
| 1006 void test_assignmentToFinals_importWithPrefix() { | 1006 void test_assignmentToFinals_importWithPrefix() { |
| 1007 Source source = addSource(EngineTestCase.createSource([ | 1007 Source source = addSource(EngineTestCase.createSource([ |
| 1008 "library lib;", | 1008 "library lib;", |
| 1009 "import 'lib1.dart' as foo;", | 1009 "import 'lib1.dart' as foo;", |
| 1010 "main() {", | 1010 "main() {", |
| 1011 " foo.x = true;", | 1011 " foo.x = true;", |
| 1012 "}"])); | 1012 "}"])); |
| 1013 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "bool
x = false;"])); | 1013 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "bool
x = false;"])); |
| 1014 resolve(source); | 1014 resolve(source); |
| 1015 assertNoErrors(); | 1015 assertNoErrors(source); |
| 1016 verify([source]); | 1016 verify([source]); |
| 1017 } | 1017 } |
| 1018 void test_breakWithoutLabelInSwitch() { | 1018 void test_breakWithoutLabelInSwitch() { |
| 1019 Source source = addSource(EngineTestCase.createSource([ | 1019 Source source = addSource(EngineTestCase.createSource([ |
| 1020 "class A {", | 1020 "class A {", |
| 1021 " void m(int i) {", | 1021 " void m(int i) {", |
| 1022 " switch (i) {", | 1022 " switch (i) {", |
| 1023 " case 0:", | 1023 " case 0:", |
| 1024 " break;", | 1024 " break;", |
| 1025 " }", | 1025 " }", |
| 1026 " }", | 1026 " }", |
| 1027 "}"])); | 1027 "}"])); |
| 1028 resolve(source); | 1028 resolve(source); |
| 1029 assertNoErrors(); | 1029 assertNoErrors(source); |
| 1030 verify([source]); | 1030 verify([source]); |
| 1031 } | 1031 } |
| 1032 void test_builtInIdentifierAsType_dynamic() { | 1032 void test_builtInIdentifierAsType_dynamic() { |
| 1033 Source source = addSource(EngineTestCase.createSource(["f() {", " dynamic x
;", "}"])); | 1033 Source source = addSource(EngineTestCase.createSource(["f() {", " dynamic x
;", "}"])); |
| 1034 resolve(source); | 1034 resolve(source); |
| 1035 assertNoErrors(); | 1035 assertNoErrors(source); |
| 1036 verify([source]); | 1036 verify([source]); |
| 1037 } | 1037 } |
| 1038 void test_caseBlockNotTerminated() { | 1038 void test_caseBlockNotTerminated() { |
| 1039 Source source = addSource(EngineTestCase.createSource([ | 1039 Source source = addSource(EngineTestCase.createSource([ |
| 1040 "f(int p) {", | 1040 "f(int p) {", |
| 1041 " for (int i = 0; i < 10; i++) {", | 1041 " for (int i = 0; i < 10; i++) {", |
| 1042 " switch (p) {", | 1042 " switch (p) {", |
| 1043 " case 0:", | 1043 " case 0:", |
| 1044 " break;", | 1044 " break;", |
| 1045 " case 1:", | 1045 " case 1:", |
| 1046 " continue;", | 1046 " continue;", |
| 1047 " case 2:", | 1047 " case 2:", |
| 1048 " return;", | 1048 " return;", |
| 1049 " case 3:", | 1049 " case 3:", |
| 1050 " throw new Object();", | 1050 " throw new Object();", |
| 1051 " case 4:", | 1051 " case 4:", |
| 1052 " case 5:", | 1052 " case 5:", |
| 1053 " return;", | 1053 " return;", |
| 1054 " case 6:", | 1054 " case 6:", |
| 1055 " default:", | 1055 " default:", |
| 1056 " return;", | 1056 " return;", |
| 1057 " }", | 1057 " }", |
| 1058 " }", | 1058 " }", |
| 1059 "}"])); | 1059 "}"])); |
| 1060 resolve(source); | 1060 resolve(source); |
| 1061 assertNoErrors(); | 1061 assertNoErrors(source); |
| 1062 verify([source]); | 1062 verify([source]); |
| 1063 } | 1063 } |
| 1064 void test_caseBlockNotTerminated_lastCase() { | 1064 void test_caseBlockNotTerminated_lastCase() { |
| 1065 Source source = addSource(EngineTestCase.createSource([ | 1065 Source source = addSource(EngineTestCase.createSource([ |
| 1066 "f(int p) {", | 1066 "f(int p) {", |
| 1067 " switch (p) {", | 1067 " switch (p) {", |
| 1068 " case 0:", | 1068 " case 0:", |
| 1069 " p = p + 1;", | 1069 " p = p + 1;", |
| 1070 " }", | 1070 " }", |
| 1071 "}"])); | 1071 "}"])); |
| 1072 resolve(source); | 1072 resolve(source); |
| 1073 assertNoErrors(); | 1073 assertNoErrors(source); |
| 1074 verify([source]); | 1074 verify([source]); |
| 1075 } | 1075 } |
| 1076 void test_caseExpressionTypeImplementsEquals_int() { | 1076 void test_caseExpressionTypeImplementsEquals_int() { |
| 1077 Source source = addSource(EngineTestCase.createSource([ | 1077 Source source = addSource(EngineTestCase.createSource([ |
| 1078 "f(int i) {", | 1078 "f(int i) {", |
| 1079 " switch(i) {", | 1079 " switch(i) {", |
| 1080 " case(1) : return 1;", | 1080 " case(1) : return 1;", |
| 1081 " default: return 0;", | 1081 " default: return 0;", |
| 1082 " }", | 1082 " }", |
| 1083 "}"])); | 1083 "}"])); |
| 1084 resolve(source); | 1084 resolve(source); |
| 1085 assertNoErrors(); | 1085 assertNoErrors(source); |
| 1086 verify([source]); | 1086 verify([source]); |
| 1087 } | 1087 } |
| 1088 void test_caseExpressionTypeImplementsEquals_Object() { | 1088 void test_caseExpressionTypeImplementsEquals_Object() { |
| 1089 Source source = addSource(EngineTestCase.createSource([ | 1089 Source source = addSource(EngineTestCase.createSource([ |
| 1090 "class IntWrapper {", | 1090 "class IntWrapper {", |
| 1091 " final int value;", | 1091 " final int value;", |
| 1092 " const IntWrapper(this.value);", | 1092 " const IntWrapper(this.value);", |
| 1093 "}", | 1093 "}", |
| 1094 "", | 1094 "", |
| 1095 "f(IntWrapper intWrapper) {", | 1095 "f(IntWrapper intWrapper) {", |
| 1096 " switch(intWrapper) {", | 1096 " switch(intWrapper) {", |
| 1097 " case(const IntWrapper(1)) : return 1;", | 1097 " case(const IntWrapper(1)) : return 1;", |
| 1098 " default: return 0;", | 1098 " default: return 0;", |
| 1099 " }", | 1099 " }", |
| 1100 "}"])); | 1100 "}"])); |
| 1101 resolve(source); | 1101 resolve(source); |
| 1102 assertNoErrors(); | 1102 assertNoErrors(source); |
| 1103 verify([source]); | 1103 verify([source]); |
| 1104 } | 1104 } |
| 1105 void test_caseExpressionTypeImplementsEquals_String() { | 1105 void test_caseExpressionTypeImplementsEquals_String() { |
| 1106 Source source = addSource(EngineTestCase.createSource([ | 1106 Source source = addSource(EngineTestCase.createSource([ |
| 1107 "f(String s) {", | 1107 "f(String s) {", |
| 1108 " switch(s) {", | 1108 " switch(s) {", |
| 1109 " case('1') : return 1;", | 1109 " case('1') : return 1;", |
| 1110 " default: return 0;", | 1110 " default: return 0;", |
| 1111 " }", | 1111 " }", |
| 1112 "}"])); | 1112 "}"])); |
| 1113 resolve(source); | 1113 resolve(source); |
| 1114 assertNoErrors(); | 1114 assertNoErrors(source); |
| 1115 verify([source]); | 1115 verify([source]); |
| 1116 } | 1116 } |
| 1117 void test_concreteClassWithAbstractMember() { | 1117 void test_concreteClassWithAbstractMember() { |
| 1118 Source source = addSource(EngineTestCase.createSource(["abstract class A {",
" m();", "}"])); | 1118 Source source = addSource(EngineTestCase.createSource(["abstract class A {",
" m();", "}"])); |
| 1119 resolve(source); | 1119 resolve(source); |
| 1120 assertNoErrors(); | 1120 assertNoErrors(source); |
| 1121 verify([source]); | 1121 verify([source]); |
| 1122 } | 1122 } |
| 1123 void test_conflictingInstanceGetterAndSuperclassMember_instance() { | 1123 void test_conflictingInstanceGetterAndSuperclassMember_instance() { |
| 1124 Source source = addSource(EngineTestCase.createSource([ | 1124 Source source = addSource(EngineTestCase.createSource([ |
| 1125 "class A {", | 1125 "class A {", |
| 1126 " get v => 0;", | 1126 " get v => 0;", |
| 1127 "}", | 1127 "}", |
| 1128 "class B extends A {", | 1128 "class B extends A {", |
| 1129 " get v => 1;", | 1129 " get v => 1;", |
| 1130 "}"])); | 1130 "}"])); |
| 1131 resolve(source); | 1131 resolve(source); |
| 1132 assertNoErrors(); | 1132 assertNoErrors(source); |
| 1133 verify([source]); | 1133 verify([source]); |
| 1134 } | 1134 } |
| 1135 void test_conflictingStaticGetterAndInstanceSetter_thisClass() { | 1135 void test_conflictingStaticGetterAndInstanceSetter_thisClass() { |
| 1136 Source source = addSource(EngineTestCase.createSource([ | 1136 Source source = addSource(EngineTestCase.createSource([ |
| 1137 "class A {", | 1137 "class A {", |
| 1138 " static get x => 0;", | 1138 " static get x => 0;", |
| 1139 " static set x(int p) {}", | 1139 " static set x(int p) {}", |
| 1140 "}"])); | 1140 "}"])); |
| 1141 resolve(source); | 1141 resolve(source); |
| 1142 assertNoErrors(); | 1142 assertNoErrors(source); |
| 1143 verify([source]); | 1143 verify([source]); |
| 1144 } | 1144 } |
| 1145 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() { | 1145 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() { |
| 1146 Source source = addSource(EngineTestCase.createSource([ | 1146 Source source = addSource(EngineTestCase.createSource([ |
| 1147 "class A {", | 1147 "class A {", |
| 1148 " static x() {}", | 1148 " static x() {}", |
| 1149 " static set x(int p) {}", | 1149 " static set x(int p) {}", |
| 1150 "}"])); | 1150 "}"])); |
| 1151 resolve(source); | 1151 resolve(source); |
| 1152 assertNoErrors(); | 1152 assertNoErrors(source); |
| 1153 verify([source]); | 1153 verify([source]); |
| 1154 } | 1154 } |
| 1155 void test_constConstructorWithNonConstSuper_redirectingFactory() { | 1155 void test_constConstructorWithNonConstSuper_redirectingFactory() { |
| 1156 Source source = addSource(EngineTestCase.createSource([ | 1156 Source source = addSource(EngineTestCase.createSource([ |
| 1157 "class A {", | 1157 "class A {", |
| 1158 " A();", | 1158 " A();", |
| 1159 "}", | 1159 "}", |
| 1160 "class B implements C {", | 1160 "class B implements C {", |
| 1161 " const B();", | 1161 " const B();", |
| 1162 "}", | 1162 "}", |
| 1163 "class C extends A {", | 1163 "class C extends A {", |
| 1164 " const factory C() = B;", | 1164 " const factory C() = B;", |
| 1165 "}"])); | 1165 "}"])); |
| 1166 resolve(source); | 1166 resolve(source); |
| 1167 assertNoErrors(); | 1167 assertNoErrors(source); |
| 1168 verify([source]); | 1168 verify([source]); |
| 1169 } | 1169 } |
| 1170 void test_constConstructorWithNonFinalField_finalInstanceVar() { | 1170 void test_constConstructorWithNonFinalField_finalInstanceVar() { |
| 1171 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " const A();", "}"])); | 1171 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " const A();", "}"])); |
| 1172 resolve(source); | 1172 resolve(source); |
| 1173 assertNoErrors(); | 1173 assertNoErrors(source); |
| 1174 verify([source]); | 1174 verify([source]); |
| 1175 } | 1175 } |
| 1176 void test_constConstructorWithNonFinalField_mixin() { | 1176 void test_constConstructorWithNonFinalField_mixin() { |
| 1177 Source source = addSource(EngineTestCase.createSource([ | 1177 Source source = addSource(EngineTestCase.createSource([ |
| 1178 "class A {", | 1178 "class A {", |
| 1179 " a() {}", | 1179 " a() {}", |
| 1180 "}", | 1180 "}", |
| 1181 "class B extends Object with A {", | 1181 "class B extends Object with A {", |
| 1182 " const B();", | 1182 " const B();", |
| 1183 "}"])); | 1183 "}"])); |
| 1184 resolve(source); | 1184 resolve(source); |
| 1185 assertNoErrors(); | 1185 assertNoErrors(source); |
| 1186 verify([source]); | 1186 verify([source]); |
| 1187 } | 1187 } |
| 1188 void test_constConstructorWithNonFinalField_static() { | 1188 void test_constConstructorWithNonFinalField_static() { |
| 1189 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " const A();", "}"])); | 1189 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " const A();", "}"])); |
| 1190 resolve(source); | 1190 resolve(source); |
| 1191 assertNoErrors(); | 1191 assertNoErrors(source); |
| 1192 verify([source]); | 1192 verify([source]); |
| 1193 } | 1193 } |
| 1194 void test_constConstructorWithNonFinalField_syntheticField() { | 1194 void test_constConstructorWithNonFinalField_syntheticField() { |
| 1195 Source source = addSource(EngineTestCase.createSource([ | 1195 Source source = addSource(EngineTestCase.createSource([ |
| 1196 "class A {", | 1196 "class A {", |
| 1197 " const A();", | 1197 " const A();", |
| 1198 " set x(value) {}", | 1198 " set x(value) {}", |
| 1199 " get x {return 0;}", | 1199 " get x {return 0;}", |
| 1200 "}"])); | 1200 "}"])); |
| 1201 resolve(source); | 1201 resolve(source); |
| 1202 assertNoErrors(); | 1202 assertNoErrors(source); |
| 1203 verify([source]); | 1203 verify([source]); |
| 1204 } | 1204 } |
| 1205 void test_constEval_propertyExtraction_fieldStatic_targetType() { | 1205 void test_constEval_propertyExtraction_fieldStatic_targetType() { |
| 1206 addSource2("/math.dart", EngineTestCase.createSource(["library math;", "cons
t PI = 3.14;"])); | 1206 addSource2("/math.dart", EngineTestCase.createSource(["library math;", "cons
t PI = 3.14;"])); |
| 1207 Source source = addSource(EngineTestCase.createSource(["import 'math.dart' a
s math;", "const C = math.PI;"])); | 1207 Source source = addSource(EngineTestCase.createSource(["import 'math.dart' a
s math;", "const C = math.PI;"])); |
| 1208 resolve(source); | 1208 resolve(source); |
| 1209 assertNoErrors(); | 1209 assertNoErrors(source); |
| 1210 verify([source]); | 1210 verify([source]); |
| 1211 } | 1211 } |
| 1212 void test_constEval_propertyExtraction_methodStatic_targetType() { | 1212 void test_constEval_propertyExtraction_methodStatic_targetType() { |
| 1213 Source source = addSource(EngineTestCase.createSource([ | 1213 Source source = addSource(EngineTestCase.createSource([ |
| 1214 "class A {", | 1214 "class A {", |
| 1215 " const A();", | 1215 " const A();", |
| 1216 " static m() {}", | 1216 " static m() {}", |
| 1217 "}", | 1217 "}", |
| 1218 "const C = A.m;"])); | 1218 "const C = A.m;"])); |
| 1219 resolve(source); | 1219 resolve(source); |
| 1220 assertNoErrors(); | 1220 assertNoErrors(source); |
| 1221 verify([source]); | 1221 verify([source]); |
| 1222 } | 1222 } |
| 1223 void test_constEvalTypeBoolNumString_equal() { | 1223 void test_constEvalTypeBoolNumString_equal() { |
| 1224 Source source = addSource(EngineTestCase.createSource([ | 1224 Source source = addSource(EngineTestCase.createSource([ |
| 1225 "class A {", | 1225 "class A {", |
| 1226 " const A();", | 1226 " const A();", |
| 1227 "}", | 1227 "}", |
| 1228 "class B {", | 1228 "class B {", |
| 1229 " final v;", | 1229 " final v;", |
| 1230 " const B.a1(bool p) : v = p == true;", | 1230 " const B.a1(bool p) : v = p == true;", |
| 1231 " const B.a2(bool p) : v = p == false;", | 1231 " const B.a2(bool p) : v = p == false;", |
| 1232 " const B.a3(bool p) : v = p == 0;", | 1232 " const B.a3(bool p) : v = p == 0;", |
| 1233 " const B.a4(bool p) : v = p == 0.0;", | 1233 " const B.a4(bool p) : v = p == 0.0;", |
| 1234 " const B.a5(bool p) : v = p == '';", | 1234 " const B.a5(bool p) : v = p == '';", |
| 1235 " const B.b1(int p) : v = p == true;", | 1235 " const B.b1(int p) : v = p == true;", |
| 1236 " const B.b2(int p) : v = p == false;", | 1236 " const B.b2(int p) : v = p == false;", |
| 1237 " const B.b3(int p) : v = p == 0;", | 1237 " const B.b3(int p) : v = p == 0;", |
| 1238 " const B.b4(int p) : v = p == 0.0;", | 1238 " const B.b4(int p) : v = p == 0.0;", |
| 1239 " const B.b5(int p) : v = p == '';", | 1239 " const B.b5(int p) : v = p == '';", |
| 1240 " const B.c1(String p) : v = p == true;", | 1240 " const B.c1(String p) : v = p == true;", |
| 1241 " const B.c2(String p) : v = p == false;", | 1241 " const B.c2(String p) : v = p == false;", |
| 1242 " const B.c3(String p) : v = p == 0;", | 1242 " const B.c3(String p) : v = p == 0;", |
| 1243 " const B.c4(String p) : v = p == 0.0;", | 1243 " const B.c4(String p) : v = p == 0.0;", |
| 1244 " const B.c5(String p) : v = p == '';", | 1244 " const B.c5(String p) : v = p == '';", |
| 1245 " const B.n1(num p) : v = p == null;", | 1245 " const B.n1(num p) : v = p == null;", |
| 1246 " const B.n2(num p) : v = null == p;", | 1246 " const B.n2(num p) : v = null == p;", |
| 1247 "}"])); | 1247 "}"])); |
| 1248 resolve(source); | 1248 resolve(source); |
| 1249 assertNoErrors(); | 1249 assertNoErrors(source); |
| 1250 verify([source]); | 1250 verify([source]); |
| 1251 } | 1251 } |
| 1252 void test_constEvalTypeBoolNumString_notEqual() { | 1252 void test_constEvalTypeBoolNumString_notEqual() { |
| 1253 Source source = addSource(EngineTestCase.createSource([ | 1253 Source source = addSource(EngineTestCase.createSource([ |
| 1254 "class A {", | 1254 "class A {", |
| 1255 " const A();", | 1255 " const A();", |
| 1256 "}", | 1256 "}", |
| 1257 "class B {", | 1257 "class B {", |
| 1258 " final v;", | 1258 " final v;", |
| 1259 " const B.a1(bool p) : v = p != true;", | 1259 " const B.a1(bool p) : v = p != true;", |
| 1260 " const B.a2(bool p) : v = p != false;", | 1260 " const B.a2(bool p) : v = p != false;", |
| 1261 " const B.a3(bool p) : v = p != 0;", | 1261 " const B.a3(bool p) : v = p != 0;", |
| 1262 " const B.a4(bool p) : v = p != 0.0;", | 1262 " const B.a4(bool p) : v = p != 0.0;", |
| 1263 " const B.a5(bool p) : v = p != '';", | 1263 " const B.a5(bool p) : v = p != '';", |
| 1264 " const B.b1(int p) : v = p != true;", | 1264 " const B.b1(int p) : v = p != true;", |
| 1265 " const B.b2(int p) : v = p != false;", | 1265 " const B.b2(int p) : v = p != false;", |
| 1266 " const B.b3(int p) : v = p != 0;", | 1266 " const B.b3(int p) : v = p != 0;", |
| 1267 " const B.b4(int p) : v = p != 0.0;", | 1267 " const B.b4(int p) : v = p != 0.0;", |
| 1268 " const B.b5(int p) : v = p != '';", | 1268 " const B.b5(int p) : v = p != '';", |
| 1269 " const B.c1(String p) : v = p != true;", | 1269 " const B.c1(String p) : v = p != true;", |
| 1270 " const B.c2(String p) : v = p != false;", | 1270 " const B.c2(String p) : v = p != false;", |
| 1271 " const B.c3(String p) : v = p != 0;", | 1271 " const B.c3(String p) : v = p != 0;", |
| 1272 " const B.c4(String p) : v = p != 0.0;", | 1272 " const B.c4(String p) : v = p != 0.0;", |
| 1273 " const B.c5(String p) : v = p != '';", | 1273 " const B.c5(String p) : v = p != '';", |
| 1274 " const B.n1(num p) : v = p != null;", | 1274 " const B.n1(num p) : v = p != null;", |
| 1275 " const B.n2(num p) : v = null != p;", | 1275 " const B.n2(num p) : v = null != p;", |
| 1276 "}"])); | 1276 "}"])); |
| 1277 resolve(source); | 1277 resolve(source); |
| 1278 assertNoErrors(); | 1278 assertNoErrors(source); |
| 1279 verify([source]); |
| 1280 } |
| 1281 void test_constNotInitialized_field() { |
| 1282 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c const int x = 0;", "}"])); |
| 1283 resolve(source); |
| 1284 assertNoErrors(source); |
| 1285 verify([source]); |
| 1286 } |
| 1287 void test_constNotInitialized_local() { |
| 1288 Source source = addSource(EngineTestCase.createSource(["main() {", " const
int x = 0;", "}"])); |
| 1289 resolve(source); |
| 1290 assertNoErrors(source); |
| 1279 verify([source]); | 1291 verify([source]); |
| 1280 } | 1292 } |
| 1281 void test_constWithNonConstantArgument_literals() { | 1293 void test_constWithNonConstantArgument_literals() { |
| 1282 Source source = addSource(EngineTestCase.createSource([ | 1294 Source source = addSource(EngineTestCase.createSource([ |
| 1283 "class A {", | 1295 "class A {", |
| 1284 " const A(a, b, c, d);", | 1296 " const A(a, b, c, d);", |
| 1285 "}", | 1297 "}", |
| 1286 "f() { return const A(true, 0, 1.0, '2'); }"])); | 1298 "f() { return const A(true, 0, 1.0, '2'); }"])); |
| 1287 resolve(source); | 1299 resolve(source); |
| 1288 assertNoErrors(); | 1300 assertNoErrors(source); |
| 1289 verify([source]); | 1301 verify([source]); |
| 1290 } | 1302 } |
| 1291 void test_constWithTypeParameters_direct() { | 1303 void test_constWithTypeParameters_direct() { |
| 1292 Source source = addSource(EngineTestCase.createSource([ | 1304 Source source = addSource(EngineTestCase.createSource([ |
| 1293 "class A<T> {", | 1305 "class A<T> {", |
| 1294 " static const V = const A<int>();", | 1306 " static const V = const A<int>();", |
| 1295 " const A();", | 1307 " const A();", |
| 1296 "}"])); | 1308 "}"])); |
| 1297 resolve(source); | 1309 resolve(source); |
| 1298 assertNoErrors(); | 1310 assertNoErrors(source); |
| 1299 verify([source]); | 1311 verify([source]); |
| 1300 } | 1312 } |
| 1301 void test_constWithUndefinedConstructor() { | 1313 void test_constWithUndefinedConstructor() { |
| 1302 Source source = addSource(EngineTestCase.createSource([ | 1314 Source source = addSource(EngineTestCase.createSource([ |
| 1303 "class A {", | 1315 "class A {", |
| 1304 " const A.name();", | 1316 " const A.name();", |
| 1305 "}", | 1317 "}", |
| 1306 "f() {", | 1318 "f() {", |
| 1307 " return const A.name();", | 1319 " return const A.name();", |
| 1308 "}"])); | 1320 "}"])); |
| 1309 resolve(source); | 1321 resolve(source); |
| 1310 assertNoErrors(); | 1322 assertNoErrors(source); |
| 1311 verify([source]); | 1323 verify([source]); |
| 1312 } | 1324 } |
| 1313 void test_constWithUndefinedConstructorDefault() { | 1325 void test_constWithUndefinedConstructorDefault() { |
| 1314 Source source = addSource(EngineTestCase.createSource([ | 1326 Source source = addSource(EngineTestCase.createSource([ |
| 1315 "class A {", | 1327 "class A {", |
| 1316 " const A();", | 1328 " const A();", |
| 1317 "}", | 1329 "}", |
| 1318 "f() {", | 1330 "f() {", |
| 1319 " return const A();", | 1331 " return const A();", |
| 1320 "}"])); | 1332 "}"])); |
| 1321 resolve(source); | 1333 resolve(source); |
| 1322 assertNoErrors(); | 1334 assertNoErrors(source); |
| 1323 verify([source]); | 1335 verify([source]); |
| 1324 } | 1336 } |
| 1325 void test_defaultValueInFunctionTypeAlias() { | 1337 void test_defaultValueInFunctionTypeAlias() { |
| 1326 Source source = addSource(EngineTestCase.createSource(["typedef F([x]);"])); | 1338 Source source = addSource(EngineTestCase.createSource(["typedef F([x]);"])); |
| 1327 resolve(source); | 1339 resolve(source); |
| 1328 assertErrors([]); | 1340 assertNoErrors(source); |
| 1329 verify([source]); | 1341 verify([source]); |
| 1330 } | 1342 } |
| 1331 void test_defaultValueInFunctionTypedParameter_named() { | 1343 void test_defaultValueInFunctionTypedParameter_named() { |
| 1332 Source source = addSource(EngineTestCase.createSource(["f(g({p})) {}"])); | 1344 Source source = addSource(EngineTestCase.createSource(["f(g({p})) {}"])); |
| 1333 resolve(source); | 1345 resolve(source); |
| 1334 assertNoErrors(); | 1346 assertNoErrors(source); |
| 1335 verify([source]); | 1347 verify([source]); |
| 1336 } | 1348 } |
| 1337 void test_defaultValueInFunctionTypedParameter_optional() { | 1349 void test_defaultValueInFunctionTypedParameter_optional() { |
| 1338 Source source = addSource(EngineTestCase.createSource(["f(g([p])) {}"])); | 1350 Source source = addSource(EngineTestCase.createSource(["f(g([p])) {}"])); |
| 1339 resolve(source); | 1351 resolve(source); |
| 1340 assertNoErrors(); | 1352 assertNoErrors(source); |
| 1341 verify([source]); | 1353 verify([source]); |
| 1342 } | 1354 } |
| 1343 void test_duplicateDefinition_emptyName() { | 1355 void test_duplicateDefinition_emptyName() { |
| 1344 Source source = addSource(EngineTestCase.createSource([ | 1356 Source source = addSource(EngineTestCase.createSource([ |
| 1345 "Map _globalMap = {", | 1357 "Map _globalMap = {", |
| 1346 " 'a' : () {},", | 1358 " 'a' : () {},", |
| 1347 " 'b' : () {}", | 1359 " 'b' : () {}", |
| 1348 "};"])); | 1360 "};"])); |
| 1349 resolve(source); | 1361 resolve(source); |
| 1350 assertNoErrors(); | 1362 assertNoErrors(source); |
| 1351 verify([source]); | 1363 verify([source]); |
| 1352 } | 1364 } |
| 1353 void test_duplicateDefinition_getter() { | 1365 void test_duplicateDefinition_getter() { |
| 1354 Source source = addSource(EngineTestCase.createSource(["bool get a => true;"
])); | 1366 Source source = addSource(EngineTestCase.createSource(["bool get a => true;"
])); |
| 1355 resolve(source); | 1367 resolve(source); |
| 1356 assertNoErrors(); | 1368 assertNoErrors(source); |
| 1357 verify([source]); | 1369 verify([source]); |
| 1358 } | 1370 } |
| 1359 void test_dynamicIdentifier() { | 1371 void test_dynamicIdentifier() { |
| 1360 Source source = addSource(EngineTestCase.createSource(["main() {", " var v
= dynamic;", "}"])); | 1372 Source source = addSource(EngineTestCase.createSource(["main() {", " var v
= dynamic;", "}"])); |
| 1361 resolve(source); | 1373 resolve(source); |
| 1362 assertNoErrors(); | 1374 assertNoErrors(source); |
| 1363 verify([source]); | 1375 verify([source]); |
| 1364 } | 1376 } |
| 1365 void test_exportOfNonLibrary_libraryDeclared() { | 1377 void test_exportOfNonLibrary_libraryDeclared() { |
| 1366 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); | 1378 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); |
| 1367 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); | 1379 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); |
| 1368 resolve(source); | 1380 resolve(source); |
| 1369 assertNoErrors(); | 1381 assertNoErrors(source); |
| 1370 verify([source]); | 1382 verify([source]); |
| 1371 } | 1383 } |
| 1372 void test_exportOfNonLibrary_libraryNotDeclared() { | 1384 void test_exportOfNonLibrary_libraryNotDeclared() { |
| 1373 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); | 1385 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); |
| 1374 addSource2("/lib1.dart", EngineTestCase.createSource([""])); | 1386 addSource2("/lib1.dart", EngineTestCase.createSource([""])); |
| 1375 resolve(source); | 1387 resolve(source); |
| 1376 assertNoErrors(); | 1388 assertNoErrors(source); |
| 1377 verify([source]); | 1389 verify([source]); |
| 1378 } | 1390 } |
| 1379 void test_extraPositionalArguments_function() { | 1391 void test_extraPositionalArguments_function() { |
| 1380 Source source = addSource(EngineTestCase.createSource(["f(p1, p2) {}", "main
() {", " f(1, 2);", "}"])); | 1392 Source source = addSource(EngineTestCase.createSource(["f(p1, p2) {}", "main
() {", " f(1, 2);", "}"])); |
| 1381 resolve(source); | 1393 resolve(source); |
| 1382 assertNoErrors(); | 1394 assertNoErrors(source); |
| 1383 verify([source]); | 1395 verify([source]); |
| 1384 } | 1396 } |
| 1385 void test_extraPositionalArguments_Function() { | 1397 void test_extraPositionalArguments_Function() { |
| 1386 Source source = addSource(EngineTestCase.createSource(["f(Function a) {", "
a(1, 2);", "}"])); | 1398 Source source = addSource(EngineTestCase.createSource(["f(Function a) {", "
a(1, 2);", "}"])); |
| 1387 resolve(source); | 1399 resolve(source); |
| 1388 assertNoErrors(); | 1400 assertNoErrors(source); |
| 1389 verify([source]); | 1401 verify([source]); |
| 1390 } | 1402 } |
| 1391 void test_extraPositionalArguments_typedef_local() { | 1403 void test_extraPositionalArguments_typedef_local() { |
| 1392 Source source = addSource(EngineTestCase.createSource([ | 1404 Source source = addSource(EngineTestCase.createSource([ |
| 1393 "typedef A(p1, p2);", | 1405 "typedef A(p1, p2);", |
| 1394 "A getA() => null;", | 1406 "A getA() => null;", |
| 1395 "f() {", | 1407 "f() {", |
| 1396 " A a = getA();", | 1408 " A a = getA();", |
| 1397 " a(1, 2);", | 1409 " a(1, 2);", |
| 1398 "}"])); | 1410 "}"])); |
| 1399 resolve(source); | 1411 resolve(source); |
| 1400 assertNoErrors(); | 1412 assertNoErrors(source); |
| 1401 verify([source]); | 1413 verify([source]); |
| 1402 } | 1414 } |
| 1403 void test_extraPositionalArguments_typedef_parameter() { | 1415 void test_extraPositionalArguments_typedef_parameter() { |
| 1404 Source source = addSource(EngineTestCase.createSource(["typedef A(p1, p2);",
"f(A a) {", " a(1, 2);", "}"])); | 1416 Source source = addSource(EngineTestCase.createSource(["typedef A(p1, p2);",
"f(A a) {", " a(1, 2);", "}"])); |
| 1405 resolve(source); | 1417 resolve(source); |
| 1406 assertNoErrors(); | 1418 assertNoErrors(source); |
| 1407 verify([source]); | 1419 verify([source]); |
| 1408 } | 1420 } |
| 1409 void test_fieldInitializedByMultipleInitializers() { | 1421 void test_fieldInitializedByMultipleInitializers() { |
| 1410 Source source = addSource(EngineTestCase.createSource([ | 1422 Source source = addSource(EngineTestCase.createSource([ |
| 1411 "class A {", | 1423 "class A {", |
| 1412 " int x;", | 1424 " int x;", |
| 1413 " int y;", | 1425 " int y;", |
| 1414 " A() : x = 0, y = 0 {}", | 1426 " A() : x = 0, y = 0 {}", |
| 1415 "}"])); | 1427 "}"])); |
| 1416 resolve(source); | 1428 resolve(source); |
| 1417 assertNoErrors(); | 1429 assertNoErrors(source); |
| 1418 verify([source]); | 1430 verify([source]); |
| 1419 } | 1431 } |
| 1420 void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() { | 1432 void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() { |
| 1421 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
= 0;", " A() : x = 1 {}", "}"])); | 1433 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
= 0;", " A() : x = 1 {}", "}"])); |
| 1422 resolve(source); | 1434 resolve(source); |
| 1423 assertNoErrors(); | 1435 assertNoErrors(source); |
| 1424 verify([source]); | 1436 verify([source]); |
| 1425 } | 1437 } |
| 1426 void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() { | 1438 void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() { |
| 1427 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() : x = 1 {}", "}"])); | 1439 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() : x = 1 {}", "}"])); |
| 1428 resolve(source); | 1440 resolve(source); |
| 1429 assertNoErrors(); | 1441 assertNoErrors(source); |
| 1430 verify([source]); | 1442 verify([source]); |
| 1431 } | 1443 } |
| 1432 void test_fieldInitializerOutsideConstructor() { | 1444 void test_fieldInitializerOutsideConstructor() { |
| 1433 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); | 1445 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); |
| 1434 resolve(source); | 1446 resolve(source); |
| 1435 assertNoErrors(); | 1447 assertNoErrors(source); |
| 1436 verify([source]); | 1448 verify([source]); |
| 1437 } | 1449 } |
| 1438 void test_fieldInitializerOutsideConstructor_defaultParameters() { | 1450 void test_fieldInitializerOutsideConstructor_defaultParameters() { |
| 1439 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A([this.x]) {}", "}"])); | 1451 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A([this.x]) {}", "}"])); |
| 1440 resolve(source); | 1452 resolve(source); |
| 1441 assertNoErrors(); | 1453 assertNoErrors(source); |
| 1442 verify([source]); | 1454 verify([source]); |
| 1443 } | 1455 } |
| 1444 void test_fieldInitializerRedirectingConstructor_super() { | 1456 void test_fieldInitializerRedirectingConstructor_super() { |
| 1445 Source source = addSource(EngineTestCase.createSource([ | 1457 Source source = addSource(EngineTestCase.createSource([ |
| 1446 "class A {", | 1458 "class A {", |
| 1447 " A() {}", | 1459 " A() {}", |
| 1448 "}", | 1460 "}", |
| 1449 "class B extends A {", | 1461 "class B extends A {", |
| 1450 " int x;", | 1462 " int x;", |
| 1451 " B(this.x) : super();", | 1463 " B(this.x) : super();", |
| 1452 "}"])); | 1464 "}"])); |
| 1453 resolve(source); | 1465 resolve(source); |
| 1454 assertNoErrors(); | 1466 assertNoErrors(source); |
| 1455 verify([source]); | 1467 verify([source]); |
| 1456 } | 1468 } |
| 1457 void test_finalInitializedInDeclarationAndConstructor_initializer() { | 1469 void test_finalInitializedInDeclarationAndConstructor_initializer() { |
| 1458 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A() : x = 1 {}", "}"])); | 1470 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A() : x = 1 {}", "}"])); |
| 1459 resolve(source); | 1471 resolve(source); |
| 1460 assertNoErrors(); | 1472 assertNoErrors(source); |
| 1461 verify([source]); | 1473 verify([source]); |
| 1462 } | 1474 } |
| 1463 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { | 1475 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { |
| 1464 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x) {}", "}"])); | 1476 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x) {}", "}"])); |
| 1465 resolve(source); | 1477 resolve(source); |
| 1466 assertNoErrors(); | 1478 assertNoErrors(source); |
| 1467 verify([source]); | 1479 verify([source]); |
| 1468 } | 1480 } |
| 1469 void test_finalNotInitialized_atDeclaration() { | 1481 void test_finalNotInitialized_atDeclaration() { |
| 1470 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " A() {}", "}"])); | 1482 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " A() {}", "}"])); |
| 1471 resolve(source); | 1483 resolve(source); |
| 1472 assertNoErrors(); | 1484 assertNoErrors(source); |
| 1473 verify([source]); | 1485 verify([source]); |
| 1474 } | 1486 } |
| 1475 void test_finalNotInitialized_fieldFormal() { | 1487 void test_finalNotInitialized_fieldFormal() { |
| 1476 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " A() {}", "}"])); | 1488 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x = 0;", " A() {}", "}"])); |
| 1477 resolve(source); | 1489 resolve(source); |
| 1478 assertNoErrors(); | 1490 assertNoErrors(source); |
| 1479 verify([source]); | 1491 verify([source]); |
| 1480 } | 1492 } |
| 1481 void test_finalNotInitialized_functionTypedFieldFormal() { | 1493 void test_finalNotInitialized_functionTypedFieldFormal() { |
| 1482 Source source = addSource(EngineTestCase.createSource([ | 1494 Source source = addSource(EngineTestCase.createSource([ |
| 1483 "class A {", | 1495 "class A {", |
| 1484 " final Function x;", | 1496 " final Function x;", |
| 1485 " A(int this.x(int p)) {}", | 1497 " A(int this.x(int p)) {}", |
| 1486 "}"])); | 1498 "}"])); |
| 1487 resolve(source); | 1499 resolve(source); |
| 1488 assertNoErrors(); | 1500 assertNoErrors(source); |
| 1489 verify([source]); | 1501 verify([source]); |
| 1490 } | 1502 } |
| 1491 void test_finalNotInitialized_hasNativeClause_hasConstructor() { | 1503 void test_finalNotInitialized_hasNativeClause_hasConstructor() { |
| 1492 Source source = addSource(EngineTestCase.createSource([ | 1504 Source source = addSource(EngineTestCase.createSource([ |
| 1493 "class A native 'something' {", | 1505 "class A native 'something' {", |
| 1494 " final int x;", | 1506 " final int x;", |
| 1495 " A() {}", | 1507 " A() {}", |
| 1496 "}"])); | 1508 "}"])); |
| 1497 resolve(source); | 1509 resolve(source); |
| 1498 assertErrors([ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); | 1510 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); |
| 1499 verify([source]); | 1511 verify([source]); |
| 1500 } | 1512 } |
| 1501 void test_finalNotInitialized_hasNativeClause_noConstructor() { | 1513 void test_finalNotInitialized_hasNativeClause_noConstructor() { |
| 1502 Source source = addSource(EngineTestCase.createSource(["class A native 'some
thing' {", " final int x;", "}"])); | 1514 Source source = addSource(EngineTestCase.createSource(["class A native 'some
thing' {", " final int x;", "}"])); |
| 1503 resolve(source); | 1515 resolve(source); |
| 1504 assertErrors([ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); | 1516 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); |
| 1505 verify([source]); | 1517 verify([source]); |
| 1506 } | 1518 } |
| 1507 void test_finalNotInitialized_initializer() { | 1519 void test_finalNotInitialized_initializer() { |
| 1508 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() : x = 0 {}", "}"])); | 1520 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() : x = 0 {}", "}"])); |
| 1509 resolve(source); | 1521 resolve(source); |
| 1510 assertNoErrors(); | 1522 assertNoErrors(source); |
| 1511 verify([source]); | 1523 verify([source]); |
| 1512 } | 1524 } |
| 1513 void test_finalNotInitialized_redirectingConstructor() { | 1525 void test_finalNotInitialized_redirectingConstructor() { |
| 1514 Source source = addSource(EngineTestCase.createSource([ | 1526 Source source = addSource(EngineTestCase.createSource([ |
| 1515 "class A {", | 1527 "class A {", |
| 1516 " final int x;", | 1528 " final int x;", |
| 1517 " A(this.x);", | 1529 " A(this.x);", |
| 1518 " A.named() : this (42);", | 1530 " A.named() : this (42);", |
| 1519 "}"])); | 1531 "}"])); |
| 1520 resolve(source); | 1532 resolve(source); |
| 1521 assertNoErrors(); | 1533 assertNoErrors(source); |
| 1522 verify([source]); | 1534 verify([source]); |
| 1523 } | 1535 } |
| 1524 void test_implicitThisReferenceInInitializer_constructorName() { | 1536 void test_implicitThisReferenceInInitializer_constructorName() { |
| 1525 Source source = addSource(EngineTestCase.createSource([ | 1537 Source source = addSource(EngineTestCase.createSource([ |
| 1526 "class A {", | 1538 "class A {", |
| 1527 " A.named() {}", | 1539 " A.named() {}", |
| 1528 "}", | 1540 "}", |
| 1529 "class B {", | 1541 "class B {", |
| 1530 " var v;", | 1542 " var v;", |
| 1531 " B() : v = new A.named();", | 1543 " B() : v = new A.named();", |
| 1532 "}"])); | 1544 "}"])); |
| 1533 resolve(source); | 1545 resolve(source); |
| 1534 assertNoErrors(); | 1546 assertNoErrors(source); |
| 1535 verify([source]); | 1547 verify([source]); |
| 1536 } | 1548 } |
| 1537 void test_implicitThisReferenceInInitializer_prefixedIdentifier() { | 1549 void test_implicitThisReferenceInInitializer_prefixedIdentifier() { |
| 1538 Source source = addSource(EngineTestCase.createSource([ | 1550 Source source = addSource(EngineTestCase.createSource([ |
| 1539 "class A {", | 1551 "class A {", |
| 1540 " var f;", | 1552 " var f;", |
| 1541 "}", | 1553 "}", |
| 1542 "class B {", | 1554 "class B {", |
| 1543 " var v;", | 1555 " var v;", |
| 1544 " B(A a) : v = a.f;", | 1556 " B(A a) : v = a.f;", |
| 1545 "}"])); | 1557 "}"])); |
| 1546 resolve(source); | 1558 resolve(source); |
| 1547 assertNoErrors(); | 1559 assertNoErrors(source); |
| 1548 verify([source]); | 1560 verify([source]); |
| 1549 } | 1561 } |
| 1550 void test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() { | 1562 void test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() { |
| 1551 Source source = addSource(EngineTestCase.createSource([ | 1563 Source source = addSource(EngineTestCase.createSource([ |
| 1552 "class A {", | 1564 "class A {", |
| 1553 " f() {}", | 1565 " f() {}", |
| 1554 "}", | 1566 "}", |
| 1555 "class B {", | 1567 "class B {", |
| 1556 " var v;", | 1568 " var v;", |
| 1557 " B() : v = new A().f();", | 1569 " B() : v = new A().f();", |
| 1558 "}"])); | 1570 "}"])); |
| 1559 resolve(source); | 1571 resolve(source); |
| 1560 assertNoErrors(); | 1572 assertNoErrors(source); |
| 1561 verify([source]); | 1573 verify([source]); |
| 1562 } | 1574 } |
| 1563 void test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() { | 1575 void test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() { |
| 1564 Source source = addSource(EngineTestCase.createSource([ | 1576 Source source = addSource(EngineTestCase.createSource([ |
| 1565 "class A {", | 1577 "class A {", |
| 1566 " var f;", | 1578 " var f;", |
| 1567 "}", | 1579 "}", |
| 1568 "class B {", | 1580 "class B {", |
| 1569 " var v;", | 1581 " var v;", |
| 1570 " B() : v = new A().f;", | 1582 " B() : v = new A().f;", |
| 1571 "}"])); | 1583 "}"])); |
| 1572 resolve(source); | 1584 resolve(source); |
| 1573 assertNoErrors(); | 1585 assertNoErrors(source); |
| 1574 verify([source]); | 1586 verify([source]); |
| 1575 } | 1587 } |
| 1576 void test_implicitThisReferenceInInitializer_staticField_thisClass() { | 1588 void test_implicitThisReferenceInInitializer_staticField_thisClass() { |
| 1577 Source source = addSource(EngineTestCase.createSource([ | 1589 Source source = addSource(EngineTestCase.createSource([ |
| 1578 "class A {", | 1590 "class A {", |
| 1579 " var v;", | 1591 " var v;", |
| 1580 " A() : v = f;", | 1592 " A() : v = f;", |
| 1581 " static var f;", | 1593 " static var f;", |
| 1582 "}"])); | 1594 "}"])); |
| 1583 resolve(source); | 1595 resolve(source); |
| 1584 assertNoErrors(); | 1596 assertNoErrors(source); |
| 1585 verify([source]); | 1597 verify([source]); |
| 1586 } | 1598 } |
| 1587 void test_implicitThisReferenceInInitializer_staticGetter() { | 1599 void test_implicitThisReferenceInInitializer_staticGetter() { |
| 1588 Source source = addSource(EngineTestCase.createSource([ | 1600 Source source = addSource(EngineTestCase.createSource([ |
| 1589 "class A {", | 1601 "class A {", |
| 1590 " var v;", | 1602 " var v;", |
| 1591 " A() : v = f;", | 1603 " A() : v = f;", |
| 1592 " static get f => 42;", | 1604 " static get f => 42;", |
| 1593 "}"])); | 1605 "}"])); |
| 1594 resolve(source); | 1606 resolve(source); |
| 1595 assertNoErrors(); | 1607 assertNoErrors(source); |
| 1596 verify([source]); | 1608 verify([source]); |
| 1597 } | 1609 } |
| 1598 void test_implicitThisReferenceInInitializer_staticMethod() { | 1610 void test_implicitThisReferenceInInitializer_staticMethod() { |
| 1599 Source source = addSource(EngineTestCase.createSource([ | 1611 Source source = addSource(EngineTestCase.createSource([ |
| 1600 "class A {", | 1612 "class A {", |
| 1601 " var v;", | 1613 " var v;", |
| 1602 " A() : v = f();", | 1614 " A() : v = f();", |
| 1603 " static f() => 42;", | 1615 " static f() => 42;", |
| 1604 "}"])); | 1616 "}"])); |
| 1605 resolve(source); | 1617 resolve(source); |
| 1606 assertNoErrors(); | 1618 assertNoErrors(source); |
| 1607 verify([source]); | 1619 verify([source]); |
| 1608 } | 1620 } |
| 1609 void test_implicitThisReferenceInInitializer_topLevelField() { | 1621 void test_implicitThisReferenceInInitializer_topLevelField() { |
| 1610 Source source = addSource(EngineTestCase.createSource([ | 1622 Source source = addSource(EngineTestCase.createSource([ |
| 1611 "class A {", | 1623 "class A {", |
| 1612 " var v;", | 1624 " var v;", |
| 1613 " A() : v = f;", | 1625 " A() : v = f;", |
| 1614 "}", | 1626 "}", |
| 1615 "var f = 42;"])); | 1627 "var f = 42;"])); |
| 1616 resolve(source); | 1628 resolve(source); |
| 1617 assertNoErrors(); | 1629 assertNoErrors(source); |
| 1618 verify([source]); | 1630 verify([source]); |
| 1619 } | 1631 } |
| 1620 void test_implicitThisReferenceInInitializer_topLevelFunction() { | 1632 void test_implicitThisReferenceInInitializer_topLevelFunction() { |
| 1621 Source source = addSource(EngineTestCase.createSource([ | 1633 Source source = addSource(EngineTestCase.createSource([ |
| 1622 "class A {", | 1634 "class A {", |
| 1623 " var v;", | 1635 " var v;", |
| 1624 " A() : v = f();", | 1636 " A() : v = f();", |
| 1625 "}", | 1637 "}", |
| 1626 "f() => 42;"])); | 1638 "f() => 42;"])); |
| 1627 resolve(source); | 1639 resolve(source); |
| 1628 assertNoErrors(); | 1640 assertNoErrors(source); |
| 1629 verify([source]); | 1641 verify([source]); |
| 1630 } | 1642 } |
| 1631 void test_implicitThisReferenceInInitializer_topLevelGetter() { | 1643 void test_implicitThisReferenceInInitializer_topLevelGetter() { |
| 1632 Source source = addSource(EngineTestCase.createSource([ | 1644 Source source = addSource(EngineTestCase.createSource([ |
| 1633 "class A {", | 1645 "class A {", |
| 1634 " var v;", | 1646 " var v;", |
| 1635 " A() : v = f;", | 1647 " A() : v = f;", |
| 1636 "}", | 1648 "}", |
| 1637 "get f => 42;"])); | 1649 "get f => 42;"])); |
| 1638 resolve(source); | 1650 resolve(source); |
| 1639 assertNoErrors(); | 1651 assertNoErrors(source); |
| 1640 verify([source]); | 1652 verify([source]); |
| 1641 } | 1653 } |
| 1642 void test_implicitThisReferenceInInitializer_typeVariable() { | 1654 void test_implicitThisReferenceInInitializer_typeParameter() { |
| 1643 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " va
r v;", " A(p) : v = (p is T);", "}"])); | 1655 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " va
r v;", " A(p) : v = (p is T);", "}"])); |
| 1644 resolve(source); | 1656 resolve(source); |
| 1645 assertNoErrors(); | 1657 assertNoErrors(source); |
| 1646 verify([source]); | 1658 verify([source]); |
| 1647 } | 1659 } |
| 1648 void test_importDuplicatedLibraryName() { | 1660 void test_importDuplicatedLibraryName() { |
| 1649 Source source = addSource(EngineTestCase.createSource([ | 1661 Source source = addSource(EngineTestCase.createSource([ |
| 1650 "library test;", | 1662 "library test;", |
| 1651 "import 'lib.dart';", | 1663 "import 'lib.dart';", |
| 1652 "import 'lib.dart';"])); | 1664 "import 'lib.dart';"])); |
| 1653 addSource2("/lib.dart", "library lib;"); | 1665 addSource2("/lib.dart", "library lib;"); |
| 1654 resolve(source); | 1666 resolve(source); |
| 1655 assertErrors([HintCode.UNUSED_IMPORT, HintCode.UNUSED_IMPORT]); | 1667 assertErrors(source, [ |
| 1668 HintCode.UNUSED_IMPORT, |
| 1669 HintCode.UNUSED_IMPORT, |
| 1670 HintCode.DUPLICATE_IMPORT]); |
| 1656 verify([source]); | 1671 verify([source]); |
| 1657 } | 1672 } |
| 1658 void test_importOfNonLibrary_libraryDeclared() { | 1673 void test_importOfNonLibrary_libraryDeclared() { |
| 1659 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); | 1674 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); |
| 1660 addSource2("/part.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); | 1675 addSource2("/part.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); |
| 1661 resolve(source); | 1676 resolve(source); |
| 1662 assertNoErrors(); | 1677 assertNoErrors(source); |
| 1663 verify([source]); | 1678 verify([source]); |
| 1664 } | 1679 } |
| 1665 void test_importOfNonLibrary_libraryNotDeclared() { | 1680 void test_importOfNonLibrary_libraryNotDeclared() { |
| 1666 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); | 1681 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); |
| 1667 addSource2("/part.dart", EngineTestCase.createSource(["class A {}"])); | 1682 addSource2("/part.dart", EngineTestCase.createSource(["class A {}"])); |
| 1668 resolve(source); | 1683 resolve(source); |
| 1669 assertNoErrors(); | 1684 assertNoErrors(source); |
| 1670 verify([source]); | 1685 verify([source]); |
| 1671 } | 1686 } |
| 1672 void test_inconsistentCaseExpressionTypes() { | 1687 void test_inconsistentCaseExpressionTypes() { |
| 1673 Source source = addSource(EngineTestCase.createSource([ | 1688 Source source = addSource(EngineTestCase.createSource([ |
| 1674 "f(var p) {", | 1689 "f(var p) {", |
| 1675 " switch (p) {", | 1690 " switch (p) {", |
| 1676 " case 1:", | 1691 " case 1:", |
| 1677 " break;", | 1692 " break;", |
| 1678 " case 2:", | 1693 " case 2:", |
| 1679 " break;", | 1694 " break;", |
| 1680 " }", | 1695 " }", |
| 1681 "}"])); | 1696 "}"])); |
| 1682 resolve(source); | 1697 resolve(source); |
| 1683 assertNoErrors(); | 1698 assertNoErrors(source); |
| 1684 verify([source]); | 1699 verify([source]); |
| 1685 } | 1700 } |
| 1686 void test_inconsistentMethodInheritance_accessors_typeVariables_diamond() { | 1701 void test_inconsistentMethodInheritance_accessors_typeParameter2() { |
| 1702 Source source = addSource(EngineTestCase.createSource([ |
| 1703 "abstract class A<E> {", |
| 1704 " E get x {return 1;}", |
| 1705 "}", |
| 1706 "class B<E> {", |
| 1707 " E get x {return 1;}", |
| 1708 "}", |
| 1709 "class C<E> extends A<E> implements B<E> {", |
| 1710 "}"])); |
| 1711 resolve(source); |
| 1712 assertNoErrors(source); |
| 1713 verify([source]); |
| 1714 } |
| 1715 void test_inconsistentMethodInheritance_accessors_typeParameters_diamond() { |
| 1687 Source source = addSource(EngineTestCase.createSource([ | 1716 Source source = addSource(EngineTestCase.createSource([ |
| 1688 "abstract class F<E> extends B<E> {}", | 1717 "abstract class F<E> extends B<E> {}", |
| 1689 "class D<E> extends F<E> {", | 1718 "class D<E> extends F<E> {", |
| 1690 " external E get g;", | 1719 " external E get g;", |
| 1691 "}", | 1720 "}", |
| 1692 "abstract class C<E> {", | 1721 "abstract class C<E> {", |
| 1693 " E get g;", | 1722 " E get g;", |
| 1694 "}", | 1723 "}", |
| 1695 "abstract class B<E> implements C<E> {", | 1724 "abstract class B<E> implements C<E> {", |
| 1696 " E get g { return null; }", | 1725 " E get g { return null; }", |
| 1697 "}", | 1726 "}", |
| 1698 "class A<E> extends B<E> implements D<E> {", | 1727 "class A<E> extends B<E> implements D<E> {", |
| 1699 "}"])); | 1728 "}"])); |
| 1700 resolve(source); | 1729 resolve(source); |
| 1701 assertNoErrors(); | 1730 assertNoErrors(source); |
| 1702 verify([source]); | 1731 verify([source]); |
| 1703 } | 1732 } |
| 1704 void test_inconsistentMethodInheritance_accessors_typeVariables1() { | 1733 void test_inconsistentMethodInheritance_accessors_typeParameters1() { |
| 1705 Source source = addSource(EngineTestCase.createSource([ | 1734 Source source = addSource(EngineTestCase.createSource([ |
| 1706 "abstract class A<E> {", | 1735 "abstract class A<E> {", |
| 1707 " E get x;", | 1736 " E get x;", |
| 1708 "}", | 1737 "}", |
| 1709 "abstract class B<E> {", | 1738 "abstract class B<E> {", |
| 1710 " E get x;", | 1739 " E get x;", |
| 1711 "}", | 1740 "}", |
| 1712 "class C<E> implements A<E>, B<E> {", | 1741 "class C<E> implements A<E>, B<E> {", |
| 1713 " E get x => 1;", | 1742 " E get x => 1;", |
| 1714 "}"])); | 1743 "}"])); |
| 1715 resolve(source); | 1744 resolve(source); |
| 1716 assertNoErrors(); | 1745 assertNoErrors(source); |
| 1717 verify([source]); | 1746 verify([source]); |
| 1718 } | 1747 } |
| 1719 void test_inconsistentMethodInheritance_accessors_typeVariables2() { | 1748 void test_inconsistentMethodInheritance_methods_typeParameter2() { |
| 1720 Source source = addSource(EngineTestCase.createSource([ | |
| 1721 "abstract class A<E> {", | |
| 1722 " E get x {return 1;}", | |
| 1723 "}", | |
| 1724 "class B<E> {", | |
| 1725 " E get x {return 1;}", | |
| 1726 "}", | |
| 1727 "class C<E> extends A<E> implements B<E> {", | |
| 1728 "}"])); | |
| 1729 resolve(source); | |
| 1730 assertNoErrors(); | |
| 1731 verify([source]); | |
| 1732 } | |
| 1733 void test_inconsistentMethodInheritance_methods_typeVariables1() { | |
| 1734 Source source = addSource(EngineTestCase.createSource([ | 1749 Source source = addSource(EngineTestCase.createSource([ |
| 1735 "class A<E> {", | 1750 "class A<E> {", |
| 1736 " x(E e) {}", | 1751 " x(E e) {}", |
| 1737 "}", | 1752 "}", |
| 1738 "class B<E> {", | 1753 "class B<E> {", |
| 1739 " x(E e) {}", | 1754 " x(E e) {}", |
| 1740 "}", | 1755 "}", |
| 1741 "class C<E> implements A<E>, B<E> {", | 1756 "class C<E> extends A<E> implements B<E> {", |
| 1742 " x(E e) {}", | 1757 " x(E e) {}", |
| 1743 "}"])); | 1758 "}"])); |
| 1744 resolve(source); | 1759 resolve(source); |
| 1745 assertNoErrors(); | 1760 assertNoErrors(source); |
| 1746 verify([source]); | 1761 verify([source]); |
| 1747 } | 1762 } |
| 1748 void test_inconsistentMethodInheritance_methods_typeVariables2() { | 1763 void test_inconsistentMethodInheritance_methods_typeParameters1() { |
| 1749 Source source = addSource(EngineTestCase.createSource([ | 1764 Source source = addSource(EngineTestCase.createSource([ |
| 1750 "class A<E> {", | 1765 "class A<E> {", |
| 1751 " x(E e) {}", | 1766 " x(E e) {}", |
| 1752 "}", | 1767 "}", |
| 1753 "class B<E> {", | 1768 "class B<E> {", |
| 1754 " x(E e) {}", | 1769 " x(E e) {}", |
| 1755 "}", | 1770 "}", |
| 1756 "class C<E> extends A<E> implements B<E> {", | 1771 "class C<E> implements A<E>, B<E> {", |
| 1757 " x(E e) {}", | 1772 " x(E e) {}", |
| 1758 "}"])); | 1773 "}"])); |
| 1759 resolve(source); | 1774 resolve(source); |
| 1760 assertNoErrors(); | 1775 assertNoErrors(source); |
| 1761 verify([source]); | 1776 verify([source]); |
| 1762 } | 1777 } |
| 1763 void test_inconsistentMethodInheritance_simple() { | 1778 void test_inconsistentMethodInheritance_simple() { |
| 1764 Source source = addSource(EngineTestCase.createSource([ | 1779 Source source = addSource(EngineTestCase.createSource([ |
| 1765 "abstract class A {", | 1780 "abstract class A {", |
| 1766 " x();", | 1781 " x();", |
| 1767 "}", | 1782 "}", |
| 1768 "abstract class B {", | 1783 "abstract class B {", |
| 1769 " x();", | 1784 " x();", |
| 1770 "}", | 1785 "}", |
| 1771 "class C implements A, B {", | 1786 "class C implements A, B {", |
| 1772 " x() {}", | 1787 " x() {}", |
| 1773 "}"])); | 1788 "}"])); |
| 1774 resolve(source); | 1789 resolve(source); |
| 1775 assertNoErrors(); | 1790 assertNoErrors(source); |
| 1776 verify([source]); | 1791 verify([source]); |
| 1777 } | 1792 } |
| 1778 void test_initializingFormalForNonExistantField() { | 1793 void test_initializingFormalForNonExistantField() { |
| 1779 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); | 1794 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); |
| 1780 resolve(source); | 1795 resolve(source); |
| 1781 assertNoErrors(); | 1796 assertNoErrors(source); |
| 1782 verify([source]); | 1797 verify([source]); |
| 1783 } | 1798 } |
| 1784 void test_instanceAccessToStaticMember_fromComment() { | 1799 void test_instanceAccessToStaticMember_fromComment() { |
| 1785 Source source = addSource(EngineTestCase.createSource([ | 1800 Source source = addSource(EngineTestCase.createSource([ |
| 1786 "class A {", | 1801 "class A {", |
| 1787 " static m() {}", | 1802 " static m() {}", |
| 1788 "}", | 1803 "}", |
| 1789 "/// [A.m]", | 1804 "/// [A.m]", |
| 1790 "main() {", | 1805 "main() {", |
| 1791 "}"])); | 1806 "}"])); |
| 1792 resolve(source); | 1807 resolve(source); |
| 1793 assertNoErrors(); | 1808 assertNoErrors(source); |
| 1794 verify([source]); | 1809 verify([source]); |
| 1795 } | 1810 } |
| 1796 void test_instanceAccessToStaticMember_topLevel() { | 1811 void test_instanceAccessToStaticMember_topLevel() { |
| 1797 Source source = addSource(EngineTestCase.createSource(["m() {}", "main() {",
" m();", "}"])); | 1812 Source source = addSource(EngineTestCase.createSource(["m() {}", "main() {",
" m();", "}"])); |
| 1798 resolve(source); | 1813 resolve(source); |
| 1799 assertNoErrors(); | 1814 assertNoErrors(source); |
| 1800 verify([source]); | 1815 verify([source]); |
| 1801 } | 1816 } |
| 1802 void test_instanceMemberAccessFromStatic_fromComment() { | 1817 void test_instanceMemberAccessFromStatic_fromComment() { |
| 1803 Source source = addSource(EngineTestCase.createSource([ | 1818 Source source = addSource(EngineTestCase.createSource([ |
| 1804 "class A {", | 1819 "class A {", |
| 1805 " m() {}", | 1820 " m() {}", |
| 1806 " /// [m]", | 1821 " /// [m]", |
| 1807 " static foo() {", | 1822 " static foo() {", |
| 1808 " }", | 1823 " }", |
| 1809 "}"])); | 1824 "}"])); |
| 1810 resolve(source); | 1825 resolve(source); |
| 1811 assertNoErrors(); | 1826 assertNoErrors(source); |
| 1812 verify([source]); | 1827 verify([source]); |
| 1813 } | 1828 } |
| 1814 void test_invalidAnnotation_constantVariable() { | 1829 void test_invalidAnnotation_constantVariable() { |
| 1815 Source source = addSource(EngineTestCase.createSource(["const C = 0;", "@C",
"main() {", "}"])); | 1830 Source source = addSource(EngineTestCase.createSource(["const C = 0;", "@C",
"main() {", "}"])); |
| 1816 resolve(source); | 1831 resolve(source); |
| 1817 assertNoErrors(); | 1832 assertNoErrors(source); |
| 1818 verify([source]); | 1833 verify([source]); |
| 1819 } | 1834 } |
| 1820 void test_invalidAnnotation_importWithPrefix_constantVariable() { | 1835 void test_invalidAnnotation_importWithPrefix_constantVariable() { |
| 1821 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "const
C = 0;"])); | 1836 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "const
C = 0;"])); |
| 1822 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.C", "main() {", "}"])); | 1837 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.C", "main() {", "}"])); |
| 1823 resolve(source); | 1838 resolve(source); |
| 1824 assertNoErrors(); | 1839 assertNoErrors(source); |
| 1825 verify([source]); | 1840 verify([source]); |
| 1826 } | 1841 } |
| 1827 void test_invalidAnnotation_importWithPrefix_constConstructor() { | 1842 void test_invalidAnnotation_importWithPrefix_constConstructor() { |
| 1828 addSource2("/lib.dart", EngineTestCase.createSource([ | 1843 addSource2("/lib.dart", EngineTestCase.createSource([ |
| 1829 "library lib;", | 1844 "library lib;", |
| 1830 "class A {", | 1845 "class A {", |
| 1831 " const A.named(int p);", | 1846 " const A.named(int p);", |
| 1832 "}"])); | 1847 "}"])); |
| 1833 Source source = addSource(EngineTestCase.createSource([ | 1848 Source source = addSource(EngineTestCase.createSource([ |
| 1834 "import 'lib.dart' as p;", | 1849 "import 'lib.dart' as p;", |
| 1835 "@p.A.named(42)", | 1850 "@p.A.named(42)", |
| 1836 "main() {", | 1851 "main() {", |
| 1837 "}"])); | 1852 "}"])); |
| 1838 resolve(source); | 1853 resolve(source); |
| 1839 assertNoErrors(); | 1854 assertNoErrors(source); |
| 1840 verify([source]); | 1855 verify([source]); |
| 1841 } | 1856 } |
| 1842 void test_invalidAssignment() { | 1857 void test_invalidAssignment() { |
| 1843 Source source = addSource(EngineTestCase.createSource(["f() {", " var x;",
" var y;", " x = y;", "}"])); | 1858 Source source = addSource(EngineTestCase.createSource(["f() {", " var x;",
" var y;", " x = y;", "}"])); |
| 1844 resolve(source); | 1859 resolve(source); |
| 1845 assertNoErrors(); | 1860 assertNoErrors(source); |
| 1846 verify([source]); | 1861 verify([source]); |
| 1847 } | 1862 } |
| 1848 void test_invalidAssignment_compoundAssignment() { | 1863 void test_invalidAssignment_compoundAssignment() { |
| 1849 Source source = addSource(EngineTestCase.createSource([ | 1864 Source source = addSource(EngineTestCase.createSource([ |
| 1850 "class byte {", | 1865 "class byte {", |
| 1851 " int _value;", | 1866 " int _value;", |
| 1852 " byte(this._value);", | 1867 " byte(this._value);", |
| 1853 " byte operator +(int val) {}", | 1868 " byte operator +(int val) {}", |
| 1854 "}", | 1869 "}", |
| 1855 "", | 1870 "", |
| 1856 "void main() {", | 1871 "void main() {", |
| 1857 " byte b = new byte(52);", | 1872 " byte b = new byte(52);", |
| 1858 " b += 3;", | 1873 " b += 3;", |
| 1859 "}"])); | 1874 "}"])); |
| 1860 resolve(source); | 1875 resolve(source); |
| 1861 assertNoErrors(); | 1876 assertNoErrors(source); |
| 1862 verify([source]); | 1877 verify([source]); |
| 1863 } | 1878 } |
| 1864 void test_invalidAssignment_defaultValue_named() { | 1879 void test_invalidAssignment_defaultValue_named() { |
| 1865 Source source = addSource(EngineTestCase.createSource(["f({String x: '0'}) {
", "}"])); | 1880 Source source = addSource(EngineTestCase.createSource(["f({String x: '0'}) {
", "}"])); |
| 1866 resolve(source); | 1881 resolve(source); |
| 1867 assertNoErrors(); | 1882 assertNoErrors(source); |
| 1868 verify([source]); | 1883 verify([source]); |
| 1869 } | 1884 } |
| 1870 void test_invalidAssignment_defaultValue_optional() { | 1885 void test_invalidAssignment_defaultValue_optional() { |
| 1871 Source source = addSource(EngineTestCase.createSource(["f([String x = '0'])
{", "}"])); | 1886 Source source = addSource(EngineTestCase.createSource(["f([String x = '0'])
{", "}"])); |
| 1872 resolve(source); | 1887 resolve(source); |
| 1873 assertNoErrors(); | 1888 assertNoErrors(source); |
| 1874 verify([source]); | 1889 verify([source]); |
| 1875 } | 1890 } |
| 1876 void test_invalidAssignment_toDynamic() { | 1891 void test_invalidAssignment_toDynamic() { |
| 1877 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;",
" g = () => 0;", "}"])); | 1892 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;",
" g = () => 0;", "}"])); |
| 1878 resolve(source); | 1893 resolve(source); |
| 1879 assertNoErrors(); | 1894 assertNoErrors(source); |
| 1880 verify([source]); | 1895 verify([source]); |
| 1881 } | 1896 } |
| 1882 void test_invalidFactoryNameNotAClass() { | 1897 void test_invalidFactoryNameNotAClass() { |
| 1883 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() {}", "}"])); | 1898 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() {}", "}"])); |
| 1884 resolve(source); | 1899 resolve(source); |
| 1885 assertNoErrors(); | 1900 assertNoErrors(source); |
| 1886 verify([source]); | 1901 verify([source]); |
| 1887 } | 1902 } |
| 1888 void test_invalidMethodOverrideNamedParamType() { | 1903 void test_invalidMethodOverrideNamedParamType() { |
| 1889 Source source = addSource(EngineTestCase.createSource([ | 1904 Source source = addSource(EngineTestCase.createSource([ |
| 1890 "class A {", | 1905 "class A {", |
| 1891 " m({int a}) {}", | 1906 " m({int a}) {}", |
| 1892 "}", | 1907 "}", |
| 1893 "class B implements A {", | 1908 "class B implements A {", |
| 1894 " m({int a, int b}) {}", | 1909 " m({int a, int b}) {}", |
| 1895 "}"])); | 1910 "}"])); |
| 1896 resolve(source); | 1911 resolve(source); |
| 1897 assertNoErrors(); | 1912 assertNoErrors(source); |
| 1898 verify([source]); | 1913 verify([source]); |
| 1899 } | 1914 } |
| 1900 void test_invalidOverrideDifferentDefaultValues_named() { | 1915 void test_invalidOverrideDifferentDefaultValues_named() { |
| 1901 Source source = addSource(EngineTestCase.createSource([ | 1916 Source source = addSource(EngineTestCase.createSource([ |
| 1902 "class A {", | 1917 "class A {", |
| 1903 " m({int p : 0}) {}", | 1918 " m({int p : 0}) {}", |
| 1904 "}", | 1919 "}", |
| 1905 "class B extends A {", | 1920 "class B extends A {", |
| 1906 " m({int p : 0}) {}", | 1921 " m({int p : 0}) {}", |
| 1907 "}"])); | 1922 "}"])); |
| 1908 resolve(source); | 1923 resolve(source); |
| 1909 assertNoErrors(); | 1924 assertNoErrors(source); |
| 1910 verify([source]); | 1925 verify([source]); |
| 1911 } | 1926 } |
| 1912 void test_invalidOverrideDifferentDefaultValues_positional() { | 1927 void test_invalidOverrideDifferentDefaultValues_positional() { |
| 1913 Source source = addSource(EngineTestCase.createSource([ | 1928 Source source = addSource(EngineTestCase.createSource([ |
| 1914 "class A {", | 1929 "class A {", |
| 1915 " m([int p = 0]) {}", | 1930 " m([int p = 0]) {}", |
| 1916 "}", | 1931 "}", |
| 1917 "class B extends A {", | 1932 "class B extends A {", |
| 1918 " m([int p = 0]) {}", | 1933 " m([int p = 0]) {}", |
| 1919 "}"])); | 1934 "}"])); |
| 1920 resolve(source); | 1935 resolve(source); |
| 1921 assertNoErrors(); | 1936 assertNoErrors(source); |
| 1922 verify([source]); | 1937 verify([source]); |
| 1923 } | 1938 } |
| 1924 void test_invalidOverrideDifferentDefaultValues_positional_changedOrder() { | 1939 void test_invalidOverrideDifferentDefaultValues_positional_changedOrder() { |
| 1925 Source source = addSource(EngineTestCase.createSource([ | 1940 Source source = addSource(EngineTestCase.createSource([ |
| 1926 "class A {", | 1941 "class A {", |
| 1927 " m([int a = 0, String b = '0']) {}", | 1942 " m([int a = 0, String b = '0']) {}", |
| 1928 "}", | 1943 "}", |
| 1929 "class B extends A {", | 1944 "class B extends A {", |
| 1930 " m([int b = 0, String a = '0']) {}", | 1945 " m([int b = 0, String a = '0']) {}", |
| 1931 "}"])); | 1946 "}"])); |
| 1932 resolve(source); | 1947 resolve(source); |
| 1933 assertNoErrors(); | 1948 assertNoErrors(source); |
| 1934 verify([source]); | 1949 verify([source]); |
| 1935 } | 1950 } |
| 1936 void test_invalidOverrideNamed_unorderedNamedParameter() { | 1951 void test_invalidOverrideNamed_unorderedNamedParameter() { |
| 1937 Source source = addSource(EngineTestCase.createSource([ | 1952 Source source = addSource(EngineTestCase.createSource([ |
| 1938 "class A {", | 1953 "class A {", |
| 1939 " m({a, b}) {}", | 1954 " m({a, b}) {}", |
| 1940 "}", | 1955 "}", |
| 1941 "class B extends A {", | 1956 "class B extends A {", |
| 1942 " m({b, a}) {}", | 1957 " m({b, a}) {}", |
| 1943 "}"])); | 1958 "}"])); |
| 1944 resolve(source); | 1959 resolve(source); |
| 1945 assertNoErrors(); | 1960 assertNoErrors(source); |
| 1961 verify([source]); |
| 1962 } |
| 1963 void test_invalidOverrideRequired_less() { |
| 1964 Source source = addSource(EngineTestCase.createSource([ |
| 1965 "class A {", |
| 1966 " m(a, b) {}", |
| 1967 "}", |
| 1968 "class B extends A {", |
| 1969 " m(a) {}", |
| 1970 "}"])); |
| 1971 resolve(source); |
| 1972 assertNoErrors(source); |
| 1973 verify([source]); |
| 1974 } |
| 1975 void test_invalidOverrideRequired_same() { |
| 1976 Source source = addSource(EngineTestCase.createSource([ |
| 1977 "class A {", |
| 1978 " m(a) {}", |
| 1979 "}", |
| 1980 "class B extends A {", |
| 1981 " m(a) {}", |
| 1982 "}"])); |
| 1983 resolve(source); |
| 1984 assertNoErrors(source); |
| 1946 verify([source]); | 1985 verify([source]); |
| 1947 } | 1986 } |
| 1948 void test_invalidOverrideReturnType_returnType_interface() { | 1987 void test_invalidOverrideReturnType_returnType_interface() { |
| 1949 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 1988 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 1950 "abstract class A {", | 1989 "abstract class A {", |
| 1951 " num m();", | 1990 " num m();", |
| 1952 "}", | 1991 "}", |
| 1953 "class B implements A {", | 1992 "class B implements A {", |
| 1954 " int m() { return 1; }", | 1993 " int m() { return 1; }", |
| 1955 "}"])); | 1994 "}"])); |
| 1956 resolve(source); | 1995 resolve(source); |
| 1957 assertNoErrors(); | 1996 assertNoErrors(source); |
| 1958 verify([source]); | 1997 verify([source]); |
| 1959 } | 1998 } |
| 1960 void test_invalidOverrideReturnType_returnType_interface2() { | 1999 void test_invalidOverrideReturnType_returnType_interface2() { |
| 1961 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2000 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 1962 "abstract class A {", | 2001 "abstract class A {", |
| 1963 " num m();", | 2002 " num m();", |
| 1964 "}", | 2003 "}", |
| 1965 "abstract class B implements A {", | 2004 "abstract class B implements A {", |
| 1966 "}", | 2005 "}", |
| 1967 "class C implements B {", | 2006 "class C implements B {", |
| 1968 " int m() { return 1; }", | 2007 " int m() { return 1; }", |
| 1969 "}"])); | 2008 "}"])); |
| 1970 resolve(source); | 2009 resolve(source); |
| 1971 assertNoErrors(); | 2010 assertNoErrors(source); |
| 1972 verify([source]); | 2011 verify([source]); |
| 1973 } | 2012 } |
| 1974 void test_invalidOverrideReturnType_returnType_mixin() { | 2013 void test_invalidOverrideReturnType_returnType_mixin() { |
| 1975 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2014 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 1976 "class A {", | 2015 "class A {", |
| 1977 " num m() { return 0; }", | 2016 " num m() { return 0; }", |
| 1978 "}", | 2017 "}", |
| 1979 "class B extends Object with A {", | 2018 "class B extends Object with A {", |
| 1980 " int m() { return 1; }", | 2019 " int m() { return 1; }", |
| 1981 "}"])); | 2020 "}"])); |
| 1982 resolve(source); | 2021 resolve(source); |
| 1983 assertNoErrors(); | 2022 assertNoErrors(source); |
| 1984 verify([source]); | 2023 verify([source]); |
| 1985 } | 2024 } |
| 1986 void test_invalidOverrideReturnType_returnType_parameterizedTypes() { | 2025 void test_invalidOverrideReturnType_returnType_parameterizedTypes() { |
| 1987 Source source = addSource(EngineTestCase.createSource([ | 2026 Source source = addSource(EngineTestCase.createSource([ |
| 1988 "abstract class A<E> {", | 2027 "abstract class A<E> {", |
| 1989 " List<E> m();", | 2028 " List<E> m();", |
| 1990 "}", | 2029 "}", |
| 1991 "class B extends A<dynamic> {", | 2030 "class B extends A<dynamic> {", |
| 1992 " List<dynamic> m() { return new List<dynamic>(); }", | 2031 " List<dynamic> m() { return new List<dynamic>(); }", |
| 1993 "}"])); | 2032 "}"])); |
| 1994 resolve(source); | 2033 resolve(source); |
| 1995 assertNoErrors(); | 2034 assertNoErrors(source); |
| 1996 verify([source]); | 2035 verify([source]); |
| 1997 } | 2036 } |
| 1998 void test_invalidOverrideReturnType_returnType_sameType() { | 2037 void test_invalidOverrideReturnType_returnType_sameType() { |
| 1999 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2038 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 2000 "class A {", | 2039 "class A {", |
| 2001 " int m() { return 0; }", | 2040 " int m() { return 0; }", |
| 2002 "}", | 2041 "}", |
| 2003 "class B extends A {", | 2042 "class B extends A {", |
| 2004 " int m() { return 1; }", | 2043 " int m() { return 1; }", |
| 2005 "}"])); | 2044 "}"])); |
| 2006 resolve(source); | 2045 resolve(source); |
| 2007 assertNoErrors(); | 2046 assertNoErrors(source); |
| 2008 verify([source]); | 2047 verify([source]); |
| 2009 } | 2048 } |
| 2010 void test_invalidOverrideReturnType_returnType_superclass() { | 2049 void test_invalidOverrideReturnType_returnType_superclass() { |
| 2011 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2050 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 2012 "class A {", | 2051 "class A {", |
| 2013 " num m() { return 0; }", | 2052 " num m() { return 0; }", |
| 2014 "}", | 2053 "}", |
| 2015 "class B extends A {", | 2054 "class B extends A {", |
| 2016 " int m() { return 1; }", | 2055 " int m() { return 1; }", |
| 2017 "}"])); | 2056 "}"])); |
| 2018 resolve(source); | 2057 resolve(source); |
| 2019 assertNoErrors(); | 2058 assertNoErrors(source); |
| 2020 verify([source]); | 2059 verify([source]); |
| 2021 } | 2060 } |
| 2022 void test_invalidOverrideReturnType_returnType_superclass2() { | 2061 void test_invalidOverrideReturnType_returnType_superclass2() { |
| 2023 Source source = addSource2("/test.dart", EngineTestCase.createSource([ | 2062 Source source = addSource2("/test.dart", EngineTestCase.createSource([ |
| 2024 "class A {", | 2063 "class A {", |
| 2025 " num m() { return 0; }", | 2064 " num m() { return 0; }", |
| 2026 "}", | 2065 "}", |
| 2027 "class B extends A {", | 2066 "class B extends A {", |
| 2028 "}", | 2067 "}", |
| 2029 "class C extends B {", | 2068 "class C extends B {", |
| 2030 " int m() { return 1; }", | 2069 " int m() { return 1; }", |
| 2031 "}"])); | 2070 "}"])); |
| 2032 resolve(source); | 2071 resolve(source); |
| 2033 assertNoErrors(); | 2072 assertNoErrors(source); |
| 2034 verify([source]); | 2073 verify([source]); |
| 2035 } | 2074 } |
| 2036 void test_invalidOverrideReturnType_returnType_void() { | 2075 void test_invalidOverrideReturnType_returnType_void() { |
| 2037 Source source = addSource(EngineTestCase.createSource([ | 2076 Source source = addSource(EngineTestCase.createSource([ |
| 2038 "class A {", | 2077 "class A {", |
| 2039 " void m() {}", | 2078 " void m() {}", |
| 2040 "}", | 2079 "}", |
| 2041 "class B extends A {", | 2080 "class B extends A {", |
| 2042 " int m() {}", | 2081 " int m() {}", |
| 2043 "}"])); | 2082 "}"])); |
| 2044 resolve(source); | 2083 resolve(source); |
| 2045 assertNoErrors(); | 2084 assertNoErrors(source); |
| 2046 verify([source]); | 2085 verify([source]); |
| 2047 } | 2086 } |
| 2048 void test_invalidReferenceToThis_constructor() { | 2087 void test_invalidReferenceToThis_constructor() { |
| 2049 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
", " var v = this;", " }", "}"])); | 2088 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
", " var v = this;", " }", "}"])); |
| 2050 resolve(source); | 2089 resolve(source); |
| 2051 assertNoErrors(); | 2090 assertNoErrors(source); |
| 2052 verify([source]); | 2091 verify([source]); |
| 2053 } | 2092 } |
| 2054 void test_invalidReferenceToThis_instanceMethod() { | 2093 void test_invalidReferenceToThis_instanceMethod() { |
| 2055 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
", " var v = this;", " }", "}"])); | 2094 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
", " var v = this;", " }", "}"])); |
| 2056 resolve(source); | 2095 resolve(source); |
| 2057 assertNoErrors(); | 2096 assertNoErrors(source); |
| 2058 verify([source]); | 2097 verify([source]); |
| 2059 } | 2098 } |
| 2060 void test_invalidTypeArgumentForKey() { | 2099 void test_invalidTypeArgumentForKey() { |
| 2061 Source source = addSource(EngineTestCase.createSource([ | 2100 Source source = addSource(EngineTestCase.createSource([ |
| 2062 "class A {", | 2101 "class A {", |
| 2063 " m() {", | 2102 " m() {", |
| 2064 " return const <int, int>{};", | 2103 " return const <int, int>{};", |
| 2065 " }", | 2104 " }", |
| 2066 "}"])); | 2105 "}"])); |
| 2067 resolve(source); | 2106 resolve(source); |
| 2068 assertNoErrors(); | 2107 assertNoErrors(source); |
| 2069 verify([source]); | 2108 verify([source]); |
| 2070 } | 2109 } |
| 2071 void test_invalidTypeArgumentInConstList() { | 2110 void test_invalidTypeArgumentInConstList() { |
| 2072 Source source = addSource(EngineTestCase.createSource([ | 2111 Source source = addSource(EngineTestCase.createSource([ |
| 2073 "class A<E> {", | 2112 "class A<E> {", |
| 2074 " m() {", | 2113 " m() {", |
| 2075 " return <E>[];", | 2114 " return <E>[];", |
| 2076 " }", | 2115 " }", |
| 2077 "}"])); | 2116 "}"])); |
| 2078 resolve(source); | 2117 resolve(source); |
| 2079 assertNoErrors(); | 2118 assertNoErrors(source); |
| 2080 verify([source]); | 2119 verify([source]); |
| 2081 } | 2120 } |
| 2082 void test_invalidTypeArgumentInConstMap() { | 2121 void test_invalidTypeArgumentInConstMap() { |
| 2083 Source source = addSource(EngineTestCase.createSource([ | 2122 Source source = addSource(EngineTestCase.createSource([ |
| 2084 "class A<E> {", | 2123 "class A<E> {", |
| 2085 " m() {", | 2124 " m() {", |
| 2086 " return <String, E>{};", | 2125 " return <String, E>{};", |
| 2087 " }", | 2126 " }", |
| 2088 "}"])); | 2127 "}"])); |
| 2089 resolve(source); | 2128 resolve(source); |
| 2090 assertNoErrors(); | 2129 assertNoErrors(source); |
| 2091 verify([source]); | 2130 verify([source]); |
| 2092 } | 2131 } |
| 2093 void test_invocationOfNonFunction_dynamic() { | 2132 void test_invocationOfNonFunction_dynamic() { |
| 2094 Source source = addSource(EngineTestCase.createSource([ | 2133 Source source = addSource(EngineTestCase.createSource([ |
| 2095 "class A {", | 2134 "class A {", |
| 2096 " var f;", | 2135 " var f;", |
| 2097 "}", | 2136 "}", |
| 2098 "class B extends A {", | 2137 "class B extends A {", |
| 2099 " g() {", | 2138 " g() {", |
| 2100 " f();", | 2139 " f();", |
| 2101 " }", | 2140 " }", |
| 2102 "}"])); | 2141 "}"])); |
| 2103 resolve(source); | 2142 resolve(source); |
| 2104 assertNoErrors(); | 2143 assertNoErrors(source); |
| 2105 verify([source]); | 2144 verify([source]); |
| 2106 } | 2145 } |
| 2107 void test_invocationOfNonFunction_getter() { | 2146 void test_invocationOfNonFunction_getter() { |
| 2108 Source source = addSource(EngineTestCase.createSource([ | 2147 Source source = addSource(EngineTestCase.createSource([ |
| 2109 "class A {", | 2148 "class A {", |
| 2110 " var g;", | 2149 " var g;", |
| 2111 "}", | 2150 "}", |
| 2112 "f() {", | 2151 "f() {", |
| 2113 " A a;", | 2152 " A a;", |
| 2114 " a.g();", | 2153 " a.g();", |
| 2115 "}"])); | 2154 "}"])); |
| 2116 resolve(source); | 2155 resolve(source); |
| 2117 assertNoErrors(); | 2156 assertNoErrors(source); |
| 2118 verify([source]); | 2157 verify([source]); |
| 2119 } | 2158 } |
| 2120 void test_invocationOfNonFunction_localVariable() { | 2159 void test_invocationOfNonFunction_localVariable() { |
| 2121 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;",
" g();", "}"])); | 2160 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;",
" g();", "}"])); |
| 2122 resolve(source); | 2161 resolve(source); |
| 2123 assertNoErrors(); | 2162 assertNoErrors(source); |
| 2124 verify([source]); | 2163 verify([source]); |
| 2125 } | 2164 } |
| 2126 void test_invocationOfNonFunction_localVariable_dynamic() { | 2165 void test_invocationOfNonFunction_localVariable_dynamic() { |
| 2127 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" var v = f;", " v();", "}"])); | 2166 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" var v = f;", " v();", "}"])); |
| 2128 resolve(source); | 2167 resolve(source); |
| 2129 assertNoErrors(); | 2168 assertNoErrors(source); |
| 2130 verify([source]); | 2169 verify([source]); |
| 2131 } | 2170 } |
| 2132 void test_invocationOfNonFunction_localVariable_dynamic2() { | 2171 void test_invocationOfNonFunction_localVariable_dynamic2() { |
| 2133 Source source = addSource(EngineTestCase.createSource([ | 2172 Source source = addSource(EngineTestCase.createSource([ |
| 2134 "f() {}", | 2173 "f() {}", |
| 2135 "main() {", | 2174 "main() {", |
| 2136 " var v = f;", | 2175 " var v = f;", |
| 2137 " v = 1;", | 2176 " v = 1;", |
| 2138 " v();", | 2177 " v();", |
| 2139 "}"])); | 2178 "}"])); |
| 2140 resolve(source); | 2179 resolve(source); |
| 2141 assertNoErrors(); | 2180 assertNoErrors(source); |
| 2142 verify([source]); | 2181 verify([source]); |
| 2143 } | 2182 } |
| 2144 void test_invocationOfNonFunction_Object() { | 2183 void test_invocationOfNonFunction_Object() { |
| 2145 Source source = addSource(EngineTestCase.createSource(["main() {", " Object
v = null;", " v();", "}"])); | 2184 Source source = addSource(EngineTestCase.createSource(["main() {", " Object
v = null;", " v();", "}"])); |
| 2146 resolve(source); | 2185 resolve(source); |
| 2147 assertNoErrors(); | 2186 assertNoErrors(source); |
| 2148 verify([source]); | 2187 verify([source]); |
| 2149 } | 2188 } |
| 2150 void test_listElementTypeNotAssignable() { | 2189 void test_listElementTypeNotAssignable() { |
| 2151 Source source = addSource(EngineTestCase.createSource(["var v1 = <int> [42];
", "var v2 = const <int> [42];"])); | 2190 Source source = addSource(EngineTestCase.createSource(["var v1 = <int> [42];
", "var v2 = const <int> [42];"])); |
| 2152 resolve(source); | 2191 resolve(source); |
| 2153 assertNoErrors(); | 2192 assertNoErrors(source); |
| 2154 verify([source]); | 2193 verify([source]); |
| 2155 } | 2194 } |
| 2156 void test_mapKeyTypeNotAssignable() { | 2195 void test_mapKeyTypeNotAssignable() { |
| 2157 Source source = addSource(EngineTestCase.createSource(["var v = <String, int
> {'a' : 1};"])); | 2196 Source source = addSource(EngineTestCase.createSource(["var v = <String, int
> {'a' : 1};"])); |
| 2158 resolve(source); | 2197 resolve(source); |
| 2159 assertNoErrors(); | 2198 assertNoErrors(source); |
| 2160 verify([source]); | 2199 verify([source]); |
| 2161 } | 2200 } |
| 2162 void test_memberWithClassName_setter() { | 2201 void test_memberWithClassName_setter() { |
| 2163 Source source = addSource(EngineTestCase.createSource(["class A {", " set A
(v) {}", "}"])); | 2202 Source source = addSource(EngineTestCase.createSource(["class A {", " set A
(v) {}", "}"])); |
| 2164 resolve(source); | 2203 resolve(source); |
| 2165 assertNoErrors(); | 2204 assertNoErrors(source); |
| 2166 verify([source]); | 2205 verify([source]); |
| 2167 } | 2206 } |
| 2168 void test_misMatchedGetterAndSetterTypes_instance_sameTypes() { | 2207 void test_misMatchedGetterAndSetterTypes_instance_sameTypes() { |
| 2169 Source source = addSource(EngineTestCase.createSource([ | 2208 Source source = addSource(EngineTestCase.createSource([ |
| 2170 "class C {", | 2209 "class C {", |
| 2171 " int get x => 0;", | 2210 " int get x => 0;", |
| 2172 " set x(int v) {}", | 2211 " set x(int v) {}", |
| 2173 "}"])); | 2212 "}"])); |
| 2174 resolve(source); | 2213 resolve(source); |
| 2175 assertNoErrors(); | 2214 assertNoErrors(source); |
| 2176 verify([source]); | 2215 verify([source]); |
| 2177 } | 2216 } |
| 2178 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() { | 2217 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() { |
| 2179 Source source = addSource(EngineTestCase.createSource(["class C {", " get x
=> 0;", " set x(String v) {}", "}"])); | 2218 Source source = addSource(EngineTestCase.createSource(["class C {", " get x
=> 0;", " set x(String v) {}", "}"])); |
| 2180 resolve(source); | 2219 resolve(source); |
| 2181 assertNoErrors(); | 2220 assertNoErrors(source); |
| 2182 verify([source]); | 2221 verify([source]); |
| 2183 } | 2222 } |
| 2184 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() { | 2223 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() { |
| 2185 Source source = addSource(EngineTestCase.createSource(["class C {", " int g
et x => 0;", " set x(v) {}", "}"])); | 2224 Source source = addSource(EngineTestCase.createSource(["class C {", " int g
et x => 0;", " set x(v) {}", "}"])); |
| 2186 resolve(source); | 2225 resolve(source); |
| 2187 assertNoErrors(); | 2226 assertNoErrors(source); |
| 2188 verify([source]); | 2227 verify([source]); |
| 2189 } | 2228 } |
| 2190 void test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() { | 2229 void test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() { |
| 2191 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s
et x(int v) {}"])); | 2230 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s
et x(int v) {}"])); |
| 2192 resolve(source); | 2231 resolve(source); |
| 2193 assertNoErrors(); | 2232 assertNoErrors(source); |
| 2194 verify([source]); | 2233 verify([source]); |
| 2195 } | 2234 } |
| 2196 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() { | 2235 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() { |
| 2197 Source source = addSource(EngineTestCase.createSource(["get x => 0;", "set x
(String v) {}"])); | 2236 Source source = addSource(EngineTestCase.createSource(["get x => 0;", "set x
(String v) {}"])); |
| 2198 resolve(source); | 2237 resolve(source); |
| 2199 assertNoErrors(); | 2238 assertNoErrors(source); |
| 2200 verify([source]); | 2239 verify([source]); |
| 2201 } | 2240 } |
| 2202 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() { | 2241 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() { |
| 2203 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s
et x(v) {}"])); | 2242 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s
et x(v) {}"])); |
| 2204 resolve(source); | 2243 resolve(source); |
| 2205 assertNoErrors(); | 2244 assertNoErrors(source); |
| 2206 verify([source]); | 2245 verify([source]); |
| 2207 } | 2246 } |
| 2208 void test_mixinDeclaresConstructor() { | 2247 void test_mixinDeclaresConstructor() { |
| 2209 Source source = addSource(EngineTestCase.createSource([ | 2248 Source source = addSource(EngineTestCase.createSource([ |
| 2210 "class A {", | 2249 "class A {", |
| 2211 " m() {}", | 2250 " m() {}", |
| 2212 "}", | 2251 "}", |
| 2213 "class B extends Object with A {}"])); | 2252 "class B extends Object with A {}"])); |
| 2214 resolve(source); | 2253 resolve(source); |
| 2215 assertNoErrors(); | 2254 assertNoErrors(source); |
| 2216 verify([source]); | 2255 verify([source]); |
| 2217 } | 2256 } |
| 2218 void test_mixinDeclaresConstructor_factory() { | 2257 void test_mixinDeclaresConstructor_factory() { |
| 2219 Source source = addSource(EngineTestCase.createSource([ | 2258 Source source = addSource(EngineTestCase.createSource([ |
| 2220 "class A {", | 2259 "class A {", |
| 2221 " factory A() {}", | 2260 " factory A() {}", |
| 2222 "}", | 2261 "}", |
| 2223 "class B extends Object with A {}"])); | 2262 "class B extends Object with A {}"])); |
| 2224 resolve(source); | 2263 resolve(source); |
| 2225 assertNoErrors(); | 2264 assertNoErrors(source); |
| 2226 verify([source]); | 2265 verify([source]); |
| 2227 } | 2266 } |
| 2228 void test_mixinInheritsFromNotObject_classDeclaration_mixTypedef() { | 2267 void test_mixinInheritsFromNotObject_classDeclaration_mixTypedef() { |
| 2229 Source source = addSource(EngineTestCase.createSource([ | 2268 Source source = addSource(EngineTestCase.createSource([ |
| 2230 "class A {}", | 2269 "class A {}", |
| 2231 "typedef B = Object with A;", | 2270 "typedef B = Object with A;", |
| 2232 "class C extends Object with B {}"])); | 2271 "class C extends Object with B {}"])); |
| 2233 resolve(source); | 2272 resolve(source); |
| 2234 assertNoErrors(); | 2273 assertNoErrors(source); |
| 2235 verify([source]); | 2274 verify([source]); |
| 2236 } | 2275 } |
| 2237 void test_mixinInheritsFromNotObject_typedef_mixTypedef() { | 2276 void test_mixinInheritsFromNotObject_typedef_mixTypedef() { |
| 2238 Source source = addSource(EngineTestCase.createSource([ | 2277 Source source = addSource(EngineTestCase.createSource([ |
| 2239 "class A {}", | 2278 "class A {}", |
| 2240 "typedef B = Object with A;", | 2279 "typedef B = Object with A;", |
| 2241 "typedef C = Object with B;"])); | 2280 "typedef C = Object with B;"])); |
| 2242 resolve(source); | 2281 resolve(source); |
| 2243 assertNoErrors(); | 2282 assertNoErrors(source); |
| 2244 verify([source]); | 2283 verify([source]); |
| 2245 } | 2284 } |
| 2246 void test_multipleSuperInitializers_no() { | 2285 void test_multipleSuperInitializers_no() { |
| 2247 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A {", " B() {}", "}"])); | 2286 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A {", " B() {}", "}"])); |
| 2248 resolve(source); | 2287 resolve(source); |
| 2249 assertNoErrors(); | 2288 assertNoErrors(source); |
| 2250 verify([source]); | 2289 verify([source]); |
| 2251 } | 2290 } |
| 2252 void test_multipleSuperInitializers_single() { | 2291 void test_multipleSuperInitializers_single() { |
| 2253 Source source = addSource(EngineTestCase.createSource([ | 2292 Source source = addSource(EngineTestCase.createSource([ |
| 2254 "class A {}", | 2293 "class A {}", |
| 2255 "class B extends A {", | 2294 "class B extends A {", |
| 2256 " B() : super() {}", | 2295 " B() : super() {}", |
| 2257 "}"])); | 2296 "}"])); |
| 2258 resolve(source); | 2297 resolve(source); |
| 2259 assertNoErrors(); | 2298 assertNoErrors(source); |
| 2260 verify([source]); | 2299 verify([source]); |
| 2261 } | 2300 } |
| 2262 void test_newWithAbstractClass_factory() { | 2301 void test_newWithAbstractClass_factory() { |
| 2263 Source source = addSource(EngineTestCase.createSource([ | 2302 Source source = addSource(EngineTestCase.createSource([ |
| 2264 "abstract class A {", | 2303 "abstract class A {", |
| 2265 " factory A() { return new B(); }", | 2304 " factory A() { return new B(); }", |
| 2266 "}", | 2305 "}", |
| 2267 "class B implements A {", | 2306 "class B implements A {", |
| 2268 " B() {}", | 2307 " B() {}", |
| 2269 "}", | 2308 "}", |
| 2270 "A f() {", | 2309 "A f() {", |
| 2271 " return new A();", | 2310 " return new A();", |
| 2272 "}"])); | 2311 "}"])); |
| 2273 resolve(source); | 2312 resolve(source); |
| 2274 assertNoErrors(); | 2313 assertNoErrors(source); |
| 2275 verify([source]); | 2314 verify([source]); |
| 2276 } | 2315 } |
| 2277 void test_newWithUndefinedConstructor() { | 2316 void test_newWithUndefinedConstructor() { |
| 2278 Source source = addSource(EngineTestCase.createSource([ | 2317 Source source = addSource(EngineTestCase.createSource([ |
| 2279 "class A {", | 2318 "class A {", |
| 2280 " A.name() {}", | 2319 " A.name() {}", |
| 2281 "}", | 2320 "}", |
| 2282 "f() {", | 2321 "f() {", |
| 2283 " new A.name();", | 2322 " new A.name();", |
| 2284 "}"])); | 2323 "}"])); |
| 2285 resolve(source); | 2324 resolve(source); |
| 2286 assertNoErrors(); | 2325 assertNoErrors(source); |
| 2287 verify([source]); | 2326 verify([source]); |
| 2288 } | 2327 } |
| 2289 void test_newWithUndefinedConstructorDefault() { | 2328 void test_newWithUndefinedConstructorDefault() { |
| 2290 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "f() {", " new A();", "}"])); | 2329 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "f() {", " new A();", "}"])); |
| 2291 resolve(source); | 2330 resolve(source); |
| 2292 assertNoErrors(); | 2331 assertNoErrors(source); |
| 2293 verify([source]); | 2332 verify([source]); |
| 2294 } | 2333 } |
| 2295 void test_nonAbstractClassInheritsAbstractMemberOne_abstractOverridesConcrete_
accessor() { | 2334 void test_nonAbstractClassInheritsAbstractMemberOne_abstractOverridesConcrete_
accessor() { |
| 2296 Source source = addSource(EngineTestCase.createSource([ | 2335 Source source = addSource(EngineTestCase.createSource([ |
| 2297 "class A {", | 2336 "class A {", |
| 2298 " int get g => 0;", | 2337 " int get g => 0;", |
| 2299 "}", | 2338 "}", |
| 2300 "abstract class B extends A {", | 2339 "abstract class B extends A {", |
| 2301 " int get g;", | 2340 " int get g;", |
| 2302 "}", | 2341 "}", |
| 2303 "class C extends B {", | 2342 "class C extends B {", |
| 2304 "}"])); | 2343 "}"])); |
| 2305 resolve(source); | 2344 resolve(source); |
| 2306 assertNoErrors(); | 2345 assertNoErrors(source); |
| 2307 verify([source]); | 2346 verify([source]); |
| 2308 } | 2347 } |
| 2309 void test_nonAbstractClassInheritsAbstractMemberOne_abstractOverridesConcrete_
method() { | 2348 void test_nonAbstractClassInheritsAbstractMemberOne_abstractOverridesConcrete_
method() { |
| 2310 Source source = addSource(EngineTestCase.createSource([ | 2349 Source source = addSource(EngineTestCase.createSource([ |
| 2311 "class A {", | 2350 "class A {", |
| 2312 " m(p) {}", | 2351 " m(p) {}", |
| 2313 "}", | 2352 "}", |
| 2314 "abstract class B extends A {", | 2353 "abstract class B extends A {", |
| 2315 " m(p);", | 2354 " m(p);", |
| 2316 "}", | 2355 "}", |
| 2317 "class C extends B {", | 2356 "class C extends B {", |
| 2318 "}"])); | 2357 "}"])); |
| 2319 resolve(source); | 2358 resolve(source); |
| 2320 assertNoErrors(); | 2359 assertNoErrors(source); |
| 2321 verify([source]); | 2360 verify([source]); |
| 2322 } | 2361 } |
| 2323 void test_nonBoolExpression_functionType() { | 2362 void test_nonBoolExpression_functionType() { |
| 2324 Source source = addSource(EngineTestCase.createSource([ | 2363 Source source = addSource(EngineTestCase.createSource([ |
| 2325 "bool makeAssertion() => true;", | 2364 "bool makeAssertion() => true;", |
| 2326 "f() {", | 2365 "f() {", |
| 2327 " assert(makeAssertion);", | 2366 " assert(makeAssertion);", |
| 2328 "}"])); | 2367 "}"])); |
| 2329 resolve(source); | 2368 resolve(source); |
| 2330 assertNoErrors(); | 2369 assertNoErrors(source); |
| 2331 verify([source]); | 2370 verify([source]); |
| 2332 } | 2371 } |
| 2333 void test_nonBoolExpression_interfaceType() { | 2372 void test_nonBoolExpression_interfaceType() { |
| 2334 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(tr
ue);", "}"])); | 2373 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(tr
ue);", "}"])); |
| 2335 resolve(source); | 2374 resolve(source); |
| 2336 assertNoErrors(); | 2375 assertNoErrors(source); |
| 2337 verify([source]); | 2376 verify([source]); |
| 2338 } | 2377 } |
| 2339 void test_nonConstantDefaultValue_function_named() { | 2378 void test_nonConstantDefaultValue_function_named() { |
| 2340 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"])
); | 2379 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"])
); |
| 2341 resolve(source); | 2380 resolve(source); |
| 2342 assertNoErrors(); | 2381 assertNoErrors(source); |
| 2343 verify([source]); | 2382 verify([source]); |
| 2344 } | 2383 } |
| 2345 void test_nonConstantDefaultValue_function_positional() { | 2384 void test_nonConstantDefaultValue_function_positional() { |
| 2346 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"])
); | 2385 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"])
); |
| 2347 resolve(source); | 2386 resolve(source); |
| 2348 assertNoErrors(); | 2387 assertNoErrors(source); |
| 2349 verify([source]); | 2388 verify([source]); |
| 2350 } | 2389 } |
| 2351 void test_nonConstantDefaultValue_inConstructor_named() { | 2390 void test_nonConstantDefaultValue_inConstructor_named() { |
| 2352 Source source = addSource(EngineTestCase.createSource(["class A {", " A({x
: 2 + 3}) {}", "}"])); | 2391 Source source = addSource(EngineTestCase.createSource(["class A {", " A({x
: 2 + 3}) {}", "}"])); |
| 2353 resolve(source); | 2392 resolve(source); |
| 2354 assertNoErrors(); | 2393 assertNoErrors(source); |
| 2355 verify([source]); | 2394 verify([source]); |
| 2356 } | 2395 } |
| 2357 void test_nonConstantDefaultValue_inConstructor_positional() { | 2396 void test_nonConstantDefaultValue_inConstructor_positional() { |
| 2358 Source source = addSource(EngineTestCase.createSource(["class A {", " A([x
= 2 + 3]) {}", "}"])); | 2397 Source source = addSource(EngineTestCase.createSource(["class A {", " A([x
= 2 + 3]) {}", "}"])); |
| 2359 resolve(source); | 2398 resolve(source); |
| 2360 assertNoErrors(); | 2399 assertNoErrors(source); |
| 2361 verify([source]); | 2400 verify([source]); |
| 2362 } | 2401 } |
| 2363 void test_nonConstantDefaultValue_method_named() { | 2402 void test_nonConstantDefaultValue_method_named() { |
| 2364 Source source = addSource(EngineTestCase.createSource(["class A {", " m({x
: 2 + 3}) {}", "}"])); | 2403 Source source = addSource(EngineTestCase.createSource(["class A {", " m({x
: 2 + 3}) {}", "}"])); |
| 2365 resolve(source); | 2404 resolve(source); |
| 2366 assertNoErrors(); | 2405 assertNoErrors(source); |
| 2367 verify([source]); | 2406 verify([source]); |
| 2368 } | 2407 } |
| 2369 void test_nonConstantDefaultValue_method_positional() { | 2408 void test_nonConstantDefaultValue_method_positional() { |
| 2370 Source source = addSource(EngineTestCase.createSource(["class A {", " m([x
= 2 + 3]) {}", "}"])); | 2409 Source source = addSource(EngineTestCase.createSource(["class A {", " m([x
= 2 + 3]) {}", "}"])); |
| 2371 resolve(source); | 2410 resolve(source); |
| 2372 assertNoErrors(); | 2411 assertNoErrors(source); |
| 2373 verify([source]); | 2412 verify([source]); |
| 2374 } | 2413 } |
| 2375 void test_nonConstantValueInInitializer_namedArgument() { | 2414 void test_nonConstantValueInInitializer_namedArgument() { |
| 2376 Source source = addSource(EngineTestCase.createSource([ | 2415 Source source = addSource(EngineTestCase.createSource([ |
| 2377 "class A {", | 2416 "class A {", |
| 2378 " final a;", | 2417 " final a;", |
| 2379 " const A({this.a});", | 2418 " const A({this.a});", |
| 2380 "}", | 2419 "}", |
| 2381 "class B extends A {", | 2420 "class B extends A {", |
| 2382 " const B({b}) : super(a: b);", | 2421 " const B({b}) : super(a: b);", |
| 2383 "}"])); | 2422 "}"])); |
| 2384 resolve(source); | 2423 resolve(source); |
| 2385 assertNoErrors(); | 2424 assertNoErrors(source); |
| 2386 verify([source]); | 2425 verify([source]); |
| 2387 } | 2426 } |
| 2388 void test_nonConstCaseExpression() { | 2427 void test_nonConstCaseExpression() { |
| 2389 Source source = addSource(EngineTestCase.createSource([ | 2428 Source source = addSource(EngineTestCase.createSource([ |
| 2390 "f(Type t) {", | 2429 "f(Type t) {", |
| 2391 " switch (t) {", | 2430 " switch (t) {", |
| 2392 " case bool:", | 2431 " case bool:", |
| 2393 " case int:", | 2432 " case int:", |
| 2394 " return true;", | 2433 " return true;", |
| 2395 " default:", | 2434 " default:", |
| 2396 " return false;", | 2435 " return false;", |
| 2397 " }", | 2436 " }", |
| 2398 "}"])); | 2437 "}"])); |
| 2399 resolve(source); | 2438 resolve(source); |
| 2400 assertNoErrors(); | 2439 assertNoErrors(source); |
| 2401 verify([source]); | 2440 verify([source]); |
| 2402 } | 2441 } |
| 2403 void test_nonConstMapAsExpressionStatement_const() { | 2442 void test_nonConstMapAsExpressionStatement_const() { |
| 2404 Source source = addSource(EngineTestCase.createSource(["f() {", " const {'a
' : 0, 'b' : 1};", "}"])); | 2443 Source source = addSource(EngineTestCase.createSource(["f() {", " const {'a
' : 0, 'b' : 1};", "}"])); |
| 2405 resolve(source); | 2444 resolve(source); |
| 2406 assertNoErrors(); | 2445 assertNoErrors(source); |
| 2407 verify([source]); | 2446 verify([source]); |
| 2408 } | 2447 } |
| 2409 void test_nonConstMapAsExpressionStatement_notExpressionStatement() { | 2448 void test_nonConstMapAsExpressionStatement_notExpressionStatement() { |
| 2410 Source source = addSource(EngineTestCase.createSource(["f() {", " var m = {
'a' : 0, 'b' : 1};", "}"])); | 2449 Source source = addSource(EngineTestCase.createSource(["f() {", " var m = {
'a' : 0, 'b' : 1};", "}"])); |
| 2411 resolve(source); | 2450 resolve(source); |
| 2412 assertNoErrors(); | 2451 assertNoErrors(source); |
| 2413 verify([source]); | 2452 verify([source]); |
| 2414 } | 2453 } |
| 2415 void test_nonConstMapAsExpressionStatement_typeArguments() { | 2454 void test_nonConstMapAsExpressionStatement_typeArguments() { |
| 2416 Source source = addSource(EngineTestCase.createSource(["f() {", " <String,
int> {'a' : 0, 'b' : 1};", "}"])); | 2455 Source source = addSource(EngineTestCase.createSource(["f() {", " <String,
int> {'a' : 0, 'b' : 1};", "}"])); |
| 2417 resolve(source); | 2456 resolve(source); |
| 2418 assertNoErrors(); | 2457 assertNoErrors(source); |
| 2419 verify([source]); | 2458 verify([source]); |
| 2420 } | 2459 } |
| 2421 void test_nonConstValueInInitializer_binary_bool() { | 2460 void test_nonConstValueInInitializer_binary_bool() { |
| 2422 Source source = addSource(EngineTestCase.createSource([ | 2461 Source source = addSource(EngineTestCase.createSource([ |
| 2423 "class A {", | 2462 "class A {", |
| 2424 " final v;", | 2463 " final v;", |
| 2425 " const A.a1(bool p) : v = p && true;", | 2464 " const A.a1(bool p) : v = p && true;", |
| 2426 " const A.a2(bool p) : v = true && p;", | 2465 " const A.a2(bool p) : v = true && p;", |
| 2427 " const A.b1(bool p) : v = p || true;", | 2466 " const A.b1(bool p) : v = p || true;", |
| 2428 " const A.b2(bool p) : v = true || p;", | 2467 " const A.b2(bool p) : v = true || p;", |
| 2429 "}"])); | 2468 "}"])); |
| 2430 resolve(source); | 2469 resolve(source); |
| 2431 assertErrors([HintCode.DEAD_CODE]); | 2470 assertErrors(source, [HintCode.DEAD_CODE]); |
| 2432 verify([source]); | 2471 verify([source]); |
| 2433 } | 2472 } |
| 2434 void test_nonConstValueInInitializer_binary_dynamic() { | 2473 void test_nonConstValueInInitializer_binary_dynamic() { |
| 2435 Source source = addSource(EngineTestCase.createSource([ | 2474 Source source = addSource(EngineTestCase.createSource([ |
| 2436 "class A {", | 2475 "class A {", |
| 2437 " final v;", | 2476 " final v;", |
| 2438 " const A.a1(p) : v = p + 5;", | 2477 " const A.a1(p) : v = p + 5;", |
| 2439 " const A.a2(p) : v = 5 + p;", | 2478 " const A.a2(p) : v = 5 + p;", |
| 2440 " const A.b1(p) : v = p - 5;", | 2479 " const A.b1(p) : v = p - 5;", |
| 2441 " const A.b2(p) : v = 5 - p;", | 2480 " const A.b2(p) : v = 5 - p;", |
| 2442 " const A.c1(p) : v = p * 5;", | 2481 " const A.c1(p) : v = p * 5;", |
| 2443 " const A.c2(p) : v = 5 * p;", | 2482 " const A.c2(p) : v = 5 * p;", |
| 2444 " const A.d1(p) : v = p / 5;", | 2483 " const A.d1(p) : v = p / 5;", |
| 2445 " const A.d2(p) : v = 5 / p;", | 2484 " const A.d2(p) : v = 5 / p;", |
| 2446 " const A.e1(p) : v = p ~/ 5;", | 2485 " const A.e1(p) : v = p ~/ 5;", |
| 2447 " const A.e2(p) : v = 5 ~/ p;", | 2486 " const A.e2(p) : v = 5 ~/ p;", |
| 2448 " const A.f1(p) : v = p > 5;", | 2487 " const A.f1(p) : v = p > 5;", |
| 2449 " const A.f2(p) : v = 5 > p;", | 2488 " const A.f2(p) : v = 5 > p;", |
| 2450 " const A.g1(p) : v = p < 5;", | 2489 " const A.g1(p) : v = p < 5;", |
| 2451 " const A.g2(p) : v = 5 < p;", | 2490 " const A.g2(p) : v = 5 < p;", |
| 2452 " const A.h1(p) : v = p >= 5;", | 2491 " const A.h1(p) : v = p >= 5;", |
| 2453 " const A.h2(p) : v = 5 >= p;", | 2492 " const A.h2(p) : v = 5 >= p;", |
| 2454 " const A.i1(p) : v = p <= 5;", | 2493 " const A.i1(p) : v = p <= 5;", |
| 2455 " const A.i2(p) : v = 5 <= p;", | 2494 " const A.i2(p) : v = 5 <= p;", |
| 2456 " const A.j1(p) : v = p % 5;", | 2495 " const A.j1(p) : v = p % 5;", |
| 2457 " const A.j2(p) : v = 5 % p;", | 2496 " const A.j2(p) : v = 5 % p;", |
| 2458 "}"])); | 2497 "}"])); |
| 2459 resolve(source); | 2498 resolve(source); |
| 2460 assertNoErrors(); | 2499 assertNoErrors(source); |
| 2461 } | 2500 } |
| 2462 void test_nonConstValueInInitializer_binary_int() { | 2501 void test_nonConstValueInInitializer_binary_int() { |
| 2463 Source source = addSource(EngineTestCase.createSource([ | 2502 Source source = addSource(EngineTestCase.createSource([ |
| 2464 "class A {", | 2503 "class A {", |
| 2465 " final v;", | 2504 " final v;", |
| 2466 " const A.a1(int p) : v = p ^ 5;", | 2505 " const A.a1(int p) : v = p ^ 5;", |
| 2467 " const A.a2(int p) : v = 5 ^ p;", | 2506 " const A.a2(int p) : v = 5 ^ p;", |
| 2468 " const A.b1(int p) : v = p & 5;", | 2507 " const A.b1(int p) : v = p & 5;", |
| 2469 " const A.b2(int p) : v = 5 & p;", | 2508 " const A.b2(int p) : v = 5 & p;", |
| 2470 " const A.c1(int p) : v = p | 5;", | 2509 " const A.c1(int p) : v = p | 5;", |
| 2471 " const A.c2(int p) : v = 5 | p;", | 2510 " const A.c2(int p) : v = 5 | p;", |
| 2472 " const A.d1(int p) : v = p >> 5;", | 2511 " const A.d1(int p) : v = p >> 5;", |
| 2473 " const A.d2(int p) : v = 5 >> p;", | 2512 " const A.d2(int p) : v = 5 >> p;", |
| 2474 " const A.e1(int p) : v = p << 5;", | 2513 " const A.e1(int p) : v = p << 5;", |
| 2475 " const A.e2(int p) : v = 5 << p;", | 2514 " const A.e2(int p) : v = 5 << p;", |
| 2476 "}"])); | 2515 "}"])); |
| 2477 resolve(source); | 2516 resolve(source); |
| 2478 assertNoErrors(); | 2517 assertNoErrors(source); |
| 2479 verify([source]); | 2518 verify([source]); |
| 2480 } | 2519 } |
| 2481 void test_nonConstValueInInitializer_binary_num() { | 2520 void test_nonConstValueInInitializer_binary_num() { |
| 2482 Source source = addSource(EngineTestCase.createSource([ | 2521 Source source = addSource(EngineTestCase.createSource([ |
| 2483 "class A {", | 2522 "class A {", |
| 2484 " final v;", | 2523 " final v;", |
| 2485 " const A.a1(num p) : v = p + 5;", | 2524 " const A.a1(num p) : v = p + 5;", |
| 2486 " const A.a2(num p) : v = 5 + p;", | 2525 " const A.a2(num p) : v = 5 + p;", |
| 2487 " const A.b1(num p) : v = p - 5;", | 2526 " const A.b1(num p) : v = p - 5;", |
| 2488 " const A.b2(num p) : v = 5 - p;", | 2527 " const A.b2(num p) : v = 5 - p;", |
| 2489 " const A.c1(num p) : v = p * 5;", | 2528 " const A.c1(num p) : v = p * 5;", |
| 2490 " const A.c2(num p) : v = 5 * p;", | 2529 " const A.c2(num p) : v = 5 * p;", |
| 2491 " const A.d1(num p) : v = p / 5;", | 2530 " const A.d1(num p) : v = p / 5;", |
| 2492 " const A.d2(num p) : v = 5 / p;", | 2531 " const A.d2(num p) : v = 5 / p;", |
| 2493 " const A.e1(num p) : v = p ~/ 5;", | 2532 " const A.e1(num p) : v = p ~/ 5;", |
| 2494 " const A.e2(num p) : v = 5 ~/ p;", | 2533 " const A.e2(num p) : v = 5 ~/ p;", |
| 2495 " const A.f1(num p) : v = p > 5;", | 2534 " const A.f1(num p) : v = p > 5;", |
| 2496 " const A.f2(num p) : v = 5 > p;", | 2535 " const A.f2(num p) : v = 5 > p;", |
| 2497 " const A.g1(num p) : v = p < 5;", | 2536 " const A.g1(num p) : v = p < 5;", |
| 2498 " const A.g2(num p) : v = 5 < p;", | 2537 " const A.g2(num p) : v = 5 < p;", |
| 2499 " const A.h1(num p) : v = p >= 5;", | 2538 " const A.h1(num p) : v = p >= 5;", |
| 2500 " const A.h2(num p) : v = 5 >= p;", | 2539 " const A.h2(num p) : v = 5 >= p;", |
| 2501 " const A.i1(num p) : v = p <= 5;", | 2540 " const A.i1(num p) : v = p <= 5;", |
| 2502 " const A.i2(num p) : v = 5 <= p;", | 2541 " const A.i2(num p) : v = 5 <= p;", |
| 2503 " const A.j1(num p) : v = p % 5;", | 2542 " const A.j1(num p) : v = p % 5;", |
| 2504 " const A.j2(num p) : v = 5 % p;", | 2543 " const A.j2(num p) : v = 5 % p;", |
| 2505 "}"])); | 2544 "}"])); |
| 2506 resolve(source); | 2545 resolve(source); |
| 2507 assertNoErrors(); | 2546 assertNoErrors(source); |
| 2508 verify([source]); | 2547 verify([source]); |
| 2509 } | 2548 } |
| 2510 void test_nonConstValueInInitializer_field() { | 2549 void test_nonConstValueInInitializer_field() { |
| 2511 Source source = addSource(EngineTestCase.createSource([ | 2550 Source source = addSource(EngineTestCase.createSource([ |
| 2512 "class A {", | 2551 "class A {", |
| 2513 " final int a;", | 2552 " final int a;", |
| 2514 " const A() : a = 5;", | 2553 " const A() : a = 5;", |
| 2515 "}"])); | 2554 "}"])); |
| 2516 resolve(source); | 2555 resolve(source); |
| 2517 assertNoErrors(); | 2556 assertNoErrors(source); |
| 2518 verify([source]); | 2557 verify([source]); |
| 2519 } | 2558 } |
| 2520 void test_nonConstValueInInitializer_redirecting() { | 2559 void test_nonConstValueInInitializer_redirecting() { |
| 2521 Source source = addSource(EngineTestCase.createSource([ | 2560 Source source = addSource(EngineTestCase.createSource([ |
| 2522 "class A {", | 2561 "class A {", |
| 2523 " const A.named(p);", | 2562 " const A.named(p);", |
| 2524 " const A() : this.named(42);", | 2563 " const A() : this.named(42);", |
| 2525 "}"])); | 2564 "}"])); |
| 2526 resolve(source); | 2565 resolve(source); |
| 2527 assertNoErrors(); | 2566 assertNoErrors(source); |
| 2528 verify([source]); | 2567 verify([source]); |
| 2529 } | 2568 } |
| 2530 void test_nonConstValueInInitializer_super() { | 2569 void test_nonConstValueInInitializer_super() { |
| 2531 Source source = addSource(EngineTestCase.createSource([ | 2570 Source source = addSource(EngineTestCase.createSource([ |
| 2532 "class A {", | 2571 "class A {", |
| 2533 " const A(p);", | 2572 " const A(p);", |
| 2534 "}", | 2573 "}", |
| 2535 "class B extends A {", | 2574 "class B extends A {", |
| 2536 " const B() : super(42);", | 2575 " const B() : super(42);", |
| 2537 "}"])); | 2576 "}"])); |
| 2538 resolve(source); | 2577 resolve(source); |
| 2539 assertNoErrors(); | 2578 assertNoErrors(source); |
| 2540 verify([source]); | 2579 verify([source]); |
| 2541 } | 2580 } |
| 2542 void test_nonConstValueInInitializer_unary() { | 2581 void test_nonConstValueInInitializer_unary() { |
| 2543 Source source = addSource(EngineTestCase.createSource([ | 2582 Source source = addSource(EngineTestCase.createSource([ |
| 2544 "class A {", | 2583 "class A {", |
| 2545 " final v;", | 2584 " final v;", |
| 2546 " const A.a(bool p) : v = !p;", | 2585 " const A.a(bool p) : v = !p;", |
| 2547 " const A.b(int p) : v = ~p;", | 2586 " const A.b(int p) : v = ~p;", |
| 2548 " const A.c(num p) : v = -p;", | 2587 " const A.c(num p) : v = -p;", |
| 2549 "}"])); | 2588 "}"])); |
| 2550 resolve(source); | 2589 resolve(source); |
| 2551 assertNoErrors(); | 2590 assertNoErrors(source); |
| 2552 verify([source]); | 2591 verify([source]); |
| 2553 } | 2592 } |
| 2554 void test_nonGenerativeConstructor() { | 2593 void test_nonGenerativeConstructor() { |
| 2555 Source source = addSource(EngineTestCase.createSource([ | 2594 Source source = addSource(EngineTestCase.createSource([ |
| 2556 "class A {", | 2595 "class A {", |
| 2557 " A.named() {}", | 2596 " A.named() {}", |
| 2558 " factory A() {}", | 2597 " factory A() {}", |
| 2559 "}", | 2598 "}", |
| 2560 "class B extends A {", | 2599 "class B extends A {", |
| 2561 " B() : super.named();", | 2600 " B() : super.named();", |
| 2562 "}"])); | 2601 "}"])); |
| 2563 resolve(source); | 2602 resolve(source); |
| 2564 assertNoErrors(); | 2603 assertNoErrors(source); |
| 2565 verify([source]); | 2604 verify([source]); |
| 2566 } | 2605 } |
| 2567 void test_nonTypeInCatchClause_isClass() { | 2606 void test_nonTypeInCatchClause_isClass() { |
| 2568 Source source = addSource(EngineTestCase.createSource([ | 2607 Source source = addSource(EngineTestCase.createSource([ |
| 2569 "f() {", | 2608 "f() {", |
| 2570 " try {", | 2609 " try {", |
| 2571 " } on String catch (e) {", | 2610 " } on String catch (e) {", |
| 2572 " }", | 2611 " }", |
| 2573 "}"])); | 2612 "}"])); |
| 2574 resolve(source); | 2613 resolve(source); |
| 2575 assertNoErrors(); | 2614 assertNoErrors(source); |
| 2576 verify([source]); | 2615 verify([source]); |
| 2577 } | 2616 } |
| 2578 void test_nonTypeInCatchClause_isFunctionTypeAlias() { | 2617 void test_nonTypeInCatchClause_isFunctionTypeAlias() { |
| 2579 Source source = addSource(EngineTestCase.createSource([ | 2618 Source source = addSource(EngineTestCase.createSource([ |
| 2580 "typedef F();", | 2619 "typedef F();", |
| 2581 "f() {", | 2620 "f() {", |
| 2582 " try {", | 2621 " try {", |
| 2583 " } on F catch (e) {", | 2622 " } on F catch (e) {", |
| 2584 " }", | 2623 " }", |
| 2585 "}"])); | 2624 "}"])); |
| 2586 resolve(source); | 2625 resolve(source); |
| 2587 assertNoErrors(); | 2626 assertNoErrors(source); |
| 2588 verify([source]); | 2627 verify([source]); |
| 2589 } | 2628 } |
| 2590 void test_nonTypeInCatchClause_isTypeVariable() { | 2629 void test_nonTypeInCatchClause_isTypeParameter() { |
| 2591 Source source = addSource(EngineTestCase.createSource([ | 2630 Source source = addSource(EngineTestCase.createSource([ |
| 2592 "class A<T> {", | 2631 "class A<T> {", |
| 2593 " f() {", | 2632 " f() {", |
| 2594 " try {", | 2633 " try {", |
| 2595 " } on T catch (e) {", | 2634 " } on T catch (e) {", |
| 2596 " }", | 2635 " }", |
| 2597 " }", | 2636 " }", |
| 2598 "}"])); | 2637 "}"])); |
| 2599 resolve(source); | 2638 resolve(source); |
| 2600 assertNoErrors(); | 2639 assertNoErrors(source); |
| 2601 verify([source]); | 2640 verify([source]); |
| 2602 } | 2641 } |
| 2603 void test_nonTypeInCatchClause_noType() { | 2642 void test_nonTypeInCatchClause_noType() { |
| 2604 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", "
} catch (e) {", " }", "}"])); | 2643 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", "
} catch (e) {", " }", "}"])); |
| 2605 resolve(source); | 2644 resolve(source); |
| 2606 assertNoErrors(); | 2645 assertNoErrors(source); |
| 2607 verify([source]); | 2646 verify([source]); |
| 2608 } | 2647 } |
| 2609 void test_nonVoidReturnForOperator_no() { | 2648 void test_nonVoidReturnForOperator_no() { |
| 2610 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor []=(a, b) {}", "}"])); | 2649 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor []=(a, b) {}", "}"])); |
| 2611 resolve(source); | 2650 resolve(source); |
| 2612 assertNoErrors(); | 2651 assertNoErrors(source); |
| 2613 verify([source]); | 2652 verify([source]); |
| 2614 } | 2653 } |
| 2615 void test_nonVoidReturnForOperator_void() { | 2654 void test_nonVoidReturnForOperator_void() { |
| 2616 Source source = addSource(EngineTestCase.createSource(["class A {", " void
operator []=(a, b) {}", "}"])); | 2655 Source source = addSource(EngineTestCase.createSource(["class A {", " void
operator []=(a, b) {}", "}"])); |
| 2617 resolve(source); | 2656 resolve(source); |
| 2618 assertNoErrors(); | 2657 assertNoErrors(source); |
| 2619 verify([source]); | 2658 verify([source]); |
| 2620 } | 2659 } |
| 2621 void test_nonVoidReturnForSetter_function_no() { | 2660 void test_nonVoidReturnForSetter_function_no() { |
| 2622 Source source = addSource("set x(v) {}"); | 2661 Source source = addSource("set x(v) {}"); |
| 2623 resolve(source); | 2662 resolve(source); |
| 2624 assertNoErrors(); | 2663 assertNoErrors(source); |
| 2625 verify([source]); | 2664 verify([source]); |
| 2626 } | 2665 } |
| 2627 void test_nonVoidReturnForSetter_function_void() { | 2666 void test_nonVoidReturnForSetter_function_void() { |
| 2628 Source source = addSource("void set x(v) {}"); | 2667 Source source = addSource("void set x(v) {}"); |
| 2629 resolve(source); | 2668 resolve(source); |
| 2630 assertNoErrors(); | 2669 assertNoErrors(source); |
| 2631 verify([source]); | 2670 verify([source]); |
| 2632 } | 2671 } |
| 2633 void test_nonVoidReturnForSetter_method_no() { | 2672 void test_nonVoidReturnForSetter_method_no() { |
| 2634 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(v) {}", "}"])); | 2673 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(v) {}", "}"])); |
| 2635 resolve(source); | 2674 resolve(source); |
| 2636 assertNoErrors(); | 2675 assertNoErrors(source); |
| 2637 verify([source]); | 2676 verify([source]); |
| 2638 } | 2677 } |
| 2639 void test_nonVoidReturnForSetter_method_void() { | 2678 void test_nonVoidReturnForSetter_method_void() { |
| 2640 Source source = addSource(EngineTestCase.createSource(["class A {", " void
set x(v) {}", "}"])); | 2679 Source source = addSource(EngineTestCase.createSource(["class A {", " void
set x(v) {}", "}"])); |
| 2641 resolve(source); | 2680 resolve(source); |
| 2642 assertNoErrors(); | 2681 assertNoErrors(source); |
| 2643 verify([source]); | 2682 verify([source]); |
| 2644 } | 2683 } |
| 2645 void test_optionalParameterInOperator_required() { | 2684 void test_optionalParameterInOperator_required() { |
| 2646 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +(p) {}", "}"])); | 2685 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +(p) {}", "}"])); |
| 2647 resolve(source); | 2686 resolve(source); |
| 2648 assertNoErrors(); | 2687 assertNoErrors(source); |
| 2649 verify([source]); | 2688 verify([source]); |
| 2650 } | 2689 } |
| 2651 void test_prefixCollidesWithTopLevelMembers() { | 2690 void test_prefixCollidesWithTopLevelMembers() { |
| 2652 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {}"])); | 2691 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A {}"])); |
| 2653 Source source = addSource(EngineTestCase.createSource([ | 2692 Source source = addSource(EngineTestCase.createSource([ |
| 2654 "import 'lib.dart' as p;", | 2693 "import 'lib.dart' as p;", |
| 2655 "typedef P();", | 2694 "typedef P();", |
| 2656 "p2() {}", | 2695 "p2() {}", |
| 2657 "var p3;", | 2696 "var p3;", |
| 2658 "class p4 {}", | 2697 "class p4 {}", |
| 2659 "p.A a;"])); | 2698 "p.A a;"])); |
| 2660 resolve(source); | 2699 resolve(source); |
| 2661 assertNoErrors(); | 2700 assertNoErrors(source); |
| 2662 verify([source]); | 2701 verify([source]); |
| 2663 } | 2702 } |
| 2664 void test_proxy_annotation_prefixed() { | 2703 void test_proxy_annotation_prefixed() { |
| 2665 Source source = addSource(EngineTestCase.createSource([ | 2704 Source source = addSource(EngineTestCase.createSource([ |
| 2666 "library L;", | 2705 "library L;", |
| 2667 "import 'meta.dart';", | 2706 "import 'meta.dart';", |
| 2668 "@proxy", | 2707 "@proxy", |
| 2669 "class A {}", | 2708 "class A {}", |
| 2670 "f(A a) {", | 2709 "f(A a) {", |
| 2671 " a.m();", | 2710 " a.m();", |
| 2672 " var x = a.g;", | 2711 " var x = a.g;", |
| 2673 " a.s = 1;", | 2712 " a.s = 1;", |
| 2674 " var y = a + a;", | 2713 " var y = a + a;", |
| 2675 " a++;", | 2714 " a++;", |
| 2676 " ++a;", | 2715 " ++a;", |
| 2677 "}"])); | 2716 "}"])); |
| 2678 addSource2("/meta.dart", EngineTestCase.createSource([ | 2717 addSource2("/meta.dart", EngineTestCase.createSource([ |
| 2679 "library meta;", | 2718 "library meta;", |
| 2680 "const proxy = const _Proxy();", | 2719 "const proxy = const _Proxy();", |
| 2681 "class _Proxy { const _Proxy(); }"])); | 2720 "class _Proxy { const _Proxy(); }"])); |
| 2682 resolve(source); | 2721 resolve(source); |
| 2683 assertNoErrors(); | 2722 assertNoErrors(source); |
| 2684 } | 2723 } |
| 2685 void test_proxy_annotation_prefixed2() { | 2724 void test_proxy_annotation_prefixed2() { |
| 2686 Source source = addSource(EngineTestCase.createSource([ | 2725 Source source = addSource(EngineTestCase.createSource([ |
| 2687 "library L;", | 2726 "library L;", |
| 2688 "import 'meta.dart';", | 2727 "import 'meta.dart';", |
| 2689 "@proxy", | 2728 "@proxy", |
| 2690 "class A {}", | 2729 "class A {}", |
| 2691 "class B {", | 2730 "class B {", |
| 2692 " f(A a) {", | 2731 " f(A a) {", |
| 2693 " a.m();", | 2732 " a.m();", |
| 2694 " var x = a.g;", | 2733 " var x = a.g;", |
| 2695 " a.s = 1;", | 2734 " a.s = 1;", |
| 2696 " var y = a + a;", | 2735 " var y = a + a;", |
| 2697 " a++;", | 2736 " a++;", |
| 2698 " ++a;", | 2737 " ++a;", |
| 2699 " }", | 2738 " }", |
| 2700 "}"])); | 2739 "}"])); |
| 2701 addSource2("/meta.dart", EngineTestCase.createSource([ | 2740 addSource2("/meta.dart", EngineTestCase.createSource([ |
| 2702 "library meta;", | 2741 "library meta;", |
| 2703 "const proxy = const _Proxy();", | 2742 "const proxy = const _Proxy();", |
| 2704 "class _Proxy { const _Proxy(); }"])); | 2743 "class _Proxy { const _Proxy(); }"])); |
| 2705 resolve(source); | 2744 resolve(source); |
| 2706 assertNoErrors(); | 2745 assertNoErrors(source); |
| 2707 } | 2746 } |
| 2708 void test_proxy_annotation_prefixed3() { | 2747 void test_proxy_annotation_prefixed3() { |
| 2709 Source source = addSource(EngineTestCase.createSource([ | 2748 Source source = addSource(EngineTestCase.createSource([ |
| 2710 "library L;", | 2749 "library L;", |
| 2711 "import 'meta.dart';", | 2750 "import 'meta.dart';", |
| 2712 "class B {", | 2751 "class B {", |
| 2713 " f(A a) {", | 2752 " f(A a) {", |
| 2714 " a.m();", | 2753 " a.m();", |
| 2715 " var x = a.g;", | 2754 " var x = a.g;", |
| 2716 " a.s = 1;", | 2755 " a.s = 1;", |
| 2717 " var y = a + a;", | 2756 " var y = a + a;", |
| 2718 " a++;", | 2757 " a++;", |
| 2719 " ++a;", | 2758 " ++a;", |
| 2720 " }", | 2759 " }", |
| 2721 "}", | 2760 "}", |
| 2722 "@proxy", | 2761 "@proxy", |
| 2723 "class A {}"])); | 2762 "class A {}"])); |
| 2724 addSource2("/meta.dart", EngineTestCase.createSource([ | 2763 addSource2("/meta.dart", EngineTestCase.createSource([ |
| 2725 "library meta;", | 2764 "library meta;", |
| 2726 "const proxy = const _Proxy();", | 2765 "const proxy = const _Proxy();", |
| 2727 "class _Proxy { const _Proxy(); }"])); | 2766 "class _Proxy { const _Proxy(); }"])); |
| 2728 resolve(source); | 2767 resolve(source); |
| 2729 assertNoErrors(); | 2768 assertNoErrors(source); |
| 2730 } | 2769 } |
| 2731 void test_proxy_annotation_simple() { | 2770 void test_proxy_annotation_simple() { |
| 2732 Source source = addSource(EngineTestCase.createSource([ | 2771 Source source = addSource(EngineTestCase.createSource([ |
| 2733 "library L;", | 2772 "library L;", |
| 2734 "import 'meta.dart';", | 2773 "import 'meta.dart';", |
| 2735 "@proxy", | 2774 "@proxy", |
| 2736 "class B {", | 2775 "class B {", |
| 2737 " m() {", | 2776 " m() {", |
| 2738 " n();", | 2777 " n();", |
| 2739 " var x = g;", | 2778 " var x = g;", |
| 2740 " s = 1;", | 2779 " s = 1;", |
| 2741 " var y = this + this;", | 2780 " var y = this + this;", |
| 2742 " }", | 2781 " }", |
| 2743 "}"])); | 2782 "}"])); |
| 2744 addSource2("/meta.dart", EngineTestCase.createSource([ | 2783 addSource2("/meta.dart", EngineTestCase.createSource([ |
| 2745 "library meta;", | 2784 "library meta;", |
| 2746 "const proxy = const _Proxy();", | 2785 "const proxy = const _Proxy();", |
| 2747 "class _Proxy { const _Proxy(); }"])); | 2786 "class _Proxy { const _Proxy(); }"])); |
| 2748 resolve(source); | 2787 resolve(source); |
| 2749 assertNoErrors(); | 2788 assertNoErrors(source); |
| 2750 } | 2789 } |
| 2751 void test_recursiveConstructorRedirect() { | 2790 void test_recursiveConstructorRedirect() { |
| 2752 Source source = addSource(EngineTestCase.createSource([ | 2791 Source source = addSource(EngineTestCase.createSource([ |
| 2753 "class A {", | 2792 "class A {", |
| 2754 " A.a() : this.b();", | 2793 " A.a() : this.b();", |
| 2755 " A.b() : this.c();", | 2794 " A.b() : this.c();", |
| 2756 " A.c() {}", | 2795 " A.c() {}", |
| 2757 "}"])); | 2796 "}"])); |
| 2758 resolve(source); | 2797 resolve(source); |
| 2759 assertNoErrors(); | 2798 assertNoErrors(source); |
| 2760 verify([source]); | 2799 verify([source]); |
| 2761 } | 2800 } |
| 2762 void test_recursiveFactoryRedirect() { | 2801 void test_recursiveFactoryRedirect() { |
| 2763 Source source = addSource(EngineTestCase.createSource([ | 2802 Source source = addSource(EngineTestCase.createSource([ |
| 2764 "class A {", | 2803 "class A {", |
| 2765 " factory A() = B;", | 2804 " factory A() = B;", |
| 2766 "}", | 2805 "}", |
| 2767 "class B implements A {", | 2806 "class B implements A {", |
| 2768 " factory B() = C;", | 2807 " factory B() = C;", |
| 2769 "}", | 2808 "}", |
| 2770 "class C implements B {", | 2809 "class C implements B {", |
| 2771 " factory C() {}", | 2810 " factory C() {}", |
| 2772 "}"])); | 2811 "}"])); |
| 2773 resolve(source); | 2812 resolve(source); |
| 2774 assertNoErrors(); | 2813 assertNoErrors(source); |
| 2775 verify([source]); | 2814 verify([source]); |
| 2776 } | 2815 } |
| 2777 void test_redirectToInvalidFunctionType() { | 2816 void test_redirectToInvalidFunctionType() { |
| 2778 Source source = addSource(EngineTestCase.createSource([ | 2817 Source source = addSource(EngineTestCase.createSource([ |
| 2779 "class A implements B {", | 2818 "class A implements B {", |
| 2780 " A(int p) {}", | 2819 " A(int p) {}", |
| 2781 "}", | 2820 "}", |
| 2782 "class B {", | 2821 "class B {", |
| 2783 " factory B(int p) = A;", | 2822 " factory B(int p) = A;", |
| 2784 "}"])); | 2823 "}"])); |
| 2785 resolve(source); | 2824 resolve(source); |
| 2786 assertNoErrors(); | 2825 assertNoErrors(source); |
| 2787 verify([source]); | 2826 verify([source]); |
| 2788 } | 2827 } |
| 2789 void test_redirectToNonConstConstructor() { | 2828 void test_redirectToNonConstConstructor() { |
| 2790 Source source = addSource(EngineTestCase.createSource([ | 2829 Source source = addSource(EngineTestCase.createSource([ |
| 2791 "class A {", | 2830 "class A {", |
| 2792 " const A.a();", | 2831 " const A.a();", |
| 2793 " const factory A.b() = A.a;", | 2832 " const factory A.b() = A.a;", |
| 2794 "}"])); | 2833 "}"])); |
| 2795 resolve(source); | 2834 resolve(source); |
| 2796 assertNoErrors(); | 2835 assertNoErrors(source); |
| 2797 verify([source]); | 2836 verify([source]); |
| 2798 } | 2837 } |
| 2799 void test_referenceToDeclaredVariableInInitializer_constructorName() { | 2838 void test_referenceToDeclaredVariableInInitializer_constructorName() { |
| 2800 Source source = addSource(EngineTestCase.createSource([ | 2839 Source source = addSource(EngineTestCase.createSource([ |
| 2801 "class A {", | 2840 "class A {", |
| 2802 " A.x() {}", | 2841 " A.x() {}", |
| 2803 "}", | 2842 "}", |
| 2804 "f() {", | 2843 "f() {", |
| 2805 " var x = new A.x();", | 2844 " var x = new A.x();", |
| 2806 "}"])); | 2845 "}"])); |
| 2807 resolve(source); | 2846 resolve(source); |
| 2808 assertNoErrors(); | 2847 assertNoErrors(source); |
| 2809 verify([source]); | 2848 verify([source]); |
| 2810 } | 2849 } |
| 2811 void test_referenceToDeclaredVariableInInitializer_methodName() { | 2850 void test_referenceToDeclaredVariableInInitializer_methodName() { |
| 2812 Source source = addSource(EngineTestCase.createSource([ | 2851 Source source = addSource(EngineTestCase.createSource([ |
| 2813 "class A {", | 2852 "class A {", |
| 2814 " x() {}", | 2853 " x() {}", |
| 2815 "}", | 2854 "}", |
| 2816 "f(A a) {", | 2855 "f(A a) {", |
| 2817 " var x = a.x();", | 2856 " var x = a.x();", |
| 2818 "}"])); | 2857 "}"])); |
| 2819 resolve(source); | 2858 resolve(source); |
| 2820 assertNoErrors(); | 2859 assertNoErrors(source); |
| 2821 verify([source]); | 2860 verify([source]); |
| 2822 } | 2861 } |
| 2823 void test_referenceToDeclaredVariableInInitializer_propertyName() { | 2862 void test_referenceToDeclaredVariableInInitializer_propertyName() { |
| 2824 Source source = addSource(EngineTestCase.createSource([ | 2863 Source source = addSource(EngineTestCase.createSource([ |
| 2825 "class A {", | 2864 "class A {", |
| 2826 " var x;", | 2865 " var x;", |
| 2827 "}", | 2866 "}", |
| 2828 "f(A a) {", | 2867 "f(A a) {", |
| 2829 " var x = a.x;", | 2868 " var x = a.x;", |
| 2830 "}"])); | 2869 "}"])); |
| 2831 resolve(source); | 2870 resolve(source); |
| 2832 assertNoErrors(); | 2871 assertNoErrors(source); |
| 2833 verify([source]); | 2872 verify([source]); |
| 2834 } | 2873 } |
| 2835 void test_rethrowOutsideCatch() { | 2874 void test_rethrowOutsideCatch() { |
| 2836 Source source = addSource(EngineTestCase.createSource([ | 2875 Source source = addSource(EngineTestCase.createSource([ |
| 2837 "class A {", | 2876 "class A {", |
| 2838 " void m() {", | 2877 " void m() {", |
| 2839 " try {} catch (e) {rethrow;}", | 2878 " try {} catch (e) {rethrow;}", |
| 2840 " }", | 2879 " }", |
| 2841 "}"])); | 2880 "}"])); |
| 2842 resolve(source); | 2881 resolve(source); |
| 2843 assertNoErrors(); | 2882 assertNoErrors(source); |
| 2844 verify([source]); | 2883 verify([source]); |
| 2845 } | 2884 } |
| 2846 void test_returnInGenerativeConstructor() { | 2885 void test_returnInGenerativeConstructor() { |
| 2847 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
return; }", "}"])); | 2886 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
return; }", "}"])); |
| 2848 resolve(source); | 2887 resolve(source); |
| 2849 assertNoErrors(); | 2888 assertNoErrors(source); |
| 2850 verify([source]); | 2889 verify([source]); |
| 2851 } | 2890 } |
| 2852 void test_returnOfInvalidType_dynamic() { | 2891 void test_returnOfInvalidType_dynamic() { |
| 2853 Source source = addSource(EngineTestCase.createSource([ | 2892 Source source = addSource(EngineTestCase.createSource([ |
| 2854 "class TypeError {}", | 2893 "class TypeError {}", |
| 2855 "class A {", | 2894 "class A {", |
| 2856 " static void testLogicalOp() {", | 2895 " static void testLogicalOp() {", |
| 2857 " testOr(a, b, onTypeError) {", | 2896 " testOr(a, b, onTypeError) {", |
| 2858 " try {", | 2897 " try {", |
| 2859 " return a || b;", | 2898 " return a || b;", |
| 2860 " } on TypeError catch (t) {", | 2899 " } on TypeError catch (t) {", |
| 2861 " return onTypeError;", | 2900 " return onTypeError;", |
| 2862 " }", | 2901 " }", |
| 2863 " }", | 2902 " }", |
| 2864 " }", | 2903 " }", |
| 2865 "}"])); | 2904 "}"])); |
| 2866 resolve(source); | 2905 resolve(source); |
| 2867 assertNoErrors(); | 2906 assertNoErrors(source); |
| 2868 verify([source]); | 2907 verify([source]); |
| 2869 } | 2908 } |
| 2870 void test_returnOfInvalidType_dynamicAsTypeArgument() { | 2909 void test_returnOfInvalidType_dynamicAsTypeArgument() { |
| 2871 Source source = addSource(EngineTestCase.createSource([ | 2910 Source source = addSource(EngineTestCase.createSource([ |
| 2872 "class I<T> {", | 2911 "class I<T> {", |
| 2873 " factory I() => new A<T>();", | 2912 " factory I() => new A<T>();", |
| 2874 "}", | 2913 "}", |
| 2875 "class A<T> implements I {", | 2914 "class A<T> implements I {", |
| 2876 "}"])); | 2915 "}"])); |
| 2877 resolve(source); | 2916 resolve(source); |
| 2878 assertNoErrors(); | 2917 assertNoErrors(source); |
| 2879 verify([source]); | 2918 verify([source]); |
| 2880 } | 2919 } |
| 2881 void test_returnOfInvalidType_subtype() { | 2920 void test_returnOfInvalidType_subtype() { |
| 2882 Source source = addSource(EngineTestCase.createSource([ | 2921 Source source = addSource(EngineTestCase.createSource([ |
| 2883 "class A {}", | 2922 "class A {}", |
| 2884 "class B extends A {}", | 2923 "class B extends A {}", |
| 2885 "A f(B b) { return b; }"])); | 2924 "A f(B b) { return b; }"])); |
| 2886 resolve(source); | 2925 resolve(source); |
| 2887 assertNoErrors(); | 2926 assertNoErrors(source); |
| 2888 verify([source]); | 2927 verify([source]); |
| 2889 } | 2928 } |
| 2890 void test_returnOfInvalidType_supertype() { | 2929 void test_returnOfInvalidType_supertype() { |
| 2891 Source source = addSource(EngineTestCase.createSource([ | 2930 Source source = addSource(EngineTestCase.createSource([ |
| 2892 "class A {}", | 2931 "class A {}", |
| 2893 "class B extends A {}", | 2932 "class B extends A {}", |
| 2894 "B f(A a) { return a; }"])); | 2933 "B f(A a) { return a; }"])); |
| 2895 resolve(source); | 2934 resolve(source); |
| 2896 assertNoErrors(); | 2935 assertNoErrors(source); |
| 2897 verify([source]); | 2936 verify([source]); |
| 2898 } | 2937 } |
| 2899 void test_returnOfInvalidType_void() { | 2938 void test_returnOfInvalidType_void() { |
| 2900 Source source = addSource(EngineTestCase.createSource([ | 2939 Source source = addSource(EngineTestCase.createSource([ |
| 2901 "void f1() {}", | 2940 "void f1() {}", |
| 2902 "void f2() { return; }", | 2941 "void f2() { return; }", |
| 2903 "void f3() { return null; }", | 2942 "void f3() { return null; }", |
| 2904 "void f4() { return g1(); }", | 2943 "void f4() { return g1(); }", |
| 2905 "void f5() { return g2(); }", | 2944 "void f5() { return g2(); }", |
| 2906 "g1() {}", | 2945 "g1() {}", |
| 2907 "void g2() {}", | 2946 "void g2() {}", |
| 2908 ""])); | 2947 ""])); |
| 2909 resolve(source); | 2948 resolve(source); |
| 2910 assertNoErrors(); | 2949 assertNoErrors(source); |
| 2911 verify([source]); | 2950 verify([source]); |
| 2912 } | 2951 } |
| 2913 void test_returnWithoutValue_noReturnType() { | 2952 void test_returnWithoutValue_noReturnType() { |
| 2914 Source source = addSource(EngineTestCase.createSource(["f() { return; }"])); | 2953 Source source = addSource(EngineTestCase.createSource(["f() { return; }"])); |
| 2915 resolve(source); | 2954 resolve(source); |
| 2916 assertNoErrors(); | 2955 assertNoErrors(source); |
| 2917 verify([source]); | 2956 verify([source]); |
| 2918 } | 2957 } |
| 2919 void test_returnWithoutValue_void() { | 2958 void test_returnWithoutValue_void() { |
| 2920 Source source = addSource(EngineTestCase.createSource(["void f() { return; }
"])); | 2959 Source source = addSource(EngineTestCase.createSource(["void f() { return; }
"])); |
| 2921 resolve(source); | 2960 resolve(source); |
| 2922 assertNoErrors(); | 2961 assertNoErrors(source); |
| 2923 verify([source]); | 2962 verify([source]); |
| 2924 } | 2963 } |
| 2925 void test_staticAccessToInstanceMember_annotation() { | 2964 void test_staticAccessToInstanceMember_annotation() { |
| 2926 Source source = addSource(EngineTestCase.createSource([ | 2965 Source source = addSource(EngineTestCase.createSource([ |
| 2927 "class A {", | 2966 "class A {", |
| 2928 " const A.name();", | 2967 " const A.name();", |
| 2929 "}", | 2968 "}", |
| 2930 "@A.name()", | 2969 "@A.name()", |
| 2931 "main() {", | 2970 "main() {", |
| 2932 "}"])); | 2971 "}"])); |
| 2933 resolve(source); | 2972 resolve(source); |
| 2934 assertNoErrors(); | 2973 assertNoErrors(source); |
| 2935 verify([source]); | 2974 verify([source]); |
| 2936 } | 2975 } |
| 2937 void test_staticAccessToInstanceMember_method() { | 2976 void test_staticAccessToInstanceMember_method() { |
| 2938 Source source = addSource(EngineTestCase.createSource([ | 2977 Source source = addSource(EngineTestCase.createSource([ |
| 2939 "class A {", | 2978 "class A {", |
| 2940 " static m() {}", | 2979 " static m() {}", |
| 2941 "}", | 2980 "}", |
| 2942 "main() {", | 2981 "main() {", |
| 2943 " A.m;", | 2982 " A.m;", |
| 2944 " A.m();", | 2983 " A.m();", |
| 2945 "}"])); | 2984 "}"])); |
| 2946 resolve(source); | 2985 resolve(source); |
| 2947 assertNoErrors(); | 2986 assertNoErrors(source); |
| 2948 verify([source]); | 2987 verify([source]); |
| 2949 } | 2988 } |
| 2950 void test_staticAccessToInstanceMember_propertyAccess_field() { | 2989 void test_staticAccessToInstanceMember_propertyAccess_field() { |
| 2951 Source source = addSource(EngineTestCase.createSource([ | 2990 Source source = addSource(EngineTestCase.createSource([ |
| 2952 "class A {", | 2991 "class A {", |
| 2953 " static var f;", | 2992 " static var f;", |
| 2954 "}", | 2993 "}", |
| 2955 "main() {", | 2994 "main() {", |
| 2956 " A.f;", | 2995 " A.f;", |
| 2957 " A.f = 1;", | 2996 " A.f = 1;", |
| 2958 "}"])); | 2997 "}"])); |
| 2959 resolve(source); | 2998 resolve(source); |
| 2960 assertNoErrors(); | 2999 assertNoErrors(source); |
| 2961 verify([source]); | 3000 verify([source]); |
| 2962 } | 3001 } |
| 2963 void test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() { | 3002 void test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() { |
| 2964 Source source = addSource(EngineTestCase.createSource([ | 3003 Source source = addSource(EngineTestCase.createSource([ |
| 2965 "class A {", | 3004 "class A {", |
| 2966 " static get f => 42;", | 3005 " static get f => 42;", |
| 2967 " static set f(x) {}", | 3006 " static set f(x) {}", |
| 2968 "}", | 3007 "}", |
| 2969 "main() {", | 3008 "main() {", |
| 2970 " A.f;", | 3009 " A.f;", |
| 2971 " A.f = 1;", | 3010 " A.f = 1;", |
| 2972 "}"])); | 3011 "}"])); |
| 2973 resolve(source); | 3012 resolve(source); |
| 2974 assertNoErrors(); | 3013 assertNoErrors(source); |
| 2975 verify([source]); | 3014 verify([source]); |
| 2976 } | 3015 } |
| 2977 void test_superInInvalidContext() { | 3016 void test_superInInvalidContext() { |
| 2978 Source source = addSource(EngineTestCase.createSource([ | 3017 Source source = addSource(EngineTestCase.createSource([ |
| 2979 "class A {", | 3018 "class A {", |
| 2980 " m() {}", | 3019 " m() {}", |
| 2981 "}", | 3020 "}", |
| 2982 "class B extends A {", | 3021 "class B extends A {", |
| 2983 " B() {", | 3022 " B() {", |
| 2984 " var v = super.m();", | 3023 " var v = super.m();", |
| 2985 " }", | 3024 " }", |
| 2986 " n() {", | 3025 " n() {", |
| 2987 " var v = super.m();", | 3026 " var v = super.m();", |
| 2988 " }", | 3027 " }", |
| 2989 "}"])); | 3028 "}"])); |
| 2990 resolve(source); | 3029 resolve(source); |
| 2991 assertNoErrors(); | 3030 assertNoErrors(source); |
| 2992 verify([source]); | 3031 verify([source]); |
| 2993 } | 3032 } |
| 2994 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { | 3033 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { |
| 2995 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "cl
ass B {", " A a;", "}"])); | 3034 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "cl
ass B {", " A a;", "}"])); |
| 2996 resolve(source); | 3035 resolve(source); |
| 2997 assertNoErrors(); | 3036 assertNoErrors(source); |
| 2998 verify([source]); | 3037 verify([source]); |
| 2999 } | 3038 } |
| 3000 void test_typeAliasCannotReferenceItself_typeVariableBounds() { | 3039 void test_typeAliasCannotReferenceItself_typeParameterBounds() { |
| 3001 Source source = addSource(EngineTestCase.createSource(["typedef A<T extends
A>();"])); | 3040 Source source = addSource(EngineTestCase.createSource(["typedef A<T extends
A>();"])); |
| 3002 resolve(source); | 3041 resolve(source); |
| 3003 assertNoErrors(); | 3042 assertNoErrors(source); |
| 3004 verify([source]); | 3043 verify([source]); |
| 3005 } | 3044 } |
| 3006 void test_typeArgumentNotMatchingBounds_const() { | 3045 void test_typeArgumentNotMatchingBounds_const() { |
| 3007 Source source = addSource(EngineTestCase.createSource([ | 3046 Source source = addSource(EngineTestCase.createSource([ |
| 3008 "class A {}", | 3047 "class A {}", |
| 3009 "class B extends A {}", | 3048 "class B extends A {}", |
| 3010 "class G<E extends A> {", | 3049 "class G<E extends A> {", |
| 3011 " const G();", | 3050 " const G();", |
| 3012 "}", | 3051 "}", |
| 3013 "f() { return const G<B>(); }"])); | 3052 "f() { return const G<B>(); }"])); |
| 3014 resolve(source); | 3053 resolve(source); |
| 3015 assertNoErrors(); | 3054 assertNoErrors(source); |
| 3016 verify([source]); | 3055 verify([source]); |
| 3017 } | 3056 } |
| 3018 void test_typeArgumentNotMatchingBounds_new() { | 3057 void test_typeArgumentNotMatchingBounds_new() { |
| 3019 Source source = addSource(EngineTestCase.createSource([ | 3058 Source source = addSource(EngineTestCase.createSource([ |
| 3020 "class A {}", | 3059 "class A {}", |
| 3021 "class B extends A {}", | 3060 "class B extends A {}", |
| 3022 "class G<E extends A> {}", | 3061 "class G<E extends A> {}", |
| 3023 "f() { return new G<B>(); }"])); | 3062 "f() { return new G<B>(); }"])); |
| 3024 resolve(source); | 3063 resolve(source); |
| 3025 assertNoErrors(); | 3064 assertNoErrors(source); |
| 3026 verify([source]); | 3065 verify([source]); |
| 3027 } | 3066 } |
| 3028 void test_typeArgumentNotMatchingBounds_typeArgumentList_0() { | 3067 void test_typeArgumentNotMatchingBounds_typeArgumentList_0() { |
| 3029 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A>{}"])); | 3068 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A>{}"])); |
| 3030 resolve(source); | 3069 resolve(source); |
| 3031 assertNoErrors(); | 3070 assertNoErrors(source); |
| 3032 verify([source]); | 3071 verify([source]); |
| 3033 } | 3072 } |
| 3034 void test_typeArgumentNotMatchingBounds_typeArgumentList_1() { | 3073 void test_typeArgumentNotMatchingBounds_typeArgumentList_1() { |
| 3035 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A<A>>{}"])); | 3074 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e
xtends A<A>>{}"])); |
| 3036 resolve(source); | 3075 resolve(source); |
| 3037 assertNoErrors(); | 3076 assertNoErrors(source); |
| 3038 verify([source]); | 3077 verify([source]); |
| 3039 } | 3078 } |
| 3040 void test_typeArgumentNotMatchingBounds_typeArgumentList_20() { | 3079 void test_typeArgumentNotMatchingBounds_typeArgumentList_20() { |
| 3041 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>>>>>>>>>>>>>>>>>>>>>{}"])); | 3080 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>>>>>>>>>>>>>>>>>>>>>{}"])); |
| 3042 resolve(source); | 3081 resolve(source); |
| 3043 assertNoErrors(); | 3082 assertNoErrors(source); |
| 3044 verify([source]); | 3083 verify([source]); |
| 3045 } | 3084 } |
| 3046 void test_undefinedConstructorInInitializer_explicit_named() { | 3085 void test_undefinedConstructorInInitializer_explicit_named() { |
| 3047 Source source = addSource(EngineTestCase.createSource([ | 3086 Source source = addSource(EngineTestCase.createSource([ |
| 3048 "class A {", | 3087 "class A {", |
| 3049 " A.named() {}", | 3088 " A.named() {}", |
| 3050 "}", | 3089 "}", |
| 3051 "class B extends A {", | 3090 "class B extends A {", |
| 3052 " B() : super.named();", | 3091 " B() : super.named();", |
| 3053 "}"])); | 3092 "}"])); |
| 3054 resolve(source); | 3093 resolve(source); |
| 3055 assertNoErrors(); | 3094 assertNoErrors(source); |
| 3056 verify([source]); | 3095 verify([source]); |
| 3057 } | 3096 } |
| 3058 void test_undefinedConstructorInInitializer_explicit_unnamed() { | 3097 void test_undefinedConstructorInInitializer_explicit_unnamed() { |
| 3059 Source source = addSource(EngineTestCase.createSource([ | 3098 Source source = addSource(EngineTestCase.createSource([ |
| 3060 "class A {", | 3099 "class A {", |
| 3061 " A() {}", | 3100 " A() {}", |
| 3062 "}", | 3101 "}", |
| 3063 "class B extends A {", | 3102 "class B extends A {", |
| 3064 " B() : super();", | 3103 " B() : super();", |
| 3065 "}"])); | 3104 "}"])); |
| 3066 resolve(source); | 3105 resolve(source); |
| 3067 assertNoErrors(); | 3106 assertNoErrors(source); |
| 3068 verify([source]); | 3107 verify([source]); |
| 3069 } | 3108 } |
| 3070 void test_undefinedConstructorInInitializer_hasOptionalParameters() { | 3109 void test_undefinedConstructorInInitializer_hasOptionalParameters() { |
| 3071 Source source = addSource(EngineTestCase.createSource([ | 3110 Source source = addSource(EngineTestCase.createSource([ |
| 3072 "class A {", | 3111 "class A {", |
| 3073 " A([p]) {}", | 3112 " A([p]) {}", |
| 3074 "}", | 3113 "}", |
| 3075 "class B extends A {", | 3114 "class B extends A {", |
| 3076 " B();", | 3115 " B();", |
| 3077 "}"])); | 3116 "}"])); |
| 3078 resolve(source); | 3117 resolve(source); |
| 3079 assertNoErrors(); | 3118 assertNoErrors(source); |
| 3080 verify([source]); | 3119 verify([source]); |
| 3081 } | 3120 } |
| 3082 void test_undefinedConstructorInInitializer_implicit() { | 3121 void test_undefinedConstructorInInitializer_implicit() { |
| 3083 Source source = addSource(EngineTestCase.createSource([ | 3122 Source source = addSource(EngineTestCase.createSource([ |
| 3084 "class A {", | 3123 "class A {", |
| 3085 " A() {}", | 3124 " A() {}", |
| 3086 "}", | 3125 "}", |
| 3087 "class B extends A {", | 3126 "class B extends A {", |
| 3088 " B();", | 3127 " B();", |
| 3089 "}"])); | 3128 "}"])); |
| 3090 resolve(source); | 3129 resolve(source); |
| 3091 assertNoErrors(); | 3130 assertNoErrors(source); |
| 3092 verify([source]); | 3131 verify([source]); |
| 3093 } | 3132 } |
| 3094 void test_undefinedConstructorInInitializer_implicit_typedef() { | 3133 void test_undefinedConstructorInInitializer_implicit_typedef() { |
| 3095 Source source = addSource(EngineTestCase.createSource([ | 3134 Source source = addSource(EngineTestCase.createSource([ |
| 3096 "class M {}", | 3135 "class M {}", |
| 3097 "typedef A = Object with M;", | 3136 "typedef A = Object with M;", |
| 3098 "class B extends A {", | 3137 "class B extends A {", |
| 3099 " B();", | 3138 " B();", |
| 3100 "}"])); | 3139 "}"])); |
| 3101 resolve(source); | 3140 resolve(source); |
| 3102 assertNoErrors(); | 3141 assertNoErrors(source); |
| 3103 verify([source]); | 3142 verify([source]); |
| 3104 } | 3143 } |
| 3105 void test_undefinedConstructorInInitializer_redirecting() { | 3144 void test_undefinedConstructorInInitializer_redirecting() { |
| 3106 Source source = addSource(EngineTestCase.createSource([ | 3145 Source source = addSource(EngineTestCase.createSource([ |
| 3107 "class Foo {", | 3146 "class Foo {", |
| 3108 " Foo.ctor();", | 3147 " Foo.ctor();", |
| 3109 "}", | 3148 "}", |
| 3110 "class Bar extends Foo {", | 3149 "class Bar extends Foo {", |
| 3111 " Bar() : this.ctor();", | 3150 " Bar() : this.ctor();", |
| 3112 " Bar.ctor() : super.ctor();", | 3151 " Bar.ctor() : super.ctor();", |
| 3113 "}"])); | 3152 "}"])); |
| 3114 resolve(source); | 3153 resolve(source); |
| 3115 assertNoErrors(); | 3154 assertNoErrors(source); |
| 3116 verify([source]); | 3155 verify([source]); |
| 3117 } | 3156 } |
| 3118 void test_undefinedGetter_typeSubstitution() { | 3157 void test_undefinedGetter_typeSubstitution() { |
| 3119 Source source = addSource(EngineTestCase.createSource([ | 3158 Source source = addSource(EngineTestCase.createSource([ |
| 3120 "class A<E> {", | 3159 "class A<E> {", |
| 3121 " E element;", | 3160 " E element;", |
| 3122 "}", | 3161 "}", |
| 3123 "class B extends A<List> {", | 3162 "class B extends A<List> {", |
| 3124 " m() {", | 3163 " m() {", |
| 3125 " element.last;", | 3164 " element.last;", |
| 3126 " }", | 3165 " }", |
| 3127 "}"])); | 3166 "}"])); |
| 3128 resolve(source); | 3167 resolve(source); |
| 3129 assertNoErrors(); | 3168 assertNoErrors(source); |
| 3130 verify([source]); | 3169 verify([source]); |
| 3131 } | 3170 } |
| 3132 void test_undefinedIdentifier_hide() { | 3171 void test_undefinedIdentifier_hide() { |
| 3133 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart' hide a;"])); | 3172 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart' hide a;"])); |
| 3134 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); | 3173 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); |
| 3135 resolve(source); | 3174 resolve(source); |
| 3136 assertNoErrors(); | 3175 assertNoErrors(source); |
| 3137 verify([source]); | 3176 verify([source]); |
| 3138 } | 3177 } |
| 3139 void test_undefinedIdentifier_show() { | 3178 void test_undefinedIdentifier_show() { |
| 3140 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart' show a;"])); | 3179 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart' show a;"])); |
| 3141 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); | 3180 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); |
| 3142 resolve(source); | 3181 resolve(source); |
| 3143 assertNoErrors(); | 3182 assertNoErrors(source); |
| 3144 verify([source]); | 3183 verify([source]); |
| 3145 } | 3184 } |
| 3146 void test_undefinedMethod_functionExpression_callMethod() { | 3185 void test_undefinedMethod_functionExpression_callMethod() { |
| 3147 Source source = addSource(EngineTestCase.createSource(["main() {", " (() =>
null).call();", "}"])); | 3186 Source source = addSource(EngineTestCase.createSource(["main() {", " (() =>
null).call();", "}"])); |
| 3148 resolve(source); | 3187 resolve(source); |
| 3149 assertNoErrors(); | 3188 assertNoErrors(source); |
| 3150 } | 3189 } |
| 3151 void test_undefinedMethod_functionExpression_directCall() { | 3190 void test_undefinedMethod_functionExpression_directCall() { |
| 3152 Source source = addSource(EngineTestCase.createSource(["main() {", " (() =>
null)();", "}"])); | 3191 Source source = addSource(EngineTestCase.createSource(["main() {", " (() =>
null)();", "}"])); |
| 3153 resolve(source); | 3192 resolve(source); |
| 3154 assertNoErrors(); | 3193 assertNoErrors(source); |
| 3155 } | 3194 } |
| 3156 void test_undefinedOperator_index() { | 3195 void test_undefinedOperator_index() { |
| 3157 Source source = addSource(EngineTestCase.createSource([ | 3196 Source source = addSource(EngineTestCase.createSource([ |
| 3158 "class A {", | 3197 "class A {", |
| 3159 " operator [](a) {}", | 3198 " operator [](a) {}", |
| 3160 " operator []=(a, b) {}", | 3199 " operator []=(a, b) {}", |
| 3161 "}", | 3200 "}", |
| 3162 "f(A a) {", | 3201 "f(A a) {", |
| 3163 " a[0];", | 3202 " a[0];", |
| 3164 " a[0] = 1;", | 3203 " a[0] = 1;", |
| 3165 "}"])); | 3204 "}"])); |
| 3166 resolve(source); | 3205 resolve(source); |
| 3167 assertNoErrors(); | 3206 assertNoErrors(source); |
| 3168 verify([source]); | 3207 verify([source]); |
| 3169 } | 3208 } |
| 3170 void test_undefinedOperator_tilde() { | 3209 void test_undefinedOperator_tilde() { |
| 3171 Source source = addSource(EngineTestCase.createSource(["const A = 3;", "cons
t B = ~((1 << A) - 1);"])); | 3210 Source source = addSource(EngineTestCase.createSource(["const A = 3;", "cons
t B = ~((1 << A) - 1);"])); |
| 3172 resolve(source); | 3211 resolve(source); |
| 3173 assertNoErrors(); | 3212 assertNoErrors(source); |
| 3174 verify([source]); | 3213 verify([source]); |
| 3175 } | 3214 } |
| 3176 void test_undefinedSetter_importWithPrefix() { | 3215 void test_undefinedSetter_importWithPrefix() { |
| 3177 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "set y(
int value) {}"])); | 3216 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "set y(
int value) {}"])); |
| 3178 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
x;", "main() {", " x.y = 0;", "}"])); | 3217 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
x;", "main() {", " x.y = 0;", "}"])); |
| 3179 resolve(source); | 3218 resolve(source); |
| 3180 assertNoErrors(); | 3219 assertNoErrors(source); |
| 3181 verify([source]); | 3220 verify([source]); |
| 3182 } | 3221 } |
| 3183 void test_undefinedSuperMethod_field() { | 3222 void test_undefinedSuperMethod_field() { |
| 3184 Source source = addSource(EngineTestCase.createSource([ | 3223 Source source = addSource(EngineTestCase.createSource([ |
| 3185 "class A {", | 3224 "class A {", |
| 3186 " var m;", | 3225 " var m;", |
| 3187 "}", | 3226 "}", |
| 3188 "class B extends A {", | 3227 "class B extends A {", |
| 3189 " f() {", | 3228 " f() {", |
| 3190 " super.m();", | 3229 " super.m();", |
| 3191 " }", | 3230 " }", |
| 3192 "}"])); | 3231 "}"])); |
| 3193 resolve(source); | 3232 resolve(source); |
| 3194 assertNoErrors(); | 3233 assertNoErrors(source); |
| 3195 verify([source]); | 3234 verify([source]); |
| 3196 } | 3235 } |
| 3197 void test_undefinedSuperMethod_method() { | 3236 void test_undefinedSuperMethod_method() { |
| 3198 Source source = addSource(EngineTestCase.createSource([ | 3237 Source source = addSource(EngineTestCase.createSource([ |
| 3199 "class A {", | 3238 "class A {", |
| 3200 " m() {}", | 3239 " m() {}", |
| 3201 "}", | 3240 "}", |
| 3202 "class B extends A {", | 3241 "class B extends A {", |
| 3203 " f() {", | 3242 " f() {", |
| 3204 " super.m();", | 3243 " super.m();", |
| 3205 " }", | 3244 " }", |
| 3206 "}"])); | 3245 "}"])); |
| 3207 resolve(source); | 3246 resolve(source); |
| 3208 assertNoErrors(); | 3247 assertNoErrors(source); |
| 3209 verify([source]); | 3248 verify([source]); |
| 3210 } | 3249 } |
| 3211 void test_wrongNumberOfParametersForOperator_index() { | 3250 void test_wrongNumberOfParametersForOperator_index() { |
| 3212 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor []=(a, b) {}", "}"])); | 3251 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor []=(a, b) {}", "}"])); |
| 3213 resolve(source); | 3252 resolve(source); |
| 3214 assertNoErrors(); | 3253 assertNoErrors(source); |
| 3215 verify([source]); | 3254 verify([source]); |
| 3216 } | 3255 } |
| 3217 void test_wrongNumberOfParametersForOperator_minus() { | 3256 void test_wrongNumberOfParametersForOperator_minus() { |
| 3218 check_wrongNumberOfParametersForOperator("-", ""); | 3257 check_wrongNumberOfParametersForOperator("-", ""); |
| 3219 check_wrongNumberOfParametersForOperator("-", "a"); | 3258 check_wrongNumberOfParametersForOperator("-", "a"); |
| 3220 } | 3259 } |
| 3221 void test_wrongNumberOfParametersForOperator1() { | 3260 void test_wrongNumberOfParametersForOperator1() { |
| 3222 check_wrongNumberOfParametersForOperator1("<"); | 3261 check_wrongNumberOfParametersForOperator1("<"); |
| 3223 check_wrongNumberOfParametersForOperator1(">"); | 3262 check_wrongNumberOfParametersForOperator1(">"); |
| 3224 check_wrongNumberOfParametersForOperator1("<="); | 3263 check_wrongNumberOfParametersForOperator1("<="); |
| 3225 check_wrongNumberOfParametersForOperator1(">="); | 3264 check_wrongNumberOfParametersForOperator1(">="); |
| 3226 check_wrongNumberOfParametersForOperator1("+"); | 3265 check_wrongNumberOfParametersForOperator1("+"); |
| 3227 check_wrongNumberOfParametersForOperator1("/"); | 3266 check_wrongNumberOfParametersForOperator1("/"); |
| 3228 check_wrongNumberOfParametersForOperator1("~/"); | 3267 check_wrongNumberOfParametersForOperator1("~/"); |
| 3229 check_wrongNumberOfParametersForOperator1("*"); | 3268 check_wrongNumberOfParametersForOperator1("*"); |
| 3230 check_wrongNumberOfParametersForOperator1("%"); | 3269 check_wrongNumberOfParametersForOperator1("%"); |
| 3231 check_wrongNumberOfParametersForOperator1("|"); | 3270 check_wrongNumberOfParametersForOperator1("|"); |
| 3232 check_wrongNumberOfParametersForOperator1("^"); | 3271 check_wrongNumberOfParametersForOperator1("^"); |
| 3233 check_wrongNumberOfParametersForOperator1("&"); | 3272 check_wrongNumberOfParametersForOperator1("&"); |
| 3234 check_wrongNumberOfParametersForOperator1("<<"); | 3273 check_wrongNumberOfParametersForOperator1("<<"); |
| 3235 check_wrongNumberOfParametersForOperator1(">>"); | 3274 check_wrongNumberOfParametersForOperator1(">>"); |
| 3236 check_wrongNumberOfParametersForOperator1("[]"); | 3275 check_wrongNumberOfParametersForOperator1("[]"); |
| 3237 } | 3276 } |
| 3238 void test_wrongNumberOfParametersForSetter() { | 3277 void test_wrongNumberOfParametersForSetter() { |
| 3239 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(a) {}", "}"])); | 3278 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(a) {}", "}"])); |
| 3240 resolve(source); | 3279 resolve(source); |
| 3241 assertNoErrors(); | 3280 assertNoErrors(source); |
| 3242 verify([source]); | 3281 verify([source]); |
| 3243 } | 3282 } |
| 3244 void check_wrongNumberOfParametersForOperator(String name, String parameters)
{ | 3283 void check_wrongNumberOfParametersForOperator(String name, String parameters)
{ |
| 3245 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor ${name}(${parameters}) {}", "}"])); | 3284 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor ${name}(${parameters}) {}", "}"])); |
| 3246 resolve(source); | 3285 resolve(source); |
| 3247 assertNoErrors(); | 3286 assertNoErrors(source); |
| 3248 verify([source]); | 3287 verify([source]); |
| 3249 reset(); | 3288 reset(); |
| 3250 } | 3289 } |
| 3251 void check_wrongNumberOfParametersForOperator1(String name) { | 3290 void check_wrongNumberOfParametersForOperator1(String name) { |
| 3252 check_wrongNumberOfParametersForOperator(name, "a"); | 3291 check_wrongNumberOfParametersForOperator(name, "a"); |
| 3253 } | 3292 } |
| 3254 static dartSuite() { | 3293 static dartSuite() { |
| 3255 _ut.group('NonErrorResolverTest', () { | 3294 _ut.group('NonErrorResolverTest', () { |
| 3256 _ut.test('test_ambiguousExport', () { | 3295 _ut.test('test_ambiguousExport', () { |
| 3257 final __test = new NonErrorResolverTest(); | 3296 final __test = new NonErrorResolverTest(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3382 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual); | 3421 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual); |
| 3383 }); | 3422 }); |
| 3384 _ut.test('test_constEval_propertyExtraction_fieldStatic_targetType', () { | 3423 _ut.test('test_constEval_propertyExtraction_fieldStatic_targetType', () { |
| 3385 final __test = new NonErrorResolverTest(); | 3424 final __test = new NonErrorResolverTest(); |
| 3386 runJUnitTest(__test, __test.test_constEval_propertyExtraction_fieldStati
c_targetType); | 3425 runJUnitTest(__test, __test.test_constEval_propertyExtraction_fieldStati
c_targetType); |
| 3387 }); | 3426 }); |
| 3388 _ut.test('test_constEval_propertyExtraction_methodStatic_targetType', () { | 3427 _ut.test('test_constEval_propertyExtraction_methodStatic_targetType', () { |
| 3389 final __test = new NonErrorResolverTest(); | 3428 final __test = new NonErrorResolverTest(); |
| 3390 runJUnitTest(__test, __test.test_constEval_propertyExtraction_methodStat
ic_targetType); | 3429 runJUnitTest(__test, __test.test_constEval_propertyExtraction_methodStat
ic_targetType); |
| 3391 }); | 3430 }); |
| 3431 _ut.test('test_constNotInitialized_field', () { |
| 3432 final __test = new NonErrorResolverTest(); |
| 3433 runJUnitTest(__test, __test.test_constNotInitialized_field); |
| 3434 }); |
| 3435 _ut.test('test_constNotInitialized_local', () { |
| 3436 final __test = new NonErrorResolverTest(); |
| 3437 runJUnitTest(__test, __test.test_constNotInitialized_local); |
| 3438 }); |
| 3392 _ut.test('test_constWithNonConstantArgument_literals', () { | 3439 _ut.test('test_constWithNonConstantArgument_literals', () { |
| 3393 final __test = new NonErrorResolverTest(); | 3440 final __test = new NonErrorResolverTest(); |
| 3394 runJUnitTest(__test, __test.test_constWithNonConstantArgument_literals); | 3441 runJUnitTest(__test, __test.test_constWithNonConstantArgument_literals); |
| 3395 }); | 3442 }); |
| 3396 _ut.test('test_constWithTypeParameters_direct', () { | 3443 _ut.test('test_constWithTypeParameters_direct', () { |
| 3397 final __test = new NonErrorResolverTest(); | 3444 final __test = new NonErrorResolverTest(); |
| 3398 runJUnitTest(__test, __test.test_constWithTypeParameters_direct); | 3445 runJUnitTest(__test, __test.test_constWithTypeParameters_direct); |
| 3399 }); | 3446 }); |
| 3400 _ut.test('test_constWithUndefinedConstructor', () { | 3447 _ut.test('test_constWithUndefinedConstructor', () { |
| 3401 final __test = new NonErrorResolverTest(); | 3448 final __test = new NonErrorResolverTest(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3546 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL
evelField); | 3593 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL
evelField); |
| 3547 }); | 3594 }); |
| 3548 _ut.test('test_implicitThisReferenceInInitializer_topLevelFunction', () { | 3595 _ut.test('test_implicitThisReferenceInInitializer_topLevelFunction', () { |
| 3549 final __test = new NonErrorResolverTest(); | 3596 final __test = new NonErrorResolverTest(); |
| 3550 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL
evelFunction); | 3597 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL
evelFunction); |
| 3551 }); | 3598 }); |
| 3552 _ut.test('test_implicitThisReferenceInInitializer_topLevelGetter', () { | 3599 _ut.test('test_implicitThisReferenceInInitializer_topLevelGetter', () { |
| 3553 final __test = new NonErrorResolverTest(); | 3600 final __test = new NonErrorResolverTest(); |
| 3554 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL
evelGetter); | 3601 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL
evelGetter); |
| 3555 }); | 3602 }); |
| 3556 _ut.test('test_implicitThisReferenceInInitializer_typeVariable', () { | 3603 _ut.test('test_implicitThisReferenceInInitializer_typeParameter', () { |
| 3557 final __test = new NonErrorResolverTest(); | 3604 final __test = new NonErrorResolverTest(); |
| 3558 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_type
Variable); | 3605 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_type
Parameter); |
| 3559 }); | 3606 }); |
| 3560 _ut.test('test_importDuplicatedLibraryName', () { | 3607 _ut.test('test_importDuplicatedLibraryName', () { |
| 3561 final __test = new NonErrorResolverTest(); | 3608 final __test = new NonErrorResolverTest(); |
| 3562 runJUnitTest(__test, __test.test_importDuplicatedLibraryName); | 3609 runJUnitTest(__test, __test.test_importDuplicatedLibraryName); |
| 3563 }); | 3610 }); |
| 3564 _ut.test('test_importOfNonLibrary_libraryDeclared', () { | 3611 _ut.test('test_importOfNonLibrary_libraryDeclared', () { |
| 3565 final __test = new NonErrorResolverTest(); | 3612 final __test = new NonErrorResolverTest(); |
| 3566 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryDeclared); | 3613 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryDeclared); |
| 3567 }); | 3614 }); |
| 3568 _ut.test('test_importOfNonLibrary_libraryNotDeclared', () { | 3615 _ut.test('test_importOfNonLibrary_libraryNotDeclared', () { |
| 3569 final __test = new NonErrorResolverTest(); | 3616 final __test = new NonErrorResolverTest(); |
| 3570 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryNotDeclared); | 3617 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryNotDeclared); |
| 3571 }); | 3618 }); |
| 3572 _ut.test('test_inconsistentCaseExpressionTypes', () { | 3619 _ut.test('test_inconsistentCaseExpressionTypes', () { |
| 3573 final __test = new NonErrorResolverTest(); | 3620 final __test = new NonErrorResolverTest(); |
| 3574 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes); | 3621 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes); |
| 3575 }); | 3622 }); |
| 3576 _ut.test('test_inconsistentMethodInheritance_accessors_typeVariables1', ()
{ | 3623 _ut.test('test_inconsistentMethodInheritance_accessors_typeParameter2', ()
{ |
| 3577 final __test = new NonErrorResolverTest(); | 3624 final __test = new NonErrorResolverTest(); |
| 3578 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_accessors
_typeVariables1); | 3625 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_accessors
_typeParameter2); |
| 3579 }); | 3626 }); |
| 3580 _ut.test('test_inconsistentMethodInheritance_accessors_typeVariables2', ()
{ | 3627 _ut.test('test_inconsistentMethodInheritance_accessors_typeParameters1', (
) { |
| 3581 final __test = new NonErrorResolverTest(); | 3628 final __test = new NonErrorResolverTest(); |
| 3582 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_accessors
_typeVariables2); | 3629 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_accessors
_typeParameters1); |
| 3583 }); | 3630 }); |
| 3584 _ut.test('test_inconsistentMethodInheritance_accessors_typeVariables_diamo
nd', () { | 3631 _ut.test('test_inconsistentMethodInheritance_accessors_typeParameters_diam
ond', () { |
| 3585 final __test = new NonErrorResolverTest(); | 3632 final __test = new NonErrorResolverTest(); |
| 3586 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_accessors
_typeVariables_diamond); | 3633 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_accessors
_typeParameters_diamond); |
| 3587 }); | 3634 }); |
| 3588 _ut.test('test_inconsistentMethodInheritance_methods_typeVariables1', () { | 3635 _ut.test('test_inconsistentMethodInheritance_methods_typeParameter2', () { |
| 3589 final __test = new NonErrorResolverTest(); | 3636 final __test = new NonErrorResolverTest(); |
| 3590 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_methods_t
ypeVariables1); | 3637 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_methods_t
ypeParameter2); |
| 3591 }); | 3638 }); |
| 3592 _ut.test('test_inconsistentMethodInheritance_methods_typeVariables2', () { | 3639 _ut.test('test_inconsistentMethodInheritance_methods_typeParameters1', ()
{ |
| 3593 final __test = new NonErrorResolverTest(); | 3640 final __test = new NonErrorResolverTest(); |
| 3594 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_methods_t
ypeVariables2); | 3641 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_methods_t
ypeParameters1); |
| 3595 }); | 3642 }); |
| 3596 _ut.test('test_inconsistentMethodInheritance_simple', () { | 3643 _ut.test('test_inconsistentMethodInheritance_simple', () { |
| 3597 final __test = new NonErrorResolverTest(); | 3644 final __test = new NonErrorResolverTest(); |
| 3598 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_simple); | 3645 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_simple); |
| 3599 }); | 3646 }); |
| 3600 _ut.test('test_initializingFormalForNonExistantField', () { | 3647 _ut.test('test_initializingFormalForNonExistantField', () { |
| 3601 final __test = new NonErrorResolverTest(); | 3648 final __test = new NonErrorResolverTest(); |
| 3602 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField); | 3649 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField); |
| 3603 }); | 3650 }); |
| 3604 _ut.test('test_instanceAccessToStaticMember_fromComment', () { | 3651 _ut.test('test_instanceAccessToStaticMember_fromComment', () { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3662 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p
ositional); | 3709 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p
ositional); |
| 3663 }); | 3710 }); |
| 3664 _ut.test('test_invalidOverrideDifferentDefaultValues_positional_changedOrd
er', () { | 3711 _ut.test('test_invalidOverrideDifferentDefaultValues_positional_changedOrd
er', () { |
| 3665 final __test = new NonErrorResolverTest(); | 3712 final __test = new NonErrorResolverTest(); |
| 3666 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p
ositional_changedOrder); | 3713 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p
ositional_changedOrder); |
| 3667 }); | 3714 }); |
| 3668 _ut.test('test_invalidOverrideNamed_unorderedNamedParameter', () { | 3715 _ut.test('test_invalidOverrideNamed_unorderedNamedParameter', () { |
| 3669 final __test = new NonErrorResolverTest(); | 3716 final __test = new NonErrorResolverTest(); |
| 3670 runJUnitTest(__test, __test.test_invalidOverrideNamed_unorderedNamedPara
meter); | 3717 runJUnitTest(__test, __test.test_invalidOverrideNamed_unorderedNamedPara
meter); |
| 3671 }); | 3718 }); |
| 3719 _ut.test('test_invalidOverrideRequired_less', () { |
| 3720 final __test = new NonErrorResolverTest(); |
| 3721 runJUnitTest(__test, __test.test_invalidOverrideRequired_less); |
| 3722 }); |
| 3723 _ut.test('test_invalidOverrideRequired_same', () { |
| 3724 final __test = new NonErrorResolverTest(); |
| 3725 runJUnitTest(__test, __test.test_invalidOverrideRequired_same); |
| 3726 }); |
| 3672 _ut.test('test_invalidOverrideReturnType_returnType_interface', () { | 3727 _ut.test('test_invalidOverrideReturnType_returnType_interface', () { |
| 3673 final __test = new NonErrorResolverTest(); | 3728 final __test = new NonErrorResolverTest(); |
| 3674 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_in
terface); | 3729 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_in
terface); |
| 3675 }); | 3730 }); |
| 3676 _ut.test('test_invalidOverrideReturnType_returnType_interface2', () { | 3731 _ut.test('test_invalidOverrideReturnType_returnType_interface2', () { |
| 3677 final __test = new NonErrorResolverTest(); | 3732 final __test = new NonErrorResolverTest(); |
| 3678 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_in
terface2); | 3733 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_in
terface2); |
| 3679 }); | 3734 }); |
| 3680 _ut.test('test_invalidOverrideReturnType_returnType_mixin', () { | 3735 _ut.test('test_invalidOverrideReturnType_returnType_mixin', () { |
| 3681 final __test = new NonErrorResolverTest(); | 3736 final __test = new NonErrorResolverTest(); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3914 runJUnitTest(__test, __test.test_nonGenerativeConstructor); | 3969 runJUnitTest(__test, __test.test_nonGenerativeConstructor); |
| 3915 }); | 3970 }); |
| 3916 _ut.test('test_nonTypeInCatchClause_isClass', () { | 3971 _ut.test('test_nonTypeInCatchClause_isClass', () { |
| 3917 final __test = new NonErrorResolverTest(); | 3972 final __test = new NonErrorResolverTest(); |
| 3918 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isClass); | 3973 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isClass); |
| 3919 }); | 3974 }); |
| 3920 _ut.test('test_nonTypeInCatchClause_isFunctionTypeAlias', () { | 3975 _ut.test('test_nonTypeInCatchClause_isFunctionTypeAlias', () { |
| 3921 final __test = new NonErrorResolverTest(); | 3976 final __test = new NonErrorResolverTest(); |
| 3922 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isFunctionTypeAlia
s); | 3977 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isFunctionTypeAlia
s); |
| 3923 }); | 3978 }); |
| 3924 _ut.test('test_nonTypeInCatchClause_isTypeVariable', () { | 3979 _ut.test('test_nonTypeInCatchClause_isTypeParameter', () { |
| 3925 final __test = new NonErrorResolverTest(); | 3980 final __test = new NonErrorResolverTest(); |
| 3926 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isTypeVariable); | 3981 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isTypeParameter); |
| 3927 }); | 3982 }); |
| 3928 _ut.test('test_nonTypeInCatchClause_noType', () { | 3983 _ut.test('test_nonTypeInCatchClause_noType', () { |
| 3929 final __test = new NonErrorResolverTest(); | 3984 final __test = new NonErrorResolverTest(); |
| 3930 runJUnitTest(__test, __test.test_nonTypeInCatchClause_noType); | 3985 runJUnitTest(__test, __test.test_nonTypeInCatchClause_noType); |
| 3931 }); | 3986 }); |
| 3932 _ut.test('test_nonVoidReturnForOperator_no', () { | 3987 _ut.test('test_nonVoidReturnForOperator_no', () { |
| 3933 final __test = new NonErrorResolverTest(); | 3988 final __test = new NonErrorResolverTest(); |
| 3934 runJUnitTest(__test, __test.test_nonVoidReturnForOperator_no); | 3989 runJUnitTest(__test, __test.test_nonVoidReturnForOperator_no); |
| 3935 }); | 3990 }); |
| 3936 _ut.test('test_nonVoidReturnForOperator_void', () { | 3991 _ut.test('test_nonVoidReturnForOperator_void', () { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4058 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc
cess_propertyAccessor); | 4113 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc
cess_propertyAccessor); |
| 4059 }); | 4114 }); |
| 4060 _ut.test('test_superInInvalidContext', () { | 4115 _ut.test('test_superInInvalidContext', () { |
| 4061 final __test = new NonErrorResolverTest(); | 4116 final __test = new NonErrorResolverTest(); |
| 4062 runJUnitTest(__test, __test.test_superInInvalidContext); | 4117 runJUnitTest(__test, __test.test_superInInvalidContext); |
| 4063 }); | 4118 }); |
| 4064 _ut.test('test_typeAliasCannotReferenceItself_returnClass_withTypeAlias',
() { | 4119 _ut.test('test_typeAliasCannotReferenceItself_returnClass_withTypeAlias',
() { |
| 4065 final __test = new NonErrorResolverTest(); | 4120 final __test = new NonErrorResolverTest(); |
| 4066 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_returnCl
ass_withTypeAlias); | 4121 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_returnCl
ass_withTypeAlias); |
| 4067 }); | 4122 }); |
| 4068 _ut.test('test_typeAliasCannotReferenceItself_typeVariableBounds', () { | 4123 _ut.test('test_typeAliasCannotReferenceItself_typeParameterBounds', () { |
| 4069 final __test = new NonErrorResolverTest(); | 4124 final __test = new NonErrorResolverTest(); |
| 4070 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_typeVari
ableBounds); | 4125 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_typePara
meterBounds); |
| 4071 }); | 4126 }); |
| 4072 _ut.test('test_typeArgumentNotMatchingBounds_const', () { | 4127 _ut.test('test_typeArgumentNotMatchingBounds_const', () { |
| 4073 final __test = new NonErrorResolverTest(); | 4128 final __test = new NonErrorResolverTest(); |
| 4074 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const); | 4129 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const); |
| 4075 }); | 4130 }); |
| 4076 _ut.test('test_typeArgumentNotMatchingBounds_new', () { | 4131 _ut.test('test_typeArgumentNotMatchingBounds_new', () { |
| 4077 final __test = new NonErrorResolverTest(); | 4132 final __test = new NonErrorResolverTest(); |
| 4078 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new); | 4133 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new); |
| 4079 }); | 4134 }); |
| 4080 _ut.test('test_typeArgumentNotMatchingBounds_typeArgumentList_0', () { | 4135 _ut.test('test_typeArgumentNotMatchingBounds_typeArgumentList_0', () { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4297 final __test = new LibraryTest(); | 4352 final __test = new LibraryTest(); |
| 4298 runJUnitTest(__test, __test.test_setLibraryElement); | 4353 runJUnitTest(__test, __test.test_setLibraryElement); |
| 4299 }); | 4354 }); |
| 4300 }); | 4355 }); |
| 4301 } | 4356 } |
| 4302 } | 4357 } |
| 4303 class StaticTypeWarningCodeTest extends ResolverTestCase { | 4358 class StaticTypeWarningCodeTest extends ResolverTestCase { |
| 4304 void fail_inaccessibleSetter() { | 4359 void fail_inaccessibleSetter() { |
| 4305 Source source = addSource(EngineTestCase.createSource([])); | 4360 Source source = addSource(EngineTestCase.createSource([])); |
| 4306 resolve(source); | 4361 resolve(source); |
| 4307 assertErrors([StaticTypeWarningCode.INACCESSIBLE_SETTER]); | 4362 assertErrors(source, [StaticTypeWarningCode.INACCESSIBLE_SETTER]); |
| 4308 verify([source]); | 4363 verify([source]); |
| 4309 } | 4364 } |
| 4310 void test_inconsistentMethodInheritance_paramCount() { | 4365 void test_inconsistentMethodInheritance_paramCount() { |
| 4311 Source source = addSource(EngineTestCase.createSource([ | 4366 Source source = addSource(EngineTestCase.createSource([ |
| 4312 "abstract class A {", | 4367 "abstract class A {", |
| 4313 " int x();", | 4368 " int x();", |
| 4314 "}", | 4369 "}", |
| 4315 "abstract class B {", | 4370 "abstract class B {", |
| 4316 " int x(int y);", | 4371 " int x(int y);", |
| 4317 "}", | 4372 "}", |
| 4318 "class C implements A, B {", | 4373 "class C implements A, B {", |
| 4319 "}"])); | 4374 "}"])); |
| 4320 resolve(source); | 4375 resolve(source); |
| 4321 assertErrors([StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); | 4376 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); |
| 4322 verify([source]); | 4377 verify([source]); |
| 4323 } | 4378 } |
| 4324 void test_inconsistentMethodInheritance_paramType() { | 4379 void test_inconsistentMethodInheritance_paramType() { |
| 4325 Source source = addSource(EngineTestCase.createSource([ | 4380 Source source = addSource(EngineTestCase.createSource([ |
| 4326 "abstract class A {", | 4381 "abstract class A {", |
| 4327 " x(int i);", | 4382 " x(int i);", |
| 4328 "}", | 4383 "}", |
| 4329 "abstract class B {", | 4384 "abstract class B {", |
| 4330 " x(String s);", | 4385 " x(String s);", |
| 4331 "}", | 4386 "}", |
| 4332 "abstract class C implements A, B {}"])); | 4387 "abstract class C implements A, B {}"])); |
| 4333 resolve(source); | 4388 resolve(source); |
| 4334 assertErrors([StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); | 4389 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); |
| 4335 verify([source]); | 4390 verify([source]); |
| 4336 } | 4391 } |
| 4337 void test_inconsistentMethodInheritance_returnType() { | 4392 void test_inconsistentMethodInheritance_returnType() { |
| 4338 Source source = addSource(EngineTestCase.createSource([ | 4393 Source source = addSource(EngineTestCase.createSource([ |
| 4339 "abstract class A {", | 4394 "abstract class A {", |
| 4340 " int x();", | 4395 " int x();", |
| 4341 "}", | 4396 "}", |
| 4342 "abstract class B {", | 4397 "abstract class B {", |
| 4343 " String x();", | 4398 " String x();", |
| 4344 "}", | 4399 "}", |
| 4345 "abstract class C implements A, B {}"])); | 4400 "abstract class C implements A, B {}"])); |
| 4346 resolve(source); | 4401 resolve(source); |
| 4347 assertErrors([StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); | 4402 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]
); |
| 4348 verify([source]); | 4403 verify([source]); |
| 4349 } | 4404 } |
| 4350 void test_instanceAccessToStaticMember_method_invocation() { | 4405 void test_instanceAccessToStaticMember_method_invocation() { |
| 4351 Source source = addSource(EngineTestCase.createSource([ | 4406 Source source = addSource(EngineTestCase.createSource([ |
| 4352 "class A {", | 4407 "class A {", |
| 4353 " static m() {}", | 4408 " static m() {}", |
| 4354 "}", | 4409 "}", |
| 4355 "main(A a) {", | 4410 "main(A a) {", |
| 4356 " a.m();", | 4411 " a.m();", |
| 4357 "}"])); | 4412 "}"])); |
| 4358 resolve(source); | 4413 resolve(source); |
| 4359 assertErrors([StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); | 4414 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); |
| 4360 verify([source]); | 4415 verify([source]); |
| 4361 } | 4416 } |
| 4362 void test_instanceAccessToStaticMember_method_reference() { | 4417 void test_instanceAccessToStaticMember_method_reference() { |
| 4363 Source source = addSource(EngineTestCase.createSource([ | 4418 Source source = addSource(EngineTestCase.createSource([ |
| 4364 "class A {", | 4419 "class A {", |
| 4365 " static m() {}", | 4420 " static m() {}", |
| 4366 "}", | 4421 "}", |
| 4367 "main(A a) {", | 4422 "main(A a) {", |
| 4368 " a.m;", | 4423 " a.m;", |
| 4369 "}"])); | 4424 "}"])); |
| 4370 resolve(source); | 4425 resolve(source); |
| 4371 assertErrors([StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); | 4426 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); |
| 4372 verify([source]); | 4427 verify([source]); |
| 4373 } | 4428 } |
| 4374 void test_instanceAccessToStaticMember_propertyAccess_field() { | 4429 void test_instanceAccessToStaticMember_propertyAccess_field() { |
| 4375 Source source = addSource(EngineTestCase.createSource([ | 4430 Source source = addSource(EngineTestCase.createSource([ |
| 4376 "class A {", | 4431 "class A {", |
| 4377 " static var f;", | 4432 " static var f;", |
| 4378 "}", | 4433 "}", |
| 4379 "main(A a) {", | 4434 "main(A a) {", |
| 4380 " a.f;", | 4435 " a.f;", |
| 4381 "}"])); | 4436 "}"])); |
| 4382 resolve(source); | 4437 resolve(source); |
| 4383 assertErrors([StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); | 4438 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); |
| 4384 verify([source]); | 4439 verify([source]); |
| 4385 } | 4440 } |
| 4386 void test_instanceAccessToStaticMember_propertyAccess_getter() { | 4441 void test_instanceAccessToStaticMember_propertyAccess_getter() { |
| 4387 Source source = addSource(EngineTestCase.createSource([ | 4442 Source source = addSource(EngineTestCase.createSource([ |
| 4388 "class A {", | 4443 "class A {", |
| 4389 " static get f => 42;", | 4444 " static get f => 42;", |
| 4390 "}", | 4445 "}", |
| 4391 "main(A a) {", | 4446 "main(A a) {", |
| 4392 " a.f;", | 4447 " a.f;", |
| 4393 "}"])); | 4448 "}"])); |
| 4394 resolve(source); | 4449 resolve(source); |
| 4395 assertErrors([StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); | 4450 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); |
| 4396 verify([source]); | 4451 verify([source]); |
| 4397 } | 4452 } |
| 4398 void test_instanceAccessToStaticMember_propertyAccess_setter() { | 4453 void test_instanceAccessToStaticMember_propertyAccess_setter() { |
| 4399 Source source = addSource(EngineTestCase.createSource([ | 4454 Source source = addSource(EngineTestCase.createSource([ |
| 4400 "class A {", | 4455 "class A {", |
| 4401 " static set f(x) {}", | 4456 " static set f(x) {}", |
| 4402 "}", | 4457 "}", |
| 4403 "main(A a) {", | 4458 "main(A a) {", |
| 4404 " a.f = 42;", | 4459 " a.f = 42;", |
| 4405 "}"])); | 4460 "}"])); |
| 4406 resolve(source); | 4461 resolve(source); |
| 4407 assertErrors([StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER]); | 4462 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER
]); |
| 4408 verify([source]); | 4463 verify([source]); |
| 4409 } | 4464 } |
| 4410 void test_invalidAssignment_compoundAssignment() { | 4465 void test_invalidAssignment_compoundAssignment() { |
| 4411 Source source = addSource(EngineTestCase.createSource([ | 4466 Source source = addSource(EngineTestCase.createSource([ |
| 4412 "class byte {", | 4467 "class byte {", |
| 4413 " int _value;", | 4468 " int _value;", |
| 4414 " byte(this._value);", | 4469 " byte(this._value);", |
| 4415 " int operator +(int val) {}", | 4470 " int operator +(int val) {}", |
| 4416 "}", | 4471 "}", |
| 4417 "", | 4472 "", |
| 4418 "void main() {", | 4473 "void main() {", |
| 4419 " byte b = new byte(52);", | 4474 " byte b = new byte(52);", |
| 4420 " b += 3;", | 4475 " b += 3;", |
| 4421 "}"])); | 4476 "}"])); |
| 4422 resolve(source); | 4477 resolve(source); |
| 4423 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 4478 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 4424 verify([source]); | 4479 verify([source]); |
| 4425 } | 4480 } |
| 4426 void test_invalidAssignment_defaultValue_named() { | 4481 void test_invalidAssignment_defaultValue_named() { |
| 4427 Source source = addSource(EngineTestCase.createSource(["f({String x: 0}) {",
"}"])); | 4482 Source source = addSource(EngineTestCase.createSource(["f({String x: 0}) {",
"}"])); |
| 4428 resolve(source); | 4483 resolve(source); |
| 4429 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 4484 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 4430 verify([source]); | 4485 verify([source]); |
| 4431 } | 4486 } |
| 4432 void test_invalidAssignment_defaultValue_optional() { | 4487 void test_invalidAssignment_defaultValue_optional() { |
| 4433 Source source = addSource(EngineTestCase.createSource(["f([String x = 0]) {"
, "}"])); | 4488 Source source = addSource(EngineTestCase.createSource(["f([String x = 0]) {"
, "}"])); |
| 4434 resolve(source); | 4489 resolve(source); |
| 4435 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 4490 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 4436 verify([source]); | 4491 verify([source]); |
| 4437 } | 4492 } |
| 4438 void test_invalidAssignment_instanceVariable() { | 4493 void test_invalidAssignment_instanceVariable() { |
| 4439 Source source = addSource(EngineTestCase.createSource([ | 4494 Source source = addSource(EngineTestCase.createSource([ |
| 4440 "class A {", | 4495 "class A {", |
| 4441 " int x;", | 4496 " int x;", |
| 4442 "}", | 4497 "}", |
| 4443 "f() {", | 4498 "f() {", |
| 4444 " A a;", | 4499 " A a;", |
| 4445 " a.x = '0';", | 4500 " a.x = '0';", |
| 4446 "}"])); | 4501 "}"])); |
| 4447 resolve(source); | 4502 resolve(source); |
| 4448 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 4503 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 4449 verify([source]); | 4504 verify([source]); |
| 4450 } | 4505 } |
| 4451 void test_invalidAssignment_localVariable() { | 4506 void test_invalidAssignment_localVariable() { |
| 4452 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;",
" x = '0';", "}"])); | 4507 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;",
" x = '0';", "}"])); |
| 4453 resolve(source); | 4508 resolve(source); |
| 4454 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 4509 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 4455 verify([source]); | 4510 verify([source]); |
| 4456 } | 4511 } |
| 4457 void test_invalidAssignment_staticVariable() { | 4512 void test_invalidAssignment_staticVariable() { |
| 4458 Source source = addSource(EngineTestCase.createSource([ | 4513 Source source = addSource(EngineTestCase.createSource([ |
| 4459 "class A {", | 4514 "class A {", |
| 4460 " static int x;", | 4515 " static int x;", |
| 4461 "}", | 4516 "}", |
| 4462 "f() {", | 4517 "f() {", |
| 4463 " A.x = '0';", | 4518 " A.x = '0';", |
| 4464 "}"])); | 4519 "}"])); |
| 4465 resolve(source); | 4520 resolve(source); |
| 4466 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 4521 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 4467 verify([source]); | 4522 verify([source]); |
| 4468 } | 4523 } |
| 4469 void test_invalidAssignment_topLevelVariableDeclaration() { | 4524 void test_invalidAssignment_topLevelVariableDeclaration() { |
| 4470 Source source = addSource(EngineTestCase.createSource(["int x = 'string';"])
); | 4525 Source source = addSource(EngineTestCase.createSource(["int x = 'string';"])
); |
| 4471 resolve(source); | 4526 resolve(source); |
| 4472 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 4527 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 4473 verify([source]); | 4528 verify([source]); |
| 4474 } | 4529 } |
| 4475 void test_invalidAssignment_variableDeclaration() { | 4530 void test_invalidAssignment_variableDeclaration() { |
| 4476 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
= 'string';", "}"])); | 4531 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
= 'string';", "}"])); |
| 4477 resolve(source); | 4532 resolve(source); |
| 4478 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 4533 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 4479 verify([source]); | 4534 verify([source]); |
| 4480 } | 4535 } |
| 4481 void test_invocationOfNonFunction_class() { | 4536 void test_invocationOfNonFunction_class() { |
| 4482 Source source = addSource(EngineTestCase.createSource(["class A {", " void
m() {", " A();", " }", "}"])); | 4537 Source source = addSource(EngineTestCase.createSource(["class A {", " void
m() {", " A();", " }", "}"])); |
| 4483 resolve(source); | 4538 resolve(source); |
| 4484 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); | 4539 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); |
| 4485 } | 4540 } |
| 4486 void test_invocationOfNonFunction_localVariable() { | 4541 void test_invocationOfNonFunction_localVariable() { |
| 4487 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;",
" return x();", "}"])); | 4542 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;",
" return x();", "}"])); |
| 4488 resolve(source); | 4543 resolve(source); |
| 4489 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); | 4544 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); |
| 4490 verify([source]); | 4545 verify([source]); |
| 4491 } | 4546 } |
| 4492 void test_invocationOfNonFunction_ordinaryInvocation() { | 4547 void test_invocationOfNonFunction_ordinaryInvocation() { |
| 4493 Source source = addSource(EngineTestCase.createSource([ | 4548 Source source = addSource(EngineTestCase.createSource([ |
| 4494 "class A {", | 4549 "class A {", |
| 4495 " static int x;", | 4550 " static int x;", |
| 4496 "}", | 4551 "}", |
| 4497 "class B {", | 4552 "class B {", |
| 4498 " m() {", | 4553 " m() {", |
| 4499 " A.x();", | 4554 " A.x();", |
| 4500 " }", | 4555 " }", |
| 4501 "}"])); | 4556 "}"])); |
| 4502 resolve(source); | 4557 resolve(source); |
| 4503 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); | 4558 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); |
| 4504 } | 4559 } |
| 4505 void test_invocationOfNonFunction_staticInvocation() { | 4560 void test_invocationOfNonFunction_staticInvocation() { |
| 4506 Source source = addSource(EngineTestCase.createSource([ | 4561 Source source = addSource(EngineTestCase.createSource([ |
| 4507 "class A {", | 4562 "class A {", |
| 4508 " static int get g => 0;", | 4563 " static int get g => 0;", |
| 4509 " f() {", | 4564 " f() {", |
| 4510 " A.g();", | 4565 " A.g();", |
| 4511 " }", | 4566 " }", |
| 4512 "}"])); | 4567 "}"])); |
| 4513 resolve(source); | 4568 resolve(source); |
| 4514 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); | 4569 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); |
| 4515 } | 4570 } |
| 4516 void test_invocationOfNonFunction_superExpression() { | 4571 void test_invocationOfNonFunction_superExpression() { |
| 4517 Source source = addSource(EngineTestCase.createSource([ | 4572 Source source = addSource(EngineTestCase.createSource([ |
| 4518 "class A {", | 4573 "class A {", |
| 4519 " int get g => 0;", | 4574 " int get g => 0;", |
| 4520 "}", | 4575 "}", |
| 4521 "class B extends A {", | 4576 "class B extends A {", |
| 4522 " m() {", | 4577 " m() {", |
| 4523 " var v = super.g();", | 4578 " var v = super.g();", |
| 4524 " }", | 4579 " }", |
| 4525 "}"])); | 4580 "}"])); |
| 4526 resolve(source); | 4581 resolve(source); |
| 4527 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); | 4582 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); |
| 4528 verify([source]); | 4583 verify([source]); |
| 4529 } | 4584 } |
| 4530 void test_invocationOfNonFunctionExpression_literal() { | 4585 void test_invocationOfNonFunctionExpression_literal() { |
| 4531 Source source = addSource(EngineTestCase.createSource(["f() {", " 3(5);", "
}"])); | 4586 Source source = addSource(EngineTestCase.createSource(["f() {", " 3(5);", "
}"])); |
| 4532 resolve(source); | 4587 resolve(source); |
| 4533 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION]); | 4588 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRE
SSION]); |
| 4534 verify([source]); | 4589 verify([source]); |
| 4535 } | 4590 } |
| 4536 void test_nonBoolCondition_conditional() { | 4591 void test_nonBoolCondition_conditional() { |
| 4537 Source source = addSource(EngineTestCase.createSource(["f() { return 3 ? 2 :
1; }"])); | 4592 Source source = addSource(EngineTestCase.createSource(["f() { return 3 ? 2 :
1; }"])); |
| 4538 resolve(source); | 4593 resolve(source); |
| 4539 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); | 4594 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); |
| 4540 verify([source]); | 4595 verify([source]); |
| 4541 } | 4596 } |
| 4542 void test_nonBoolCondition_do() { | 4597 void test_nonBoolCondition_do() { |
| 4543 Source source = addSource(EngineTestCase.createSource(["f() {", " do {} whi
le (3);", "}"])); | 4598 Source source = addSource(EngineTestCase.createSource(["f() {", " do {} whi
le (3);", "}"])); |
| 4544 resolve(source); | 4599 resolve(source); |
| 4545 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); | 4600 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); |
| 4546 verify([source]); | 4601 verify([source]); |
| 4547 } | 4602 } |
| 4548 void test_nonBoolCondition_if() { | 4603 void test_nonBoolCondition_if() { |
| 4549 Source source = addSource(EngineTestCase.createSource(["f() {", " if (3) re
turn 2; else return 1;", "}"])); | 4604 Source source = addSource(EngineTestCase.createSource(["f() {", " if (3) re
turn 2; else return 1;", "}"])); |
| 4550 resolve(source); | 4605 resolve(source); |
| 4551 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); | 4606 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); |
| 4552 verify([source]); | 4607 verify([source]); |
| 4553 } | 4608 } |
| 4554 void test_nonBoolCondition_while() { | 4609 void test_nonBoolCondition_while() { |
| 4555 Source source = addSource(EngineTestCase.createSource(["f() {", " while (3)
{}", "}"])); | 4610 Source source = addSource(EngineTestCase.createSource(["f() {", " while (3)
{}", "}"])); |
| 4556 resolve(source); | 4611 resolve(source); |
| 4557 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); | 4612 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]); |
| 4558 verify([source]); | 4613 verify([source]); |
| 4559 } | 4614 } |
| 4560 void test_nonBoolExpression_functionType() { | 4615 void test_nonBoolExpression_functionType() { |
| 4561 Source source = addSource(EngineTestCase.createSource([ | 4616 Source source = addSource(EngineTestCase.createSource([ |
| 4562 "int makeAssertion() => 1;", | 4617 "int makeAssertion() => 1;", |
| 4563 "f() {", | 4618 "f() {", |
| 4564 " assert(makeAssertion);", | 4619 " assert(makeAssertion);", |
| 4565 "}"])); | 4620 "}"])); |
| 4566 resolve(source); | 4621 resolve(source); |
| 4567 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]); | 4622 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); |
| 4568 verify([source]); | 4623 verify([source]); |
| 4569 } | 4624 } |
| 4570 void test_nonBoolExpression_interfaceType() { | 4625 void test_nonBoolExpression_interfaceType() { |
| 4571 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0)
;", "}"])); | 4626 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0)
;", "}"])); |
| 4572 resolve(source); | 4627 resolve(source); |
| 4573 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]); | 4628 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_EXPRESSION]); |
| 4574 verify([source]); | 4629 verify([source]); |
| 4575 } | 4630 } |
| 4576 void test_nonTypeAsTypeArgument_notAType() { | 4631 void test_nonTypeAsTypeArgument_notAType() { |
| 4577 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E>
{}", "f(B<A> b) {}"])); | 4632 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E>
{}", "f(B<A> b) {}"])); |
| 4578 resolve(source); | 4633 resolve(source); |
| 4579 assertErrors([StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); | 4634 assertErrors(source, [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); |
| 4580 verify([source]); | 4635 verify([source]); |
| 4581 } | 4636 } |
| 4582 void test_nonTypeAsTypeArgument_undefinedIdentifier() { | 4637 void test_nonTypeAsTypeArgument_undefinedIdentifier() { |
| 4583 Source source = addSource(EngineTestCase.createSource(["class B<E> {}", "f(B
<A> b) {}"])); | 4638 Source source = addSource(EngineTestCase.createSource(["class B<E> {}", "f(B
<A> b) {}"])); |
| 4584 resolve(source); | 4639 resolve(source); |
| 4585 assertErrors([StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); | 4640 assertErrors(source, [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); |
| 4586 verify([source]); | 4641 verify([source]); |
| 4587 } | 4642 } |
| 4588 void test_returnOfInvalidType_expressionFunctionBody_function() { | 4643 void test_returnOfInvalidType_expressionFunctionBody_function() { |
| 4589 Source source = addSource(EngineTestCase.createSource(["int f() => '0';"])); | 4644 Source source = addSource(EngineTestCase.createSource(["int f() => '0';"])); |
| 4590 resolve(source); | 4645 resolve(source); |
| 4591 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 4646 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 4592 verify([source]); | 4647 verify([source]); |
| 4593 } | 4648 } |
| 4594 void test_returnOfInvalidType_expressionFunctionBody_getter() { | 4649 void test_returnOfInvalidType_expressionFunctionBody_getter() { |
| 4595 Source source = addSource(EngineTestCase.createSource(["int get g => '0';"])
); | 4650 Source source = addSource(EngineTestCase.createSource(["int get g => '0';"])
); |
| 4596 resolve(source); | 4651 resolve(source); |
| 4597 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 4652 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 4598 verify([source]); | 4653 verify([source]); |
| 4599 } | 4654 } |
| 4600 void test_returnOfInvalidType_expressionFunctionBody_localFunction() { | 4655 void test_returnOfInvalidType_expressionFunctionBody_localFunction() { |
| 4601 Source source = addSource(EngineTestCase.createSource([ | 4656 Source source = addSource(EngineTestCase.createSource([ |
| 4602 "class A {", | 4657 "class A {", |
| 4603 " String m() {", | 4658 " String m() {", |
| 4604 " int f() => '0';", | 4659 " int f() => '0';", |
| 4605 " }", | 4660 " }", |
| 4606 "}"])); | 4661 "}"])); |
| 4607 resolve(source); | 4662 resolve(source); |
| 4608 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 4663 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 4609 verify([source]); | 4664 verify([source]); |
| 4610 } | 4665 } |
| 4611 void test_returnOfInvalidType_expressionFunctionBody_method() { | 4666 void test_returnOfInvalidType_expressionFunctionBody_method() { |
| 4612 Source source = addSource(EngineTestCase.createSource(["class A {", " int f
() => '0';", "}"])); | 4667 Source source = addSource(EngineTestCase.createSource(["class A {", " int f
() => '0';", "}"])); |
| 4613 resolve(source); | 4668 resolve(source); |
| 4614 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 4669 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 4615 verify([source]); | 4670 verify([source]); |
| 4616 } | 4671 } |
| 4617 void test_returnOfInvalidType_expressionFunctionBody_void() { | 4672 void test_returnOfInvalidType_expressionFunctionBody_void() { |
| 4618 Source source = addSource(EngineTestCase.createSource(["void f() => 42;"])); | 4673 Source source = addSource(EngineTestCase.createSource(["void f() => 42;"])); |
| 4619 resolve(source); | 4674 resolve(source); |
| 4620 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 4675 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 4621 verify([source]); | 4676 verify([source]); |
| 4622 } | 4677 } |
| 4623 void test_returnOfInvalidType_function() { | 4678 void test_returnOfInvalidType_function() { |
| 4624 Source source = addSource(EngineTestCase.createSource(["int f() { return '0'
; }"])); | 4679 Source source = addSource(EngineTestCase.createSource(["int f() { return '0'
; }"])); |
| 4625 resolve(source); | 4680 resolve(source); |
| 4626 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 4681 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 4627 verify([source]); | 4682 verify([source]); |
| 4628 } | 4683 } |
| 4629 void test_returnOfInvalidType_getter() { | 4684 void test_returnOfInvalidType_getter() { |
| 4630 Source source = addSource(EngineTestCase.createSource(["int get g { return '
0'; }"])); | 4685 Source source = addSource(EngineTestCase.createSource(["int get g { return '
0'; }"])); |
| 4631 resolve(source); | 4686 resolve(source); |
| 4632 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 4687 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 4633 verify([source]); | 4688 verify([source]); |
| 4634 } | 4689 } |
| 4635 void test_returnOfInvalidType_localFunction() { | 4690 void test_returnOfInvalidType_localFunction() { |
| 4636 Source source = addSource(EngineTestCase.createSource([ | 4691 Source source = addSource(EngineTestCase.createSource([ |
| 4637 "class A {", | 4692 "class A {", |
| 4638 " String m() {", | 4693 " String m() {", |
| 4639 " int f() { return '0'; }", | 4694 " int f() { return '0'; }", |
| 4640 " }", | 4695 " }", |
| 4641 "}"])); | 4696 "}"])); |
| 4642 resolve(source); | 4697 resolve(source); |
| 4643 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 4698 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 4644 verify([source]); | 4699 verify([source]); |
| 4645 } | 4700 } |
| 4646 void test_returnOfInvalidType_method() { | 4701 void test_returnOfInvalidType_method() { |
| 4647 Source source = addSource(EngineTestCase.createSource(["class A {", " int f
() { return '0'; }", "}"])); | 4702 Source source = addSource(EngineTestCase.createSource(["class A {", " int f
() { return '0'; }", "}"])); |
| 4648 resolve(source); | 4703 resolve(source); |
| 4649 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 4704 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 4650 verify([source]); | 4705 verify([source]); |
| 4651 } | 4706 } |
| 4652 void test_returnOfInvalidType_void() { | 4707 void test_returnOfInvalidType_void() { |
| 4653 Source source = addSource(EngineTestCase.createSource(["void f() { return 42
; }"])); | 4708 Source source = addSource(EngineTestCase.createSource(["void f() { return 42
; }"])); |
| 4654 resolve(source); | 4709 resolve(source); |
| 4655 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); | 4710 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); |
| 4656 verify([source]); | 4711 verify([source]); |
| 4657 } | 4712 } |
| 4658 void test_typeArgumentNotMatchingBounds_classTypeAlias() { | 4713 void test_typeArgumentNotMatchingBounds_classTypeAlias() { |
| 4659 Source source = addSource(EngineTestCase.createSource([ | 4714 Source source = addSource(EngineTestCase.createSource([ |
| 4660 "class A {}", | 4715 "class A {}", |
| 4661 "class B {}", | 4716 "class B {}", |
| 4662 "class C {}", | 4717 "class C {}", |
| 4663 "class G<E extends A> {}", | 4718 "class G<E extends A> {}", |
| 4664 "typedef D = G<B> with C;"])); | 4719 "typedef D = G<B> with C;"])); |
| 4665 resolve(source); | 4720 resolve(source); |
| 4666 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4721 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4667 verify([source]); | 4722 verify([source]); |
| 4668 } | 4723 } |
| 4669 void test_typeArgumentNotMatchingBounds_extends() { | 4724 void test_typeArgumentNotMatchingBounds_extends() { |
| 4670 Source source = addSource(EngineTestCase.createSource([ | 4725 Source source = addSource(EngineTestCase.createSource([ |
| 4671 "class A {}", | 4726 "class A {}", |
| 4672 "class B {}", | 4727 "class B {}", |
| 4673 "class G<E extends A> {}", | 4728 "class G<E extends A> {}", |
| 4674 "class C extends G<B>{}"])); | 4729 "class C extends G<B>{}"])); |
| 4675 resolve(source); | 4730 resolve(source); |
| 4676 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4731 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4677 verify([source]); | 4732 verify([source]); |
| 4678 } | 4733 } |
| 4679 void test_typeArgumentNotMatchingBounds_fieldFormalParameter() { | 4734 void test_typeArgumentNotMatchingBounds_fieldFormalParameter() { |
| 4680 Source source = addSource(EngineTestCase.createSource([ | 4735 Source source = addSource(EngineTestCase.createSource([ |
| 4681 "class A {}", | 4736 "class A {}", |
| 4682 "class B {}", | 4737 "class B {}", |
| 4683 "class G<E extends A> {}", | 4738 "class G<E extends A> {}", |
| 4684 "class C {", | 4739 "class C {", |
| 4685 " var f;", | 4740 " var f;", |
| 4686 " C(G<B> this.f) {}", | 4741 " C(G<B> this.f) {}", |
| 4687 "}"])); | 4742 "}"])); |
| 4688 resolve(source); | 4743 resolve(source); |
| 4689 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4744 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4690 verify([source]); | 4745 verify([source]); |
| 4691 } | 4746 } |
| 4692 void test_typeArgumentNotMatchingBounds_functionReturnType() { | 4747 void test_typeArgumentNotMatchingBounds_functionReturnType() { |
| 4693 Source source = addSource(EngineTestCase.createSource([ | 4748 Source source = addSource(EngineTestCase.createSource([ |
| 4694 "class A {}", | 4749 "class A {}", |
| 4695 "class B {}", | 4750 "class B {}", |
| 4696 "class G<E extends A> {}", | 4751 "class G<E extends A> {}", |
| 4697 "G<B> f() {}"])); | 4752 "G<B> f() {}"])); |
| 4698 resolve(source); | 4753 resolve(source); |
| 4699 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4754 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4700 verify([source]); | 4755 verify([source]); |
| 4701 } | 4756 } |
| 4702 void test_typeArgumentNotMatchingBounds_functionTypeAlias() { | 4757 void test_typeArgumentNotMatchingBounds_functionTypeAlias() { |
| 4703 Source source = addSource(EngineTestCase.createSource([ | 4758 Source source = addSource(EngineTestCase.createSource([ |
| 4704 "class A {}", | 4759 "class A {}", |
| 4705 "class B {}", | 4760 "class B {}", |
| 4706 "class G<E extends A> {}", | 4761 "class G<E extends A> {}", |
| 4707 "typedef G<B> f();"])); | 4762 "typedef G<B> f();"])); |
| 4708 resolve(source); | 4763 resolve(source); |
| 4709 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4764 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4710 verify([source]); | 4765 verify([source]); |
| 4711 } | 4766 } |
| 4712 void test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() { | 4767 void test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() { |
| 4713 Source source = addSource(EngineTestCase.createSource([ | 4768 Source source = addSource(EngineTestCase.createSource([ |
| 4714 "class A {}", | 4769 "class A {}", |
| 4715 "class B {}", | 4770 "class B {}", |
| 4716 "class G<E extends A> {}", | 4771 "class G<E extends A> {}", |
| 4717 "f(G<B> h()) {}"])); | 4772 "f(G<B> h()) {}"])); |
| 4718 resolve(source); | 4773 resolve(source); |
| 4719 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4774 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4720 verify([source]); | 4775 verify([source]); |
| 4721 } | 4776 } |
| 4722 void test_typeArgumentNotMatchingBounds_implements() { | 4777 void test_typeArgumentNotMatchingBounds_implements() { |
| 4723 Source source = addSource(EngineTestCase.createSource([ | 4778 Source source = addSource(EngineTestCase.createSource([ |
| 4724 "class A {}", | 4779 "class A {}", |
| 4725 "class B {}", | 4780 "class B {}", |
| 4726 "class G<E extends A> {}", | 4781 "class G<E extends A> {}", |
| 4727 "class C implements G<B>{}"])); | 4782 "class C implements G<B>{}"])); |
| 4728 resolve(source); | 4783 resolve(source); |
| 4729 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4784 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4730 verify([source]); | 4785 verify([source]); |
| 4731 } | 4786 } |
| 4732 void test_typeArgumentNotMatchingBounds_is() { | 4787 void test_typeArgumentNotMatchingBounds_is() { |
| 4733 Source source = addSource(EngineTestCase.createSource([ | 4788 Source source = addSource(EngineTestCase.createSource([ |
| 4734 "class A {}", | 4789 "class A {}", |
| 4735 "class B {}", | 4790 "class B {}", |
| 4736 "class G<E extends A> {}", | 4791 "class G<E extends A> {}", |
| 4737 "var b = 1 is G<B>;"])); | 4792 "var b = 1 is G<B>;"])); |
| 4738 resolve(source); | 4793 resolve(source); |
| 4739 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4794 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4740 verify([source]); | 4795 verify([source]); |
| 4741 } | 4796 } |
| 4742 void test_typeArgumentNotMatchingBounds_methodReturnType() { | 4797 void test_typeArgumentNotMatchingBounds_methodReturnType() { |
| 4743 Source source = addSource(EngineTestCase.createSource([ | 4798 Source source = addSource(EngineTestCase.createSource([ |
| 4744 "class A {}", | 4799 "class A {}", |
| 4745 "class B {}", | 4800 "class B {}", |
| 4746 "class G<E extends A> {}", | 4801 "class G<E extends A> {}", |
| 4747 "class C {", | 4802 "class C {", |
| 4748 " G<B> m() {}", | 4803 " G<B> m() {}", |
| 4749 "}"])); | 4804 "}"])); |
| 4750 resolve(source); | 4805 resolve(source); |
| 4751 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4806 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4752 verify([source]); | 4807 verify([source]); |
| 4753 } | 4808 } |
| 4754 void test_typeArgumentNotMatchingBounds_new() { | 4809 void test_typeArgumentNotMatchingBounds_new() { |
| 4755 Source source = addSource(EngineTestCase.createSource([ | 4810 Source source = addSource(EngineTestCase.createSource([ |
| 4756 "class A {}", | 4811 "class A {}", |
| 4757 "class B {}", | 4812 "class B {}", |
| 4758 "class G<E extends A> {}", | 4813 "class G<E extends A> {}", |
| 4759 "f() { return new G<B>(); }"])); | 4814 "f() { return new G<B>(); }"])); |
| 4760 resolve(source); | 4815 resolve(source); |
| 4761 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4816 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4762 verify([source]); | 4817 verify([source]); |
| 4763 } | 4818 } |
| 4764 void test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() { | 4819 void test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() { |
| 4765 Source source = addSource(EngineTestCase.createSource([ | 4820 Source source = addSource(EngineTestCase.createSource([ |
| 4766 "class A {}", | 4821 "class A {}", |
| 4767 "class B extends A {}", | 4822 "class B extends A {}", |
| 4768 "class C extends B {}", | 4823 "class C extends B {}", |
| 4769 "class G<E extends B> {}", | 4824 "class G<E extends B> {}", |
| 4770 "f() { return new G<A>(); }"])); | 4825 "f() { return new G<A>(); }"])); |
| 4771 resolve(source); | 4826 resolve(source); |
| 4772 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4827 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4773 verify([source]); | 4828 verify([source]); |
| 4774 } | 4829 } |
| 4775 void test_typeArgumentNotMatchingBounds_parameter() { | 4830 void test_typeArgumentNotMatchingBounds_parameter() { |
| 4776 Source source = addSource(EngineTestCase.createSource([ | 4831 Source source = addSource(EngineTestCase.createSource([ |
| 4777 "class A {}", | 4832 "class A {}", |
| 4778 "class B {}", | 4833 "class B {}", |
| 4779 "class G<E extends A> {}", | 4834 "class G<E extends A> {}", |
| 4780 "f(G<B> g) {}"])); | 4835 "f(G<B> g) {}"])); |
| 4781 resolve(source); | 4836 resolve(source); |
| 4782 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4837 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4783 verify([source]); | 4838 verify([source]); |
| 4784 } | 4839 } |
| 4785 void test_typeArgumentNotMatchingBounds_redirectingConstructor() { | 4840 void test_typeArgumentNotMatchingBounds_redirectingConstructor() { |
| 4786 Source source = addSource(EngineTestCase.createSource([ | 4841 Source source = addSource(EngineTestCase.createSource([ |
| 4787 "class A {}", | 4842 "class A {}", |
| 4788 "class B {}", | 4843 "class B {}", |
| 4789 "class X<T extends A> {", | 4844 "class X<T extends A> {", |
| 4790 " X(int x, int y) {}", | 4845 " X(int x, int y) {}", |
| 4791 " factory X.name(int x, int y) = X<B>;", | 4846 " factory X.name(int x, int y) = X<B>;", |
| 4792 "}"])); | 4847 "}"])); |
| 4793 resolve(source); | 4848 resolve(source); |
| 4794 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4849 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4795 verify([source]); | 4850 verify([source]); |
| 4796 } | 4851 } |
| 4797 void test_typeArgumentNotMatchingBounds_typeArgumentList() { | 4852 void test_typeArgumentNotMatchingBounds_typeArgumentList() { |
| 4798 Source source = addSource(EngineTestCase.createSource([ | 4853 Source source = addSource(EngineTestCase.createSource([ |
| 4799 "class A {}", | 4854 "class A {}", |
| 4800 "class B {}", | 4855 "class B {}", |
| 4801 "class C<E> {}", | 4856 "class C<E> {}", |
| 4802 "class D<E extends A> {}", | 4857 "class D<E extends A> {}", |
| 4803 "C<D<B>> Var;"])); | 4858 "C<D<B>> Var;"])); |
| 4804 resolve(source); | 4859 resolve(source); |
| 4805 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4860 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4806 verify([source]); | 4861 verify([source]); |
| 4807 } | 4862 } |
| 4808 void test_typeArgumentNotMatchingBounds_typeParameter() { | 4863 void test_typeArgumentNotMatchingBounds_typeParameter() { |
| 4809 Source source = addSource(EngineTestCase.createSource([ | 4864 Source source = addSource(EngineTestCase.createSource([ |
| 4810 "class A {}", | 4865 "class A {}", |
| 4811 "class B {}", | 4866 "class B {}", |
| 4812 "class C {}", | 4867 "class C {}", |
| 4813 "class G<E extends A> {}", | 4868 "class G<E extends A> {}", |
| 4814 "class D<F extends G<B>> {}"])); | 4869 "class D<F extends G<B>> {}"])); |
| 4815 resolve(source); | 4870 resolve(source); |
| 4816 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4871 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4817 verify([source]); | 4872 verify([source]); |
| 4818 } | 4873 } |
| 4819 void test_typeArgumentNotMatchingBounds_variableDeclaration() { | 4874 void test_typeArgumentNotMatchingBounds_variableDeclaration() { |
| 4820 Source source = addSource(EngineTestCase.createSource([ | 4875 Source source = addSource(EngineTestCase.createSource([ |
| 4821 "class A {}", | 4876 "class A {}", |
| 4822 "class B {}", | 4877 "class B {}", |
| 4823 "class G<E extends A> {}", | 4878 "class G<E extends A> {}", |
| 4824 "G<B> g;"])); | 4879 "G<B> g;"])); |
| 4825 resolve(source); | 4880 resolve(source); |
| 4826 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4881 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4827 verify([source]); | 4882 verify([source]); |
| 4828 } | 4883 } |
| 4829 void test_typeArgumentNotMatchingBounds_with() { | 4884 void test_typeArgumentNotMatchingBounds_with() { |
| 4830 Source source = addSource(EngineTestCase.createSource([ | 4885 Source source = addSource(EngineTestCase.createSource([ |
| 4831 "class A {}", | 4886 "class A {}", |
| 4832 "class B {}", | 4887 "class B {}", |
| 4833 "class G<E extends A> {}", | 4888 "class G<E extends A> {}", |
| 4834 "class C extends Object with G<B>{}"])); | 4889 "class C extends Object with G<B>{}"])); |
| 4835 resolve(source); | 4890 resolve(source); |
| 4836 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 4891 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND
S]); |
| 4837 verify([source]); | 4892 verify([source]); |
| 4838 } | 4893 } |
| 4839 void test_undefinedGetter() { | 4894 void test_undefinedGetter() { |
| 4840 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e)
{ return e.m; }"])); | 4895 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e)
{ return e.m; }"])); |
| 4841 resolve(source); | 4896 resolve(source); |
| 4842 assertErrors([StaticTypeWarningCode.UNDEFINED_GETTER]); | 4897 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 4843 } | 4898 } |
| 4844 void test_undefinedGetter_static() { | 4899 void test_undefinedGetter_static() { |
| 4845 Source source = addSource(EngineTestCase.createSource(["class A {}", "var a
= A.B;"])); | 4900 Source source = addSource(EngineTestCase.createSource(["class A {}", "var a
= A.B;"])); |
| 4846 resolve(source); | 4901 resolve(source); |
| 4847 assertErrors([StaticTypeWarningCode.UNDEFINED_GETTER]); | 4902 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]); |
| 4848 } | 4903 } |
| 4849 void test_undefinedMethod() { | 4904 void test_undefinedMethod() { |
| 4850 Source source = addSource(EngineTestCase.createSource(["class A {", " void
m() {", " n();", " }", "}"])); | 4905 Source source = addSource(EngineTestCase.createSource(["class A {", " void
m() {", " n();", " }", "}"])); |
| 4851 resolve(source); | 4906 resolve(source); |
| 4852 assertErrors([StaticTypeWarningCode.UNDEFINED_METHOD]); | 4907 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); |
| 4853 } | 4908 } |
| 4854 void test_undefinedMethod_ignoreTypePropagation() { | 4909 void test_undefinedMethod_ignoreTypePropagation() { |
| 4855 Source source = addSource(EngineTestCase.createSource([ | 4910 Source source = addSource(EngineTestCase.createSource([ |
| 4856 "class A {}", | 4911 "class A {}", |
| 4857 "class B extends A {", | 4912 "class B extends A {", |
| 4858 " m() {}", | 4913 " m() {}", |
| 4859 "}", | 4914 "}", |
| 4860 "class C {", | 4915 "class C {", |
| 4861 "f() {", | 4916 "f() {", |
| 4862 " A a = new B();", | 4917 " A a = new B();", |
| 4863 " a.m();", | 4918 " a.m();", |
| 4864 " }", | 4919 " }", |
| 4865 "}"])); | 4920 "}"])); |
| 4866 resolve(source); | 4921 resolve(source); |
| 4867 assertErrors([StaticTypeWarningCode.UNDEFINED_METHOD]); | 4922 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]); |
| 4868 } | 4923 } |
| 4869 void test_undefinedOperator_indexBoth() { | 4924 void test_undefinedOperator_indexBoth() { |
| 4870 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0]++;", "}"])); | 4925 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0]++;", "}"])); |
| 4871 resolve(source); | 4926 resolve(source); |
| 4872 assertErrors([ | 4927 assertErrors(source, [ |
| 4873 StaticTypeWarningCode.UNDEFINED_OPERATOR, | 4928 StaticTypeWarningCode.UNDEFINED_OPERATOR, |
| 4874 StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 4929 StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 4875 } | 4930 } |
| 4876 void test_undefinedOperator_indexGetter() { | 4931 void test_undefinedOperator_indexGetter() { |
| 4877 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0];", "}"])); | 4932 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0];", "}"])); |
| 4878 resolve(source); | 4933 resolve(source); |
| 4879 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 4934 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 4880 } | 4935 } |
| 4881 void test_undefinedOperator_indexSetter() { | 4936 void test_undefinedOperator_indexSetter() { |
| 4882 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0] = 1;", "}"])); | 4937 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a[0] = 1;", "}"])); |
| 4883 resolve(source); | 4938 resolve(source); |
| 4884 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 4939 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 4885 } | 4940 } |
| 4886 void test_undefinedOperator_plus() { | 4941 void test_undefinedOperator_plus() { |
| 4887 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a + 1;", "}"])); | 4942 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a)
{", " a + 1;", "}"])); |
| 4888 resolve(source); | 4943 resolve(source); |
| 4889 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 4944 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 4890 } | 4945 } |
| 4891 void test_undefinedSetter() { | 4946 void test_undefinedSetter() { |
| 4892 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e1
) { e1.m = 0; }"])); | 4947 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e1
) { e1.m = 0; }"])); |
| 4893 resolve(source); | 4948 resolve(source); |
| 4894 assertErrors([StaticTypeWarningCode.UNDEFINED_SETTER]); | 4949 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]); |
| 4895 } | 4950 } |
| 4896 void test_undefinedSetter_static() { | 4951 void test_undefinedSetter_static() { |
| 4897 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() {
A.B = 0;}"])); | 4952 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() {
A.B = 0;}"])); |
| 4898 resolve(source); | 4953 resolve(source); |
| 4899 assertErrors([StaticTypeWarningCode.UNDEFINED_SETTER]); | 4954 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]); |
| 4900 } | 4955 } |
| 4901 void test_undefinedSuperMethod() { | 4956 void test_undefinedSuperMethod() { |
| 4902 Source source = addSource(EngineTestCase.createSource([ | 4957 Source source = addSource(EngineTestCase.createSource([ |
| 4903 "class A {}", | 4958 "class A {}", |
| 4904 "class B extends A {", | 4959 "class B extends A {", |
| 4905 " m() { return super.m(); }", | 4960 " m() { return super.m(); }", |
| 4906 "}"])); | 4961 "}"])); |
| 4907 resolve(source); | 4962 resolve(source); |
| 4908 assertErrors([StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]); | 4963 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]); |
| 4909 } | 4964 } |
| 4910 void test_unqualifiedReferenceToNonLocalStaticMember_getter() { | 4965 void test_unqualifiedReferenceToNonLocalStaticMember_getter() { |
| 4911 Source source = addSource(EngineTestCase.createSource([ | 4966 Source source = addSource(EngineTestCase.createSource([ |
| 4912 "class A {", | 4967 "class A {", |
| 4913 " static int get a => 0;", | 4968 " static int get a => 0;", |
| 4914 "}", | 4969 "}", |
| 4915 "class B extends A {", | 4970 "class B extends A {", |
| 4916 " int b() {", | 4971 " int b() {", |
| 4917 " return a;", | 4972 " return a;", |
| 4918 " }", | 4973 " }", |
| 4919 "}"])); | 4974 "}"])); |
| 4920 resolve(source); | 4975 resolve(source); |
| 4921 assertErrors([StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATI
C_MEMBER]); | 4976 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC
AL_STATIC_MEMBER]); |
| 4922 verify([source]); | 4977 verify([source]); |
| 4923 } | 4978 } |
| 4924 void test_unqualifiedReferenceToNonLocalStaticMember_method() { | 4979 void test_unqualifiedReferenceToNonLocalStaticMember_method() { |
| 4925 Source source = addSource(EngineTestCase.createSource([ | 4980 Source source = addSource(EngineTestCase.createSource([ |
| 4926 "class A {", | 4981 "class A {", |
| 4927 " static void a() {}", | 4982 " static void a() {}", |
| 4928 "}", | 4983 "}", |
| 4929 "class B extends A {", | 4984 "class B extends A {", |
| 4930 " void b() {", | 4985 " void b() {", |
| 4931 " a();", | 4986 " a();", |
| 4932 " }", | 4987 " }", |
| 4933 "}"])); | 4988 "}"])); |
| 4934 resolve(source); | 4989 resolve(source); |
| 4935 assertErrors([StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATI
C_MEMBER]); | 4990 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC
AL_STATIC_MEMBER]); |
| 4936 verify([source]); | 4991 verify([source]); |
| 4937 } | 4992 } |
| 4938 void test_unqualifiedReferenceToNonLocalStaticMember_setter() { | 4993 void test_unqualifiedReferenceToNonLocalStaticMember_setter() { |
| 4939 Source source = addSource(EngineTestCase.createSource([ | 4994 Source source = addSource(EngineTestCase.createSource([ |
| 4940 "class A {", | 4995 "class A {", |
| 4941 " static set a(x) {}", | 4996 " static set a(x) {}", |
| 4942 "}", | 4997 "}", |
| 4943 "class B extends A {", | 4998 "class B extends A {", |
| 4944 " b(y) {", | 4999 " b(y) {", |
| 4945 " a = y;", | 5000 " a = y;", |
| 4946 " }", | 5001 " }", |
| 4947 "}"])); | 5002 "}"])); |
| 4948 resolve(source); | 5003 resolve(source); |
| 4949 assertErrors([StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATI
C_MEMBER]); | 5004 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC
AL_STATIC_MEMBER]); |
| 4950 verify([source]); | 5005 verify([source]); |
| 4951 } | 5006 } |
| 4952 void test_wrongNumberOfTypeArguments_tooFew() { | 5007 void test_wrongNumberOfTypeArguments_tooFew() { |
| 4953 Source source = addSource(EngineTestCase.createSource(["class A<E, F> {}", "
A<A> a = null;"])); | 5008 Source source = addSource(EngineTestCase.createSource(["class A<E, F> {}", "
A<A> a = null;"])); |
| 4954 resolve(source); | 5009 resolve(source); |
| 4955 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); | 5010 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; |
| 4956 verify([source]); | 5011 verify([source]); |
| 4957 } | 5012 } |
| 4958 void test_wrongNumberOfTypeArguments_tooMany() { | 5013 void test_wrongNumberOfTypeArguments_tooMany() { |
| 4959 Source source = addSource(EngineTestCase.createSource(["class A<E> {}", "A<A
, A> a = null;"])); | 5014 Source source = addSource(EngineTestCase.createSource(["class A<E> {}", "A<A
, A> a = null;"])); |
| 4960 resolve(source); | 5015 resolve(source); |
| 4961 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); | 5016 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; |
| 4962 verify([source]); | 5017 verify([source]); |
| 4963 } | 5018 } |
| 4964 void test_wrongNumberOfTypeArguments_typeTest_tooFew() { | 5019 void test_wrongNumberOfTypeArguments_typeTest_tooFew() { |
| 4965 Source source = addSource(EngineTestCase.createSource([ | 5020 Source source = addSource(EngineTestCase.createSource([ |
| 4966 "class A {}", | 5021 "class A {}", |
| 4967 "class C<K, V> {}", | 5022 "class C<K, V> {}", |
| 4968 "f(p) {", | 5023 "f(p) {", |
| 4969 " return p is C<A>;", | 5024 " return p is C<A>;", |
| 4970 "}"])); | 5025 "}"])); |
| 4971 resolve(source); | 5026 resolve(source); |
| 4972 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); | 5027 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; |
| 4973 verify([source]); | 5028 verify([source]); |
| 4974 } | 5029 } |
| 4975 void test_wrongNumberOfTypeArguments_typeTest_tooMany() { | 5030 void test_wrongNumberOfTypeArguments_typeTest_tooMany() { |
| 4976 Source source = addSource(EngineTestCase.createSource([ | 5031 Source source = addSource(EngineTestCase.createSource([ |
| 4977 "class A {}", | 5032 "class A {}", |
| 4978 "class C<E> {}", | 5033 "class C<E> {}", |
| 4979 "f(p) {", | 5034 "f(p) {", |
| 4980 " return p is C<A, A>;", | 5035 " return p is C<A, A>;", |
| 4981 "}"])); | 5036 "}"])); |
| 4982 resolve(source); | 5037 resolve(source); |
| 4983 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); | 5038 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS])
; |
| 4984 verify([source]); | 5039 verify([source]); |
| 4985 } | 5040 } |
| 4986 static dartSuite() { | 5041 static dartSuite() { |
| 4987 _ut.group('StaticTypeWarningCodeTest', () { | 5042 _ut.group('StaticTypeWarningCodeTest', () { |
| 4988 _ut.test('test_inconsistentMethodInheritance_paramCount', () { | 5043 _ut.test('test_inconsistentMethodInheritance_paramCount', () { |
| 4989 final __test = new StaticTypeWarningCodeTest(); | 5044 final __test = new StaticTypeWarningCodeTest(); |
| 4990 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_paramCoun
t); | 5045 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_paramCoun
t); |
| 4991 }); | 5046 }); |
| 4992 _ut.test('test_inconsistentMethodInheritance_paramType', () { | 5047 _ut.test('test_inconsistentMethodInheritance_paramType', () { |
| 4993 final __test = new StaticTypeWarningCodeTest(); | 5048 final __test = new StaticTypeWarningCodeTest(); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5282 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too
Few); | 5337 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too
Few); |
| 5283 }); | 5338 }); |
| 5284 _ut.test('test_wrongNumberOfTypeArguments_typeTest_tooMany', () { | 5339 _ut.test('test_wrongNumberOfTypeArguments_typeTest_tooMany', () { |
| 5285 final __test = new StaticTypeWarningCodeTest(); | 5340 final __test = new StaticTypeWarningCodeTest(); |
| 5286 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too
Many); | 5341 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too
Many); |
| 5287 }); | 5342 }); |
| 5288 }); | 5343 }); |
| 5289 } | 5344 } |
| 5290 } | 5345 } |
| 5291 class HintCodeTest extends ResolverTestCase { | 5346 class HintCodeTest extends ResolverTestCase { |
| 5347 void fail_isInt() { |
| 5348 Source source = addSource(EngineTestCase.createSource(["var v = 1 is int;"])
); |
| 5349 resolve(source); |
| 5350 assertErrors(source, [HintCode.IS_INT]); |
| 5351 verify([source]); |
| 5352 } |
| 5353 void fail_isNotInt() { |
| 5354 Source source = addSource(EngineTestCase.createSource(["var v = 1 is! int;"]
)); |
| 5355 resolve(source); |
| 5356 assertErrors(source, [HintCode.IS_NOT_INT]); |
| 5357 verify([source]); |
| 5358 } |
| 5359 void fail_overrideEqualsButNotHashCode() { |
| 5360 Source source = addSource(EngineTestCase.createSource(["class A {", " bool
operator ==(x) {}", "}"])); |
| 5361 resolve(source); |
| 5362 assertErrors(source, [HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE]); |
| 5363 verify([source]); |
| 5364 } |
| 5292 void test_deadCode_deadBlock_conditionalElse() { | 5365 void test_deadCode_deadBlock_conditionalElse() { |
| 5293 Source source = addSource(EngineTestCase.createSource(["f() {", " true ? 1
: 2;", "}"])); | 5366 Source source = addSource(EngineTestCase.createSource(["f() {", " true ? 1
: 2;", "}"])); |
| 5294 resolve(source); | 5367 resolve(source); |
| 5295 assertErrors([HintCode.DEAD_CODE]); | 5368 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5296 verify([source]); | 5369 verify([source]); |
| 5297 } | 5370 } |
| 5298 void test_deadCode_deadBlock_conditionalElse_nested() { | 5371 void test_deadCode_deadBlock_conditionalElse_nested() { |
| 5299 Source source = addSource(EngineTestCase.createSource(["f() {", " true ? tr
ue : false && false;", "}"])); | 5372 Source source = addSource(EngineTestCase.createSource(["f() {", " true ? tr
ue : false && false;", "}"])); |
| 5300 resolve(source); | 5373 resolve(source); |
| 5301 assertErrors([HintCode.DEAD_CODE]); | 5374 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5302 verify([source]); | 5375 verify([source]); |
| 5303 } | 5376 } |
| 5304 void test_deadCode_deadBlock_conditionalIf() { | 5377 void test_deadCode_deadBlock_conditionalIf() { |
| 5305 Source source = addSource(EngineTestCase.createSource(["f() {", " false ? 1
: 2;", "}"])); | 5378 Source source = addSource(EngineTestCase.createSource(["f() {", " false ? 1
: 2;", "}"])); |
| 5306 resolve(source); | 5379 resolve(source); |
| 5307 assertErrors([HintCode.DEAD_CODE]); | 5380 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5308 verify([source]); | 5381 verify([source]); |
| 5309 } | 5382 } |
| 5310 void test_deadCode_deadBlock_conditionalIf_nested() { | 5383 void test_deadCode_deadBlock_conditionalIf_nested() { |
| 5311 Source source = addSource(EngineTestCase.createSource(["f() {", " false ? f
alse && false : true;", "}"])); | 5384 Source source = addSource(EngineTestCase.createSource(["f() {", " false ? f
alse && false : true;", "}"])); |
| 5312 resolve(source); | 5385 resolve(source); |
| 5313 assertErrors([HintCode.DEAD_CODE]); | 5386 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5314 verify([source]); | 5387 verify([source]); |
| 5315 } | 5388 } |
| 5316 void test_deadCode_deadBlock_else() { | 5389 void test_deadCode_deadBlock_else() { |
| 5317 Source source = addSource(EngineTestCase.createSource(["f() {", " if(true)
{} else {}", "}"])); | 5390 Source source = addSource(EngineTestCase.createSource(["f() {", " if(true)
{} else {}", "}"])); |
| 5318 resolve(source); | 5391 resolve(source); |
| 5319 assertErrors([HintCode.DEAD_CODE]); | 5392 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5320 verify([source]); | 5393 verify([source]); |
| 5321 } | 5394 } |
| 5322 void test_deadCode_deadBlock_else_nested() { | 5395 void test_deadCode_deadBlock_else_nested() { |
| 5323 Source source = addSource(EngineTestCase.createSource(["f() {", " if(true)
{} else {if (false) {}}", "}"])); | 5396 Source source = addSource(EngineTestCase.createSource(["f() {", " if(true)
{} else {if (false) {}}", "}"])); |
| 5324 resolve(source); | 5397 resolve(source); |
| 5325 assertErrors([HintCode.DEAD_CODE]); | 5398 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5326 verify([source]); | 5399 verify([source]); |
| 5327 } | 5400 } |
| 5328 void test_deadCode_deadBlock_if() { | 5401 void test_deadCode_deadBlock_if() { |
| 5329 Source source = addSource(EngineTestCase.createSource(["f() {", " if(false)
{}", "}"])); | 5402 Source source = addSource(EngineTestCase.createSource(["f() {", " if(false)
{}", "}"])); |
| 5330 resolve(source); | 5403 resolve(source); |
| 5331 assertErrors([HintCode.DEAD_CODE]); | 5404 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5332 verify([source]); | 5405 verify([source]); |
| 5333 } | 5406 } |
| 5334 void test_deadCode_deadBlock_if_nested() { | 5407 void test_deadCode_deadBlock_if_nested() { |
| 5335 Source source = addSource(EngineTestCase.createSource(["f() {", " if(false)
{if(false) {}}", "}"])); | 5408 Source source = addSource(EngineTestCase.createSource(["f() {", " if(false)
{if(false) {}}", "}"])); |
| 5336 resolve(source); | 5409 resolve(source); |
| 5337 assertErrors([HintCode.DEAD_CODE]); | 5410 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5338 verify([source]); | 5411 verify([source]); |
| 5339 } | 5412 } |
| 5340 void test_deadCode_deadBlock_while() { | 5413 void test_deadCode_deadBlock_while() { |
| 5341 Source source = addSource(EngineTestCase.createSource(["f() {", " while(fal
se) {}", "}"])); | 5414 Source source = addSource(EngineTestCase.createSource(["f() {", " while(fal
se) {}", "}"])); |
| 5342 resolve(source); | 5415 resolve(source); |
| 5343 assertErrors([HintCode.DEAD_CODE]); | 5416 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5344 verify([source]); | 5417 verify([source]); |
| 5345 } | 5418 } |
| 5346 void test_deadCode_deadBlock_while_nested() { | 5419 void test_deadCode_deadBlock_while_nested() { |
| 5347 Source source = addSource(EngineTestCase.createSource(["f() {", " while(fal
se) {if(false) {}}", "}"])); | 5420 Source source = addSource(EngineTestCase.createSource(["f() {", " while(fal
se) {if(false) {}}", "}"])); |
| 5348 resolve(source); | 5421 resolve(source); |
| 5349 assertErrors([HintCode.DEAD_CODE]); | 5422 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5350 verify([source]); | 5423 verify([source]); |
| 5351 } | 5424 } |
| 5352 void test_deadCode_deadCatch_catchFollowingCatch() { | 5425 void test_deadCode_deadCatch_catchFollowingCatch() { |
| 5353 Source source = addSource(EngineTestCase.createSource([ | 5426 Source source = addSource(EngineTestCase.createSource([ |
| 5354 "class A {}", | 5427 "class A {}", |
| 5355 "f() {", | 5428 "f() {", |
| 5356 " try {} catch (e) {} catch (e) {}", | 5429 " try {} catch (e) {} catch (e) {}", |
| 5357 "}"])); | 5430 "}"])); |
| 5358 resolve(source); | 5431 resolve(source); |
| 5359 assertErrors([HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); | 5432 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); |
| 5360 verify([source]); | 5433 verify([source]); |
| 5361 } | 5434 } |
| 5362 void test_deadCode_deadCatch_catchFollowingCatch_nested() { | 5435 void test_deadCode_deadCatch_catchFollowingCatch_nested() { |
| 5363 Source source = addSource(EngineTestCase.createSource([ | 5436 Source source = addSource(EngineTestCase.createSource([ |
| 5364 "class A {}", | 5437 "class A {}", |
| 5365 "f() {", | 5438 "f() {", |
| 5366 " try {} catch (e) {} catch (e) {if(false) {}}", | 5439 " try {} catch (e) {} catch (e) {if(false) {}}", |
| 5367 "}"])); | 5440 "}"])); |
| 5368 resolve(source); | 5441 resolve(source); |
| 5369 assertErrors([HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); | 5442 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); |
| 5370 verify([source]); | 5443 verify([source]); |
| 5371 } | 5444 } |
| 5372 void test_deadCode_deadCatch_catchFollowingCatch_object() { | 5445 void test_deadCode_deadCatch_catchFollowingCatch_object() { |
| 5373 Source source = addSource(EngineTestCase.createSource([ | 5446 Source source = addSource(EngineTestCase.createSource([ |
| 5374 "f() {", | 5447 "f() {", |
| 5375 " try {} on Object catch (e) {} catch (e) {}", | 5448 " try {} on Object catch (e) {} catch (e) {}", |
| 5376 "}"])); | 5449 "}"])); |
| 5377 resolve(source); | 5450 resolve(source); |
| 5378 assertErrors([HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); | 5451 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); |
| 5379 verify([source]); | 5452 verify([source]); |
| 5380 } | 5453 } |
| 5381 void test_deadCode_deadCatch_catchFollowingCatch_object_nested() { | 5454 void test_deadCode_deadCatch_catchFollowingCatch_object_nested() { |
| 5382 Source source = addSource(EngineTestCase.createSource([ | 5455 Source source = addSource(EngineTestCase.createSource([ |
| 5383 "f() {", | 5456 "f() {", |
| 5384 " try {} on Object catch (e) {} catch (e) {if(false) {}}", | 5457 " try {} on Object catch (e) {} catch (e) {if(false) {}}", |
| 5385 "}"])); | 5458 "}"])); |
| 5386 resolve(source); | 5459 resolve(source); |
| 5387 assertErrors([HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); | 5460 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]); |
| 5388 verify([source]); | 5461 verify([source]); |
| 5389 } | 5462 } |
| 5390 void test_deadCode_deadCatch_onCatchSubtype() { | 5463 void test_deadCode_deadCatch_onCatchSubtype() { |
| 5391 Source source = addSource(EngineTestCase.createSource([ | 5464 Source source = addSource(EngineTestCase.createSource([ |
| 5392 "class A {}", | 5465 "class A {}", |
| 5393 "class B extends A {}", | 5466 "class B extends A {}", |
| 5394 "f() {", | 5467 "f() {", |
| 5395 " try {} on A catch (e) {} on B catch (e) {}", | 5468 " try {} on A catch (e) {} on B catch (e) {}", |
| 5396 "}"])); | 5469 "}"])); |
| 5397 resolve(source); | 5470 resolve(source); |
| 5398 assertErrors([HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]); | 5471 assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]); |
| 5399 verify([source]); | 5472 verify([source]); |
| 5400 } | 5473 } |
| 5401 void test_deadCode_deadCatch_onCatchSubtype_nested() { | 5474 void test_deadCode_deadCatch_onCatchSubtype_nested() { |
| 5402 Source source = addSource(EngineTestCase.createSource([ | 5475 Source source = addSource(EngineTestCase.createSource([ |
| 5403 "class A {}", | 5476 "class A {}", |
| 5404 "class B extends A {}", | 5477 "class B extends A {}", |
| 5405 "f() {", | 5478 "f() {", |
| 5406 " try {} on A catch (e) {} on B catch (e) {if(false) {}}", | 5479 " try {} on A catch (e) {} on B catch (e) {if(false) {}}", |
| 5407 "}"])); | 5480 "}"])); |
| 5408 resolve(source); | 5481 resolve(source); |
| 5409 assertErrors([HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]); | 5482 assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]); |
| 5410 verify([source]); | 5483 verify([source]); |
| 5411 } | 5484 } |
| 5412 void test_deadCode_deadOperandLHS_and() { | 5485 void test_deadCode_deadOperandLHS_and() { |
| 5413 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
false && false;", "}"])); | 5486 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
false && false;", "}"])); |
| 5414 resolve(source); | 5487 resolve(source); |
| 5415 assertErrors([HintCode.DEAD_CODE]); | 5488 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5416 verify([source]); | 5489 verify([source]); |
| 5417 } | 5490 } |
| 5418 void test_deadCode_deadOperandLHS_and_nested() { | 5491 void test_deadCode_deadOperandLHS_and_nested() { |
| 5419 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
false && (false && false);", "}"])); | 5492 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
false && (false && false);", "}"])); |
| 5420 resolve(source); | 5493 resolve(source); |
| 5421 assertErrors([HintCode.DEAD_CODE]); | 5494 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5422 verify([source]); | 5495 verify([source]); |
| 5423 } | 5496 } |
| 5424 void test_deadCode_deadOperandLHS_or() { | 5497 void test_deadCode_deadOperandLHS_or() { |
| 5425 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
true || true;", "}"])); | 5498 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
true || true;", "}"])); |
| 5426 resolve(source); | 5499 resolve(source); |
| 5427 assertErrors([HintCode.DEAD_CODE]); | 5500 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5428 verify([source]); | 5501 verify([source]); |
| 5429 } | 5502 } |
| 5430 void test_deadCode_deadOperandLHS_or_nested() { | 5503 void test_deadCode_deadOperandLHS_or_nested() { |
| 5431 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
true || (false && false);", "}"])); | 5504 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b =
true || (false && false);", "}"])); |
| 5432 resolve(source); | 5505 resolve(source); |
| 5433 assertErrors([HintCode.DEAD_CODE]); | 5506 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5434 verify([source]); | 5507 verify([source]); |
| 5435 } | 5508 } |
| 5436 void test_deadCode_statementAfterReturn_function() { | 5509 void test_deadCode_statementAfterReturn_function() { |
| 5437 Source source = addSource(EngineTestCase.createSource([ | 5510 Source source = addSource(EngineTestCase.createSource([ |
| 5438 "f() {", | 5511 "f() {", |
| 5439 " var one = 1;", | 5512 " var one = 1;", |
| 5440 " return;", | 5513 " return;", |
| 5441 " var two = 2;", | 5514 " var two = 2;", |
| 5442 "}"])); | 5515 "}"])); |
| 5443 resolve(source); | 5516 resolve(source); |
| 5444 assertErrors([HintCode.DEAD_CODE]); | 5517 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5445 verify([source]); | 5518 verify([source]); |
| 5446 } | 5519 } |
| 5447 void test_deadCode_statementAfterReturn_ifStatement() { | 5520 void test_deadCode_statementAfterReturn_ifStatement() { |
| 5448 Source source = addSource(EngineTestCase.createSource([ | 5521 Source source = addSource(EngineTestCase.createSource([ |
| 5449 "f(bool b) {", | 5522 "f(bool b) {", |
| 5450 " if(b) {", | 5523 " if(b) {", |
| 5451 " var one = 1;", | 5524 " var one = 1;", |
| 5452 " return;", | 5525 " return;", |
| 5453 " var two = 2;", | 5526 " var two = 2;", |
| 5454 " }", | 5527 " }", |
| 5455 "}"])); | 5528 "}"])); |
| 5456 resolve(source); | 5529 resolve(source); |
| 5457 assertErrors([HintCode.DEAD_CODE]); | 5530 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5458 verify([source]); | 5531 verify([source]); |
| 5459 } | 5532 } |
| 5460 void test_deadCode_statementAfterReturn_method() { | 5533 void test_deadCode_statementAfterReturn_method() { |
| 5461 Source source = addSource(EngineTestCase.createSource([ | 5534 Source source = addSource(EngineTestCase.createSource([ |
| 5462 "class A {", | 5535 "class A {", |
| 5463 " m() {", | 5536 " m() {", |
| 5464 " var one = 1;", | 5537 " var one = 1;", |
| 5465 " return;", | 5538 " return;", |
| 5466 " var two = 2;", | 5539 " var two = 2;", |
| 5467 " }", | 5540 " }", |
| 5468 "}"])); | 5541 "}"])); |
| 5469 resolve(source); | 5542 resolve(source); |
| 5470 assertErrors([HintCode.DEAD_CODE]); | 5543 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5471 verify([source]); | 5544 verify([source]); |
| 5472 } | 5545 } |
| 5473 void test_deadCode_statementAfterReturn_nested() { | 5546 void test_deadCode_statementAfterReturn_nested() { |
| 5474 Source source = addSource(EngineTestCase.createSource([ | 5547 Source source = addSource(EngineTestCase.createSource([ |
| 5475 "f() {", | 5548 "f() {", |
| 5476 " var one = 1;", | 5549 " var one = 1;", |
| 5477 " return;", | 5550 " return;", |
| 5478 " if(false) {}", | 5551 " if(false) {}", |
| 5479 "}"])); | 5552 "}"])); |
| 5480 resolve(source); | 5553 resolve(source); |
| 5481 assertErrors([HintCode.DEAD_CODE]); | 5554 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5482 verify([source]); | 5555 verify([source]); |
| 5483 } | 5556 } |
| 5484 void test_deadCode_statementAfterReturn_twoReturns() { | 5557 void test_deadCode_statementAfterReturn_twoReturns() { |
| 5485 Source source = addSource(EngineTestCase.createSource([ | 5558 Source source = addSource(EngineTestCase.createSource([ |
| 5486 "f() {", | 5559 "f() {", |
| 5487 " var one = 1;", | 5560 " var one = 1;", |
| 5488 " return;", | 5561 " return;", |
| 5489 " var two = 2;", | 5562 " var two = 2;", |
| 5490 " return;", | 5563 " return;", |
| 5491 " var three = 3;", | 5564 " var three = 3;", |
| 5492 "}"])); | 5565 "}"])); |
| 5493 resolve(source); | 5566 resolve(source); |
| 5494 assertErrors([HintCode.DEAD_CODE]); | 5567 assertErrors(source, [HintCode.DEAD_CODE]); |
| 5568 verify([source]); |
| 5569 } |
| 5570 void test_divisionOptimization_double() { |
| 5571 Source source = addSource(EngineTestCase.createSource([ |
| 5572 "f(double x, double y) {", |
| 5573 " var v = (x / y).toInt();", |
| 5574 "}"])); |
| 5575 resolve(source); |
| 5576 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); |
| 5577 verify([source]); |
| 5578 } |
| 5579 void test_divisionOptimization_int() { |
| 5580 Source source = addSource(EngineTestCase.createSource(["f(int x, int y) {",
" var v = (x / y).toInt();", "}"])); |
| 5581 resolve(source); |
| 5582 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); |
| 5583 verify([source]); |
| 5584 } |
| 5585 void test_divisionOptimization_propagatedType() { |
| 5586 Source source = addSource(EngineTestCase.createSource([ |
| 5587 "f(x, y) {", |
| 5588 " x = 1;", |
| 5589 " y = 1;", |
| 5590 " var v = (x / y).toInt();", |
| 5591 "}"])); |
| 5592 resolve(source); |
| 5593 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); |
| 5594 verify([source]); |
| 5595 } |
| 5596 void test_divisionOptimization_wrappedBinaryExpression() { |
| 5597 Source source = addSource(EngineTestCase.createSource([ |
| 5598 "f(int x, int y) {", |
| 5599 " var v = (((x / y))).toInt();", |
| 5600 "}"])); |
| 5601 resolve(source); |
| 5602 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); |
| 5603 verify([source]); |
| 5604 } |
| 5605 void test_duplicateImport() { |
| 5606 Source source = addSource(EngineTestCase.createSource([ |
| 5607 "library L;", |
| 5608 "import 'lib1.dart';", |
| 5609 "import 'lib1.dart';", |
| 5610 "A a;"])); |
| 5611 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); |
| 5612 resolve(source); |
| 5613 assertErrors(source, [HintCode.DUPLICATE_IMPORT]); |
| 5614 verify([source]); |
| 5615 } |
| 5616 void test_duplicateImport2() { |
| 5617 Source source = addSource(EngineTestCase.createSource([ |
| 5618 "library L;", |
| 5619 "import 'lib1.dart';", |
| 5620 "import 'lib1.dart';", |
| 5621 "import 'lib1.dart';", |
| 5622 "A a;"])); |
| 5623 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); |
| 5624 resolve(source); |
| 5625 assertErrors(source, [HintCode.DUPLICATE_IMPORT, HintCode.DUPLICATE_IMPORT])
; |
| 5626 verify([source]); |
| 5627 } |
| 5628 void test_duplicateImport3() { |
| 5629 Source source = addSource(EngineTestCase.createSource([ |
| 5630 "library L;", |
| 5631 "import 'lib1.dart' as M show A hide B;", |
| 5632 "import 'lib1.dart' as M show A hide B;", |
| 5633 "M.A a;"])); |
| 5634 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}", "class B {}"])); |
| 5635 resolve(source); |
| 5636 assertErrors(source, [HintCode.DUPLICATE_IMPORT, HintCode.UNUSED_IMPORT]); |
| 5637 verify([source]); |
| 5638 } |
| 5639 void test_isDouble() { |
| 5640 Source source = addSource(EngineTestCase.createSource(["var v = 1 is double;
"])); |
| 5641 resolve(source); |
| 5642 assertErrors(source, [HintCode.IS_DOUBLE]); |
| 5643 verify([source]); |
| 5644 } |
| 5645 void test_isNotDouble() { |
| 5646 Source source = addSource(EngineTestCase.createSource(["var v = 1 is! double
;"])); |
| 5647 resolve(source); |
| 5648 assertErrors(source, [HintCode.IS_NOT_DOUBLE]); |
| 5649 verify([source]); |
| 5650 } |
| 5651 void test_overriddingPrivateMember_getter() { |
| 5652 Source source = addSource(EngineTestCase.createSource([ |
| 5653 "import 'lib1.dart';", |
| 5654 "class B extends A {", |
| 5655 " get _g => 0;", |
| 5656 "}"])); |
| 5657 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " get _g => 0;", "}"])); |
| 5658 resolve(source); |
| 5659 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); |
| 5660 verify([source, source2]); |
| 5661 } |
| 5662 void test_overriddingPrivateMember_method() { |
| 5663 Source source = addSource(EngineTestCase.createSource([ |
| 5664 "import 'lib1.dart';", |
| 5665 "class B extends A {", |
| 5666 " _m(int x) => 0;", |
| 5667 "}"])); |
| 5668 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " _m(int x) => 0;", "}"])); |
| 5669 resolve(source); |
| 5670 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); |
| 5671 verify([source, source2]); |
| 5672 } |
| 5673 void test_overriddingPrivateMember_method2() { |
| 5674 Source source = addSource(EngineTestCase.createSource([ |
| 5675 "import 'lib1.dart';", |
| 5676 "class B extends A {}", |
| 5677 "class C extends B {", |
| 5678 " _m(int x) => 0;", |
| 5679 "}"])); |
| 5680 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " _m(int x) => 0;", "}"])); |
| 5681 resolve(source); |
| 5682 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); |
| 5683 verify([source, source2]); |
| 5684 } |
| 5685 void test_overriddingPrivateMember_setter() { |
| 5686 Source source = addSource(EngineTestCase.createSource([ |
| 5687 "import 'lib1.dart';", |
| 5688 "class B extends A {", |
| 5689 " set _s(int x) {}", |
| 5690 "}"])); |
| 5691 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {", " set _s(int x) {}", "}"])); |
| 5692 resolve(source); |
| 5693 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]); |
| 5694 verify([source, source2]); |
| 5695 } |
| 5696 void test_typeCheck_type_is_Null() { |
| 5697 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is Null;", "}"])); |
| 5698 resolve(source); |
| 5699 assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]); |
| 5700 verify([source]); |
| 5701 } |
| 5702 void test_typeCheck_type_not_Null() { |
| 5703 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is! Null;", "}"])); |
| 5704 resolve(source); |
| 5705 assertErrors(source, [HintCode.TYPE_CHECK_IS_NOT_NULL]); |
| 5706 verify([source]); |
| 5707 } |
| 5708 void test_unnecessaryCast_type_supertype() { |
| 5709 Source source = addSource(EngineTestCase.createSource(["m(int i) {", " var
b = i as Object;", "}"])); |
| 5710 resolve(source); |
| 5711 assertErrors(source, [HintCode.UNNECESSARY_CAST]); |
| 5712 verify([source]); |
| 5713 } |
| 5714 void test_unnecessaryCast_type_type() { |
| 5715 Source source = addSource(EngineTestCase.createSource(["m(num i) {", " var
b = i as num;", "}"])); |
| 5716 resolve(source); |
| 5717 assertErrors(source, [HintCode.UNNECESSARY_CAST]); |
| 5718 verify([source]); |
| 5719 } |
| 5720 void test_unnecessaryTypeCheck_null_is_Null() { |
| 5721 Source source = addSource(EngineTestCase.createSource(["bool b = null is Nul
l;"])); |
| 5722 resolve(source); |
| 5723 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]); |
| 5724 verify([source]); |
| 5725 } |
| 5726 void test_unnecessaryTypeCheck_null_not_Null() { |
| 5727 Source source = addSource(EngineTestCase.createSource(["bool b = null is! Nu
ll;"])); |
| 5728 resolve(source); |
| 5729 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]); |
| 5730 verify([source]); |
| 5731 } |
| 5732 void test_unnecessaryTypeCheck_type_is_dynamic() { |
| 5733 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is dynamic;", "}"])); |
| 5734 resolve(source); |
| 5735 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]); |
| 5736 verify([source]); |
| 5737 } |
| 5738 void test_unnecessaryTypeCheck_type_is_object() { |
| 5739 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is Object;", "}"])); |
| 5740 resolve(source); |
| 5741 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]); |
| 5742 verify([source]); |
| 5743 } |
| 5744 void test_unnecessaryTypeCheck_type_not_dynamic() { |
| 5745 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is! dynamic;", "}"])); |
| 5746 resolve(source); |
| 5747 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]); |
| 5748 verify([source]); |
| 5749 } |
| 5750 void test_unnecessaryTypeCheck_type_not_object() { |
| 5751 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b =
i is! Object;", "}"])); |
| 5752 resolve(source); |
| 5753 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]); |
| 5495 verify([source]); | 5754 verify([source]); |
| 5496 } | 5755 } |
| 5497 void test_unusedImport() { | 5756 void test_unusedImport() { |
| 5498 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';"])); | 5757 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';"])); |
| 5499 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); | 5758 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;"])); |
| 5500 resolve(source); | 5759 resolve(source); |
| 5501 assertErrors([HintCode.UNUSED_IMPORT]); | 5760 assertErrors(source, [HintCode.UNUSED_IMPORT]); |
| 5502 verify([source]); | 5761 assertNoErrors(source2); |
| 5762 verify([source, source2]); |
| 5503 } | 5763 } |
| 5504 void test_unusedImport_as() { | 5764 void test_unusedImport_as() { |
| 5505 Source source = addSource(EngineTestCase.createSource([ | 5765 Source source = addSource(EngineTestCase.createSource([ |
| 5506 "library L;", | 5766 "library L;", |
| 5507 "import 'lib1.dart';", | 5767 "import 'lib1.dart';", |
| 5508 "import 'lib1.dart' as one;", | 5768 "import 'lib1.dart' as one;", |
| 5509 "one.A a;"])); | 5769 "one.A a;"])); |
| 5510 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); | 5770 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {}"])); |
| 5511 resolve(source); | 5771 resolve(source); |
| 5512 assertErrors([HintCode.UNUSED_IMPORT]); | 5772 assertErrors(source, [HintCode.UNUSED_IMPORT]); |
| 5513 verify([source]); | 5773 assertNoErrors(source2); |
| 5774 verify([source, source2]); |
| 5514 } | 5775 } |
| 5515 void test_unusedImport_hide() { | 5776 void test_unusedImport_hide() { |
| 5516 Source source = addSource(EngineTestCase.createSource([ | 5777 Source source = addSource(EngineTestCase.createSource([ |
| 5517 "library L;", | 5778 "library L;", |
| 5518 "import 'lib1.dart';", | 5779 "import 'lib1.dart';", |
| 5519 "import 'lib1.dart' hide A;", | 5780 "import 'lib1.dart' hide A;", |
| 5520 "A a;"])); | 5781 "A a;"])); |
| 5521 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); | 5782 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {}"])); |
| 5522 resolve(source); | 5783 resolve(source); |
| 5523 assertErrors([HintCode.UNUSED_IMPORT]); | 5784 assertErrors(source, [HintCode.UNUSED_IMPORT]); |
| 5524 verify([source]); | 5785 assertNoErrors(source2); |
| 5786 verify([source, source2]); |
| 5525 } | 5787 } |
| 5526 void test_unusedImport_show() { | 5788 void test_unusedImport_show() { |
| 5527 Source source = addSource(EngineTestCase.createSource([ | 5789 Source source = addSource(EngineTestCase.createSource([ |
| 5528 "library L;", | 5790 "library L;", |
| 5529 "import 'lib1.dart' show A;", | 5791 "import 'lib1.dart' show A;", |
| 5530 "import 'lib1.dart' show B;", | 5792 "import 'lib1.dart' show B;", |
| 5531 "A a;"])); | 5793 "A a;"])); |
| 5532 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}", "class B {}"])); | 5794 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr
ary lib1;", "class A {}", "class B {}"])); |
| 5533 resolve(source); | 5795 resolve(source); |
| 5534 assertErrors([HintCode.UNUSED_IMPORT]); | 5796 assertErrors(source, [HintCode.UNUSED_IMPORT]); |
| 5535 verify([source]); | 5797 assertNoErrors(source2); |
| 5798 verify([source, source2]); |
| 5536 } | 5799 } |
| 5537 static dartSuite() { | 5800 static dartSuite() { |
| 5538 _ut.group('HintCodeTest', () { | 5801 _ut.group('HintCodeTest', () { |
| 5539 _ut.test('test_deadCode_deadBlock_conditionalElse', () { | 5802 _ut.test('test_deadCode_deadBlock_conditionalElse', () { |
| 5540 final __test = new HintCodeTest(); | 5803 final __test = new HintCodeTest(); |
| 5541 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse); | 5804 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse); |
| 5542 }); | 5805 }); |
| 5543 _ut.test('test_deadCode_deadBlock_conditionalElse_nested', () { | 5806 _ut.test('test_deadCode_deadBlock_conditionalElse_nested', () { |
| 5544 final __test = new HintCodeTest(); | 5807 final __test = new HintCodeTest(); |
| 5545 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse_nest
ed); | 5808 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse_nest
ed); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5629 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_method); | 5892 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_method); |
| 5630 }); | 5893 }); |
| 5631 _ut.test('test_deadCode_statementAfterReturn_nested', () { | 5894 _ut.test('test_deadCode_statementAfterReturn_nested', () { |
| 5632 final __test = new HintCodeTest(); | 5895 final __test = new HintCodeTest(); |
| 5633 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_nested); | 5896 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_nested); |
| 5634 }); | 5897 }); |
| 5635 _ut.test('test_deadCode_statementAfterReturn_twoReturns', () { | 5898 _ut.test('test_deadCode_statementAfterReturn_twoReturns', () { |
| 5636 final __test = new HintCodeTest(); | 5899 final __test = new HintCodeTest(); |
| 5637 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_twoReturn
s); | 5900 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_twoReturn
s); |
| 5638 }); | 5901 }); |
| 5902 _ut.test('test_divisionOptimization_double', () { |
| 5903 final __test = new HintCodeTest(); |
| 5904 runJUnitTest(__test, __test.test_divisionOptimization_double); |
| 5905 }); |
| 5906 _ut.test('test_divisionOptimization_int', () { |
| 5907 final __test = new HintCodeTest(); |
| 5908 runJUnitTest(__test, __test.test_divisionOptimization_int); |
| 5909 }); |
| 5910 _ut.test('test_divisionOptimization_propagatedType', () { |
| 5911 final __test = new HintCodeTest(); |
| 5912 runJUnitTest(__test, __test.test_divisionOptimization_propagatedType); |
| 5913 }); |
| 5914 _ut.test('test_divisionOptimization_wrappedBinaryExpression', () { |
| 5915 final __test = new HintCodeTest(); |
| 5916 runJUnitTest(__test, __test.test_divisionOptimization_wrappedBinaryExpre
ssion); |
| 5917 }); |
| 5918 _ut.test('test_duplicateImport', () { |
| 5919 final __test = new HintCodeTest(); |
| 5920 runJUnitTest(__test, __test.test_duplicateImport); |
| 5921 }); |
| 5922 _ut.test('test_duplicateImport2', () { |
| 5923 final __test = new HintCodeTest(); |
| 5924 runJUnitTest(__test, __test.test_duplicateImport2); |
| 5925 }); |
| 5926 _ut.test('test_duplicateImport3', () { |
| 5927 final __test = new HintCodeTest(); |
| 5928 runJUnitTest(__test, __test.test_duplicateImport3); |
| 5929 }); |
| 5930 _ut.test('test_isDouble', () { |
| 5931 final __test = new HintCodeTest(); |
| 5932 runJUnitTest(__test, __test.test_isDouble); |
| 5933 }); |
| 5934 _ut.test('test_isNotDouble', () { |
| 5935 final __test = new HintCodeTest(); |
| 5936 runJUnitTest(__test, __test.test_isNotDouble); |
| 5937 }); |
| 5938 _ut.test('test_overriddingPrivateMember_getter', () { |
| 5939 final __test = new HintCodeTest(); |
| 5940 runJUnitTest(__test, __test.test_overriddingPrivateMember_getter); |
| 5941 }); |
| 5942 _ut.test('test_overriddingPrivateMember_method', () { |
| 5943 final __test = new HintCodeTest(); |
| 5944 runJUnitTest(__test, __test.test_overriddingPrivateMember_method); |
| 5945 }); |
| 5946 _ut.test('test_overriddingPrivateMember_method2', () { |
| 5947 final __test = new HintCodeTest(); |
| 5948 runJUnitTest(__test, __test.test_overriddingPrivateMember_method2); |
| 5949 }); |
| 5950 _ut.test('test_overriddingPrivateMember_setter', () { |
| 5951 final __test = new HintCodeTest(); |
| 5952 runJUnitTest(__test, __test.test_overriddingPrivateMember_setter); |
| 5953 }); |
| 5954 _ut.test('test_typeCheck_type_is_Null', () { |
| 5955 final __test = new HintCodeTest(); |
| 5956 runJUnitTest(__test, __test.test_typeCheck_type_is_Null); |
| 5957 }); |
| 5958 _ut.test('test_typeCheck_type_not_Null', () { |
| 5959 final __test = new HintCodeTest(); |
| 5960 runJUnitTest(__test, __test.test_typeCheck_type_not_Null); |
| 5961 }); |
| 5962 _ut.test('test_unnecessaryCast_type_supertype', () { |
| 5963 final __test = new HintCodeTest(); |
| 5964 runJUnitTest(__test, __test.test_unnecessaryCast_type_supertype); |
| 5965 }); |
| 5966 _ut.test('test_unnecessaryCast_type_type', () { |
| 5967 final __test = new HintCodeTest(); |
| 5968 runJUnitTest(__test, __test.test_unnecessaryCast_type_type); |
| 5969 }); |
| 5970 _ut.test('test_unnecessaryTypeCheck_null_is_Null', () { |
| 5971 final __test = new HintCodeTest(); |
| 5972 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_null_is_Null); |
| 5973 }); |
| 5974 _ut.test('test_unnecessaryTypeCheck_null_not_Null', () { |
| 5975 final __test = new HintCodeTest(); |
| 5976 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_null_not_Null); |
| 5977 }); |
| 5978 _ut.test('test_unnecessaryTypeCheck_type_is_dynamic', () { |
| 5979 final __test = new HintCodeTest(); |
| 5980 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_type_is_dynamic); |
| 5981 }); |
| 5982 _ut.test('test_unnecessaryTypeCheck_type_is_object', () { |
| 5983 final __test = new HintCodeTest(); |
| 5984 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_type_is_object); |
| 5985 }); |
| 5986 _ut.test('test_unnecessaryTypeCheck_type_not_dynamic', () { |
| 5987 final __test = new HintCodeTest(); |
| 5988 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_type_not_dynamic); |
| 5989 }); |
| 5990 _ut.test('test_unnecessaryTypeCheck_type_not_object', () { |
| 5991 final __test = new HintCodeTest(); |
| 5992 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_type_not_object); |
| 5993 }); |
| 5639 _ut.test('test_unusedImport', () { | 5994 _ut.test('test_unusedImport', () { |
| 5640 final __test = new HintCodeTest(); | 5995 final __test = new HintCodeTest(); |
| 5641 runJUnitTest(__test, __test.test_unusedImport); | 5996 runJUnitTest(__test, __test.test_unusedImport); |
| 5642 }); | 5997 }); |
| 5643 _ut.test('test_unusedImport_as', () { | 5998 _ut.test('test_unusedImport_as', () { |
| 5644 final __test = new HintCodeTest(); | 5999 final __test = new HintCodeTest(); |
| 5645 runJUnitTest(__test, __test.test_unusedImport_as); | 6000 runJUnitTest(__test, __test.test_unusedImport_as); |
| 5646 }); | 6001 }); |
| 5647 _ut.test('test_unusedImport_hide', () { | 6002 _ut.test('test_unusedImport_hide', () { |
| 5648 final __test = new HintCodeTest(); | 6003 final __test = new HintCodeTest(); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6032 */ | 6387 */ |
| 6033 Source addSource2(String filePath, String contents) { | 6388 Source addSource2(String filePath, String contents) { |
| 6034 Source source = cacheSource(filePath, contents); | 6389 Source source = cacheSource(filePath, contents); |
| 6035 ChangeSet changeSet = new ChangeSet(); | 6390 ChangeSet changeSet = new ChangeSet(); |
| 6036 changeSet.added(source); | 6391 changeSet.added(source); |
| 6037 analysisContext.applyChanges(changeSet); | 6392 analysisContext.applyChanges(changeSet); |
| 6038 return source; | 6393 return source; |
| 6039 } | 6394 } |
| 6040 | 6395 |
| 6041 /** | 6396 /** |
| 6042 * Assert that the number of errors that have been gathered matches the number
of errors that are | 6397 * Assert that the number of errors reported against the given source matches
the number of errors |
| 6043 * given and that they have the expected error codes. The order in which the e
rrors were gathered | 6398 * that are given and that they have the expected error codes. The order in wh
ich the errors were |
| 6044 * is ignored. | 6399 * gathered is ignored. |
| 6045 * | 6400 * |
| 6046 * @param expectedErrorCodes the error codes of the errors that should have be
en gathered | 6401 * @param source the source against which the errors should have been reported |
| 6047 * @throws AssertionFailedError if a different number of errors have been gath
ered than were | 6402 * @param expectedErrorCodes the error codes of the errors that should have be
en reported |
| 6403 * @throws AnalysisException if the reported errors could not be computed |
| 6404 * @throws AssertionFailedError if a different number of errors have been repo
rted than were |
| 6048 * expected | 6405 * expected |
| 6049 */ | 6406 */ |
| 6050 void assertErrors(List<ErrorCode> expectedErrorCodes) { | 6407 void assertErrors(Source source, List<ErrorCode> expectedErrorCodes) { |
| 6051 GatheringErrorListener errorListener = new GatheringErrorListener(); | 6408 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 6052 for (ChangeNotice notice in analysisContext.performAnalysisTask()) { | 6409 for (AnalysisError error in analysisContext.computeErrors(source)) { |
| 6053 for (AnalysisError error in notice.errors) { | 6410 errorListener.onError(error); |
| 6054 errorListener.onError(error); | |
| 6055 } | |
| 6056 } | 6411 } |
| 6057 errorListener.assertErrors2(expectedErrorCodes); | 6412 errorListener.assertErrors2(expectedErrorCodes); |
| 6058 } | 6413 } |
| 6059 | 6414 |
| 6060 /** | 6415 /** |
| 6061 * Assert that no errors have been gathered. | 6416 * Assert that no errors have been reported against the given source. |
| 6062 * | 6417 * |
| 6063 * @throws AssertionFailedError if any errors have been gathered | 6418 * @param source the source against which no errors should have been reported |
| 6419 * @throws AnalysisException if the reported errors could not be computed |
| 6420 * @throws AssertionFailedError if any errors have been reported |
| 6064 */ | 6421 */ |
| 6065 void assertNoErrors() { | 6422 void assertNoErrors(Source source) { |
| 6066 GatheringErrorListener errorListener = new GatheringErrorListener(); | 6423 EngineTestCase.assertLength(0, analysisContext.computeErrors(source)); |
| 6067 for (ChangeNotice notice in analysisContext.performAnalysisTask()) { | |
| 6068 for (AnalysisError error in notice.errors) { | |
| 6069 errorListener.onError(error); | |
| 6070 } | |
| 6071 } | |
| 6072 errorListener.assertNoErrors(); | |
| 6073 } | 6424 } |
| 6074 | 6425 |
| 6075 /** | 6426 /** |
| 6076 * Cache the source file content in the source factory but don't add the sourc
e to the analysis | 6427 * Cache the source file content in the source factory but don't add the sourc
e to the analysis |
| 6077 * context. The file path should be absolute. | 6428 * context. The file path should be absolute. |
| 6078 * | 6429 * |
| 6079 * @param filePath the path of the file being cached | 6430 * @param filePath the path of the file being cached |
| 6080 * @param contents the contents to be returned by the content provider for the
specified file | 6431 * @param contents the contents to be returned by the content provider for the
specified file |
| 6081 * @return the source object representing the cached file | 6432 * @return the source object representing the cached file |
| 6082 */ | 6433 */ |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6240 JUnitTestCase.assertSame(symbolType, provider.symbolType); | 6591 JUnitTestCase.assertSame(symbolType, provider.symbolType); |
| 6241 JUnitTestCase.assertSame(typeType, provider.typeType); | 6592 JUnitTestCase.assertSame(typeType, provider.typeType); |
| 6242 } | 6593 } |
| 6243 ClassElement classElement(String typeName, InterfaceType superclassType, List<
String> parameterNames) { | 6594 ClassElement classElement(String typeName, InterfaceType superclassType, List<
String> parameterNames) { |
| 6244 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier3(typeN
ame)); | 6595 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier3(typeN
ame)); |
| 6245 element.supertype = superclassType; | 6596 element.supertype = superclassType; |
| 6246 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element); | 6597 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element); |
| 6247 element.type = type; | 6598 element.type = type; |
| 6248 int count = parameterNames.length; | 6599 int count = parameterNames.length; |
| 6249 if (count > 0) { | 6600 if (count > 0) { |
| 6250 List<TypeVariableElementImpl> typeVariables = new List<TypeVariableElement
Impl>(count); | 6601 List<TypeParameterElementImpl> typeParameters = new List<TypeParameterElem
entImpl>(count); |
| 6251 List<TypeVariableTypeImpl> typeArguments = new List<TypeVariableTypeImpl>(
count); | 6602 List<TypeParameterTypeImpl> typeArguments = new List<TypeParameterTypeImpl
>(count); |
| 6252 for (int i = 0; i < count; i++) { | 6603 for (int i = 0; i < count; i++) { |
| 6253 TypeVariableElementImpl variable = new TypeVariableElementImpl(ASTFactor
y.identifier3(parameterNames[i])); | 6604 TypeParameterElementImpl typeParameter = new TypeParameterElementImpl(AS
TFactory.identifier3(parameterNames[i])); |
| 6254 typeVariables[i] = variable; | 6605 typeParameters[i] = typeParameter; |
| 6255 typeArguments[i] = new TypeVariableTypeImpl(variable); | 6606 typeArguments[i] = new TypeParameterTypeImpl(typeParameter); |
| 6256 variable.type = typeArguments[i]; | 6607 typeParameter.type = typeArguments[i]; |
| 6257 } | 6608 } |
| 6258 element.typeVariables = typeVariables; | 6609 element.typeParameters = typeParameters; |
| 6259 type.typeArguments = typeArguments; | 6610 type.typeArguments = typeArguments; |
| 6260 } | 6611 } |
| 6261 return element; | 6612 return element; |
| 6262 } | 6613 } |
| 6263 static dartSuite() { | 6614 static dartSuite() { |
| 6264 _ut.group('TypeProviderImplTest', () { | 6615 _ut.group('TypeProviderImplTest', () { |
| 6265 _ut.test('test_creation', () { | 6616 _ut.test('test_creation', () { |
| 6266 final __test = new TypeProviderImplTest(); | 6617 final __test = new TypeProviderImplTest(); |
| 6267 runJUnitTest(__test, __test.test_creation); | 6618 runJUnitTest(__test, __test.test_creation); |
| 6268 }); | 6619 }); |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6948 final __test = new InheritanceManagerTest(); | 7299 final __test = new InheritanceManagerTest(); |
| 6949 runJUnitTest(__test, __test.test_lookupMember_setter_static); | 7300 runJUnitTest(__test, __test.test_lookupMember_setter_static); |
| 6950 }); | 7301 }); |
| 6951 }); | 7302 }); |
| 6952 } | 7303 } |
| 6953 } | 7304 } |
| 6954 class CompileTimeErrorCodeTest extends ResolverTestCase { | 7305 class CompileTimeErrorCodeTest extends ResolverTestCase { |
| 6955 void fail_compileTimeConstantRaisesException() { | 7306 void fail_compileTimeConstantRaisesException() { |
| 6956 Source source = addSource(EngineTestCase.createSource([])); | 7307 Source source = addSource(EngineTestCase.createSource([])); |
| 6957 resolve(source); | 7308 resolve(source); |
| 6958 assertErrors([CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION]); | 7309 assertErrors(source, [CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCE
PTION]); |
| 6959 verify([source]); | 7310 verify([source]); |
| 6960 } | 7311 } |
| 6961 void fail_constEvalThrowsException() { | 7312 void fail_constEvalThrowsException() { |
| 6962 Source source = addSource(EngineTestCase.createSource([ | 7313 Source source = addSource(EngineTestCase.createSource([ |
| 6963 "class C {", | 7314 "class C {", |
| 6964 " const C();", | 7315 " const C();", |
| 6965 "}", | 7316 "}", |
| 6966 "f() { return const C(); }"])); | 7317 "f() { return const C(); }"])); |
| 6967 resolve(source); | 7318 resolve(source); |
| 6968 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION]); | 7319 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTIO
N]); |
| 6969 verify([source]); | 7320 verify([source]); |
| 6970 } | 7321 } |
| 6971 void fail_mixinDeclaresConstructor() { | 7322 void fail_mixinDeclaresConstructor() { |
| 6972 Source source = addSource(EngineTestCase.createSource([ | 7323 Source source = addSource(EngineTestCase.createSource([ |
| 6973 "class A {", | 7324 "class A {", |
| 6974 " A() {}", | 7325 " A() {}", |
| 6975 "}", | 7326 "}", |
| 6976 "class B extends Object mixin A {}"])); | 7327 "class B extends Object mixin A {}"])); |
| 6977 resolve(source); | 7328 resolve(source); |
| 6978 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); | 7329 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); |
| 6979 verify([source]); | 7330 verify([source]); |
| 6980 } | 7331 } |
| 6981 void fail_mixinOfNonClass() { | 7332 void fail_mixinOfNonClass() { |
| 6982 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex
tends Object mixin A {}"])); | 7333 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex
tends Object mixin A {}"])); |
| 6983 resolve(source); | 7334 resolve(source); |
| 6984 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); | 7335 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); |
| 6985 verify([source]); | 7336 verify([source]); |
| 6986 } | 7337 } |
| 6987 void fail_objectCannotExtendAnotherClass() { | 7338 void fail_objectCannotExtendAnotherClass() { |
| 6988 Source source = addSource(EngineTestCase.createSource([])); | 7339 Source source = addSource(EngineTestCase.createSource([])); |
| 6989 resolve(source); | 7340 resolve(source); |
| 6990 assertErrors([CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLASS]); | 7341 assertErrors(source, [CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLAS
S]); |
| 6991 verify([source]); | 7342 verify([source]); |
| 6992 } | 7343 } |
| 6993 void fail_recursiveCompileTimeConstant() { | 7344 void fail_recursiveCompileTimeConstant() { |
| 6994 Source source = addSource(EngineTestCase.createSource([ | 7345 Source source = addSource(EngineTestCase.createSource([ |
| 6995 "class A {", | 7346 "class A {", |
| 6996 " const A();", | 7347 " const A();", |
| 6997 " final m = const A();", | 7348 " final m = const A();", |
| 6998 "}"])); | 7349 "}"])); |
| 6999 resolve(source); | 7350 resolve(source); |
| 7000 assertErrors([CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]); | 7351 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT])
; |
| 7001 verify([source]); | 7352 verify([source]); |
| 7002 } | 7353 } |
| 7003 void fail_recursiveCompileTimeConstant_cycle() { | 7354 void fail_recursiveCompileTimeConstant_cycle() { |
| 7004 Source source = addSource(EngineTestCase.createSource(["const x = y + 1;", "
const y = x + 1;"])); | 7355 Source source = addSource(EngineTestCase.createSource(["const x = y + 1;", "
const y = x + 1;"])); |
| 7005 resolve(source); | 7356 resolve(source); |
| 7006 assertErrors([CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]); | 7357 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT])
; |
| 7007 verify([source]); | 7358 verify([source]); |
| 7008 } | 7359 } |
| 7009 void fail_superInitializerInObject() { | 7360 void fail_superInitializerInObject() { |
| 7010 Source source = addSource(EngineTestCase.createSource([])); | 7361 Source source = addSource(EngineTestCase.createSource([])); |
| 7011 resolve(source); | 7362 resolve(source); |
| 7012 assertErrors([CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]); | 7363 assertErrors(source, [CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]); |
| 7013 verify([source]); | 7364 verify([source]); |
| 7014 } | 7365 } |
| 7015 void test_ambiguousExport() { | 7366 void test_ambiguousExport() { |
| 7016 Source source = addSource(EngineTestCase.createSource([ | 7367 Source source = addSource(EngineTestCase.createSource([ |
| 7017 "library L;", | 7368 "library L;", |
| 7018 "export 'lib1.dart';", | 7369 "export 'lib1.dart';", |
| 7019 "export 'lib2.dart';"])); | 7370 "export 'lib2.dart';"])); |
| 7020 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 7371 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 7021 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 7372 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 7022 resolve(source); | 7373 resolve(source); |
| 7023 assertErrors([CompileTimeErrorCode.AMBIGUOUS_EXPORT]); | 7374 assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]); |
| 7024 verify([source]); | 7375 verify([source]); |
| 7025 } | 7376 } |
| 7026 void test_ambiguousImport_function() { | 7377 void test_ambiguousImport_function() { |
| 7027 Source source = addSource(EngineTestCase.createSource([ | 7378 Source source = addSource(EngineTestCase.createSource([ |
| 7028 "import 'lib1.dart';", | 7379 "import 'lib1.dart';", |
| 7029 "import 'lib2.dart';", | 7380 "import 'lib2.dart';", |
| 7030 "g() { return f(); }"])); | 7381 "g() { return f(); }"])); |
| 7031 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "f()
{}"])); | 7382 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "f()
{}"])); |
| 7032 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "f()
{}"])); | 7383 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "f()
{}"])); |
| 7033 resolve(source); | 7384 resolve(source); |
| 7034 assertErrors([ | 7385 assertErrors(source, [ |
| 7035 StaticWarningCode.AMBIGUOUS_IMPORT, | 7386 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 7036 CompileTimeErrorCode.UNDEFINED_FUNCTION]); | 7387 CompileTimeErrorCode.UNDEFINED_FUNCTION]); |
| 7037 } | 7388 } |
| 7038 void test_argumentDefinitionTestNonParameter() { | 7389 void test_argumentDefinitionTestNonParameter() { |
| 7039 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0;
", " return ?v;", "}"])); | 7390 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0;
", " return ?v;", "}"])); |
| 7040 resolve(source); | 7391 resolve(source); |
| 7041 assertErrors([ | 7392 assertErrors(source, [ |
| 7042 ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST, | 7393 ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST, |
| 7043 CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER]); | 7394 CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER]); |
| 7044 verify([source]); | 7395 verify([source]); |
| 7045 } | 7396 } |
| 7046 void test_argumentTypeNotAssignable_const() { | 7397 void test_argumentTypeNotAssignable_const() { |
| 7047 Source source = addSource(EngineTestCase.createSource([ | 7398 Source source = addSource(EngineTestCase.createSource([ |
| 7048 "class A {", | 7399 "class A {", |
| 7049 " const A(String p);", | 7400 " const A(String p);", |
| 7050 "}", | 7401 "}", |
| 7051 "main() {", | 7402 "main() {", |
| 7052 " const A(42);", | 7403 " const A(42);", |
| 7053 "}"])); | 7404 "}"])); |
| 7054 resolve(source); | 7405 resolve(source); |
| 7055 assertErrors([CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 7406 assertErrors(source, [CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 7056 verify([source]); | 7407 verify([source]); |
| 7057 } | 7408 } |
| 7058 void test_argumentTypeNotAssignable_const_super() { | 7409 void test_argumentTypeNotAssignable_const_super() { |
| 7059 Source source = addSource(EngineTestCase.createSource([ | 7410 Source source = addSource(EngineTestCase.createSource([ |
| 7060 "class A {", | 7411 "class A {", |
| 7061 " const A(String p);", | 7412 " const A(String p);", |
| 7062 "}", | 7413 "}", |
| 7063 "class B extends A {", | 7414 "class B extends A {", |
| 7064 " const B() : super(42);", | 7415 " const B() : super(42);", |
| 7065 "}"])); | 7416 "}"])); |
| 7066 resolve(source); | 7417 resolve(source); |
| 7067 assertErrors([CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 7418 assertErrors(source, [CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 7068 verify([source]); | 7419 verify([source]); |
| 7069 } | 7420 } |
| 7070 void test_builtInIdentifierAsType() { | 7421 void test_builtInIdentifierAsType() { |
| 7071 Source source = addSource(EngineTestCase.createSource(["f() {", " typedef x
;", "}"])); | 7422 Source source = addSource(EngineTestCase.createSource(["f() {", " typedef x
;", "}"])); |
| 7072 resolve(source); | 7423 resolve(source); |
| 7073 assertErrors([ | 7424 assertErrors(source, [ |
| 7074 CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, | 7425 CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, |
| 7075 StaticWarningCode.UNDEFINED_CLASS]); | 7426 StaticWarningCode.UNDEFINED_CLASS]); |
| 7076 verify([source]); | 7427 verify([source]); |
| 7077 } | 7428 } |
| 7078 void test_builtInIdentifierAsTypedefName_classTypeAlias() { | 7429 void test_builtInIdentifierAsTypedefName_classTypeAlias() { |
| 7079 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B {}", "typedef as = A with B;"])); | 7430 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B {}", "typedef as = A with B;"])); |
| 7080 resolve(source); | 7431 resolve(source); |
| 7081 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]); | 7432 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NA
ME]); |
| 7082 verify([source]); | 7433 verify([source]); |
| 7083 } | 7434 } |
| 7084 void test_builtInIdentifierAsTypedefName_functionTypeAlias() { | 7435 void test_builtInIdentifierAsTypedefName_functionTypeAlias() { |
| 7085 Source source = addSource(EngineTestCase.createSource(["typedef bool as();"]
)); | 7436 Source source = addSource(EngineTestCase.createSource(["typedef bool as();"]
)); |
| 7086 resolve(source); | 7437 resolve(source); |
| 7087 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]); | 7438 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NA
ME]); |
| 7088 verify([source]); | 7439 verify([source]); |
| 7089 } | 7440 } |
| 7090 void test_builtInIdentifierAsTypeName() { | 7441 void test_builtInIdentifierAsTypeName() { |
| 7091 Source source = addSource(EngineTestCase.createSource(["class as {}"])); | 7442 Source source = addSource(EngineTestCase.createSource(["class as {}"])); |
| 7092 resolve(source); | 7443 resolve(source); |
| 7093 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]); | 7444 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]
); |
| 7094 verify([source]); | 7445 verify([source]); |
| 7095 } | 7446 } |
| 7096 void test_builtInIdentifierAsTypeVariableName() { | 7447 void test_builtInIdentifierAsTypeParameterName() { |
| 7097 Source source = addSource(EngineTestCase.createSource(["class A<as> {}"])); | 7448 Source source = addSource(EngineTestCase.createSource(["class A<as> {}"])); |
| 7098 resolve(source); | 7449 resolve(source); |
| 7099 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME
]); | 7450 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAM
ETER_NAME]); |
| 7100 verify([source]); | 7451 verify([source]); |
| 7101 } | 7452 } |
| 7102 void test_caseExpressionTypeImplementsEquals() { | 7453 void test_caseExpressionTypeImplementsEquals() { |
| 7103 Source source = addSource(EngineTestCase.createSource([ | 7454 Source source = addSource(EngineTestCase.createSource([ |
| 7104 "class IntWrapper {", | 7455 "class IntWrapper {", |
| 7105 " final int value;", | 7456 " final int value;", |
| 7106 " const IntWrapper(this.value);", | 7457 " const IntWrapper(this.value);", |
| 7107 " bool operator ==(IntWrapper x) {", | 7458 " bool operator ==(IntWrapper x) {", |
| 7108 " return value == x.value;", | 7459 " return value == x.value;", |
| 7109 " }", | 7460 " }", |
| 7461 " get hashCode => value;", |
| 7110 "}", | 7462 "}", |
| 7111 "", | 7463 "", |
| 7112 "f(var a) {", | 7464 "f(var a) {", |
| 7113 " switch(a) {", | 7465 " switch(a) {", |
| 7114 " case(const IntWrapper(1)) : return 1;", | 7466 " case(const IntWrapper(1)) : return 1;", |
| 7115 " default: return 0;", | 7467 " default: return 0;", |
| 7116 " }", | 7468 " }", |
| 7117 "}"])); | 7469 "}"])); |
| 7118 resolve(source); | 7470 resolve(source); |
| 7119 assertErrors([CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); | 7471 assertErrors(source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_E
QUALS]); |
| 7120 verify([source]); | 7472 verify([source]); |
| 7121 } | 7473 } |
| 7122 void test_conflictingConstructorNameAndMember_field() { | 7474 void test_conflictingConstructorNameAndMember_field() { |
| 7123 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A.x() {}", "}"])); | 7475 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A.x() {}", "}"])); |
| 7124 resolve(source); | 7476 resolve(source); |
| 7125 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD]); | 7477 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_
FIELD]); |
| 7126 verify([source]); | 7478 verify([source]); |
| 7127 } | 7479 } |
| 7128 void test_conflictingConstructorNameAndMember_method() { | 7480 void test_conflictingConstructorNameAndMember_method() { |
| 7129 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A.x();", " void x() {}", "}"])); | 7481 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A.x();", " void x() {}", "}"])); |
| 7130 resolve(source); | 7482 resolve(source); |
| 7131 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD])
; | 7483 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_
METHOD]); |
| 7132 verify([source]); | 7484 verify([source]); |
| 7133 } | 7485 } |
| 7134 void test_conflictingGetterAndMethod_field_method() { | 7486 void test_conflictingGetterAndMethod_field_method() { |
| 7135 Source source = addSource(EngineTestCase.createSource([ | 7487 Source source = addSource(EngineTestCase.createSource([ |
| 7136 "class A {", | 7488 "class A {", |
| 7137 " int m;", | 7489 " int m;", |
| 7138 "}", | 7490 "}", |
| 7139 "class B extends A {", | 7491 "class B extends A {", |
| 7140 " m() {}", | 7492 " m() {}", |
| 7141 "}"])); | 7493 "}"])); |
| 7142 resolve(source); | 7494 resolve(source); |
| 7143 assertErrors([CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]); | 7495 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]); |
| 7144 verify([source]); | 7496 verify([source]); |
| 7145 } | 7497 } |
| 7146 void test_conflictingGetterAndMethod_getter_method() { | 7498 void test_conflictingGetterAndMethod_getter_method() { |
| 7147 Source source = addSource(EngineTestCase.createSource([ | 7499 Source source = addSource(EngineTestCase.createSource([ |
| 7148 "class A {", | 7500 "class A {", |
| 7149 " get m => 0;", | 7501 " get m => 0;", |
| 7150 "}", | 7502 "}", |
| 7151 "class B extends A {", | 7503 "class B extends A {", |
| 7152 " m() {}", | 7504 " m() {}", |
| 7153 "}"])); | 7505 "}"])); |
| 7154 resolve(source); | 7506 resolve(source); |
| 7155 assertErrors([CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]); | 7507 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]); |
| 7156 verify([source]); | 7508 verify([source]); |
| 7157 } | 7509 } |
| 7158 void test_conflictingGetterAndMethod_method_field() { | 7510 void test_conflictingGetterAndMethod_method_field() { |
| 7159 Source source = addSource(EngineTestCase.createSource([ | 7511 Source source = addSource(EngineTestCase.createSource([ |
| 7160 "class A {", | 7512 "class A {", |
| 7161 " m() {}", | 7513 " m() {}", |
| 7162 "}", | 7514 "}", |
| 7163 "class B extends A {", | 7515 "class B extends A {", |
| 7164 " int m;", | 7516 " int m;", |
| 7165 "}"])); | 7517 "}"])); |
| 7166 resolve(source); | 7518 resolve(source); |
| 7167 assertErrors([CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]); | 7519 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]); |
| 7168 verify([source]); | 7520 verify([source]); |
| 7169 } | 7521 } |
| 7170 void test_conflictingGetterAndMethod_method_getter() { | 7522 void test_conflictingGetterAndMethod_method_getter() { |
| 7171 Source source = addSource(EngineTestCase.createSource([ | 7523 Source source = addSource(EngineTestCase.createSource([ |
| 7172 "class A {", | 7524 "class A {", |
| 7173 " m() {}", | 7525 " m() {}", |
| 7174 "}", | 7526 "}", |
| 7175 "class B extends A {", | 7527 "class B extends A {", |
| 7176 " get m => 0;", | 7528 " get m => 0;", |
| 7177 "}"])); | 7529 "}"])); |
| 7178 resolve(source); | 7530 resolve(source); |
| 7179 assertErrors([CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]); | 7531 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]); |
| 7180 verify([source]); | 7532 verify([source]); |
| 7181 } | 7533 } |
| 7182 void test_constConstructorWithNonConstSuper_explicit() { | 7534 void test_constConstructorWithNonConstSuper_explicit() { |
| 7183 Source source = addSource(EngineTestCase.createSource([ | 7535 Source source = addSource(EngineTestCase.createSource([ |
| 7184 "class A {", | 7536 "class A {", |
| 7185 " A();", | 7537 " A();", |
| 7186 "}", | 7538 "}", |
| 7187 "class B extends A {", | 7539 "class B extends A {", |
| 7188 " const B(): super();", | 7540 " const B(): super();", |
| 7189 "}"])); | 7541 "}"])); |
| 7190 resolve(source); | 7542 resolve(source); |
| 7191 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]); | 7543 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_
SUPER]); |
| 7192 verify([source]); | 7544 verify([source]); |
| 7193 } | 7545 } |
| 7194 void test_constConstructorWithNonConstSuper_implicit() { | 7546 void test_constConstructorWithNonConstSuper_implicit() { |
| 7195 Source source = addSource(EngineTestCase.createSource([ | 7547 Source source = addSource(EngineTestCase.createSource([ |
| 7196 "class A {", | 7548 "class A {", |
| 7197 " A();", | 7549 " A();", |
| 7198 "}", | 7550 "}", |
| 7199 "class B extends A {", | 7551 "class B extends A {", |
| 7200 " const B();", | 7552 " const B();", |
| 7201 "}"])); | 7553 "}"])); |
| 7202 resolve(source); | 7554 resolve(source); |
| 7203 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]); | 7555 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_
SUPER]); |
| 7204 verify([source]); | 7556 verify([source]); |
| 7205 } | 7557 } |
| 7206 void test_constConstructorWithNonFinalField_mixin() { | 7558 void test_constConstructorWithNonFinalField_mixin() { |
| 7207 Source source = addSource(EngineTestCase.createSource([ | 7559 Source source = addSource(EngineTestCase.createSource([ |
| 7208 "class A {", | 7560 "class A {", |
| 7209 " var a;", | 7561 " var a;", |
| 7210 "}", | 7562 "}", |
| 7211 "class B extends Object with A {", | 7563 "class B extends Object with A {", |
| 7212 " const B();", | 7564 " const B();", |
| 7213 "}"])); | 7565 "}"])); |
| 7214 resolve(source); | 7566 resolve(source); |
| 7215 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]); | 7567 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_
FIELD]); |
| 7216 verify([source]); | 7568 verify([source]); |
| 7217 } | 7569 } |
| 7218 void test_constConstructorWithNonFinalField_super() { | 7570 void test_constConstructorWithNonFinalField_super() { |
| 7219 Source source = addSource(EngineTestCase.createSource([ | 7571 Source source = addSource(EngineTestCase.createSource([ |
| 7220 "class A {", | 7572 "class A {", |
| 7221 " var a;", | 7573 " var a;", |
| 7222 "}", | 7574 "}", |
| 7223 "class B extends A {", | 7575 "class B extends A {", |
| 7224 " const B();", | 7576 " const B();", |
| 7225 "}"])); | 7577 "}"])); |
| 7226 resolve(source); | 7578 resolve(source); |
| 7227 assertErrors([ | 7579 assertErrors(source, [ |
| 7228 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD, | 7580 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD, |
| 7229 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]); | 7581 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]); |
| 7230 verify([source]); | 7582 verify([source]); |
| 7231 } | 7583 } |
| 7232 void test_constConstructorWithNonFinalField_this() { | 7584 void test_constConstructorWithNonFinalField_this() { |
| 7233 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " const A();", "}"])); | 7585 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " const A();", "}"])); |
| 7234 resolve(source); | 7586 resolve(source); |
| 7235 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]); | 7587 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_
FIELD]); |
| 7236 verify([source]); | 7588 verify([source]); |
| 7237 } | 7589 } |
| 7238 void test_constEval_newInstance_constConstructor() { | 7590 void test_constEval_newInstance_constConstructor() { |
| 7239 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A();", "}", "const a = new A();"])); | 7591 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A();", "}", "const a = new A();"])); |
| 7240 resolve(source); | 7592 resolve(source); |
| 7241 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
]); | 7593 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); |
| 7242 verify([source]); | 7594 verify([source]); |
| 7243 } | 7595 } |
| 7244 void test_constEval_propertyExtraction_targetNotConst() { | 7596 void test_constEval_propertyExtraction_targetNotConst() { |
| 7245 Source source = addSource(EngineTestCase.createSource([ | 7597 Source source = addSource(EngineTestCase.createSource([ |
| 7246 "class A {", | 7598 "class A {", |
| 7247 " const A();", | 7599 " const A();", |
| 7248 " m() {}", | 7600 " m() {}", |
| 7249 "}", | 7601 "}", |
| 7250 "final a = const A();", | 7602 "final a = const A();", |
| 7251 "const C = a.m;"])); | 7603 "const C = a.m;"])); |
| 7252 resolve(source); | 7604 resolve(source); |
| 7253 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
]); | 7605 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); |
| 7254 verify([source]); | 7606 verify([source]); |
| 7255 } | 7607 } |
| 7256 void test_constEvalThrowsException_binaryMinus_null() { | 7608 void test_constEvalThrowsException_binaryMinus_null() { |
| 7257 check_constEvalThrowsException_binary_null("null - 5", false); | 7609 check_constEvalThrowsException_binary_null("null - 5", false); |
| 7258 check_constEvalThrowsException_binary_null("5 - null", true); | 7610 check_constEvalThrowsException_binary_null("5 - null", true); |
| 7259 } | 7611 } |
| 7260 void test_constEvalThrowsException_binaryPlus_null() { | 7612 void test_constEvalThrowsException_binaryPlus_null() { |
| 7261 check_constEvalThrowsException_binary_null("null + 5", false); | 7613 check_constEvalThrowsException_binary_null("null + 5", false); |
| 7262 check_constEvalThrowsException_binary_null("5 + null", true); | 7614 check_constEvalThrowsException_binary_null("5 + null", true); |
| 7263 } | 7615 } |
| 7264 void test_constEvalThrowsException_divisionByZero() { | 7616 void test_constEvalThrowsException_divisionByZero() { |
| 7265 Source source = addSource("const C = 1 ~/ 0;"); | 7617 Source source = addSource("const C = 1 ~/ 0;"); |
| 7266 resolve(source); | 7618 resolve(source); |
| 7267 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE]); | 7619 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE]); |
| 7268 verify([source]); | 7620 verify([source]); |
| 7269 } | 7621 } |
| 7270 void test_constEvalThrowsException_unaryBitNot_null() { | 7622 void test_constEvalThrowsException_unaryBitNot_null() { |
| 7271 Source source = addSource("const C = ~null;"); | 7623 Source source = addSource("const C = ~null;"); |
| 7272 resolve(source); | 7624 resolve(source); |
| 7273 assertErrors([ | 7625 assertErrors(source, [ |
| 7274 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, | 7626 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, |
| 7275 StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 7627 StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 7276 } | 7628 } |
| 7277 void test_constEvalThrowsException_unaryNegated_null() { | 7629 void test_constEvalThrowsException_unaryNegated_null() { |
| 7278 Source source = addSource("const C = -null;"); | 7630 Source source = addSource("const C = -null;"); |
| 7279 resolve(source); | 7631 resolve(source); |
| 7280 assertErrors([ | 7632 assertErrors(source, [ |
| 7281 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, | 7633 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, |
| 7282 StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 7634 StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 7283 } | 7635 } |
| 7284 void test_constEvalThrowsException_unaryNot_null() { | 7636 void test_constEvalThrowsException_unaryNot_null() { |
| 7285 Source source = addSource("const C = !null;"); | 7637 Source source = addSource("const C = !null;"); |
| 7286 resolve(source); | 7638 resolve(source); |
| 7287 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); | 7639 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); |
| 7288 verify([source]); | 7640 verify([source]); |
| 7289 } | 7641 } |
| 7290 void test_constEvalTypeBool_binary() { | 7642 void test_constEvalTypeBool_binary() { |
| 7291 check_constEvalTypeBool_withParameter_binary("p && ''"); | 7643 check_constEvalTypeBool_withParameter_binary("p && ''"); |
| 7292 check_constEvalTypeBool_withParameter_binary("p || ''"); | 7644 check_constEvalTypeBool_withParameter_binary("p || ''"); |
| 7293 } | 7645 } |
| 7294 void test_constEvalTypeBool_binary_leftTrue() { | 7646 void test_constEvalTypeBool_binary_leftTrue() { |
| 7295 Source source = addSource("const C = (true || 0);"); | 7647 Source source = addSource("const C = (true || 0);"); |
| 7296 resolve(source); | 7648 resolve(source); |
| 7297 assertErrors([ | 7649 assertErrors(source, [ |
| 7298 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, | 7650 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, |
| 7299 HintCode.DEAD_CODE]); | 7651 HintCode.DEAD_CODE]); |
| 7300 verify([source]); | 7652 verify([source]); |
| 7301 } | 7653 } |
| 7302 void test_constEvalTypeBoolNumString_equal() { | 7654 void test_constEvalTypeBoolNumString_equal() { |
| 7303 Source source = addSource(EngineTestCase.createSource([ | 7655 Source source = addSource(EngineTestCase.createSource([ |
| 7304 "class A {", | 7656 "class A {", |
| 7305 " const A();", | 7657 " const A();", |
| 7306 "}", | 7658 "}", |
| 7307 "class B {", | 7659 "class B {", |
| 7308 " final a;", | 7660 " final a;", |
| 7309 " const B(num p) : a = p == const A();", | 7661 " const B(num p) : a = p == const A();", |
| 7310 "}"])); | 7662 "}"])); |
| 7311 resolve(source); | 7663 resolve(source); |
| 7312 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]); | 7664 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING])
; |
| 7313 verify([source]); | 7665 verify([source]); |
| 7314 } | 7666 } |
| 7315 void test_constEvalTypeBoolNumString_notEqual() { | 7667 void test_constEvalTypeBoolNumString_notEqual() { |
| 7316 Source source = addSource(EngineTestCase.createSource([ | 7668 Source source = addSource(EngineTestCase.createSource([ |
| 7317 "class A {", | 7669 "class A {", |
| 7318 " const A();", | 7670 " const A();", |
| 7319 "}", | 7671 "}", |
| 7320 "class B {", | 7672 "class B {", |
| 7321 " final a;", | 7673 " final a;", |
| 7322 " const B(String p) : a = p != const A();", | 7674 " const B(String p) : a = p != const A();", |
| 7323 "}"])); | 7675 "}"])); |
| 7324 resolve(source); | 7676 resolve(source); |
| 7325 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]); | 7677 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING])
; |
| 7326 verify([source]); | 7678 verify([source]); |
| 7327 } | 7679 } |
| 7328 void test_constEvalTypeInt_binary() { | 7680 void test_constEvalTypeInt_binary() { |
| 7329 check_constEvalTypeInt_withParameter_binary("p ^ ''"); | 7681 check_constEvalTypeInt_withParameter_binary("p ^ ''"); |
| 7330 check_constEvalTypeInt_withParameter_binary("p & ''"); | 7682 check_constEvalTypeInt_withParameter_binary("p & ''"); |
| 7331 check_constEvalTypeInt_withParameter_binary("p | ''"); | 7683 check_constEvalTypeInt_withParameter_binary("p | ''"); |
| 7332 check_constEvalTypeInt_withParameter_binary("p >> ''"); | 7684 check_constEvalTypeInt_withParameter_binary("p >> ''"); |
| 7333 check_constEvalTypeInt_withParameter_binary("p << ''"); | 7685 check_constEvalTypeInt_withParameter_binary("p << ''"); |
| 7334 } | 7686 } |
| 7335 void test_constEvalTypeNum_binary() { | 7687 void test_constEvalTypeNum_binary() { |
| 7336 check_constEvalTypeNum_withParameter_binary("p + ''"); | 7688 check_constEvalTypeNum_withParameter_binary("p + ''"); |
| 7337 check_constEvalTypeNum_withParameter_binary("p - ''"); | 7689 check_constEvalTypeNum_withParameter_binary("p - ''"); |
| 7338 check_constEvalTypeNum_withParameter_binary("p * ''"); | 7690 check_constEvalTypeNum_withParameter_binary("p * ''"); |
| 7339 check_constEvalTypeNum_withParameter_binary("p / ''"); | 7691 check_constEvalTypeNum_withParameter_binary("p / ''"); |
| 7340 check_constEvalTypeNum_withParameter_binary("p ~/ ''"); | 7692 check_constEvalTypeNum_withParameter_binary("p ~/ ''"); |
| 7341 check_constEvalTypeNum_withParameter_binary("p > ''"); | 7693 check_constEvalTypeNum_withParameter_binary("p > ''"); |
| 7342 check_constEvalTypeNum_withParameter_binary("p < ''"); | 7694 check_constEvalTypeNum_withParameter_binary("p < ''"); |
| 7343 check_constEvalTypeNum_withParameter_binary("p >= ''"); | 7695 check_constEvalTypeNum_withParameter_binary("p >= ''"); |
| 7344 check_constEvalTypeNum_withParameter_binary("p <= ''"); | 7696 check_constEvalTypeNum_withParameter_binary("p <= ''"); |
| 7345 check_constEvalTypeNum_withParameter_binary("p % ''"); | 7697 check_constEvalTypeNum_withParameter_binary("p % ''"); |
| 7346 } | 7698 } |
| 7347 void test_constEvalTypeNum_plus_String() { | 7699 void test_constEvalTypeNum_plus_String() { |
| 7348 Source source = addSource("const C = 'a' + 'b';"); | 7700 Source source = addSource("const C = 'a' + 'b';"); |
| 7349 resolve(source); | 7701 resolve(source); |
| 7350 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_NUM]); | 7702 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_NUM]); |
| 7351 verify([source]); | 7703 verify([source]); |
| 7352 } | 7704 } |
| 7353 void test_constFormalParameter_fieldFormalParameter() { | 7705 void test_constFormalParameter_fieldFormalParameter() { |
| 7354 Source source = addSource(EngineTestCase.createSource(["class A {", " var x
;", " A(const this.x) {}", "}"])); | 7706 Source source = addSource(EngineTestCase.createSource(["class A {", " var x
;", " A(const this.x) {}", "}"])); |
| 7355 resolve(source); | 7707 resolve(source); |
| 7356 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); | 7708 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); |
| 7357 verify([source]); | 7709 verify([source]); |
| 7358 } | 7710 } |
| 7359 void test_constFormalParameter_simpleFormalParameter() { | 7711 void test_constFormalParameter_simpleFormalParameter() { |
| 7360 Source source = addSource(EngineTestCase.createSource(["f(const x) {}"])); | 7712 Source source = addSource(EngineTestCase.createSource(["f(const x) {}"])); |
| 7361 resolve(source); | 7713 resolve(source); |
| 7362 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); | 7714 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); |
| 7363 verify([source]); | 7715 verify([source]); |
| 7364 } | 7716 } |
| 7365 void test_constInitializedWithNonConstValue() { | 7717 void test_constInitializedWithNonConstValue() { |
| 7366 Source source = addSource(EngineTestCase.createSource(["f(p) {", " const C
= p;", "}"])); | 7718 Source source = addSource(EngineTestCase.createSource(["f(p) {", " const C
= p;", "}"])); |
| 7367 resolve(source); | 7719 resolve(source); |
| 7368 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
]); | 7720 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); |
| 7369 verify([source]); | 7721 verify([source]); |
| 7370 } | 7722 } |
| 7371 void test_constInitializedWithNonConstValue_missingConstInListLiteral() { | 7723 void test_constInitializedWithNonConstValue_missingConstInListLiteral() { |
| 7372 Source source = addSource("const List L = [0];"); | 7724 Source source = addSource("const List L = [0];"); |
| 7373 resolve(source); | 7725 resolve(source); |
| 7374 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
]); | 7726 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); |
| 7375 verify([source]); | 7727 verify([source]); |
| 7376 } | 7728 } |
| 7377 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() { | 7729 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() { |
| 7378 Source source = addSource("const Map M = {'a' : 0};"); | 7730 Source source = addSource("const Map M = {'a' : 0};"); |
| 7379 resolve(source); | 7731 resolve(source); |
| 7380 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
]); | 7732 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA
NT_VALUE]); |
| 7381 verify([source]); | 7733 verify([source]); |
| 7382 } | 7734 } |
| 7383 void test_constInstanceField() { | 7735 void test_constInstanceField() { |
| 7384 Source source = addSource(EngineTestCase.createSource(["class C {", " const
int f = 0;", "}"])); | 7736 Source source = addSource(EngineTestCase.createSource(["class C {", " const
int f = 0;", "}"])); |
| 7385 resolve(source); | 7737 resolve(source); |
| 7386 assertErrors([CompileTimeErrorCode.CONST_INSTANCE_FIELD]); | 7738 assertErrors(source, [CompileTimeErrorCode.CONST_INSTANCE_FIELD]); |
| 7387 verify([source]); | 7739 verify([source]); |
| 7388 } | 7740 } |
| 7389 void test_constWithInvalidTypeParameters() { | 7741 void test_constWithInvalidTypeParameters() { |
| 7390 Source source = addSource(EngineTestCase.createSource([ | 7742 Source source = addSource(EngineTestCase.createSource([ |
| 7391 "class A {", | 7743 "class A {", |
| 7392 " const A();", | 7744 " const A();", |
| 7393 "}", | 7745 "}", |
| 7394 "f() { return const A<A>(); }"])); | 7746 "f() { return const A<A>(); }"])); |
| 7395 resolve(source); | 7747 resolve(source); |
| 7396 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]); | 7748 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER
S]); |
| 7397 verify([source]); | 7749 verify([source]); |
| 7398 } | 7750 } |
| 7399 void test_constWithInvalidTypeParameters_tooFew() { | 7751 void test_constWithInvalidTypeParameters_tooFew() { |
| 7400 Source source = addSource(EngineTestCase.createSource([ | 7752 Source source = addSource(EngineTestCase.createSource([ |
| 7401 "class A {}", | 7753 "class A {}", |
| 7402 "class C<K, V> {", | 7754 "class C<K, V> {", |
| 7403 " const C();", | 7755 " const C();", |
| 7404 "}", | 7756 "}", |
| 7405 "f(p) {", | 7757 "f(p) {", |
| 7406 " return const C<A>();", | 7758 " return const C<A>();", |
| 7407 "}"])); | 7759 "}"])); |
| 7408 resolve(source); | 7760 resolve(source); |
| 7409 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]); | 7761 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER
S]); |
| 7410 verify([source]); | 7762 verify([source]); |
| 7411 } | 7763 } |
| 7412 void test_constWithInvalidTypeParameters_tooMany() { | 7764 void test_constWithInvalidTypeParameters_tooMany() { |
| 7413 Source source = addSource(EngineTestCase.createSource([ | 7765 Source source = addSource(EngineTestCase.createSource([ |
| 7414 "class A {}", | 7766 "class A {}", |
| 7415 "class C<E> {", | 7767 "class C<E> {", |
| 7416 " const C();", | 7768 " const C();", |
| 7417 "}", | 7769 "}", |
| 7418 "f(p) {", | 7770 "f(p) {", |
| 7419 " return const C<A, A>();", | 7771 " return const C<A, A>();", |
| 7420 "}"])); | 7772 "}"])); |
| 7421 resolve(source); | 7773 resolve(source); |
| 7422 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]); | 7774 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER
S]); |
| 7423 verify([source]); | 7775 verify([source]); |
| 7424 } | 7776 } |
| 7425 void test_constWithNonConst() { | 7777 void test_constWithNonConst() { |
| 7426 Source source = addSource(EngineTestCase.createSource([ | 7778 Source source = addSource(EngineTestCase.createSource([ |
| 7427 "class T {", | 7779 "class T {", |
| 7428 " T(a, b, {c, d}) {}", | 7780 " T(a, b, {c, d}) {}", |
| 7429 "}", | 7781 "}", |
| 7430 "f() { return const T(0, 1, c: 2, d: 3); }"])); | 7782 "f() { return const T(0, 1, c: 2, d: 3); }"])); |
| 7431 resolve(source); | 7783 resolve(source); |
| 7432 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONST]); | 7784 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]); |
| 7433 verify([source]); | 7785 verify([source]); |
| 7434 } | 7786 } |
| 7435 void test_constWithNonConstantArgument_annotation() { | 7787 void test_constWithNonConstantArgument_annotation() { |
| 7436 Source source = addSource(EngineTestCase.createSource([ | 7788 Source source = addSource(EngineTestCase.createSource([ |
| 7437 "class A {", | 7789 "class A {", |
| 7438 " const A(int p);", | 7790 " const A(int p);", |
| 7439 "}", | 7791 "}", |
| 7440 "var v = 42;", | 7792 "var v = 42;", |
| 7441 "@A(v)", | 7793 "@A(v)", |
| 7442 "main() {", | 7794 "main() {", |
| 7443 "}"])); | 7795 "}"])); |
| 7444 resolve(source); | 7796 resolve(source); |
| 7445 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]); | 7797 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]
); |
| 7446 verify([source]); | 7798 verify([source]); |
| 7447 } | 7799 } |
| 7448 void test_constWithNonConstantArgument_instanceCreation() { | 7800 void test_constWithNonConstantArgument_instanceCreation() { |
| 7449 Source source = addSource(EngineTestCase.createSource([ | 7801 Source source = addSource(EngineTestCase.createSource([ |
| 7450 "class A {", | 7802 "class A {", |
| 7451 " const A(a);", | 7803 " const A(a);", |
| 7452 "}", | 7804 "}", |
| 7453 "f(p) { return const A(p); }"])); | 7805 "f(p) { return const A(p); }"])); |
| 7454 resolve(source); | 7806 resolve(source); |
| 7455 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]); | 7807 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]
); |
| 7456 verify([source]); | 7808 verify([source]); |
| 7457 } | 7809 } |
| 7458 void test_constWithNonType() { | 7810 void test_constWithNonType() { |
| 7459 Source source = addSource(EngineTestCase.createSource(["int A;", "f() {", "
return const A();", "}"])); | 7811 Source source = addSource(EngineTestCase.createSource(["int A;", "f() {", "
return const A();", "}"])); |
| 7460 resolve(source); | 7812 resolve(source); |
| 7461 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_TYPE]); | 7813 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); |
| 7462 verify([source]); | 7814 verify([source]); |
| 7463 } | 7815 } |
| 7464 void test_constWithNonType_fromLibrary() { | 7816 void test_constWithNonType_fromLibrary() { |
| 7465 Source source1 = addSource2("lib.dart", ""); | 7817 Source source1 = addSource2("lib.dart", ""); |
| 7466 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ | 7818 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ |
| 7467 "import 'lib.dart' as lib;", | 7819 "import 'lib.dart' as lib;", |
| 7468 "void f() {", | 7820 "void f() {", |
| 7469 " const lib.A();", | 7821 " const lib.A();", |
| 7470 "}"])); | 7822 "}"])); |
| 7471 resolve(source1); | 7823 resolve(source1); |
| 7472 resolve(source2); | 7824 resolve(source2); |
| 7473 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_TYPE]); | 7825 assertErrors(source2, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]); |
| 7474 verify([source1]); | 7826 verify([source1]); |
| 7475 } | 7827 } |
| 7476 void test_constWithTypeParameters_direct() { | 7828 void test_constWithTypeParameters_direct() { |
| 7477 Source source = addSource(EngineTestCase.createSource([ | 7829 Source source = addSource(EngineTestCase.createSource([ |
| 7478 "class A<T> {", | 7830 "class A<T> {", |
| 7479 " static const V = const A<T>();", | 7831 " static const V = const A<T>();", |
| 7480 " const A();", | 7832 " const A();", |
| 7481 "}"])); | 7833 "}"])); |
| 7482 resolve(source); | 7834 resolve(source); |
| 7483 assertErrors([ | 7835 assertErrors(source, [ |
| 7484 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, | 7836 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, |
| 7485 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 7837 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); |
| 7486 verify([source]); | 7838 verify([source]); |
| 7487 } | 7839 } |
| 7488 void test_constWithTypeParameters_indirect() { | 7840 void test_constWithTypeParameters_indirect() { |
| 7489 Source source = addSource(EngineTestCase.createSource([ | 7841 Source source = addSource(EngineTestCase.createSource([ |
| 7490 "class A<T> {", | 7842 "class A<T> {", |
| 7491 " static const V = const A<List<T>>();", | 7843 " static const V = const A<List<T>>();", |
| 7492 " const A();", | 7844 " const A();", |
| 7493 "}"])); | 7845 "}"])); |
| 7494 resolve(source); | 7846 resolve(source); |
| 7495 assertErrors([ | 7847 assertErrors(source, [ |
| 7496 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, | 7848 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, |
| 7497 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 7849 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); |
| 7498 verify([source]); | 7850 verify([source]); |
| 7499 } | 7851 } |
| 7500 void test_constWithUndefinedConstructor() { | 7852 void test_constWithUndefinedConstructor() { |
| 7501 Source source = addSource(EngineTestCase.createSource([ | 7853 Source source = addSource(EngineTestCase.createSource([ |
| 7502 "class A {", | 7854 "class A {", |
| 7503 " const A();", | 7855 " const A();", |
| 7504 "}", | 7856 "}", |
| 7505 "f() {", | 7857 "f() {", |
| 7506 " return const A.noSuchConstructor();", | 7858 " return const A.noSuchConstructor();", |
| 7507 "}"])); | 7859 "}"])); |
| 7508 resolve(source); | 7860 resolve(source); |
| 7509 assertErrors([CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]); | 7861 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]
); |
| 7510 } | 7862 } |
| 7511 void test_constWithUndefinedConstructorDefault() { | 7863 void test_constWithUndefinedConstructorDefault() { |
| 7512 Source source = addSource(EngineTestCase.createSource([ | 7864 Source source = addSource(EngineTestCase.createSource([ |
| 7513 "class A {", | 7865 "class A {", |
| 7514 " const A.name();", | 7866 " const A.name();", |
| 7515 "}", | 7867 "}", |
| 7516 "f() {", | 7868 "f() {", |
| 7517 " return const A();", | 7869 " return const A();", |
| 7518 "}"])); | 7870 "}"])); |
| 7519 resolve(source); | 7871 resolve(source); |
| 7520 assertErrors([CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]
); | 7872 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_
DEFAULT]); |
| 7521 verify([source]); | 7873 verify([source]); |
| 7522 } | 7874 } |
| 7523 void test_defaultValueInFunctionTypeAlias() { | 7875 void test_defaultValueInFunctionTypeAlias() { |
| 7524 Source source = addSource(EngineTestCase.createSource(["typedef F([x = 0]);"
])); | 7876 Source source = addSource(EngineTestCase.createSource(["typedef F([x = 0]);"
])); |
| 7525 resolve(source); | 7877 resolve(source); |
| 7526 assertErrors([CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS]); | 7878 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_AL
IAS]); |
| 7527 verify([source]); | 7879 verify([source]); |
| 7528 } | 7880 } |
| 7529 void test_defaultValueInFunctionTypedParameter_named() { | 7881 void test_defaultValueInFunctionTypedParameter_named() { |
| 7530 Source source = addSource(EngineTestCase.createSource(["f(g({p: null})) {}"]
)); | 7882 Source source = addSource(EngineTestCase.createSource(["f(g({p: null})) {}"]
)); |
| 7531 resolve(source); | 7883 resolve(source); |
| 7532 assertErrors([CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER
]); | 7884 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_P
ARAMETER]); |
| 7533 verify([source]); | 7885 verify([source]); |
| 7534 } | 7886 } |
| 7535 void test_defaultValueInFunctionTypedParameter_optional() { | 7887 void test_defaultValueInFunctionTypedParameter_optional() { |
| 7536 Source source = addSource(EngineTestCase.createSource(["f(g([p = null])) {}"
])); | 7888 Source source = addSource(EngineTestCase.createSource(["f(g([p = null])) {}"
])); |
| 7537 resolve(source); | 7889 resolve(source); |
| 7538 assertErrors([CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER
]); | 7890 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_P
ARAMETER]); |
| 7539 verify([source]); | 7891 verify([source]); |
| 7540 } | 7892 } |
| 7541 void test_duplicateConstructorName_named() { | 7893 void test_duplicateConstructorName_named() { |
| 7542 Source source = addSource(EngineTestCase.createSource(["class A {", " A.a()
{}", " A.a() {}", "}"])); | 7894 Source source = addSource(EngineTestCase.createSource(["class A {", " A.a()
{}", " A.a() {}", "}"])); |
| 7543 resolve(source); | 7895 resolve(source); |
| 7544 assertErrors([ | 7896 assertErrors(source, [ |
| 7545 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, | 7897 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, |
| 7546 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME]); | 7898 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME]); |
| 7547 verify([source]); | 7899 verify([source]); |
| 7548 } | 7900 } |
| 7549 void test_duplicateConstructorName_unnamed() { | 7901 void test_duplicateConstructorName_unnamed() { |
| 7550 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", " A() {}", "}"])); | 7902 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", " A() {}", "}"])); |
| 7551 resolve(source); | 7903 resolve(source); |
| 7552 assertErrors([ | 7904 assertErrors(source, [ |
| 7553 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, | 7905 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, |
| 7554 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT]); | 7906 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT]); |
| 7555 verify([source]); | 7907 verify([source]); |
| 7556 } | 7908 } |
| 7557 void test_duplicateDefinition() { | 7909 void test_duplicateDefinition() { |
| 7558 Source source = addSource(EngineTestCase.createSource(["f() {", " int m = 0
;", " m(a) {}", "}"])); | 7910 Source source = addSource(EngineTestCase.createSource(["f() {", " int m = 0
;", " m(a) {}", "}"])); |
| 7559 resolve(source); | 7911 resolve(source); |
| 7560 assertErrors([ | 7912 assertErrors(source, [ |
| 7561 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7913 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7562 CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 7914 CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 7563 verify([source]); | 7915 verify([source]); |
| 7564 } | 7916 } |
| 7565 void test_duplicateDefinition_acrossLibraries() { | 7917 void test_duplicateDefinition_acrossLibraries() { |
| 7566 Source librarySource = addSource2("/lib.dart", EngineTestCase.createSource([
"library lib;", "", "part 'a.dart';", "part 'b.dart';"])); | 7918 Source librarySource = addSource2("/lib.dart", EngineTestCase.createSource([
"library lib;", "", "part 'a.dart';", "part 'b.dart';"])); |
| 7567 Source sourceA = addSource2("/a.dart", EngineTestCase.createSource(["part of
lib;", "", "class A {}"])); | 7919 Source sourceA = addSource2("/a.dart", EngineTestCase.createSource(["part of
lib;", "", "class A {}"])); |
| 7568 Source sourceB = addSource2("/b.dart", EngineTestCase.createSource(["part of
lib;", "", "class A {}"])); | 7920 Source sourceB = addSource2("/b.dart", EngineTestCase.createSource(["part of
lib;", "", "class A {}"])); |
| 7569 resolve(librarySource); | 7921 resolve(librarySource); |
| 7570 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 7922 assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 7571 verify([librarySource, sourceA, sourceB]); | 7923 verify([librarySource, sourceA, sourceB]); |
| 7572 } | 7924 } |
| 7573 void test_duplicateDefinition_classMembers_fields() { | 7925 void test_duplicateDefinition_classMembers_fields() { |
| 7574 Source librarySource = addSource(EngineTestCase.createSource(["class A {", "
int a;", " int a;", "}"])); | 7926 Source source = addSource(EngineTestCase.createSource(["class A {", " int a
;", " int a;", "}"])); |
| 7575 resolve(librarySource); | 7927 resolve(source); |
| 7576 assertErrors([ | 7928 assertErrors(source, [ |
| 7577 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7929 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7578 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7930 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7579 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7931 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7580 CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 7932 CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 7581 verify([librarySource]); | 7933 verify([source]); |
| 7582 } | 7934 } |
| 7583 void test_duplicateDefinition_classMembers_fields_oneStatic() { | 7935 void test_duplicateDefinition_classMembers_fields_oneStatic() { |
| 7584 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " static int x;", "}"])); | 7936 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " static int x;", "}"])); |
| 7585 resolve(source); | 7937 resolve(source); |
| 7586 assertErrors([ | 7938 assertErrors(source, [ |
| 7587 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7939 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7588 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7940 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7589 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7941 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7590 CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 7942 CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 7591 verify([source]); | 7943 verify([source]); |
| 7592 } | 7944 } |
| 7593 void test_duplicateDefinition_classMembers_methods() { | 7945 void test_duplicateDefinition_classMembers_methods() { |
| 7594 Source librarySource = addSource(EngineTestCase.createSource(["class A {", "
m() {}", " m() {}", "}"])); | 7946 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", " m() {}", "}"])); |
| 7595 resolve(librarySource); | 7947 resolve(source); |
| 7596 assertErrors([ | 7948 assertErrors(source, [ |
| 7597 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7949 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7598 CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 7950 CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 7599 verify([librarySource]); | 7951 verify([source]); |
| 7600 } | 7952 } |
| 7601 void test_duplicateDefinition_localFields() { | 7953 void test_duplicateDefinition_localFields() { |
| 7602 Source librarySource = addSource(EngineTestCase.createSource([ | 7954 Source source = addSource(EngineTestCase.createSource([ |
| 7603 "class A {", | 7955 "class A {", |
| 7604 " m() {", | 7956 " m() {", |
| 7605 " int a;", | 7957 " int a;", |
| 7606 " int a;", | 7958 " int a;", |
| 7607 " }", | 7959 " }", |
| 7608 "}"])); | 7960 "}"])); |
| 7609 resolve(librarySource); | 7961 resolve(source); |
| 7610 assertErrors([ | 7962 assertErrors(source, [ |
| 7611 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7963 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7612 CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 7964 CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 7613 verify([librarySource]); | 7965 verify([source]); |
| 7614 } | 7966 } |
| 7615 void test_duplicateDefinition_parameterWithFunctionName_local() { | 7967 void test_duplicateDefinition_parameterWithFunctionName_local() { |
| 7616 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) {
}", "}"])); | 7968 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) {
}", "}"])); |
| 7617 resolve(source); | 7969 resolve(source); |
| 7618 assertErrors([ | 7970 assertErrors(source, [ |
| 7619 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7971 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7620 CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 7972 CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 7621 verify([source]); | 7973 verify([source]); |
| 7622 } | 7974 } |
| 7623 void test_duplicateDefinition_parameterWithFunctionName_topLevel() { | 7975 void test_duplicateDefinition_parameterWithFunctionName_topLevel() { |
| 7624 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) {
}", "}"])); | 7976 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) {
}", "}"])); |
| 7625 resolve(source); | 7977 resolve(source); |
| 7626 assertErrors([ | 7978 assertErrors(source, [ |
| 7627 CompileTimeErrorCode.DUPLICATE_DEFINITION, | 7979 CompileTimeErrorCode.DUPLICATE_DEFINITION, |
| 7628 CompileTimeErrorCode.DUPLICATE_DEFINITION]); | 7980 CompileTimeErrorCode.DUPLICATE_DEFINITION]); |
| 7629 verify([source]); | 7981 verify([source]); |
| 7630 } | 7982 } |
| 7631 void test_duplicateDefinitionInheritance_instanceGetter_staticGetter() { | 7983 void test_duplicateDefinitionInheritance_instanceGetter_staticGetter() { |
| 7632 Source source = addSource(EngineTestCase.createSource([ | 7984 Source source = addSource(EngineTestCase.createSource([ |
| 7633 "class A {", | 7985 "class A {", |
| 7634 " int get x => 0;", | 7986 " int get x => 0;", |
| 7635 "}", | 7987 "}", |
| 7636 "class B extends A {", | 7988 "class B extends A {", |
| 7637 " static int get x => 0;", | 7989 " static int get x => 0;", |
| 7638 "}"])); | 7990 "}"])); |
| 7639 resolve(source); | 7991 resolve(source); |
| 7640 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 7992 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 7641 verify([source]); | 7993 verify([source]); |
| 7642 } | 7994 } |
| 7643 void test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter()
{ | 7995 void test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter()
{ |
| 7644 Source source = addSource(EngineTestCase.createSource([ | 7996 Source source = addSource(EngineTestCase.createSource([ |
| 7645 "abstract class A {", | 7997 "abstract class A {", |
| 7646 " int get x;", | 7998 " int get x;", |
| 7647 "}", | 7999 "}", |
| 7648 "class B extends A {", | 8000 "class B extends A {", |
| 7649 " static int get x => 0;", | 8001 " static int get x => 0;", |
| 7650 "}"])); | 8002 "}"])); |
| 7651 resolve(source); | 8003 resolve(source); |
| 7652 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 8004 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 7653 verify([source]); | 8005 verify([source]); |
| 7654 } | 8006 } |
| 7655 void test_duplicateDefinitionInheritance_instanceMethod_staticMethod() { | 8007 void test_duplicateDefinitionInheritance_instanceMethod_staticMethod() { |
| 7656 Source source = addSource(EngineTestCase.createSource([ | 8008 Source source = addSource(EngineTestCase.createSource([ |
| 7657 "class A {", | 8009 "class A {", |
| 7658 " x() {}", | 8010 " x() {}", |
| 7659 "}", | 8011 "}", |
| 7660 "class B extends A {", | 8012 "class B extends A {", |
| 7661 " static x() {}", | 8013 " static x() {}", |
| 7662 "}"])); | 8014 "}"])); |
| 7663 resolve(source); | 8015 resolve(source); |
| 7664 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 8016 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 7665 verify([source]); | 8017 verify([source]); |
| 7666 } | 8018 } |
| 7667 void test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod()
{ | 8019 void test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod()
{ |
| 7668 Source source = addSource(EngineTestCase.createSource([ | 8020 Source source = addSource(EngineTestCase.createSource([ |
| 7669 "abstract class A {", | 8021 "abstract class A {", |
| 7670 " x();", | 8022 " x();", |
| 7671 "}", | 8023 "}", |
| 7672 "abstract class B extends A {", | 8024 "abstract class B extends A {", |
| 7673 " static x() {}", | 8025 " static x() {}", |
| 7674 "}"])); | 8026 "}"])); |
| 7675 resolve(source); | 8027 resolve(source); |
| 7676 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 8028 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 7677 verify([source]); | 8029 verify([source]); |
| 7678 } | 8030 } |
| 7679 void test_duplicateDefinitionInheritance_instanceSetter_staticSetter() { | 8031 void test_duplicateDefinitionInheritance_instanceSetter_staticSetter() { |
| 7680 Source source = addSource(EngineTestCase.createSource([ | 8032 Source source = addSource(EngineTestCase.createSource([ |
| 7681 "class A {", | 8033 "class A {", |
| 7682 " set x(value) {}", | 8034 " set x(value) {}", |
| 7683 "}", | 8035 "}", |
| 7684 "class B extends A {", | 8036 "class B extends A {", |
| 7685 " static set x(value) {}", | 8037 " static set x(value) {}", |
| 7686 "}"])); | 8038 "}"])); |
| 7687 resolve(source); | 8039 resolve(source); |
| 7688 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 8040 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 7689 verify([source]); | 8041 verify([source]); |
| 7690 } | 8042 } |
| 7691 void test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter()
{ | 8043 void test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter()
{ |
| 7692 Source source = addSource(EngineTestCase.createSource([ | 8044 Source source = addSource(EngineTestCase.createSource([ |
| 7693 "abstract class A {", | 8045 "abstract class A {", |
| 7694 " set x(value);", | 8046 " set x(value);", |
| 7695 "}", | 8047 "}", |
| 7696 "class B extends A {", | 8048 "class B extends A {", |
| 7697 " static set x(value) {}", | 8049 " static set x(value) {}", |
| 7698 "}"])); | 8050 "}"])); |
| 7699 resolve(source); | 8051 resolve(source); |
| 7700 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]); | 8052 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]
); |
| 7701 verify([source]); | 8053 verify([source]); |
| 7702 } | 8054 } |
| 7703 void test_duplicateNamedArgument() { | 8055 void test_duplicateNamedArgument() { |
| 7704 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main
() {", " f(a: 1, a: 2);", "}"])); | 8056 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main
() {", " f(a: 1, a: 2);", "}"])); |
| 7705 resolve(source); | 8057 resolve(source); |
| 7706 assertErrors([CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]); | 8058 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]); |
| 7707 verify([source]); | 8059 verify([source]); |
| 7708 } | 8060 } |
| 7709 void test_exportInternalLibrary() { | 8061 void test_exportInternalLibrary() { |
| 7710 Source source = addSource(EngineTestCase.createSource(["export 'dart:_interc
eptors';"])); | 8062 Source source = addSource(EngineTestCase.createSource(["export 'dart:_interc
eptors';"])); |
| 7711 resolve(source); | 8063 resolve(source); |
| 7712 assertErrors([CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]); | 8064 assertErrors(source, [CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]); |
| 7713 verify([source]); | 8065 verify([source]); |
| 7714 } | 8066 } |
| 7715 void test_exportOfNonLibrary() { | 8067 void test_exportOfNonLibrary() { |
| 7716 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); | 8068 Source source = addSource(EngineTestCase.createSource(["library L;", "export
'lib1.dart';"])); |
| 7717 addSource2("/lib1.dart", EngineTestCase.createSource(["part of lib;"])); | 8069 addSource2("/lib1.dart", EngineTestCase.createSource(["part of lib;"])); |
| 7718 resolve(source); | 8070 resolve(source); |
| 7719 assertErrors([CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]); | 8071 assertErrors(source, [CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]); |
| 7720 verify([source]); | 8072 verify([source]); |
| 7721 } | 8073 } |
| 7722 void test_extendsDisallowedClass_bool() { | 8074 void test_extendsDisallowedClass_bool() { |
| 7723 Source source = addSource(EngineTestCase.createSource(["class A extends bool
{}"])); | 8075 Source source = addSource(EngineTestCase.createSource(["class A extends bool
{}"])); |
| 7724 resolve(source); | 8076 resolve(source); |
| 7725 assertErrors([ | 8077 assertErrors(source, [ |
| 7726 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 8078 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 7727 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 8079 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 7728 verify([source]); | 8080 verify([source]); |
| 7729 } | 8081 } |
| 7730 void test_extendsDisallowedClass_double() { | 8082 void test_extendsDisallowedClass_double() { |
| 7731 Source source = addSource(EngineTestCase.createSource(["class A extends doub
le {}"])); | 8083 Source source = addSource(EngineTestCase.createSource(["class A extends doub
le {}"])); |
| 7732 resolve(source); | 8084 resolve(source); |
| 7733 assertErrors([ | 8085 assertErrors(source, [ |
| 7734 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 8086 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 7735 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 8087 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 7736 verify([source]); | 8088 verify([source]); |
| 7737 } | 8089 } |
| 7738 void test_extendsDisallowedClass_int() { | 8090 void test_extendsDisallowedClass_int() { |
| 7739 Source source = addSource(EngineTestCase.createSource(["class A extends int
{}"])); | 8091 Source source = addSource(EngineTestCase.createSource(["class A extends int
{}"])); |
| 7740 resolve(source); | 8092 resolve(source); |
| 7741 assertErrors([ | 8093 assertErrors(source, [ |
| 7742 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 8094 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 7743 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 8095 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 7744 verify([source]); | 8096 verify([source]); |
| 7745 } | 8097 } |
| 7746 void test_extendsDisallowedClass_Null() { | 8098 void test_extendsDisallowedClass_Null() { |
| 7747 Source source = addSource(EngineTestCase.createSource(["class A extends Null
{}"])); | 8099 Source source = addSource(EngineTestCase.createSource(["class A extends Null
{}"])); |
| 7748 resolve(source); | 8100 resolve(source); |
| 7749 assertErrors([ | 8101 assertErrors(source, [ |
| 7750 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 8102 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 7751 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 8103 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 7752 verify([source]); | 8104 verify([source]); |
| 7753 } | 8105 } |
| 7754 void test_extendsDisallowedClass_num() { | 8106 void test_extendsDisallowedClass_num() { |
| 7755 Source source = addSource(EngineTestCase.createSource(["class A extends num
{}"])); | 8107 Source source = addSource(EngineTestCase.createSource(["class A extends num
{}"])); |
| 7756 resolve(source); | 8108 resolve(source); |
| 7757 assertErrors([ | 8109 assertErrors(source, [ |
| 7758 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 8110 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 7759 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 8111 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 7760 verify([source]); | 8112 verify([source]); |
| 7761 } | 8113 } |
| 7762 void test_extendsDisallowedClass_String() { | 8114 void test_extendsDisallowedClass_String() { |
| 7763 Source source = addSource(EngineTestCase.createSource(["class A extends Stri
ng {}"])); | 8115 Source source = addSource(EngineTestCase.createSource(["class A extends Stri
ng {}"])); |
| 7764 resolve(source); | 8116 resolve(source); |
| 7765 assertErrors([ | 8117 assertErrors(source, [ |
| 7766 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | 8118 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, |
| 7767 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 8119 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); |
| 7768 verify([source]); | 8120 verify([source]); |
| 7769 } | 8121 } |
| 7770 void test_extendsNonClass_class() { | 8122 void test_extendsNonClass_class() { |
| 7771 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex
tends A {}"])); | 8123 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex
tends A {}"])); |
| 7772 resolve(source); | 8124 resolve(source); |
| 7773 assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]); | 8125 assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]); |
| 7774 verify([source]); | 8126 verify([source]); |
| 7775 } | 8127 } |
| 7776 void test_extendsNonClass_dynamic() { | 8128 void test_extendsNonClass_dynamic() { |
| 7777 Source source = addSource(EngineTestCase.createSource(["class B extends dyna
mic {}"])); | 8129 Source source = addSource(EngineTestCase.createSource(["class B extends dyna
mic {}"])); |
| 7778 resolve(source); | 8130 resolve(source); |
| 7779 assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]); | 8131 assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]); |
| 7780 verify([source]); | 8132 verify([source]); |
| 7781 } | 8133 } |
| 7782 void test_extraPositionalArguments_const() { | 8134 void test_extraPositionalArguments_const() { |
| 7783 Source source = addSource(EngineTestCase.createSource([ | 8135 Source source = addSource(EngineTestCase.createSource([ |
| 7784 "class A {", | 8136 "class A {", |
| 7785 " const A();", | 8137 " const A();", |
| 7786 "}", | 8138 "}", |
| 7787 "main() {", | 8139 "main() {", |
| 7788 " const A(0);", | 8140 " const A(0);", |
| 7789 "}"])); | 8141 "}"])); |
| 7790 resolve(source); | 8142 resolve(source); |
| 7791 assertErrors([CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]); | 8143 assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]); |
| 7792 verify([source]); | 8144 verify([source]); |
| 7793 } | 8145 } |
| 7794 void test_extraPositionalArguments_const_super() { | 8146 void test_extraPositionalArguments_const_super() { |
| 7795 Source source = addSource(EngineTestCase.createSource([ | 8147 Source source = addSource(EngineTestCase.createSource([ |
| 7796 "class A {", | 8148 "class A {", |
| 7797 " const A();", | 8149 " const A();", |
| 7798 "}", | 8150 "}", |
| 7799 "class B extends A {", | 8151 "class B extends A {", |
| 7800 " const B() : super(0);", | 8152 " const B() : super(0);", |
| 7801 "}"])); | 8153 "}"])); |
| 7802 resolve(source); | 8154 resolve(source); |
| 7803 assertErrors([CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]); | 8155 assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]); |
| 7804 verify([source]); | 8156 verify([source]); |
| 7805 } | 8157 } |
| 7806 void test_fieldInitializedByMultipleInitializers() { | 8158 void test_fieldInitializedByMultipleInitializers() { |
| 7807 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A() : x = 0, x = 1 {}", "}"])); | 8159 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A() : x = 0, x = 1 {}", "}"])); |
| 7808 resolve(source); | 8160 resolve(source); |
| 7809 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER
S]); | 8161 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INI
TIALIZERS]); |
| 7810 verify([source]); | 8162 verify([source]); |
| 7811 } | 8163 } |
| 7812 void test_fieldInitializedByMultipleInitializers_multipleInits() { | 8164 void test_fieldInitializedByMultipleInitializers_multipleInits() { |
| 7813 Source source = addSource(EngineTestCase.createSource([ | 8165 Source source = addSource(EngineTestCase.createSource([ |
| 7814 "class A {", | 8166 "class A {", |
| 7815 " int x;", | 8167 " int x;", |
| 7816 " A() : x = 0, x = 1, x = 2 {}", | 8168 " A() : x = 0, x = 1, x = 2 {}", |
| 7817 "}"])); | 8169 "}"])); |
| 7818 resolve(source); | 8170 resolve(source); |
| 7819 assertErrors([ | 8171 assertErrors(source, [ |
| 7820 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, | 8172 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, |
| 7821 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); | 8173 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); |
| 7822 verify([source]); | 8174 verify([source]); |
| 7823 } | 8175 } |
| 7824 void test_fieldInitializedByMultipleInitializers_multipleNames() { | 8176 void test_fieldInitializedByMultipleInitializers_multipleNames() { |
| 7825 Source source = addSource(EngineTestCase.createSource([ | 8177 Source source = addSource(EngineTestCase.createSource([ |
| 7826 "class A {", | 8178 "class A {", |
| 7827 " int x;", | 8179 " int x;", |
| 7828 " int y;", | 8180 " int y;", |
| 7829 " A() : x = 0, x = 1, y = 0, y = 1 {}", | 8181 " A() : x = 0, x = 1, y = 0, y = 1 {}", |
| 7830 "}"])); | 8182 "}"])); |
| 7831 resolve(source); | 8183 resolve(source); |
| 7832 assertErrors([ | 8184 assertErrors(source, [ |
| 7833 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, | 8185 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, |
| 7834 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); | 8186 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); |
| 7835 verify([source]); | 8187 verify([source]); |
| 7836 } | 8188 } |
| 7837 void test_fieldInitializedInParameterAndInitializer() { | 8189 void test_fieldInitializedInParameterAndInitializer() { |
| 7838 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) : x = 1 {}", "}"])); | 8190 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) : x = 1 {}", "}"])); |
| 7839 resolve(source); | 8191 resolve(source); |
| 7840 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIA
LIZER]); | 8192 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AN
D_INITIALIZER]); |
| 7841 verify([source]); | 8193 verify([source]); |
| 7842 } | 8194 } |
| 7843 void test_fieldInitializerFactoryConstructor() { | 8195 void test_fieldInitializerFactoryConstructor() { |
| 7844 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " factory A(this.x) {}", "}"])); | 8196 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " factory A(this.x) {}", "}"])); |
| 7845 resolve(source); | 8197 resolve(source); |
| 7846 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRUCTOR]); | 8198 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRU
CTOR]); |
| 7847 verify([source]); | 8199 verify([source]); |
| 7848 } | 8200 } |
| 7849 void test_fieldInitializerNotAssignable() { | 8201 void test_fieldInitializerNotAssignable() { |
| 7850 Source source = addSource(EngineTestCase.createSource([ | 8202 Source source = addSource(EngineTestCase.createSource([ |
| 7851 "class A {", | 8203 "class A {", |
| 7852 " final int x;", | 8204 " final int x;", |
| 7853 " const A() : x = '';", | 8205 " const A() : x = '';", |
| 7854 "}"])); | 8206 "}"])); |
| 7855 resolve(source); | 8207 resolve(source); |
| 7856 assertErrors([CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE]); | 8208 assertErrors(source, [CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIG
NABLE]); |
| 7857 verify([source]); | 8209 verify([source]); |
| 7858 } | 8210 } |
| 7859 void test_fieldInitializerOutsideConstructor() { | 8211 void test_fieldInitializerOutsideConstructor() { |
| 7860 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " m(this.x) {}", "}"])); | 8212 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " m(this.x) {}", "}"])); |
| 7861 resolve(source); | 8213 resolve(source); |
| 7862 assertErrors([ | 8214 assertErrors(source, [ |
| 7863 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, | 8215 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, |
| 7864 CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); | 8216 CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); |
| 7865 verify([source]); | 8217 verify([source]); |
| 7866 } | 8218 } |
| 7867 void test_fieldInitializerOutsideConstructor_defaultParameter() { | 8219 void test_fieldInitializerOutsideConstructor_defaultParameter() { |
| 7868 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " m([this.x]) {}", "}"])); | 8220 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " m([this.x]) {}", "}"])); |
| 7869 resolve(source); | 8221 resolve(source); |
| 7870 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); | 8222 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRU
CTOR]); |
| 7871 verify([source]); | 8223 verify([source]); |
| 7872 } | 8224 } |
| 7873 void test_fieldInitializerRedirectingConstructor_afterRedirection() { | 8225 void test_fieldInitializerRedirectingConstructor_afterRedirection() { |
| 7874 Source source = addSource(EngineTestCase.createSource([ | 8226 Source source = addSource(EngineTestCase.createSource([ |
| 7875 "class A {", | 8227 "class A {", |
| 7876 " int x;", | 8228 " int x;", |
| 7877 " A.named() {}", | 8229 " A.named() {}", |
| 7878 " A() : this.named(), x = 42;", | 8230 " A() : this.named(), x = 42;", |
| 7879 "}"])); | 8231 "}"])); |
| 7880 resolve(source); | 8232 resolve(source); |
| 7881 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
]); | 8233 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON
STRUCTOR]); |
| 7882 verify([source]); | 8234 verify([source]); |
| 7883 } | 8235 } |
| 7884 void test_fieldInitializerRedirectingConstructor_beforeRedirection() { | 8236 void test_fieldInitializerRedirectingConstructor_beforeRedirection() { |
| 7885 Source source = addSource(EngineTestCase.createSource([ | 8237 Source source = addSource(EngineTestCase.createSource([ |
| 7886 "class A {", | 8238 "class A {", |
| 7887 " int x;", | 8239 " int x;", |
| 7888 " A.named() {}", | 8240 " A.named() {}", |
| 7889 " A() : x = 42, this.named();", | 8241 " A() : x = 42, this.named();", |
| 7890 "}"])); | 8242 "}"])); |
| 7891 resolve(source); | 8243 resolve(source); |
| 7892 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
]); | 8244 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON
STRUCTOR]); |
| 7893 verify([source]); | 8245 verify([source]); |
| 7894 } | 8246 } |
| 7895 void test_fieldInitializingFormalRedirectingConstructor() { | 8247 void test_fieldInitializingFormalRedirectingConstructor() { |
| 7896 Source source = addSource(EngineTestCase.createSource([ | 8248 Source source = addSource(EngineTestCase.createSource([ |
| 7897 "class A {", | 8249 "class A {", |
| 7898 " int x;", | 8250 " int x;", |
| 7899 " A.named() {}", | 8251 " A.named() {}", |
| 7900 " A(this.x) : this.named();", | 8252 " A(this.x) : this.named();", |
| 7901 "}"])); | 8253 "}"])); |
| 7902 resolve(source); | 8254 resolve(source); |
| 7903 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
]); | 8255 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON
STRUCTOR]); |
| 7904 verify([source]); | 8256 verify([source]); |
| 7905 } | 8257 } |
| 7906 void test_finalInitializedMultipleTimes_initializers() { | 8258 void test_finalInitializedMultipleTimes_initializers() { |
| 7907 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A() : x = 0, x = 0 {}", "}"])); | 8259 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A() : x = 0, x = 0 {}", "}"])); |
| 7908 resolve(source); | 8260 resolve(source); |
| 7909 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER
S]); | 8261 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INI
TIALIZERS]); |
| 7910 verify([source]); | 8262 verify([source]); |
| 7911 } | 8263 } |
| 7912 | 8264 |
| 7913 /** | 8265 /** |
| 7914 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests
the | 8266 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests
the |
| 7915 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided
here to show | 8267 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided
here to show |
| 7916 * coverage over all of the permutations of initializers in constructor declar
ations. | 8268 * coverage over all of the permutations of initializers in constructor declar
ations. |
| 7917 * | 8269 * |
| 7918 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of | 8270 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of |
| 7919 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead
of the broader code | 8271 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead
of the broader code |
| 7920 */ | 8272 */ |
| 7921 void test_finalInitializedMultipleTimes_initializingFormal_initializer() { | 8273 void test_finalInitializedMultipleTimes_initializingFormal_initializer() { |
| 7922 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x) : x = 0 {}", "}"])); | 8274 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x) : x = 0 {}", "}"])); |
| 7923 resolve(source); | 8275 resolve(source); |
| 7924 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIA
LIZER]); | 8276 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AN
D_INITIALIZER]); |
| 7925 verify([source]); | 8277 verify([source]); |
| 7926 } | 8278 } |
| 7927 void test_finalInitializedMultipleTimes_initializingFormals() { | 8279 void test_finalInitializedMultipleTimes_initializingFormals() { |
| 7928 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x, this.x) {}", "}"])); | 8280 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x;", " A(this.x, this.x) {}", "}"])); |
| 7929 resolve(source); | 8281 resolve(source); |
| 7930 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES]); | 8282 assertErrors(source, [CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES]
); |
| 8283 verify([source]); |
| 8284 } |
| 8285 void test_finalNotInitialized_instanceField_const_static() { |
| 8286 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c const F;", "}"])); |
| 8287 resolve(source); |
| 8288 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); |
| 8289 verify([source]); |
| 8290 } |
| 8291 void test_finalNotInitialized_library_const() { |
| 8292 Source source = addSource(EngineTestCase.createSource(["const F;"])); |
| 8293 resolve(source); |
| 8294 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); |
| 8295 verify([source]); |
| 8296 } |
| 8297 void test_finalNotInitialized_local_const() { |
| 8298 Source source = addSource(EngineTestCase.createSource(["f() {", " const int
x;", "}"])); |
| 8299 resolve(source); |
| 8300 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]); |
| 7931 verify([source]); | 8301 verify([source]); |
| 7932 } | 8302 } |
| 7933 void test_getterAndMethodWithSameName() { | 8303 void test_getterAndMethodWithSameName() { |
| 7934 Source source = addSource(EngineTestCase.createSource(["class A {", " x(y)
{}", " get x => 0;", "}"])); | 8304 Source source = addSource(EngineTestCase.createSource(["class A {", " x(y)
{}", " get x => 0;", "}"])); |
| 7935 resolve(source); | 8305 resolve(source); |
| 7936 assertErrors([ | 8306 assertErrors(source, [ |
| 7937 CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME, | 8307 CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME, |
| 7938 CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]); | 8308 CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]); |
| 7939 verify([source]); | 8309 verify([source]); |
| 7940 } | 8310 } |
| 7941 void test_implementsDisallowedClass_bool() { | 8311 void test_implementsDisallowedClass_bool() { |
| 7942 Source source = addSource(EngineTestCase.createSource(["class A implements b
ool {}"])); | 8312 Source source = addSource(EngineTestCase.createSource(["class A implements b
ool {}"])); |
| 7943 resolve(source); | 8313 resolve(source); |
| 7944 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 8314 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 7945 verify([source]); | 8315 verify([source]); |
| 7946 } | 8316 } |
| 7947 void test_implementsDisallowedClass_double() { | 8317 void test_implementsDisallowedClass_double() { |
| 7948 Source source = addSource(EngineTestCase.createSource(["class A implements d
ouble {}"])); | 8318 Source source = addSource(EngineTestCase.createSource(["class A implements d
ouble {}"])); |
| 7949 resolve(source); | 8319 resolve(source); |
| 7950 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 8320 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 7951 verify([source]); | 8321 verify([source]); |
| 7952 } | 8322 } |
| 7953 void test_implementsDisallowedClass_int() { | 8323 void test_implementsDisallowedClass_int() { |
| 7954 Source source = addSource(EngineTestCase.createSource(["class A implements i
nt {}"])); | 8324 Source source = addSource(EngineTestCase.createSource(["class A implements i
nt {}"])); |
| 7955 resolve(source); | 8325 resolve(source); |
| 7956 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 8326 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 7957 verify([source]); | 8327 verify([source]); |
| 7958 } | 8328 } |
| 7959 void test_implementsDisallowedClass_Null() { | 8329 void test_implementsDisallowedClass_Null() { |
| 7960 Source source = addSource(EngineTestCase.createSource(["class A implements N
ull {}"])); | 8330 Source source = addSource(EngineTestCase.createSource(["class A implements N
ull {}"])); |
| 7961 resolve(source); | 8331 resolve(source); |
| 7962 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 8332 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 7963 verify([source]); | 8333 verify([source]); |
| 7964 } | 8334 } |
| 7965 void test_implementsDisallowedClass_num() { | 8335 void test_implementsDisallowedClass_num() { |
| 7966 Source source = addSource(EngineTestCase.createSource(["class A implements n
um {}"])); | 8336 Source source = addSource(EngineTestCase.createSource(["class A implements n
um {}"])); |
| 7967 resolve(source); | 8337 resolve(source); |
| 7968 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 8338 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 7969 verify([source]); | 8339 verify([source]); |
| 7970 } | 8340 } |
| 7971 void test_implementsDisallowedClass_String() { | 8341 void test_implementsDisallowedClass_String() { |
| 7972 Source source = addSource(EngineTestCase.createSource(["class A implements S
tring {}"])); | 8342 Source source = addSource(EngineTestCase.createSource(["class A implements S
tring {}"])); |
| 7973 resolve(source); | 8343 resolve(source); |
| 7974 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); | 8344 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); |
| 7975 verify([source]); | 8345 verify([source]); |
| 7976 } | 8346 } |
| 7977 void test_implementsDynamic() { | 8347 void test_implementsDynamic() { |
| 7978 Source source = addSource(EngineTestCase.createSource(["class A implements d
ynamic {}"])); | 8348 Source source = addSource(EngineTestCase.createSource(["class A implements d
ynamic {}"])); |
| 7979 resolve(source); | 8349 resolve(source); |
| 7980 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]); | 8350 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]); |
| 7981 verify([source]); | 8351 verify([source]); |
| 7982 } | 8352 } |
| 7983 void test_implementsNonClass_class() { | 8353 void test_implementsNonClass_class() { |
| 7984 Source source = addSource(EngineTestCase.createSource(["int A;", "class B im
plements A {}"])); | 8354 Source source = addSource(EngineTestCase.createSource(["int A;", "class B im
plements A {}"])); |
| 7985 resolve(source); | 8355 resolve(source); |
| 7986 assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); | 8356 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); |
| 7987 verify([source]); | 8357 verify([source]); |
| 7988 } | 8358 } |
| 7989 void test_implementsNonClass_typedef() { | 8359 void test_implementsNonClass_typedef() { |
| 7990 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B;
", "typedef C = A implements B;"])); | 8360 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B;
", "typedef C = A implements B;"])); |
| 7991 resolve(source); | 8361 resolve(source); |
| 7992 assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); | 8362 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); |
| 7993 verify([source]); | 8363 verify([source]); |
| 7994 } | 8364 } |
| 7995 void test_implementsRepeated() { | 8365 void test_implementsRepeated() { |
| 7996 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B implements A, A {}"])); | 8366 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B implements A, A {}"])); |
| 7997 resolve(source); | 8367 resolve(source); |
| 7998 assertErrors([CompileTimeErrorCode.IMPLEMENTS_REPEATED]); | 8368 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_REPEATED]); |
| 7999 verify([source]); | 8369 verify([source]); |
| 8000 } | 8370 } |
| 8001 void test_implementsRepeated_3times() { | 8371 void test_implementsRepeated_3times() { |
| 8002 Source source = addSource(EngineTestCase.createSource([ | 8372 Source source = addSource(EngineTestCase.createSource([ |
| 8003 "class A {} class C{}", | 8373 "class A {} class C{}", |
| 8004 "class B implements A, A, A, A {}"])); | 8374 "class B implements A, A, A, A {}"])); |
| 8005 resolve(source); | 8375 resolve(source); |
| 8006 assertErrors([ | 8376 assertErrors(source, [ |
| 8007 CompileTimeErrorCode.IMPLEMENTS_REPEATED, | 8377 CompileTimeErrorCode.IMPLEMENTS_REPEATED, |
| 8008 CompileTimeErrorCode.IMPLEMENTS_REPEATED, | 8378 CompileTimeErrorCode.IMPLEMENTS_REPEATED, |
| 8009 CompileTimeErrorCode.IMPLEMENTS_REPEATED]); | 8379 CompileTimeErrorCode.IMPLEMENTS_REPEATED]); |
| 8010 verify([source]); | 8380 verify([source]); |
| 8011 } | 8381 } |
| 8012 void test_implementsSuperClass() { | 8382 void test_implementsSuperClass() { |
| 8013 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A implements A {}"])); | 8383 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B extends A implements A {}"])); |
| 8014 resolve(source); | 8384 resolve(source); |
| 8015 assertErrors([CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); | 8385 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); |
| 8016 verify([source]); | 8386 verify([source]); |
| 8017 } | 8387 } |
| 8018 void test_implementsSuperClass_Object() { | 8388 void test_implementsSuperClass_Object() { |
| 8019 Source source = addSource(EngineTestCase.createSource(["class A implements O
bject {}"])); | 8389 Source source = addSource(EngineTestCase.createSource(["class A implements O
bject {}"])); |
| 8020 resolve(source); | 8390 resolve(source); |
| 8021 assertErrors([CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); | 8391 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]); |
| 8022 verify([source]); | 8392 verify([source]); |
| 8023 } | 8393 } |
| 8024 void test_implicitThisReferenceInInitializer_field() { | 8394 void test_implicitThisReferenceInInitializer_field() { |
| 8025 Source source = addSource(EngineTestCase.createSource([ | 8395 Source source = addSource(EngineTestCase.createSource([ |
| 8026 "class A {", | 8396 "class A {", |
| 8027 " var v;", | 8397 " var v;", |
| 8028 " A() : v = f;", | 8398 " A() : v = f;", |
| 8029 " var f;", | 8399 " var f;", |
| 8030 "}"])); | 8400 "}"])); |
| 8031 resolve(source); | 8401 resolve(source); |
| 8032 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); | 8402 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 8033 verify([source]); | 8403 verify([source]); |
| 8034 } | 8404 } |
| 8035 void test_implicitThisReferenceInInitializer_field2() { | 8405 void test_implicitThisReferenceInInitializer_field2() { |
| 8036 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " final y = x;", "}"])); | 8406 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " final y = x;", "}"])); |
| 8037 resolve(source); | 8407 resolve(source); |
| 8038 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); | 8408 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 8039 verify([source]); | 8409 verify([source]); |
| 8040 } | 8410 } |
| 8041 void test_implicitThisReferenceInInitializer_invocation() { | 8411 void test_implicitThisReferenceInInitializer_invocation() { |
| 8042 Source source = addSource(EngineTestCase.createSource([ | 8412 Source source = addSource(EngineTestCase.createSource([ |
| 8043 "class A {", | 8413 "class A {", |
| 8044 " var v;", | 8414 " var v;", |
| 8045 " A() : v = f();", | 8415 " A() : v = f();", |
| 8046 " f() {}", | 8416 " f() {}", |
| 8047 "}"])); | 8417 "}"])); |
| 8048 resolve(source); | 8418 resolve(source); |
| 8049 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); | 8419 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 8050 verify([source]); | 8420 verify([source]); |
| 8051 } | 8421 } |
| 8052 void test_implicitThisReferenceInInitializer_invocationInStatic() { | 8422 void test_implicitThisReferenceInInitializer_invocationInStatic() { |
| 8053 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c var F = m();", " m() {}", "}"])); | 8423 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c var F = m();", " m() {}", "}"])); |
| 8054 resolve(source); | 8424 resolve(source); |
| 8055 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); | 8425 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 8056 verify([source]); | 8426 verify([source]); |
| 8057 } | 8427 } |
| 8058 void test_implicitThisReferenceInInitializer_redirectingConstructorInvocation(
) { | 8428 void test_implicitThisReferenceInInitializer_redirectingConstructorInvocation(
) { |
| 8059 Source source = addSource(EngineTestCase.createSource([ | 8429 Source source = addSource(EngineTestCase.createSource([ |
| 8060 "class A {", | 8430 "class A {", |
| 8061 " A(p) {}", | 8431 " A(p) {}", |
| 8062 " A.named() : this(f);", | 8432 " A.named() : this(f);", |
| 8063 " var f;", | 8433 " var f;", |
| 8064 "}"])); | 8434 "}"])); |
| 8065 resolve(source); | 8435 resolve(source); |
| 8066 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); | 8436 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 8067 verify([source]); | 8437 verify([source]); |
| 8068 } | 8438 } |
| 8069 void test_implicitThisReferenceInInitializer_superConstructorInvocation() { | 8439 void test_implicitThisReferenceInInitializer_superConstructorInvocation() { |
| 8070 Source source = addSource(EngineTestCase.createSource([ | 8440 Source source = addSource(EngineTestCase.createSource([ |
| 8071 "class A {", | 8441 "class A {", |
| 8072 " A(p) {}", | 8442 " A(p) {}", |
| 8073 "}", | 8443 "}", |
| 8074 "class B extends A {", | 8444 "class B extends A {", |
| 8075 " B() : super(f);", | 8445 " B() : super(f);", |
| 8076 " var f;", | 8446 " var f;", |
| 8077 "}"])); | 8447 "}"])); |
| 8078 resolve(source); | 8448 resolve(source); |
| 8079 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); | 8449 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA
LIZER]); |
| 8080 verify([source]); | 8450 verify([source]); |
| 8081 } | 8451 } |
| 8082 void test_importInternalLibrary() { | 8452 void test_importInternalLibrary() { |
| 8083 Source source = addSource(EngineTestCase.createSource(["import 'dart:_interc
eptors';"])); | 8453 Source source = addSource(EngineTestCase.createSource(["import 'dart:_interc
eptors';"])); |
| 8084 resolve(source); | 8454 resolve(source); |
| 8085 assertErrors([ | 8455 assertErrors(source, [ |
| 8086 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, | 8456 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, |
| 8087 HintCode.UNUSED_IMPORT]); | 8457 HintCode.UNUSED_IMPORT]); |
| 8088 verify([source]); | 8458 verify([source]); |
| 8089 } | 8459 } |
| 8090 void test_importInternalLibrary_collection() { | 8460 void test_importInternalLibrary_collection() { |
| 8091 Source source = addSource(EngineTestCase.createSource(["import 'dart:_collec
tion-dev';"])); | 8461 Source source = addSource(EngineTestCase.createSource(["import 'dart:_collec
tion-dev';"])); |
| 8092 resolve(source); | 8462 resolve(source); |
| 8093 assertErrors([ | 8463 assertErrors(source, [ |
| 8094 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, | 8464 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, |
| 8095 HintCode.UNUSED_IMPORT]); | 8465 HintCode.UNUSED_IMPORT]); |
| 8096 verify([source]); | 8466 verify([source]); |
| 8097 } | 8467 } |
| 8098 void test_importOfNonLibrary() { | 8468 void test_importOfNonLibrary() { |
| 8099 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); | 8469 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo
rt 'part.dart';", "A a;"])); |
| 8100 addSource2("/part.dart", EngineTestCase.createSource(["part of lib;", "class
A{}"])); | 8470 addSource2("/part.dart", EngineTestCase.createSource(["part of lib;", "class
A{}"])); |
| 8101 resolve(source); | 8471 resolve(source); |
| 8102 assertErrors([CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]); | 8472 assertErrors(source, [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]); |
| 8103 verify([source]); | 8473 verify([source]); |
| 8104 } | 8474 } |
| 8105 void test_inconsistentCaseExpressionTypes() { | 8475 void test_inconsistentCaseExpressionTypes() { |
| 8106 Source source = addSource(EngineTestCase.createSource([ | 8476 Source source = addSource(EngineTestCase.createSource([ |
| 8107 "f(var p) {", | 8477 "f(var p) {", |
| 8108 " switch (p) {", | 8478 " switch (p) {", |
| 8109 " case 1:", | 8479 " case 1:", |
| 8110 " break;", | 8480 " break;", |
| 8111 " case 'a':", | 8481 " case 'a':", |
| 8112 " break;", | 8482 " break;", |
| 8113 " }", | 8483 " }", |
| 8114 "}"])); | 8484 "}"])); |
| 8115 resolve(source); | 8485 resolve(source); |
| 8116 assertErrors([CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]); | 8486 assertErrors(source, [CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPE
S]); |
| 8117 verify([source]); | 8487 verify([source]); |
| 8118 } | 8488 } |
| 8119 void test_inconsistentCaseExpressionTypes_repeated() { | 8489 void test_inconsistentCaseExpressionTypes_repeated() { |
| 8120 Source source = addSource(EngineTestCase.createSource([ | 8490 Source source = addSource(EngineTestCase.createSource([ |
| 8121 "f(var p) {", | 8491 "f(var p) {", |
| 8122 " switch (p) {", | 8492 " switch (p) {", |
| 8123 " case 1:", | 8493 " case 1:", |
| 8124 " break;", | 8494 " break;", |
| 8125 " case 'a':", | 8495 " case 'a':", |
| 8126 " break;", | 8496 " break;", |
| 8127 " case 'b':", | 8497 " case 'b':", |
| 8128 " break;", | 8498 " break;", |
| 8129 " }", | 8499 " }", |
| 8130 "}"])); | 8500 "}"])); |
| 8131 resolve(source); | 8501 resolve(source); |
| 8132 assertErrors([ | 8502 assertErrors(source, [ |
| 8133 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, | 8503 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, |
| 8134 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]); | 8504 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]); |
| 8135 verify([source]); | 8505 verify([source]); |
| 8136 } | 8506 } |
| 8137 void test_initializerForNonExistant_initializer() { | 8507 void test_initializerForNonExistant_initializer() { |
| 8138 Source source = addSource(EngineTestCase.createSource(["class A {", " A() :
x = 0 {}", "}"])); | 8508 Source source = addSource(EngineTestCase.createSource(["class A {", " A() :
x = 0 {}", "}"])); |
| 8139 resolve(source); | 8509 resolve(source); |
| 8140 assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FIELD]); | 8510 assertErrors(source, [CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FIEL
D]); |
| 8141 } | 8511 } |
| 8142 void test_initializerForStaticField() { | 8512 void test_initializerForStaticField() { |
| 8143 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " A() : x = 0 {}", "}"])); | 8513 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " A() : x = 0 {}", "}"])); |
| 8144 resolve(source); | 8514 resolve(source); |
| 8145 assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]); | 8515 assertErrors(source, [CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]); |
| 8146 verify([source]); | 8516 verify([source]); |
| 8147 } | 8517 } |
| 8148 void test_initializingFormalForNonExistantField() { | 8518 void test_initializingFormalForNonExistantField() { |
| 8149 Source source = addSource(EngineTestCase.createSource(["class A {", " A(thi
s.x) {}", "}"])); | 8519 Source source = addSource(EngineTestCase.createSource(["class A {", " A(thi
s.x) {}", "}"])); |
| 8150 resolve(source); | 8520 resolve(source); |
| 8151 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL
D]); | 8521 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); |
| 8152 verify([source]); | 8522 verify([source]); |
| 8153 } | 8523 } |
| 8154 void test_initializingFormalForNonExistantField_notInEnclosingClass() { | 8524 void test_initializingFormalForNonExistantField_notInEnclosingClass() { |
| 8155 Source source = addSource(EngineTestCase.createSource([ | 8525 Source source = addSource(EngineTestCase.createSource([ |
| 8156 "class A {", | 8526 "class A {", |
| 8157 "int x;", | 8527 "int x;", |
| 8158 "}", | 8528 "}", |
| 8159 "class B extends A {", | 8529 "class B extends A {", |
| 8160 " B(this.x) {}", | 8530 " B(this.x) {}", |
| 8161 "}"])); | 8531 "}"])); |
| 8162 resolve(source); | 8532 resolve(source); |
| 8163 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL
D]); | 8533 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); |
| 8164 verify([source]); | 8534 verify([source]); |
| 8165 } | 8535 } |
| 8166 void test_initializingFormalForNonExistantField_optional() { | 8536 void test_initializingFormalForNonExistantField_optional() { |
| 8167 Source source = addSource(EngineTestCase.createSource(["class A {", " A([th
is.x]) {}", "}"])); | 8537 Source source = addSource(EngineTestCase.createSource(["class A {", " A([th
is.x]) {}", "}"])); |
| 8168 resolve(source); | 8538 resolve(source); |
| 8169 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL
D]); | 8539 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); |
| 8170 verify([source]); | 8540 verify([source]); |
| 8171 } | 8541 } |
| 8172 void test_initializingFormalForNonExistantField_synthetic() { | 8542 void test_initializingFormalForNonExistantField_synthetic() { |
| 8173 Source source = addSource(EngineTestCase.createSource(["class A {", " int g
et x => 1;", " A(this.x) {}", "}"])); | 8543 Source source = addSource(EngineTestCase.createSource(["class A {", " int g
et x => 1;", " A(this.x) {}", "}"])); |
| 8174 resolve(source); | 8544 resolve(source); |
| 8175 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL
D]); | 8545 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST
ANT_FIELD]); |
| 8176 verify([source]); | 8546 verify([source]); |
| 8177 } | 8547 } |
| 8178 void test_initializingFormalForStaticField() { | 8548 void test_initializingFormalForStaticField() { |
| 8179 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " A([this.x]) {}", "}"])); | 8549 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c int x;", " A([this.x]) {}", "}"])); |
| 8180 resolve(source); | 8550 resolve(source); |
| 8181 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]); | 8551 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FI
ELD]); |
| 8182 verify([source]); | 8552 verify([source]); |
| 8183 } | 8553 } |
| 8184 void test_instanceMemberAccessFromStatic_field() { | 8554 void test_instanceMemberAccessFromStatic_field() { |
| 8185 Source source = addSource(EngineTestCase.createSource([ | 8555 Source source = addSource(EngineTestCase.createSource([ |
| 8186 "class A {", | 8556 "class A {", |
| 8187 " int f;", | 8557 " int f;", |
| 8188 " static foo() {", | 8558 " static foo() {", |
| 8189 " f;", | 8559 " f;", |
| 8190 " }", | 8560 " }", |
| 8191 "}"])); | 8561 "}"])); |
| 8192 resolve(source); | 8562 resolve(source); |
| 8193 assertErrors([CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]); | 8563 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI
C]); |
| 8194 verify([source]); | 8564 verify([source]); |
| 8195 } | 8565 } |
| 8196 void test_instanceMemberAccessFromStatic_getter() { | 8566 void test_instanceMemberAccessFromStatic_getter() { |
| 8197 Source source = addSource(EngineTestCase.createSource([ | 8567 Source source = addSource(EngineTestCase.createSource([ |
| 8198 "class A {", | 8568 "class A {", |
| 8199 " get g => null;", | 8569 " get g => null;", |
| 8200 " static foo() {", | 8570 " static foo() {", |
| 8201 " g;", | 8571 " g;", |
| 8202 " }", | 8572 " }", |
| 8203 "}"])); | 8573 "}"])); |
| 8204 resolve(source); | 8574 resolve(source); |
| 8205 assertErrors([CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]); | 8575 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI
C]); |
| 8206 verify([source]); | 8576 verify([source]); |
| 8207 } | 8577 } |
| 8208 void test_instanceMemberAccessFromStatic_method() { | 8578 void test_instanceMemberAccessFromStatic_method() { |
| 8209 Source source = addSource(EngineTestCase.createSource([ | 8579 Source source = addSource(EngineTestCase.createSource([ |
| 8210 "class A {", | 8580 "class A {", |
| 8211 " m() {}", | 8581 " m() {}", |
| 8212 " static foo() {", | 8582 " static foo() {", |
| 8213 " m();", | 8583 " m();", |
| 8214 " }", | 8584 " }", |
| 8215 "}"])); | 8585 "}"])); |
| 8216 resolve(source); | 8586 resolve(source); |
| 8217 assertErrors([CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]); | 8587 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI
C]); |
| 8218 verify([source]); | 8588 verify([source]); |
| 8219 } | 8589 } |
| 8220 void test_invalidAnnotation_getter() { | 8590 void test_invalidAnnotation_getter() { |
| 8221 Source source = addSource(EngineTestCase.createSource(["get V => 0;", "@V",
"main() {", "}"])); | 8591 Source source = addSource(EngineTestCase.createSource(["get V => 0;", "@V",
"main() {", "}"])); |
| 8222 resolve(source); | 8592 resolve(source); |
| 8223 assertErrors([CompileTimeErrorCode.INVALID_ANNOTATION]); | 8593 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 8224 verify([source]); | 8594 verify([source]); |
| 8225 } | 8595 } |
| 8226 void test_invalidAnnotation_importWithPrefix_getter() { | 8596 void test_invalidAnnotation_importWithPrefix_getter() { |
| 8227 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "get V
=> 0;"])); | 8597 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "get V
=> 0;"])); |
| 8228 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); | 8598 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); |
| 8229 resolve(source); | 8599 resolve(source); |
| 8230 assertErrors([CompileTimeErrorCode.INVALID_ANNOTATION]); | 8600 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 8231 verify([source]); | 8601 verify([source]); |
| 8232 } | 8602 } |
| 8233 void test_invalidAnnotation_importWithPrefix_notConstantVariable() { | 8603 void test_invalidAnnotation_importWithPrefix_notConstantVariable() { |
| 8234 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "final
V = 0;"])); | 8604 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "final
V = 0;"])); |
| 8235 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); | 8605 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); |
| 8236 resolve(source); | 8606 resolve(source); |
| 8237 assertErrors([CompileTimeErrorCode.INVALID_ANNOTATION]); | 8607 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 8238 verify([source]); | 8608 verify([source]); |
| 8239 } | 8609 } |
| 8240 void test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocatio
n() { | 8610 void test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocatio
n() { |
| 8241 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "typede
f V();"])); | 8611 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "typede
f V();"])); |
| 8242 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); | 8612 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "@p.V", "main() {", "}"])); |
| 8243 resolve(source); | 8613 resolve(source); |
| 8244 assertErrors([CompileTimeErrorCode.INVALID_ANNOTATION]); | 8614 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 8245 verify([source]); | 8615 verify([source]); |
| 8246 } | 8616 } |
| 8247 void test_invalidAnnotation_notConstantVariable() { | 8617 void test_invalidAnnotation_notConstantVariable() { |
| 8248 Source source = addSource(EngineTestCase.createSource(["final V = 0;", "@V",
"main() {", "}"])); | 8618 Source source = addSource(EngineTestCase.createSource(["final V = 0;", "@V",
"main() {", "}"])); |
| 8249 resolve(source); | 8619 resolve(source); |
| 8250 assertErrors([CompileTimeErrorCode.INVALID_ANNOTATION]); | 8620 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 8251 verify([source]); | 8621 verify([source]); |
| 8252 } | 8622 } |
| 8253 void test_invalidAnnotation_notVariableOrConstructorInvocation() { | 8623 void test_invalidAnnotation_notVariableOrConstructorInvocation() { |
| 8254 Source source = addSource(EngineTestCase.createSource(["typedef V();", "@V",
"main() {", "}"])); | 8624 Source source = addSource(EngineTestCase.createSource(["typedef V();", "@V",
"main() {", "}"])); |
| 8255 resolve(source); | 8625 resolve(source); |
| 8256 assertErrors([CompileTimeErrorCode.INVALID_ANNOTATION]); | 8626 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 8257 verify([source]); | 8627 verify([source]); |
| 8258 } | 8628 } |
| 8259 void test_invalidAnnotation_staticMethodReference() { | 8629 void test_invalidAnnotation_staticMethodReference() { |
| 8260 Source source = addSource(EngineTestCase.createSource([ | 8630 Source source = addSource(EngineTestCase.createSource([ |
| 8261 "class A {", | 8631 "class A {", |
| 8262 " static f() {}", | 8632 " static f() {}", |
| 8263 "}", | 8633 "}", |
| 8264 "@A.f", | 8634 "@A.f", |
| 8265 "main() {", | 8635 "main() {", |
| 8266 "}"])); | 8636 "}"])); |
| 8267 resolve(source); | 8637 resolve(source); |
| 8268 assertErrors([CompileTimeErrorCode.INVALID_ANNOTATION]); | 8638 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); |
| 8269 verify([source]); | 8639 verify([source]); |
| 8270 } | 8640 } |
| 8271 void test_invalidConstructorName_notEnclosingClassName_defined() { | 8641 void test_invalidConstructorName_notEnclosingClassName_defined() { |
| 8272 Source source = addSource(EngineTestCase.createSource(["class A {", " B() :
super();", "}", "class B {}"])); | 8642 Source source = addSource(EngineTestCase.createSource(["class A {", " B() :
super();", "}", "class B {}"])); |
| 8273 resolve(source); | 8643 resolve(source); |
| 8274 assertErrors([CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); | 8644 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); |
| 8275 } | 8645 } |
| 8276 void test_invalidConstructorName_notEnclosingClassName_undefined() { | 8646 void test_invalidConstructorName_notEnclosingClassName_undefined() { |
| 8277 Source source = addSource(EngineTestCase.createSource(["class A {", " B() :
super();", "}"])); | 8647 Source source = addSource(EngineTestCase.createSource(["class A {", " B() :
super();", "}"])); |
| 8278 resolve(source); | 8648 resolve(source); |
| 8279 assertErrors([CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); | 8649 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); |
| 8280 } | 8650 } |
| 8281 void test_invalidFactoryNameNotAClass_notClassName() { | 8651 void test_invalidFactoryNameNotAClass_notClassName() { |
| 8282 Source source = addSource(EngineTestCase.createSource(["int B;", "class A {"
, " factory B() {}", "}"])); | 8652 Source source = addSource(EngineTestCase.createSource(["int B;", "class A {"
, " factory B() {}", "}"])); |
| 8283 resolve(source); | 8653 resolve(source); |
| 8284 assertErrors([CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]); | 8654 assertErrors(source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]
); |
| 8285 verify([source]); | 8655 verify([source]); |
| 8286 } | 8656 } |
| 8287 void test_invalidFactoryNameNotAClass_notEnclosingClassName() { | 8657 void test_invalidFactoryNameNotAClass_notEnclosingClassName() { |
| 8288 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry B() {}", "}"])); | 8658 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry B() {}", "}"])); |
| 8289 resolve(source); | 8659 resolve(source); |
| 8290 assertErrors([CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]); | 8660 assertErrors(source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]
); |
| 8291 } | 8661 } |
| 8292 void test_invalidReferenceToThis_factoryConstructor() { | 8662 void test_invalidReferenceToThis_factoryConstructor() { |
| 8293 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() { return this; }", "}"])); | 8663 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() { return this; }", "}"])); |
| 8294 resolve(source); | 8664 resolve(source); |
| 8295 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 8665 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 8296 verify([source]); | 8666 verify([source]); |
| 8297 } | 8667 } |
| 8298 void test_invalidReferenceToThis_instanceVariableInitializer_inConstructor() { | 8668 void test_invalidReferenceToThis_instanceVariableInitializer_inConstructor() { |
| 8299 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
;", " A() : f = this;", "}"])); | 8669 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
;", " A() : f = this;", "}"])); |
| 8300 resolve(source); | 8670 resolve(source); |
| 8301 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 8671 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 8302 verify([source]); | 8672 verify([source]); |
| 8303 } | 8673 } |
| 8304 void test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration() { | 8674 void test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration() { |
| 8305 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
= this;", "}"])); | 8675 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
= this;", "}"])); |
| 8306 resolve(source); | 8676 resolve(source); |
| 8307 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 8677 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 8308 verify([source]); | 8678 verify([source]); |
| 8309 } | 8679 } |
| 8310 void test_invalidReferenceToThis_staticMethod() { | 8680 void test_invalidReferenceToThis_staticMethod() { |
| 8311 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c m() { return this; }", "}"])); | 8681 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c m() { return this; }", "}"])); |
| 8312 resolve(source); | 8682 resolve(source); |
| 8313 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 8683 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 8314 verify([source]); | 8684 verify([source]); |
| 8315 } | 8685 } |
| 8316 void test_invalidReferenceToThis_staticVariableInitializer() { | 8686 void test_invalidReferenceToThis_staticVariableInitializer() { |
| 8317 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c A f = this;", "}"])); | 8687 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c A f = this;", "}"])); |
| 8318 resolve(source); | 8688 resolve(source); |
| 8319 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 8689 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 8320 verify([source]); | 8690 verify([source]); |
| 8321 } | 8691 } |
| 8322 void test_invalidReferenceToThis_superInitializer() { | 8692 void test_invalidReferenceToThis_superInitializer() { |
| 8323 Source source = addSource(EngineTestCase.createSource([ | 8693 Source source = addSource(EngineTestCase.createSource([ |
| 8324 "class A {", | 8694 "class A {", |
| 8325 " A(var x) {}", | 8695 " A(var x) {}", |
| 8326 "}", | 8696 "}", |
| 8327 "class B extends A {", | 8697 "class B extends A {", |
| 8328 " B() : super(this);", | 8698 " B() : super(this);", |
| 8329 "}"])); | 8699 "}"])); |
| 8330 resolve(source); | 8700 resolve(source); |
| 8331 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 8701 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 8332 verify([source]); | 8702 verify([source]); |
| 8333 } | 8703 } |
| 8334 void test_invalidReferenceToThis_topLevelFunction() { | 8704 void test_invalidReferenceToThis_topLevelFunction() { |
| 8335 Source source = addSource("f() { return this; }"); | 8705 Source source = addSource("f() { return this; }"); |
| 8336 resolve(source); | 8706 resolve(source); |
| 8337 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 8707 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 8338 verify([source]); | 8708 verify([source]); |
| 8339 } | 8709 } |
| 8340 void test_invalidReferenceToThis_variableInitializer() { | 8710 void test_invalidReferenceToThis_variableInitializer() { |
| 8341 Source source = addSource("int x = this;"); | 8711 Source source = addSource("int x = this;"); |
| 8342 resolve(source); | 8712 resolve(source); |
| 8343 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); | 8713 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]); |
| 8344 verify([source]); | 8714 verify([source]); |
| 8345 } | 8715 } |
| 8346 void test_invalidTypeArgumentInConstList() { | 8716 void test_invalidTypeArgumentInConstList() { |
| 8347 Source source = addSource(EngineTestCase.createSource([ | 8717 Source source = addSource(EngineTestCase.createSource([ |
| 8348 "class A<E> {", | 8718 "class A<E> {", |
| 8349 " m() {", | 8719 " m() {", |
| 8350 " return const <E>[];", | 8720 " return const <E>[];", |
| 8351 " }", | 8721 " }", |
| 8352 "}"])); | 8722 "}"])); |
| 8353 resolve(source); | 8723 resolve(source); |
| 8354 assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST]); | 8724 assertErrors(source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LI
ST]); |
| 8355 verify([source]); | 8725 verify([source]); |
| 8356 } | 8726 } |
| 8357 void test_invalidTypeArgumentInConstMap() { | 8727 void test_invalidTypeArgumentInConstMap() { |
| 8358 Source source = addSource(EngineTestCase.createSource([ | 8728 Source source = addSource(EngineTestCase.createSource([ |
| 8359 "class A<E> {", | 8729 "class A<E> {", |
| 8360 " m() {", | 8730 " m() {", |
| 8361 " return const <String, E>{};", | 8731 " return const <String, E>{};", |
| 8362 " }", | 8732 " }", |
| 8363 "}"])); | 8733 "}"])); |
| 8364 resolve(source); | 8734 resolve(source); |
| 8365 assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP]); | 8735 assertErrors(source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MA
P]); |
| 8366 verify([source]); | 8736 verify([source]); |
| 8367 } | 8737 } |
| 8368 void test_invalidUri_export() { | 8738 void test_invalidUri_export() { |
| 8369 Source source = addSource(EngineTestCase.createSource(["export 'ht:';"])); | 8739 Source source = addSource(EngineTestCase.createSource(["export 'ht:';"])); |
| 8370 resolve(source); | 8740 resolve(source); |
| 8371 assertErrors([CompileTimeErrorCode.INVALID_URI]); | 8741 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
| 8372 } | 8742 } |
| 8373 void test_invalidUri_import() { | 8743 void test_invalidUri_import() { |
| 8374 Source source = addSource(EngineTestCase.createSource(["import 'ht:';"])); | 8744 Source source = addSource(EngineTestCase.createSource(["import 'ht:';"])); |
| 8375 resolve(source); | 8745 resolve(source); |
| 8376 assertErrors([CompileTimeErrorCode.INVALID_URI]); | 8746 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
| 8377 } | 8747 } |
| 8378 void test_invalidUri_part() { | 8748 void test_invalidUri_part() { |
| 8379 Source source = addSource(EngineTestCase.createSource(["part 'ht:';"])); | 8749 Source source = addSource(EngineTestCase.createSource(["part 'ht:';"])); |
| 8380 resolve(source); | 8750 resolve(source); |
| 8381 assertErrors([CompileTimeErrorCode.INVALID_URI]); | 8751 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]); |
| 8382 } | 8752 } |
| 8383 void test_labelInOuterScope() { | 8753 void test_labelInOuterScope() { |
| 8384 Source source = addSource(EngineTestCase.createSource([ | 8754 Source source = addSource(EngineTestCase.createSource([ |
| 8385 "class A {", | 8755 "class A {", |
| 8386 " void m(int i) {", | 8756 " void m(int i) {", |
| 8387 " l: while (i > 0) {", | 8757 " l: while (i > 0) {", |
| 8388 " void f() {", | 8758 " void f() {", |
| 8389 " break l;", | 8759 " break l;", |
| 8390 " };", | 8760 " };", |
| 8391 " }", | 8761 " }", |
| 8392 " }", | 8762 " }", |
| 8393 "}"])); | 8763 "}"])); |
| 8394 resolve(source); | 8764 resolve(source); |
| 8395 assertErrors([CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE]); | 8765 assertErrors(source, [CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE]); |
| 8396 } | 8766 } |
| 8397 void test_labelUndefined_break() { | 8767 void test_labelUndefined_break() { |
| 8398 Source source = addSource(EngineTestCase.createSource([ | 8768 Source source = addSource(EngineTestCase.createSource([ |
| 8399 "f() {", | 8769 "f() {", |
| 8400 " x: while (true) {", | 8770 " x: while (true) {", |
| 8401 " break y;", | 8771 " break y;", |
| 8402 " }", | 8772 " }", |
| 8403 "}"])); | 8773 "}"])); |
| 8404 resolve(source); | 8774 resolve(source); |
| 8405 assertErrors([CompileTimeErrorCode.LABEL_UNDEFINED]); | 8775 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]); |
| 8406 } | 8776 } |
| 8407 void test_labelUndefined_continue() { | 8777 void test_labelUndefined_continue() { |
| 8408 Source source = addSource(EngineTestCase.createSource([ | 8778 Source source = addSource(EngineTestCase.createSource([ |
| 8409 "f() {", | 8779 "f() {", |
| 8410 " x: while (true) {", | 8780 " x: while (true) {", |
| 8411 " continue y;", | 8781 " continue y;", |
| 8412 " }", | 8782 " }", |
| 8413 "}"])); | 8783 "}"])); |
| 8414 resolve(source); | 8784 resolve(source); |
| 8415 assertErrors([CompileTimeErrorCode.LABEL_UNDEFINED]); | 8785 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]); |
| 8416 } | 8786 } |
| 8417 void test_listElementTypeNotAssignable() { | 8787 void test_listElementTypeNotAssignable() { |
| 8418 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g> [42];"])); | 8788 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g> [42];"])); |
| 8419 resolve(source); | 8789 resolve(source); |
| 8420 assertErrors([CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]); | 8790 assertErrors(source, [CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]
); |
| 8421 verify([source]); | 8791 verify([source]); |
| 8422 } | 8792 } |
| 8423 void test_mapKeyTypeNotAssignable() { | 8793 void test_mapKeyTypeNotAssignable() { |
| 8424 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g, int > {1 : 2};"])); | 8794 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g, int > {1 : 2};"])); |
| 8425 resolve(source); | 8795 resolve(source); |
| 8426 assertErrors([CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]); | 8796 assertErrors(source, [CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]); |
| 8427 verify([source]); | 8797 verify([source]); |
| 8428 } | 8798 } |
| 8429 void test_mapValueTypeNotAssignable() { | 8799 void test_mapValueTypeNotAssignable() { |
| 8430 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g, String> {'a' : 2};"])); | 8800 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin
g, String> {'a' : 2};"])); |
| 8431 resolve(source); | 8801 resolve(source); |
| 8432 assertErrors([CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]); | 8802 assertErrors(source, [CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]); |
| 8433 verify([source]); | 8803 verify([source]); |
| 8434 } | 8804 } |
| 8435 void test_memberWithClassName_field() { | 8805 void test_memberWithClassName_field() { |
| 8436 Source source = addSource(EngineTestCase.createSource(["class A {", " int A
= 0;", "}"])); | 8806 Source source = addSource(EngineTestCase.createSource(["class A {", " int A
= 0;", "}"])); |
| 8437 resolve(source); | 8807 resolve(source); |
| 8438 assertErrors([CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); | 8808 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); |
| 8439 verify([source]); | 8809 verify([source]); |
| 8440 } | 8810 } |
| 8441 void test_memberWithClassName_field2() { | 8811 void test_memberWithClassName_field2() { |
| 8442 Source source = addSource(EngineTestCase.createSource(["class A {", " int z
, A, b = 0;", "}"])); | 8812 Source source = addSource(EngineTestCase.createSource(["class A {", " int z
, A, b = 0;", "}"])); |
| 8443 resolve(source); | 8813 resolve(source); |
| 8444 assertErrors([CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); | 8814 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); |
| 8445 verify([source]); | 8815 verify([source]); |
| 8446 } | 8816 } |
| 8447 void test_memberWithClassName_getter() { | 8817 void test_memberWithClassName_getter() { |
| 8448 Source source = addSource(EngineTestCase.createSource(["class A {", " get A
=> 0;", "}"])); | 8818 Source source = addSource(EngineTestCase.createSource(["class A {", " get A
=> 0;", "}"])); |
| 8449 resolve(source); | 8819 resolve(source); |
| 8450 assertErrors([CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); | 8820 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]); |
| 8451 verify([source]); | 8821 verify([source]); |
| 8452 } | 8822 } |
| 8453 void test_memberWithClassName_method() { | 8823 void test_memberWithClassName_method() { |
| 8454 } | 8824 } |
| 8455 void test_methodAndGetterWithSameName() { | 8825 void test_methodAndGetterWithSameName() { |
| 8456 Source source = addSource(EngineTestCase.createSource(["class A {", " get x
=> 0;", " x(y) {}", "}"])); | 8826 Source source = addSource(EngineTestCase.createSource(["class A {", " get x
=> 0;", " x(y) {}", "}"])); |
| 8457 resolve(source); | 8827 resolve(source); |
| 8458 assertErrors([ | 8828 assertErrors(source, [ |
| 8459 CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME, | 8829 CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME, |
| 8460 CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]); | 8830 CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]); |
| 8461 verify([source]); | 8831 verify([source]); |
| 8462 } | 8832 } |
| 8463 void test_mixinDeclaresConstructor_classDeclaration() { | 8833 void test_mixinDeclaresConstructor_classDeclaration() { |
| 8464 Source source = addSource(EngineTestCase.createSource([ | 8834 Source source = addSource(EngineTestCase.createSource([ |
| 8465 "class A {", | 8835 "class A {", |
| 8466 " A() {}", | 8836 " A() {}", |
| 8467 "}", | 8837 "}", |
| 8468 "class B extends Object with A {}"])); | 8838 "class B extends Object with A {}"])); |
| 8469 resolve(source); | 8839 resolve(source); |
| 8470 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); | 8840 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); |
| 8471 verify([source]); | 8841 verify([source]); |
| 8472 } | 8842 } |
| 8473 void test_mixinDeclaresConstructor_typedef() { | 8843 void test_mixinDeclaresConstructor_typedef() { |
| 8474 Source source = addSource(EngineTestCase.createSource([ | 8844 Source source = addSource(EngineTestCase.createSource([ |
| 8475 "class A {", | 8845 "class A {", |
| 8476 " A() {}", | 8846 " A() {}", |
| 8477 "}", | 8847 "}", |
| 8478 "typedef B = Object with A;"])); | 8848 "typedef B = Object with A;"])); |
| 8479 resolve(source); | 8849 resolve(source); |
| 8480 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); | 8850 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); |
| 8481 verify([source]); | 8851 verify([source]); |
| 8482 } | 8852 } |
| 8483 void test_mixinInheritsFromNotObject_classDeclaration_extends() { | 8853 void test_mixinInheritsFromNotObject_classDeclaration_extends() { |
| 8484 Source source = addSource(EngineTestCase.createSource([ | 8854 Source source = addSource(EngineTestCase.createSource([ |
| 8485 "class A {}", | 8855 "class A {}", |
| 8486 "class B extends A {}", | 8856 "class B extends A {}", |
| 8487 "class C extends Object with B {}"])); | 8857 "class C extends Object with B {}"])); |
| 8488 resolve(source); | 8858 resolve(source); |
| 8489 assertErrors([CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); | 8859 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); |
| 8490 verify([source]); | 8860 verify([source]); |
| 8491 } | 8861 } |
| 8492 void test_mixinInheritsFromNotObject_classDeclaration_with() { | 8862 void test_mixinInheritsFromNotObject_classDeclaration_with() { |
| 8493 Source source = addSource(EngineTestCase.createSource([ | 8863 Source source = addSource(EngineTestCase.createSource([ |
| 8494 "class A {}", | 8864 "class A {}", |
| 8495 "class B extends Object with A {}", | 8865 "class B extends Object with A {}", |
| 8496 "class C extends Object with B {}"])); | 8866 "class C extends Object with B {}"])); |
| 8497 resolve(source); | 8867 resolve(source); |
| 8498 assertErrors([CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); | 8868 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); |
| 8499 verify([source]); | 8869 verify([source]); |
| 8500 } | 8870 } |
| 8501 void test_mixinInheritsFromNotObject_typedef_extends() { | 8871 void test_mixinInheritsFromNotObject_typedef_extends() { |
| 8502 Source source = addSource(EngineTestCase.createSource([ | 8872 Source source = addSource(EngineTestCase.createSource([ |
| 8503 "class A {}", | 8873 "class A {}", |
| 8504 "class B extends A {}", | 8874 "class B extends A {}", |
| 8505 "typedef C = Object with B;"])); | 8875 "typedef C = Object with B;"])); |
| 8506 resolve(source); | 8876 resolve(source); |
| 8507 assertErrors([CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); | 8877 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); |
| 8508 verify([source]); | 8878 verify([source]); |
| 8509 } | 8879 } |
| 8510 void test_mixinInheritsFromNotObject_typedef_with() { | 8880 void test_mixinInheritsFromNotObject_typedef_with() { |
| 8511 Source source = addSource(EngineTestCase.createSource([ | 8881 Source source = addSource(EngineTestCase.createSource([ |
| 8512 "class A {}", | 8882 "class A {}", |
| 8513 "class B extends Object with A {}", | 8883 "class B extends Object with A {}", |
| 8514 "typedef C = Object with B;"])); | 8884 "typedef C = Object with B;"])); |
| 8515 resolve(source); | 8885 resolve(source); |
| 8516 assertErrors([CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); | 8886 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]); |
| 8517 verify([source]); | 8887 verify([source]); |
| 8518 } | 8888 } |
| 8519 void test_mixinOfDisallowedClass_bool() { | 8889 void test_mixinOfDisallowedClass_bool() { |
| 8520 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with bool {}"])); | 8890 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with bool {}"])); |
| 8521 resolve(source); | 8891 resolve(source); |
| 8522 assertErrors([CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 8892 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 8523 verify([source]); | 8893 verify([source]); |
| 8524 } | 8894 } |
| 8525 void test_mixinOfDisallowedClass_double() { | 8895 void test_mixinOfDisallowedClass_double() { |
| 8526 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with double {}"])); | 8896 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with double {}"])); |
| 8527 resolve(source); | 8897 resolve(source); |
| 8528 assertErrors([CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 8898 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 8529 verify([source]); | 8899 verify([source]); |
| 8530 } | 8900 } |
| 8531 void test_mixinOfDisallowedClass_int() { | 8901 void test_mixinOfDisallowedClass_int() { |
| 8532 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with int {}"])); | 8902 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with int {}"])); |
| 8533 resolve(source); | 8903 resolve(source); |
| 8534 assertErrors([CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 8904 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 8535 verify([source]); | 8905 verify([source]); |
| 8536 } | 8906 } |
| 8537 void test_mixinOfDisallowedClass_Null() { | 8907 void test_mixinOfDisallowedClass_Null() { |
| 8538 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with Null {}"])); | 8908 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with Null {}"])); |
| 8539 resolve(source); | 8909 resolve(source); |
| 8540 assertErrors([CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 8910 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 8541 verify([source]); | 8911 verify([source]); |
| 8542 } | 8912 } |
| 8543 void test_mixinOfDisallowedClass_num() { | 8913 void test_mixinOfDisallowedClass_num() { |
| 8544 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with num {}"])); | 8914 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with num {}"])); |
| 8545 resolve(source); | 8915 resolve(source); |
| 8546 assertErrors([CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 8916 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 8547 verify([source]); | 8917 verify([source]); |
| 8548 } | 8918 } |
| 8549 void test_mixinOfDisallowedClass_String() { | 8919 void test_mixinOfDisallowedClass_String() { |
| 8550 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with String {}"])); | 8920 Source source = addSource(EngineTestCase.createSource(["class A extends Obje
ct with String {}"])); |
| 8551 resolve(source); | 8921 resolve(source); |
| 8552 assertErrors([CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); | 8922 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); |
| 8553 verify([source]); | 8923 verify([source]); |
| 8554 } | 8924 } |
| 8555 void test_mixinOfNonClass_class() { | 8925 void test_mixinOfNonClass_class() { |
| 8556 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex
tends Object with A {}"])); | 8926 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex
tends Object with A {}"])); |
| 8557 resolve(source); | 8927 resolve(source); |
| 8558 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); | 8928 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); |
| 8559 verify([source]); | 8929 verify([source]); |
| 8560 } | 8930 } |
| 8561 void test_mixinOfNonClass_typedef() { | 8931 void test_mixinOfNonClass_typedef() { |
| 8562 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B;
", "typedef C = A with B;"])); | 8932 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B;
", "typedef C = A with B;"])); |
| 8563 resolve(source); | 8933 resolve(source); |
| 8564 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); | 8934 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); |
| 8565 verify([source]); | 8935 verify([source]); |
| 8566 } | 8936 } |
| 8567 void test_mixinReferencesSuper() { | 8937 void test_mixinReferencesSuper() { |
| 8568 Source source = addSource(EngineTestCase.createSource([ | 8938 Source source = addSource(EngineTestCase.createSource([ |
| 8569 "class A {", | 8939 "class A {", |
| 8570 " toString() => super.toString();", | 8940 " toString() => super.toString();", |
| 8571 "}", | 8941 "}", |
| 8572 "class B extends Object with A {}"])); | 8942 "class B extends Object with A {}"])); |
| 8573 resolve(source); | 8943 resolve(source); |
| 8574 assertErrors([CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]); | 8944 assertErrors(source, [CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]); |
| 8575 verify([source]); | 8945 verify([source]); |
| 8576 } | 8946 } |
| 8577 void test_mixinWithNonClassSuperclass_class() { | 8947 void test_mixinWithNonClassSuperclass_class() { |
| 8578 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {}
", "class C extends A with B {}"])); | 8948 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {}
", "class C extends A with B {}"])); |
| 8579 resolve(source); | 8949 resolve(source); |
| 8580 assertErrors([CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]); | 8950 assertErrors(source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS])
; |
| 8581 verify([source]); | 8951 verify([source]); |
| 8582 } | 8952 } |
| 8583 void test_mixinWithNonClassSuperclass_typedef() { | 8953 void test_mixinWithNonClassSuperclass_typedef() { |
| 8584 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {}
", "typedef C = A with B;"])); | 8954 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {}
", "typedef C = A with B;"])); |
| 8585 resolve(source); | 8955 resolve(source); |
| 8586 assertErrors([CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]); | 8956 assertErrors(source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS])
; |
| 8587 verify([source]); | 8957 verify([source]); |
| 8588 } | 8958 } |
| 8589 void test_multipleRedirectingConstructorInvocations() { | 8959 void test_multipleRedirectingConstructorInvocations() { |
| 8590 Source source = addSource(EngineTestCase.createSource([ | 8960 Source source = addSource(EngineTestCase.createSource([ |
| 8591 "class A {", | 8961 "class A {", |
| 8592 " A() : this.a(), this.b();", | 8962 " A() : this.a(), this.b();", |
| 8593 " A.a() {}", | 8963 " A.a() {}", |
| 8594 " A.b() {}", | 8964 " A.b() {}", |
| 8595 "}"])); | 8965 "}"])); |
| 8596 resolve(source); | 8966 resolve(source); |
| 8597 assertErrors([CompileTimeErrorCode.MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATI
ONS]); | 8967 assertErrors(source, [CompileTimeErrorCode.MULTIPLE_REDIRECTING_CONSTRUCTOR_
INVOCATIONS]); |
| 8598 verify([source]); | 8968 verify([source]); |
| 8599 } | 8969 } |
| 8600 void test_multipleSuperInitializers() { | 8970 void test_multipleSuperInitializers() { |
| 8601 Source source = addSource(EngineTestCase.createSource([ | 8971 Source source = addSource(EngineTestCase.createSource([ |
| 8602 "class A {}", | 8972 "class A {}", |
| 8603 "class B extends A {", | 8973 "class B extends A {", |
| 8604 " B() : super(), super() {}", | 8974 " B() : super(), super() {}", |
| 8605 "}"])); | 8975 "}"])); |
| 8606 resolve(source); | 8976 resolve(source); |
| 8607 assertErrors([CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]); | 8977 assertErrors(source, [CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]); |
| 8608 verify([source]); | 8978 verify([source]); |
| 8609 } | 8979 } |
| 8610 void test_nativeClauseInNonSDKCode() { | 8980 void test_nativeClauseInNonSDKCode() { |
| 8611 Source source = addSource(EngineTestCase.createSource(["class A native 'stri
ng' {}"])); | 8981 Source source = addSource(EngineTestCase.createSource(["class A native 'stri
ng' {}"])); |
| 8612 resolve(source); | 8982 resolve(source); |
| 8613 assertErrors([ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); | 8983 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]); |
| 8614 verify([source]); | 8984 verify([source]); |
| 8615 } | 8985 } |
| 8616 void test_nativeFunctionBodyInNonSDKCode_function() { | 8986 void test_nativeFunctionBodyInNonSDKCode_function() { |
| 8617 Source source = addSource(EngineTestCase.createSource(["int m(a) native 'str
ing';"])); | 8987 Source source = addSource(EngineTestCase.createSource(["int m(a) native 'str
ing';"])); |
| 8618 resolve(source); | 8988 resolve(source); |
| 8619 assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]); | 8989 assertErrors(source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE])
; |
| 8620 verify([source]); | 8990 verify([source]); |
| 8621 } | 8991 } |
| 8622 void test_nativeFunctionBodyInNonSDKCode_method() { | 8992 void test_nativeFunctionBodyInNonSDKCode_method() { |
| 8623 Source source = addSource(EngineTestCase.createSource(["class A{", " static
int m(a) native 'string';", "}"])); | 8993 Source source = addSource(EngineTestCase.createSource(["class A{", " static
int m(a) native 'string';", "}"])); |
| 8624 resolve(source); | 8994 resolve(source); |
| 8625 assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]); | 8995 assertErrors(source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE])
; |
| 8626 verify([source]); | 8996 verify([source]); |
| 8627 } | 8997 } |
| 8628 void test_noAnnotationConstructorArguments() { | 8998 void test_noAnnotationConstructorArguments() { |
| 8629 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A();", "}", "@A", "main() {", "}"])); | 8999 Source source = addSource(EngineTestCase.createSource(["class A {", " const
A();", "}", "@A", "main() {", "}"])); |
| 8630 resolve(source); | 9000 resolve(source); |
| 8631 assertErrors([CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS]); | 9001 assertErrors(source, [CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMEN
TS]); |
| 8632 verify([source]); | 9002 verify([source]); |
| 8633 } | 9003 } |
| 8634 void test_noDefaultSuperConstructorExplicit() { | 9004 void test_noDefaultSuperConstructorExplicit() { |
| 8635 Source source = addSource(EngineTestCase.createSource([ | 9005 Source source = addSource(EngineTestCase.createSource([ |
| 8636 "class A {", | 9006 "class A {", |
| 8637 " A(p);", | 9007 " A(p);", |
| 8638 "}", | 9008 "}", |
| 8639 "class B extends A {", | 9009 "class B extends A {", |
| 8640 " B() {}", | 9010 " B() {}", |
| 8641 "}"])); | 9011 "}"])); |
| 8642 resolve(source); | 9012 resolve(source); |
| 8643 assertErrors([CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]); | 9013 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPL
ICIT]); |
| 8644 verify([source]); | 9014 verify([source]); |
| 8645 } | 9015 } |
| 8646 void test_noDefaultSuperConstructorImplicit_superHasParameters() { | 9016 void test_noDefaultSuperConstructorImplicit_superHasParameters() { |
| 8647 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p);
", "}", "class B extends A {", "}"])); | 9017 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p);
", "}", "class B extends A {", "}"])); |
| 8648 resolve(source); | 9018 resolve(source); |
| 8649 assertErrors([CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 9019 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPL
ICIT]); |
| 8650 verify([source]); | 9020 verify([source]); |
| 8651 } | 9021 } |
| 8652 void test_noDefaultSuperConstructorImplicit_superOnlyNamed() { | 9022 void test_noDefaultSuperConstructorImplicit_superOnlyNamed() { |
| 8653 Source source = addSource(EngineTestCase.createSource(["class A { A.named()
{} }", "class B extends A {}"])); | 9023 Source source = addSource(EngineTestCase.createSource(["class A { A.named()
{} }", "class B extends A {}"])); |
| 8654 resolve(source); | 9024 resolve(source); |
| 8655 assertErrors([CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); | 9025 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPL
ICIT]); |
| 8656 verify([source]); | 9026 verify([source]); |
| 8657 } | 9027 } |
| 8658 void test_nonConstantAnnotationConstructor_named() { | 9028 void test_nonConstantAnnotationConstructor_named() { |
| 8659 Source source = addSource(EngineTestCase.createSource([ | 9029 Source source = addSource(EngineTestCase.createSource([ |
| 8660 "class A {", | 9030 "class A {", |
| 8661 " A.fromInt() {}", | 9031 " A.fromInt() {}", |
| 8662 "}", | 9032 "}", |
| 8663 "@A.fromInt()", | 9033 "@A.fromInt()", |
| 8664 "main() {", | 9034 "main() {", |
| 8665 "}"])); | 9035 "}"])); |
| 8666 resolve(source); | 9036 resolve(source); |
| 8667 assertErrors([CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR]); | 9037 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCT
OR]); |
| 8668 verify([source]); | 9038 verify([source]); |
| 8669 } | 9039 } |
| 8670 void test_nonConstantAnnotationConstructor_unnamed() { | 9040 void test_nonConstantAnnotationConstructor_unnamed() { |
| 8671 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "@A()", "main() {", "}"])); | 9041 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}", "@A()", "main() {", "}"])); |
| 8672 resolve(source); | 9042 resolve(source); |
| 8673 assertErrors([CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR]); | 9043 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCT
OR]); |
| 8674 verify([source]); | 9044 verify([source]); |
| 8675 } | 9045 } |
| 8676 void test_nonConstantDefaultValue_function_named() { | 9046 void test_nonConstantDefaultValue_function_named() { |
| 8677 Source source = addSource(EngineTestCase.createSource(["int y;", "f({x : y})
{}"])); | 9047 Source source = addSource(EngineTestCase.createSource(["int y;", "f({x : y})
{}"])); |
| 8678 resolve(source); | 9048 resolve(source); |
| 8679 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 9049 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 8680 verify([source]); | 9050 verify([source]); |
| 8681 } | 9051 } |
| 8682 void test_nonConstantDefaultValue_function_positional() { | 9052 void test_nonConstantDefaultValue_function_positional() { |
| 8683 Source source = addSource(EngineTestCase.createSource(["int y;", "f([x = y])
{}"])); | 9053 Source source = addSource(EngineTestCase.createSource(["int y;", "f([x = y])
{}"])); |
| 8684 resolve(source); | 9054 resolve(source); |
| 8685 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 9055 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 8686 verify([source]); | 9056 verify([source]); |
| 8687 } | 9057 } |
| 8688 void test_nonConstantDefaultValue_inConstructor_named() { | 9058 void test_nonConstantDefaultValue_inConstructor_named() { |
| 8689 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " A({x : y}) {}", "}"])); | 9059 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " A({x : y}) {}", "}"])); |
| 8690 resolve(source); | 9060 resolve(source); |
| 8691 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 9061 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 8692 verify([source]); | 9062 verify([source]); |
| 8693 } | 9063 } |
| 8694 void test_nonConstantDefaultValue_inConstructor_positional() { | 9064 void test_nonConstantDefaultValue_inConstructor_positional() { |
| 8695 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " A([x = y]) {}", "}"])); | 9065 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " A([x = y]) {}", "}"])); |
| 8696 resolve(source); | 9066 resolve(source); |
| 8697 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 9067 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 8698 verify([source]); | 9068 verify([source]); |
| 8699 } | 9069 } |
| 8700 void test_nonConstantDefaultValue_method_named() { | 9070 void test_nonConstantDefaultValue_method_named() { |
| 8701 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " m({x : y}) {}", "}"])); | 9071 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " m({x : y}) {}", "}"])); |
| 8702 resolve(source); | 9072 resolve(source); |
| 8703 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 9073 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 8704 verify([source]); | 9074 verify([source]); |
| 8705 } | 9075 } |
| 8706 void test_nonConstantDefaultValue_method_positional() { | 9076 void test_nonConstantDefaultValue_method_positional() { |
| 8707 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " m([x = y]) {}", "}"])); | 9077 Source source = addSource(EngineTestCase.createSource(["class A {", " int y
;", " m([x = y]) {}", "}"])); |
| 8708 resolve(source); | 9078 resolve(source); |
| 8709 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); | 9079 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); |
| 8710 verify([source]); | 9080 verify([source]); |
| 8711 } | 9081 } |
| 8712 void test_nonConstCaseExpression() { | 9082 void test_nonConstCaseExpression() { |
| 8713 Source source = addSource(EngineTestCase.createSource([ | 9083 Source source = addSource(EngineTestCase.createSource([ |
| 8714 "f(int p, int q) {", | 9084 "f(int p, int q) {", |
| 8715 " switch (p) {", | 9085 " switch (p) {", |
| 8716 " case 3 + q:", | 9086 " case 3 + q:", |
| 8717 " break;", | 9087 " break;", |
| 8718 " }", | 9088 " }", |
| 8719 "}"])); | 9089 "}"])); |
| 8720 resolve(source); | 9090 resolve(source); |
| 8721 assertErrors([CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]); | 9091 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]); |
| 8722 verify([source]); | 9092 verify([source]); |
| 8723 } | 9093 } |
| 8724 void test_nonConstListElement() { | 9094 void test_nonConstListElement() { |
| 8725 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst [a];", "}"])); | 9095 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst [a];", "}"])); |
| 8726 resolve(source); | 9096 resolve(source); |
| 8727 assertErrors([CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]); | 9097 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]); |
| 8728 verify([source]); | 9098 verify([source]); |
| 8729 } | 9099 } |
| 8730 void test_nonConstMapAsExpressionStatement_begin() { | 9100 void test_nonConstMapAsExpressionStatement_begin() { |
| 8731 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0,
'b' : 1}.length;", "}"])); | 9101 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0,
'b' : 1}.length;", "}"])); |
| 8732 resolve(source); | 9102 resolve(source); |
| 8733 assertErrors([CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]); | 9103 assertErrors(source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATE
MENT]); |
| 8734 verify([source]); | 9104 verify([source]); |
| 8735 } | 9105 } |
| 8736 void test_nonConstMapAsExpressionStatement_only() { | 9106 void test_nonConstMapAsExpressionStatement_only() { |
| 8737 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0,
'b' : 1};", "}"])); | 9107 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0,
'b' : 1};", "}"])); |
| 8738 resolve(source); | 9108 resolve(source); |
| 8739 assertErrors([CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]); | 9109 assertErrors(source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATE
MENT]); |
| 8740 verify([source]); | 9110 verify([source]); |
| 8741 } | 9111 } |
| 8742 void test_nonConstMapKey() { | 9112 void test_nonConstMapKey() { |
| 8743 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst {a : 0};", "}"])); | 9113 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst {a : 0};", "}"])); |
| 8744 resolve(source); | 9114 resolve(source); |
| 8745 assertErrors([CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]); | 9115 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]); |
| 8746 verify([source]); | 9116 verify([source]); |
| 8747 } | 9117 } |
| 8748 void test_nonConstMapValue() { | 9118 void test_nonConstMapValue() { |
| 8749 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst {'a' : a};", "}"])); | 9119 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c
onst {'a' : a};", "}"])); |
| 8750 resolve(source); | 9120 resolve(source); |
| 8751 assertErrors([CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]); | 9121 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]); |
| 8752 verify([source]); | 9122 verify([source]); |
| 8753 } | 9123 } |
| 8754 void test_nonConstValueInInitializer_binary_notBool_left() { | 9124 void test_nonConstValueInInitializer_binary_notBool_left() { |
| 8755 Source source = addSource(EngineTestCase.createSource([ | 9125 Source source = addSource(EngineTestCase.createSource([ |
| 8756 "class A {", | 9126 "class A {", |
| 8757 " final bool a;", | 9127 " final bool a;", |
| 8758 " const A(String p) : a = p && true;", | 9128 " const A(String p) : a = p && true;", |
| 8759 "}"])); | 9129 "}"])); |
| 8760 resolve(source); | 9130 resolve(source); |
| 8761 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); | 9131 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); |
| 8762 verify([source]); | 9132 verify([source]); |
| 8763 } | 9133 } |
| 8764 void test_nonConstValueInInitializer_binary_notBool_right() { | 9134 void test_nonConstValueInInitializer_binary_notBool_right() { |
| 8765 Source source = addSource(EngineTestCase.createSource([ | 9135 Source source = addSource(EngineTestCase.createSource([ |
| 8766 "class A {", | 9136 "class A {", |
| 8767 " final bool a;", | 9137 " final bool a;", |
| 8768 " const A(String p) : a = true && p;", | 9138 " const A(String p) : a = true && p;", |
| 8769 "}"])); | 9139 "}"])); |
| 8770 resolve(source); | 9140 resolve(source); |
| 8771 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); | 9141 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); |
| 8772 verify([source]); | 9142 verify([source]); |
| 8773 } | 9143 } |
| 8774 void test_nonConstValueInInitializer_binary_notInt() { | 9144 void test_nonConstValueInInitializer_binary_notInt() { |
| 8775 Source source = addSource(EngineTestCase.createSource([ | 9145 Source source = addSource(EngineTestCase.createSource([ |
| 8776 "class A {", | 9146 "class A {", |
| 8777 " final int a;", | 9147 " final int a;", |
| 8778 " const A(String p) : a = 5 & p;", | 9148 " const A(String p) : a = 5 & p;", |
| 8779 "}"])); | 9149 "}"])); |
| 8780 resolve(source); | 9150 resolve(source); |
| 8781 assertErrors([ | 9151 assertErrors(source, [ |
| 8782 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, | 9152 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, |
| 8783 CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 9153 CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 8784 verify([source]); | 9154 verify([source]); |
| 8785 } | 9155 } |
| 8786 void test_nonConstValueInInitializer_binary_notNum() { | 9156 void test_nonConstValueInInitializer_binary_notNum() { |
| 8787 Source source = addSource(EngineTestCase.createSource([ | 9157 Source source = addSource(EngineTestCase.createSource([ |
| 8788 "class A {", | 9158 "class A {", |
| 8789 " final int a;", | 9159 " final int a;", |
| 8790 " const A(String p) : a = 5 + p;", | 9160 " const A(String p) : a = 5 + p;", |
| 8791 "}"])); | 9161 "}"])); |
| 8792 resolve(source); | 9162 resolve(source); |
| 8793 assertErrors([ | 9163 assertErrors(source, [ |
| 8794 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, | 9164 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, |
| 8795 CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 9165 CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 8796 verify([source]); | 9166 verify([source]); |
| 8797 } | 9167 } |
| 8798 void test_nonConstValueInInitializer_field() { | 9168 void test_nonConstValueInInitializer_field() { |
| 8799 Source source = addSource(EngineTestCase.createSource([ | 9169 Source source = addSource(EngineTestCase.createSource([ |
| 8800 "class A {", | 9170 "class A {", |
| 8801 " static int C;", | 9171 " static int C;", |
| 8802 " final int a;", | 9172 " final int a;", |
| 8803 " const A() : a = C;", | 9173 " const A() : a = C;", |
| 8804 "}"])); | 9174 "}"])); |
| 8805 resolve(source); | 9175 resolve(source); |
| 8806 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); | 9176 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER
]); |
| 8807 verify([source]); | 9177 verify([source]); |
| 8808 } | 9178 } |
| 8809 void test_nonConstValueInInitializer_redirecting() { | 9179 void test_nonConstValueInInitializer_redirecting() { |
| 8810 Source source = addSource(EngineTestCase.createSource([ | 9180 Source source = addSource(EngineTestCase.createSource([ |
| 8811 "class A {", | 9181 "class A {", |
| 8812 " static var C;", | 9182 " static var C;", |
| 8813 " const A.named(p);", | 9183 " const A.named(p);", |
| 8814 " const A() : this.named(C);", | 9184 " const A() : this.named(C);", |
| 8815 "}"])); | 9185 "}"])); |
| 8816 resolve(source); | 9186 resolve(source); |
| 8817 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); | 9187 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER
]); |
| 8818 verify([source]); | 9188 verify([source]); |
| 8819 } | 9189 } |
| 8820 void test_nonConstValueInInitializer_super() { | 9190 void test_nonConstValueInInitializer_super() { |
| 8821 Source source = addSource(EngineTestCase.createSource([ | 9191 Source source = addSource(EngineTestCase.createSource([ |
| 8822 "class A {", | 9192 "class A {", |
| 8823 " const A(p);", | 9193 " const A(p);", |
| 8824 "}", | 9194 "}", |
| 8825 "class B extends A {", | 9195 "class B extends A {", |
| 8826 " static var C;", | 9196 " static var C;", |
| 8827 " const B() : super(C);", | 9197 " const B() : super(C);", |
| 8828 "}"])); | 9198 "}"])); |
| 8829 resolve(source); | 9199 resolve(source); |
| 8830 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); | 9200 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER
]); |
| 8831 verify([source]); | 9201 verify([source]); |
| 8832 } | 9202 } |
| 8833 void test_nonGenerativeConstructor_explicit() { | 9203 void test_nonGenerativeConstructor_explicit() { |
| 8834 Source source = addSource(EngineTestCase.createSource([ | 9204 Source source = addSource(EngineTestCase.createSource([ |
| 8835 "class A {", | 9205 "class A {", |
| 8836 " factory A.named() {}", | 9206 " factory A.named() {}", |
| 8837 "}", | 9207 "}", |
| 8838 "class B extends A {", | 9208 "class B extends A {", |
| 8839 " B() : super.named();", | 9209 " B() : super.named();", |
| 8840 "}"])); | 9210 "}"])); |
| 8841 resolve(source); | 9211 resolve(source); |
| 8842 assertErrors([CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); | 9212 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); |
| 8843 verify([source]); | 9213 verify([source]); |
| 8844 } | 9214 } |
| 8845 void test_nonGenerativeConstructor_implicit() { | 9215 void test_nonGenerativeConstructor_implicit() { |
| 8846 Source source = addSource(EngineTestCase.createSource([ | 9216 Source source = addSource(EngineTestCase.createSource([ |
| 8847 "class A {", | 9217 "class A {", |
| 8848 " factory A() {}", | 9218 " factory A() {}", |
| 8849 "}", | 9219 "}", |
| 8850 "class B extends A {", | 9220 "class B extends A {", |
| 8851 " B();", | 9221 " B();", |
| 8852 "}"])); | 9222 "}"])); |
| 8853 resolve(source); | 9223 resolve(source); |
| 8854 assertErrors([CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); | 9224 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); |
| 8855 verify([source]); | 9225 verify([source]); |
| 8856 } | 9226 } |
| 8857 void test_nonGenerativeConstructor_implicit2() { | 9227 void test_nonGenerativeConstructor_implicit2() { |
| 8858 Source source = addSource(EngineTestCase.createSource([ | 9228 Source source = addSource(EngineTestCase.createSource([ |
| 8859 "class A {", | 9229 "class A {", |
| 8860 " factory A() {}", | 9230 " factory A() {}", |
| 8861 "}", | 9231 "}", |
| 8862 "class B extends A {", | 9232 "class B extends A {", |
| 8863 "}"])); | 9233 "}"])); |
| 8864 resolve(source); | 9234 resolve(source); |
| 8865 assertErrors([CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); | 9235 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); |
| 8866 verify([source]); | 9236 verify([source]); |
| 8867 } | 9237 } |
| 8868 void test_notEnoughRequiredArguments_const() { | 9238 void test_notEnoughRequiredArguments_const() { |
| 8869 Source source = addSource(EngineTestCase.createSource([ | 9239 Source source = addSource(EngineTestCase.createSource([ |
| 8870 "class A {", | 9240 "class A {", |
| 8871 " const A(int p);", | 9241 " const A(int p);", |
| 8872 "}", | 9242 "}", |
| 8873 "main() {", | 9243 "main() {", |
| 8874 " const A();", | 9244 " const A();", |
| 8875 "}"])); | 9245 "}"])); |
| 8876 resolve(source); | 9246 resolve(source); |
| 8877 assertErrors([CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); | 9247 assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); |
| 8878 verify([source]); | 9248 verify([source]); |
| 8879 } | 9249 } |
| 8880 void test_notEnoughRequiredArguments_const_super() { | 9250 void test_notEnoughRequiredArguments_const_super() { |
| 8881 Source source = addSource(EngineTestCase.createSource([ | 9251 Source source = addSource(EngineTestCase.createSource([ |
| 8882 "class A {", | 9252 "class A {", |
| 8883 " const A(int p);", | 9253 " const A(int p);", |
| 8884 "}", | 9254 "}", |
| 8885 "class B extends A {", | 9255 "class B extends A {", |
| 8886 " const B() : super();", | 9256 " const B() : super();", |
| 8887 "}"])); | 9257 "}"])); |
| 8888 resolve(source); | 9258 resolve(source); |
| 8889 assertErrors([CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); | 9259 assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); |
| 8890 verify([source]); | 9260 verify([source]); |
| 8891 } | 9261 } |
| 8892 void test_optionalParameterInOperator_named() { | 9262 void test_optionalParameterInOperator_named() { |
| 8893 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +({p}) {}", "}"])); | 9263 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +({p}) {}", "}"])); |
| 8894 resolve(source); | 9264 resolve(source); |
| 8895 assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); | 9265 assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); |
| 8896 verify([source]); | 9266 verify([source]); |
| 8897 } | 9267 } |
| 8898 void test_optionalParameterInOperator_positional() { | 9268 void test_optionalParameterInOperator_positional() { |
| 8899 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +([p]) {}", "}"])); | 9269 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor +([p]) {}", "}"])); |
| 8900 resolve(source); | 9270 resolve(source); |
| 8901 assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); | 9271 assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); |
| 8902 verify([source]); | 9272 verify([source]); |
| 8903 } | 9273 } |
| 8904 void test_partOfNonPart() { | 9274 void test_partOfNonPart() { |
| 8905 Source source = addSource(EngineTestCase.createSource(["library l1;", "part
'l2.dart';"])); | 9275 Source source = addSource(EngineTestCase.createSource(["library l1;", "part
'l2.dart';"])); |
| 8906 addSource2("/l2.dart", EngineTestCase.createSource(["library l2;"])); | 9276 addSource2("/l2.dart", EngineTestCase.createSource(["library l2;"])); |
| 8907 resolve(source); | 9277 resolve(source); |
| 8908 assertErrors([CompileTimeErrorCode.PART_OF_NON_PART]); | 9278 assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]); |
| 8909 verify([source]); | 9279 verify([source]); |
| 8910 } | 9280 } |
| 8911 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() { | 9281 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() { |
| 8912 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); | 9282 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); |
| 8913 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "typedef p();", "p.A a;"])); | 9283 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "typedef p();", "p.A a;"])); |
| 8914 resolve(source); | 9284 resolve(source); |
| 8915 assertErrors([CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); | 9285 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); |
| 8916 verify([source]); | 9286 verify([source]); |
| 8917 } | 9287 } |
| 8918 void test_prefixCollidesWithTopLevelMembers_topLevelFunction() { | 9288 void test_prefixCollidesWithTopLevelMembers_topLevelFunction() { |
| 8919 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); | 9289 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); |
| 8920 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "p() {}", "p.A a;"])); | 9290 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "p() {}", "p.A a;"])); |
| 8921 resolve(source); | 9291 resolve(source); |
| 8922 assertErrors([CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); | 9292 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); |
| 8923 verify([source]); | 9293 verify([source]); |
| 8924 } | 9294 } |
| 8925 void test_prefixCollidesWithTopLevelMembers_topLevelVariable() { | 9295 void test_prefixCollidesWithTopLevelMembers_topLevelVariable() { |
| 8926 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); | 9296 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); |
| 8927 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "var p = null;", "p.A a;"])); | 9297 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "var p = null;", "p.A a;"])); |
| 8928 resolve(source); | 9298 resolve(source); |
| 8929 assertErrors([CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); | 9299 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); |
| 8930 verify([source]); | 9300 verify([source]); |
| 8931 } | 9301 } |
| 8932 void test_prefixCollidesWithTopLevelMembers_type() { | 9302 void test_prefixCollidesWithTopLevelMembers_type() { |
| 8933 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); | 9303 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
A{}"])); |
| 8934 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "class p {}", "p.A a;"])); | 9304 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
p;", "class p {}", "p.A a;"])); |
| 8935 resolve(source); | 9305 resolve(source); |
| 8936 assertErrors([CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]); | 9306 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME
MBER]); |
| 8937 verify([source]); | 9307 verify([source]); |
| 8938 } | 9308 } |
| 8939 void test_privateOptionalParameter() { | 9309 void test_privateOptionalParameter() { |
| 8940 Source source = addSource(EngineTestCase.createSource(["f({var _p}) {}"])); | 9310 Source source = addSource(EngineTestCase.createSource(["f({var _p}) {}"])); |
| 8941 resolve(source); | 9311 resolve(source); |
| 8942 assertErrors([CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); | 9312 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); |
| 8943 verify([source]); | 9313 verify([source]); |
| 8944 } | 9314 } |
| 8945 void test_privateOptionalParameter_fieldFormal() { | 9315 void test_privateOptionalParameter_fieldFormal() { |
| 8946 Source source = addSource(EngineTestCase.createSource(["class A {", " var _
p;", " A({this._p: 0});", "}"])); | 9316 Source source = addSource(EngineTestCase.createSource(["class A {", " var _
p;", " A({this._p: 0});", "}"])); |
| 8947 resolve(source); | 9317 resolve(source); |
| 8948 assertErrors([CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); | 9318 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); |
| 8949 verify([source]); | 9319 verify([source]); |
| 8950 } | 9320 } |
| 8951 void test_privateOptionalParameter_withDefaultValue() { | 9321 void test_privateOptionalParameter_withDefaultValue() { |
| 8952 Source source = addSource(EngineTestCase.createSource(["f({_p : 0}) {}"])); | 9322 Source source = addSource(EngineTestCase.createSource(["f({_p : 0}) {}"])); |
| 8953 resolve(source); | 9323 resolve(source); |
| 8954 assertErrors([CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); | 9324 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); |
| 8955 verify([source]); | 9325 verify([source]); |
| 8956 } | 9326 } |
| 8957 void test_recursiveConstructorRedirect() { | 9327 void test_recursiveConstructorRedirect() { |
| 8958 Source source = addSource(EngineTestCase.createSource([ | 9328 Source source = addSource(EngineTestCase.createSource([ |
| 8959 "class A {", | 9329 "class A {", |
| 8960 " A.a() : this.b();", | 9330 " A.a() : this.b();", |
| 8961 " A.b() : this.a();", | 9331 " A.b() : this.a();", |
| 8962 "}"])); | 9332 "}"])); |
| 8963 resolve(source); | 9333 resolve(source); |
| 8964 assertErrors([ | 9334 assertErrors(source, [ |
| 8965 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT, | 9335 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT, |
| 8966 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]); | 9336 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]); |
| 8967 verify([source]); | 9337 verify([source]); |
| 8968 } | 9338 } |
| 8969 void test_recursiveConstructorRedirect_directSelfReference() { | 9339 void test_recursiveConstructorRedirect_directSelfReference() { |
| 8970 Source source = addSource(EngineTestCase.createSource(["class A {", " A() :
this();", "}"])); | 9340 Source source = addSource(EngineTestCase.createSource(["class A {", " A() :
this();", "}"])); |
| 8971 resolve(source); | 9341 resolve(source); |
| 8972 assertErrors([CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]); | 9342 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]); |
| 8973 verify([source]); | 9343 verify([source]); |
| 8974 } | 9344 } |
| 8975 void test_recursiveFactoryRedirect() { | 9345 void test_recursiveFactoryRedirect() { |
| 8976 Source source = addSource(EngineTestCase.createSource([ | 9346 Source source = addSource(EngineTestCase.createSource([ |
| 8977 "class A implements B {", | 9347 "class A implements B {", |
| 8978 " factory A() = C;", | 9348 " factory A() = C;", |
| 8979 "}", | 9349 "}", |
| 8980 "class B implements C {", | 9350 "class B implements C {", |
| 8981 " factory B() = A;", | 9351 " factory B() = A;", |
| 8982 "}", | 9352 "}", |
| 8983 "class C implements A {", | 9353 "class C implements A {", |
| 8984 " factory C() = B;", | 9354 " factory C() = B;", |
| 8985 "}"])); | 9355 "}"])); |
| 8986 resolve(source); | 9356 resolve(source); |
| 8987 assertErrors([ | 9357 assertErrors(source, [ |
| 8988 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9358 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 8989 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9359 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 8990 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9360 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 8991 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9361 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 8992 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9362 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 8993 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 9363 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 8994 verify([source]); | 9364 verify([source]); |
| 8995 } | 9365 } |
| 8996 void test_recursiveFactoryRedirect_directSelfReference() { | 9366 void test_recursiveFactoryRedirect_directSelfReference() { |
| 8997 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() = A;", "}"])); | 9367 Source source = addSource(EngineTestCase.createSource(["class A {", " facto
ry A() = A;", "}"])); |
| 8998 resolve(source); | 9368 resolve(source); |
| 8999 assertErrors([CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]); | 9369 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]); |
| 9000 verify([source]); | 9370 verify([source]); |
| 9001 } | 9371 } |
| 9002 void test_recursiveFactoryRedirect_generic() { | 9372 void test_recursiveFactoryRedirect_generic() { |
| 9003 Source source = addSource(EngineTestCase.createSource([ | 9373 Source source = addSource(EngineTestCase.createSource([ |
| 9004 "class A<T> implements B<T> {", | 9374 "class A<T> implements B<T> {", |
| 9005 " factory A() = C;", | 9375 " factory A() = C;", |
| 9006 "}", | 9376 "}", |
| 9007 "class B<T> implements C<T> {", | 9377 "class B<T> implements C<T> {", |
| 9008 " factory B() = A;", | 9378 " factory B() = A;", |
| 9009 "}", | 9379 "}", |
| 9010 "class C<T> implements A<T> {", | 9380 "class C<T> implements A<T> {", |
| 9011 " factory C() = B;", | 9381 " factory C() = B;", |
| 9012 "}"])); | 9382 "}"])); |
| 9013 resolve(source); | 9383 resolve(source); |
| 9014 assertErrors([ | 9384 assertErrors(source, [ |
| 9015 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9385 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 9016 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9386 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 9017 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9387 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 9018 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9388 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9019 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9389 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9020 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 9390 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 9021 verify([source]); | 9391 verify([source]); |
| 9022 } | 9392 } |
| 9023 void test_recursiveFactoryRedirect_named() { | 9393 void test_recursiveFactoryRedirect_named() { |
| 9024 Source source = addSource(EngineTestCase.createSource([ | 9394 Source source = addSource(EngineTestCase.createSource([ |
| 9025 "class A implements B {", | 9395 "class A implements B {", |
| 9026 " factory A.nameA() = C.nameC;", | 9396 " factory A.nameA() = C.nameC;", |
| 9027 "}", | 9397 "}", |
| 9028 "class B implements C {", | 9398 "class B implements C {", |
| 9029 " factory B.nameB() = A.nameA;", | 9399 " factory B.nameB() = A.nameA;", |
| 9030 "}", | 9400 "}", |
| 9031 "class C implements A {", | 9401 "class C implements A {", |
| 9032 " factory C.nameC() = B.nameB;", | 9402 " factory C.nameC() = B.nameB;", |
| 9033 "}"])); | 9403 "}"])); |
| 9034 resolve(source); | 9404 resolve(source); |
| 9035 assertErrors([ | 9405 assertErrors(source, [ |
| 9036 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9406 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 9037 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9407 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 9038 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9408 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 9039 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9409 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9040 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9410 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9041 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 9411 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 9042 verify([source]); | 9412 verify([source]); |
| 9043 } | 9413 } |
| 9044 | 9414 |
| 9045 /** | 9415 /** |
| 9046 * "A" references "C" which has cycle with "B". But we should not report probl
em for "A" - it is | 9416 * "A" references "C" which has cycle with "B". But we should not report probl
em for "A" - it is |
| 9047 * not the part of a cycle. | 9417 * not the part of a cycle. |
| 9048 */ | 9418 */ |
| 9049 void test_recursiveFactoryRedirect_outsideCycle() { | 9419 void test_recursiveFactoryRedirect_outsideCycle() { |
| 9050 Source source = addSource(EngineTestCase.createSource([ | 9420 Source source = addSource(EngineTestCase.createSource([ |
| 9051 "class A {", | 9421 "class A {", |
| 9052 " factory A() = C;", | 9422 " factory A() = C;", |
| 9053 "}", | 9423 "}", |
| 9054 "class B implements C {", | 9424 "class B implements C {", |
| 9055 " factory B() = C;", | 9425 " factory B() = C;", |
| 9056 "}", | 9426 "}", |
| 9057 "class C implements A, B {", | 9427 "class C implements A, B {", |
| 9058 " factory C() = B;", | 9428 " factory C() = B;", |
| 9059 "}"])); | 9429 "}"])); |
| 9060 resolve(source); | 9430 resolve(source); |
| 9061 assertErrors([ | 9431 assertErrors(source, [ |
| 9062 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9432 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 9063 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | 9433 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, |
| 9064 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9434 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9065 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 9435 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 9066 verify([source]); | 9436 verify([source]); |
| 9067 } | 9437 } |
| 9068 void test_recursiveInterfaceInheritance_extends() { | 9438 void test_recursiveInterfaceInheritance_extends() { |
| 9069 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B extends A {}"])); | 9439 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B extends A {}"])); |
| 9070 resolve(source); | 9440 resolve(source); |
| 9071 assertErrors([ | 9441 assertErrors(source, [ |
| 9072 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9442 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9073 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 9443 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 9074 verify([source]); | 9444 verify([source]); |
| 9075 } | 9445 } |
| 9076 void test_recursiveInterfaceInheritance_extends_implements() { | 9446 void test_recursiveInterfaceInheritance_extends_implements() { |
| 9077 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B implements A {}"])); | 9447 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B implements A {}"])); |
| 9078 resolve(source); | 9448 resolve(source); |
| 9079 assertErrors([ | 9449 assertErrors(source, [ |
| 9080 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9450 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9081 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 9451 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 9082 verify([source]); | 9452 verify([source]); |
| 9083 } | 9453 } |
| 9084 void test_recursiveInterfaceInheritance_implements() { | 9454 void test_recursiveInterfaceInheritance_implements() { |
| 9085 Source source = addSource(EngineTestCase.createSource(["class A implements B
{}", "class B implements A {}"])); | 9455 Source source = addSource(EngineTestCase.createSource(["class A implements B
{}", "class B implements A {}"])); |
| 9086 resolve(source); | 9456 resolve(source); |
| 9087 assertErrors([ | 9457 assertErrors(source, [ |
| 9088 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9458 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9089 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 9459 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 9090 verify([source]); | 9460 verify([source]); |
| 9091 } | 9461 } |
| 9092 void test_recursiveInterfaceInheritance_tail() { | 9462 void test_recursiveInterfaceInheritance_tail() { |
| 9093 Source source = addSource(EngineTestCase.createSource([ | 9463 Source source = addSource(EngineTestCase.createSource([ |
| 9094 "abstract class A implements A {}", | 9464 "abstract class A implements A {}", |
| 9095 "class B implements A {}"])); | 9465 "class B implements A {}"])); |
| 9096 resolve(source); | 9466 resolve(source); |
| 9097 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE
_IMPLEMENTS]); | 9467 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_IMPLEMENTS]); |
| 9098 verify([source]); | 9468 verify([source]); |
| 9099 } | 9469 } |
| 9100 void test_recursiveInterfaceInheritance_tail2() { | 9470 void test_recursiveInterfaceInheritance_tail2() { |
| 9101 Source source = addSource(EngineTestCase.createSource([ | 9471 Source source = addSource(EngineTestCase.createSource([ |
| 9102 "abstract class A implements B {}", | 9472 "abstract class A implements B {}", |
| 9103 "abstract class B implements A {}", | 9473 "abstract class B implements A {}", |
| 9104 "class C implements A {}"])); | 9474 "class C implements A {}"])); |
| 9105 resolve(source); | 9475 resolve(source); |
| 9106 assertErrors([ | 9476 assertErrors(source, [ |
| 9107 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9477 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9108 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 9478 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 9109 verify([source]); | 9479 verify([source]); |
| 9110 } | 9480 } |
| 9111 void test_recursiveInterfaceInheritance_tail3() { | 9481 void test_recursiveInterfaceInheritance_tail3() { |
| 9112 Source source = addSource(EngineTestCase.createSource([ | 9482 Source source = addSource(EngineTestCase.createSource([ |
| 9113 "abstract class A implements B {}", | 9483 "abstract class A implements B {}", |
| 9114 "abstract class B implements C {}", | 9484 "abstract class B implements C {}", |
| 9115 "abstract class C implements A {}", | 9485 "abstract class C implements A {}", |
| 9116 "class D implements A {}"])); | 9486 "class D implements A {}"])); |
| 9117 resolve(source); | 9487 resolve(source); |
| 9118 assertErrors([ | 9488 assertErrors(source, [ |
| 9119 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9489 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9120 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | 9490 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, |
| 9121 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); | 9491 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]); |
| 9122 verify([source]); | 9492 verify([source]); |
| 9123 } | 9493 } |
| 9124 void test_recursiveInterfaceInheritanceBaseCaseExtends() { | 9494 void test_recursiveInterfaceInheritanceBaseCaseExtends() { |
| 9125 Source source = addSource(EngineTestCase.createSource(["class A extends A {}
"])); | 9495 Source source = addSource(EngineTestCase.createSource(["class A extends A {}
"])); |
| 9126 resolve(source); | 9496 resolve(source); |
| 9127 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE
_EXTENDS]); | 9497 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_EXTENDS]); |
| 9128 verify([source]); | 9498 verify([source]); |
| 9129 } | 9499 } |
| 9130 void test_recursiveInterfaceInheritanceBaseCaseImplements() { | 9500 void test_recursiveInterfaceInheritanceBaseCaseImplements() { |
| 9131 Source source = addSource(EngineTestCase.createSource(["class A implements A
{}"])); | 9501 Source source = addSource(EngineTestCase.createSource(["class A implements A
{}"])); |
| 9132 resolve(source); | 9502 resolve(source); |
| 9133 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE
_IMPLEMENTS]); | 9503 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_IMPLEMENTS]); |
| 9134 verify([source]); | 9504 verify([source]); |
| 9135 } | 9505 } |
| 9136 void test_recursiveInterfaceInheritanceBaseCaseImplements_typedef() { | 9506 void test_recursiveInterfaceInheritanceBaseCaseImplements_typedef() { |
| 9137 Source source = addSource(EngineTestCase.createSource([ | 9507 Source source = addSource(EngineTestCase.createSource([ |
| 9138 "class A {}", | 9508 "class A {}", |
| 9139 "class M {}", | 9509 "class M {}", |
| 9140 "typedef B = A with M implements B;"])); | 9510 "typedef B = A with M implements B;"])); |
| 9141 resolve(source); | 9511 resolve(source); |
| 9142 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE
_IMPLEMENTS]); | 9512 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B
ASE_CASE_IMPLEMENTS]); |
| 9143 verify([source]); | 9513 verify([source]); |
| 9144 } | 9514 } |
| 9145 void test_redirectToNonConstConstructor() { | 9515 void test_redirectToNonConstConstructor() { |
| 9146 Source source = addSource(EngineTestCase.createSource([ | 9516 Source source = addSource(EngineTestCase.createSource([ |
| 9147 "class A {", | 9517 "class A {", |
| 9148 " A.a() {}", | 9518 " A.a() {}", |
| 9149 " const factory A.b() = A.a;", | 9519 " const factory A.b() = A.a;", |
| 9150 "}"])); | 9520 "}"])); |
| 9151 resolve(source); | 9521 resolve(source); |
| 9152 assertErrors([CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR]); | 9522 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR
]); |
| 9153 verify([source]); | 9523 verify([source]); |
| 9154 } | 9524 } |
| 9155 void test_referenceToDeclaredVariableInInitializer_closure() { | 9525 void test_referenceToDeclaredVariableInInitializer_closure() { |
| 9156 Source source = addSource(EngineTestCase.createSource(["f() {", " var x = (
x) {};", "}"])); | 9526 Source source = addSource(EngineTestCase.createSource(["f() {", " var x = (
x) {};", "}"])); |
| 9157 resolve(source); | 9527 resolve(source); |
| 9158 assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIAL
IZER]); | 9528 assertErrors(source, [CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN
_INITIALIZER]); |
| 9159 verify([source]); | 9529 verify([source]); |
| 9160 } | 9530 } |
| 9161 void test_referenceToDeclaredVariableInInitializer_getter() { | 9531 void test_referenceToDeclaredVariableInInitializer_getter() { |
| 9162 Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x
+ 1;", "}"])); | 9532 Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x
+ 1;", "}"])); |
| 9163 resolve(source); | 9533 resolve(source); |
| 9164 assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIAL
IZER]); | 9534 assertErrors(source, [CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN
_INITIALIZER]); |
| 9165 verify([source]); | 9535 verify([source]); |
| 9166 } | 9536 } |
| 9167 void test_referenceToDeclaredVariableInInitializer_setter() { | 9537 void test_referenceToDeclaredVariableInInitializer_setter() { |
| 9168 Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x
++;", "}"])); | 9538 Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x
++;", "}"])); |
| 9169 resolve(source); | 9539 resolve(source); |
| 9170 assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIAL
IZER]); | 9540 assertErrors(source, [CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN
_INITIALIZER]); |
| 9171 verify([source]); | 9541 verify([source]); |
| 9172 } | 9542 } |
| 9173 void test_referenceToDeclaredVariableInInitializer_unqualifiedInvocation() { | 9543 void test_referenceToDeclaredVariableInInitializer_unqualifiedInvocation() { |
| 9174 Source source = addSource(EngineTestCase.createSource(["f() {", " var x = x
();", "}"])); | 9544 Source source = addSource(EngineTestCase.createSource(["f() {", " var x = x
();", "}"])); |
| 9175 resolve(source); | 9545 resolve(source); |
| 9176 assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIAL
IZER]); | 9546 assertErrors(source, [CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN
_INITIALIZER]); |
| 9177 verify([source]); | 9547 verify([source]); |
| 9178 } | 9548 } |
| 9179 void test_rethrowOutsideCatch() { | 9549 void test_rethrowOutsideCatch() { |
| 9180 Source source = addSource(EngineTestCase.createSource(["f() {", " rethrow;"
, "}"])); | 9550 Source source = addSource(EngineTestCase.createSource(["f() {", " rethrow;"
, "}"])); |
| 9181 resolve(source); | 9551 resolve(source); |
| 9182 assertErrors([CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]); | 9552 assertErrors(source, [CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]); |
| 9183 verify([source]); | 9553 verify([source]); |
| 9184 } | 9554 } |
| 9185 void test_returnInGenerativeConstructor() { | 9555 void test_returnInGenerativeConstructor() { |
| 9186 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
return 0; }", "}"])); | 9556 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
return 0; }", "}"])); |
| 9187 resolve(source); | 9557 resolve(source); |
| 9188 assertErrors([CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]); | 9558 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]
); |
| 9189 verify([source]); | 9559 verify([source]); |
| 9190 } | 9560 } |
| 9191 void test_returnInGenerativeConstructor_expressionFunctionBody() { | 9561 void test_returnInGenerativeConstructor_expressionFunctionBody() { |
| 9192 Source source = addSource(EngineTestCase.createSource(["class A {", " A() =
> null;", "}"])); | 9562 Source source = addSource(EngineTestCase.createSource(["class A {", " A() =
> null;", "}"])); |
| 9193 resolve(source); | 9563 resolve(source); |
| 9194 assertErrors([CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]); | 9564 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]
); |
| 9195 verify([source]); | 9565 verify([source]); |
| 9196 } | 9566 } |
| 9197 void test_superInInvalidContext_binaryExpression() { | 9567 void test_superInInvalidContext_binaryExpression() { |
| 9198 Source source = addSource(EngineTestCase.createSource(["var v = super + 0;"]
)); | 9568 Source source = addSource(EngineTestCase.createSource(["var v = super + 0;"]
)); |
| 9199 resolve(source); | 9569 resolve(source); |
| 9200 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 9570 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 9201 } | 9571 } |
| 9202 void test_superInInvalidContext_constructorFieldInitializer() { | 9572 void test_superInInvalidContext_constructorFieldInitializer() { |
| 9203 Source source = addSource(EngineTestCase.createSource([ | 9573 Source source = addSource(EngineTestCase.createSource([ |
| 9204 "class A {", | 9574 "class A {", |
| 9205 " m() {}", | 9575 " m() {}", |
| 9206 "}", | 9576 "}", |
| 9207 "class B extends A {", | 9577 "class B extends A {", |
| 9208 " var f;", | 9578 " var f;", |
| 9209 " B() : f = super.m();", | 9579 " B() : f = super.m();", |
| 9210 "}"])); | 9580 "}"])); |
| 9211 resolve(source); | 9581 resolve(source); |
| 9212 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 9582 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 9213 } | 9583 } |
| 9214 void test_superInInvalidContext_factoryConstructor() { | 9584 void test_superInInvalidContext_factoryConstructor() { |
| 9215 Source source = addSource(EngineTestCase.createSource([ | 9585 Source source = addSource(EngineTestCase.createSource([ |
| 9216 "class A {", | 9586 "class A {", |
| 9217 " m() {}", | 9587 " m() {}", |
| 9218 "}", | 9588 "}", |
| 9219 "class B extends A {", | 9589 "class B extends A {", |
| 9220 " factory B() {", | 9590 " factory B() {", |
| 9221 " super.m();", | 9591 " super.m();", |
| 9222 " }", | 9592 " }", |
| 9223 "}"])); | 9593 "}"])); |
| 9224 resolve(source); | 9594 resolve(source); |
| 9225 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 9595 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 9226 } | 9596 } |
| 9227 void test_superInInvalidContext_instanceVariableInitializer() { | 9597 void test_superInInvalidContext_instanceVariableInitializer() { |
| 9228 Source source = addSource(EngineTestCase.createSource([ | 9598 Source source = addSource(EngineTestCase.createSource([ |
| 9229 "class A {", | 9599 "class A {", |
| 9230 " var a;", | 9600 " var a;", |
| 9231 "}", | 9601 "}", |
| 9232 "class B extends A {", | 9602 "class B extends A {", |
| 9233 " var b = super.a;", | 9603 " var b = super.a;", |
| 9234 "}"])); | 9604 "}"])); |
| 9235 resolve(source); | 9605 resolve(source); |
| 9236 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 9606 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 9237 } | 9607 } |
| 9238 void test_superInInvalidContext_staticMethod() { | 9608 void test_superInInvalidContext_staticMethod() { |
| 9239 Source source = addSource(EngineTestCase.createSource([ | 9609 Source source = addSource(EngineTestCase.createSource([ |
| 9240 "class A {", | 9610 "class A {", |
| 9241 " static m() {}", | 9611 " static m() {}", |
| 9242 "}", | 9612 "}", |
| 9243 "class B extends A {", | 9613 "class B extends A {", |
| 9244 " static n() { return super.m(); }", | 9614 " static n() { return super.m(); }", |
| 9245 "}"])); | 9615 "}"])); |
| 9246 resolve(source); | 9616 resolve(source); |
| 9247 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 9617 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 9248 } | 9618 } |
| 9249 void test_superInInvalidContext_staticVariableInitializer() { | 9619 void test_superInInvalidContext_staticVariableInitializer() { |
| 9250 Source source = addSource(EngineTestCase.createSource([ | 9620 Source source = addSource(EngineTestCase.createSource([ |
| 9251 "class A {", | 9621 "class A {", |
| 9252 " static int a = 0;", | 9622 " static int a = 0;", |
| 9253 "}", | 9623 "}", |
| 9254 "class B extends A {", | 9624 "class B extends A {", |
| 9255 " static int b = super.a;", | 9625 " static int b = super.a;", |
| 9256 "}"])); | 9626 "}"])); |
| 9257 resolve(source); | 9627 resolve(source); |
| 9258 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 9628 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 9259 } | 9629 } |
| 9260 void test_superInInvalidContext_topLevelFunction() { | 9630 void test_superInInvalidContext_topLevelFunction() { |
| 9261 Source source = addSource(EngineTestCase.createSource(["f() {", " super.f()
;", "}"])); | 9631 Source source = addSource(EngineTestCase.createSource(["f() {", " super.f()
;", "}"])); |
| 9262 resolve(source); | 9632 resolve(source); |
| 9263 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 9633 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 9264 } | 9634 } |
| 9265 void test_superInInvalidContext_topLevelVariableInitializer() { | 9635 void test_superInInvalidContext_topLevelVariableInitializer() { |
| 9266 Source source = addSource(EngineTestCase.createSource(["var v = super.y;"]))
; | 9636 Source source = addSource(EngineTestCase.createSource(["var v = super.y;"]))
; |
| 9267 resolve(source); | 9637 resolve(source); |
| 9268 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); | 9638 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); |
| 9269 } | 9639 } |
| 9270 void test_superInRedirectingConstructor_redirectionSuper() { | 9640 void test_superInRedirectingConstructor_redirectionSuper() { |
| 9271 Source source = addSource(EngineTestCase.createSource([ | 9641 Source source = addSource(EngineTestCase.createSource([ |
| 9272 "class A {}", | 9642 "class A {}", |
| 9273 "class B {", | 9643 "class B {", |
| 9274 " B() : this.name(), super();", | 9644 " B() : this.name(), super();", |
| 9275 " B.name() {}", | 9645 " B.name() {}", |
| 9276 "}"])); | 9646 "}"])); |
| 9277 resolve(source); | 9647 resolve(source); |
| 9278 assertErrors([CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]); | 9648 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]
); |
| 9279 verify([source]); | 9649 verify([source]); |
| 9280 } | 9650 } |
| 9281 void test_superInRedirectingConstructor_superRedirection() { | 9651 void test_superInRedirectingConstructor_superRedirection() { |
| 9282 Source source = addSource(EngineTestCase.createSource([ | 9652 Source source = addSource(EngineTestCase.createSource([ |
| 9283 "class A {}", | 9653 "class A {}", |
| 9284 "class B {", | 9654 "class B {", |
| 9285 " B() : super(), this.name();", | 9655 " B() : super(), this.name();", |
| 9286 " B.name() {}", | 9656 " B.name() {}", |
| 9287 "}"])); | 9657 "}"])); |
| 9288 resolve(source); | 9658 resolve(source); |
| 9289 assertErrors([CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]); | 9659 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]
); |
| 9290 verify([source]); | 9660 verify([source]); |
| 9291 } | 9661 } |
| 9292 void test_typeAliasCannotReferenceItself_parameterType_named() { | 9662 void test_typeAliasCannotReferenceItself_parameterType_named() { |
| 9293 Source source = addSource(EngineTestCase.createSource(["typedef A({A a});"])
); | 9663 Source source = addSource(EngineTestCase.createSource(["typedef A({A a});"])
); |
| 9294 resolve(source); | 9664 resolve(source); |
| 9295 assertErrors([CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 9665 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 9296 verify([source]); | 9666 verify([source]); |
| 9297 } | 9667 } |
| 9298 void test_typeAliasCannotReferenceItself_parameterType_positional() { | 9668 void test_typeAliasCannotReferenceItself_parameterType_positional() { |
| 9299 Source source = addSource(EngineTestCase.createSource(["typedef A([A a]);"])
); | 9669 Source source = addSource(EngineTestCase.createSource(["typedef A([A a]);"])
); |
| 9300 resolve(source); | 9670 resolve(source); |
| 9301 assertErrors([CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 9671 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 9302 verify([source]); | 9672 verify([source]); |
| 9303 } | 9673 } |
| 9304 void test_typeAliasCannotReferenceItself_parameterType_required() { | 9674 void test_typeAliasCannotReferenceItself_parameterType_required() { |
| 9305 Source source = addSource(EngineTestCase.createSource(["typedef A(A a);"])); | 9675 Source source = addSource(EngineTestCase.createSource(["typedef A(A a);"])); |
| 9306 resolve(source); | 9676 resolve(source); |
| 9307 assertErrors([CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 9677 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 9308 verify([source]); | 9678 verify([source]); |
| 9309 } | 9679 } |
| 9310 void test_typeAliasCannotReferenceItself_parameterType_typeArgument() { | 9680 void test_typeAliasCannotReferenceItself_parameterType_typeArgument() { |
| 9311 Source source = addSource(EngineTestCase.createSource(["typedef A(List<A> a)
;"])); | 9681 Source source = addSource(EngineTestCase.createSource(["typedef A(List<A> a)
;"])); |
| 9312 resolve(source); | 9682 resolve(source); |
| 9313 assertErrors([CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 9683 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 9314 verify([source]); | 9684 verify([source]); |
| 9315 } | 9685 } |
| 9316 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { | 9686 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() { |
| 9317 Source source = addSource(EngineTestCase.createSource([ | 9687 Source source = addSource(EngineTestCase.createSource([ |
| 9318 "typedef C A();", | 9688 "typedef C A();", |
| 9319 "typedef A B();", | 9689 "typedef A B();", |
| 9320 "class C {", | 9690 "class C {", |
| 9321 " B a;", | 9691 " B a;", |
| 9322 "}"])); | 9692 "}"])); |
| 9323 resolve(source); | 9693 resolve(source); |
| 9324 assertErrors([CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 9694 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 9325 verify([source]); | 9695 verify([source]); |
| 9326 } | 9696 } |
| 9327 void test_typeAliasCannotReferenceItself_returnType() { | 9697 void test_typeAliasCannotReferenceItself_returnType() { |
| 9328 Source source = addSource(EngineTestCase.createSource(["typedef A A();"])); | 9698 Source source = addSource(EngineTestCase.createSource(["typedef A A();"])); |
| 9329 resolve(source); | 9699 resolve(source); |
| 9330 assertErrors([CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 9700 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 9331 verify([source]); | 9701 verify([source]); |
| 9332 } | 9702 } |
| 9333 void test_typeAliasCannotReferenceItself_returnType_indirect() { | 9703 void test_typeAliasCannotReferenceItself_returnType_indirect() { |
| 9334 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "ty
pedef A B();"])); | 9704 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "ty
pedef A B();"])); |
| 9335 resolve(source); | 9705 resolve(source); |
| 9336 assertErrors([ | 9706 assertErrors(source, [ |
| 9337 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, | 9707 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, |
| 9338 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 9708 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); |
| 9339 verify([source]); | 9709 verify([source]); |
| 9340 } | 9710 } |
| 9341 void test_typeAliasCannotRereferenceItself_mixin_direct() { | 9711 void test_typeAliasCannotRereferenceItself_mixin_direct() { |
| 9342 Source source = addSource(EngineTestCase.createSource(["typedef M = Object w
ith M;"])); | 9712 Source source = addSource(EngineTestCase.createSource(["typedef M = Object w
ith M;"])); |
| 9343 resolve(source); | 9713 resolve(source); |
| 9344 assertErrors([CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 9714 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL
F]); |
| 9345 verify([source]); | 9715 verify([source]); |
| 9346 } | 9716 } |
| 9347 void test_typeAliasCannotRereferenceItself_mixin_indirect() { | 9717 void test_typeAliasCannotRereferenceItself_mixin_indirect() { |
| 9348 Source source = addSource(EngineTestCase.createSource([ | 9718 Source source = addSource(EngineTestCase.createSource([ |
| 9349 "typedef M1 = Object with M2;", | 9719 "typedef M1 = Object with M2;", |
| 9350 "typedef M2 = Object with M1;"])); | 9720 "typedef M2 = Object with M1;"])); |
| 9351 resolve(source); | 9721 resolve(source); |
| 9352 assertErrors([ | 9722 assertErrors(source, [ |
| 9353 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, | 9723 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, |
| 9354 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); | 9724 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]); |
| 9355 verify([source]); | 9725 verify([source]); |
| 9356 } | 9726 } |
| 9357 void test_typeArgumentNotMatchingBounds_const() { | 9727 void test_typeArgumentNotMatchingBounds_const() { |
| 9358 Source source = addSource(EngineTestCase.createSource([ | 9728 Source source = addSource(EngineTestCase.createSource([ |
| 9359 "class A {}", | 9729 "class A {}", |
| 9360 "class B {}", | 9730 "class B {}", |
| 9361 "class G<E extends A> {", | 9731 "class G<E extends A> {", |
| 9362 " const G();", | 9732 " const G();", |
| 9363 "}", | 9733 "}", |
| 9364 "f() { return const G<B>(); }"])); | 9734 "f() { return const G<B>(); }"])); |
| 9365 resolve(source); | 9735 resolve(source); |
| 9366 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); | 9736 assertErrors(source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
]); |
| 9367 verify([source]); | 9737 verify([source]); |
| 9368 } | 9738 } |
| 9369 void test_undefinedClass_const() { | 9739 void test_undefinedClass_const() { |
| 9370 Source source = addSource(EngineTestCase.createSource(["f() {", " return co
nst A();", "}"])); | 9740 Source source = addSource(EngineTestCase.createSource(["f() {", " return co
nst A();", "}"])); |
| 9371 resolve(source); | 9741 resolve(source); |
| 9372 assertErrors([CompileTimeErrorCode.UNDEFINED_CLASS]); | 9742 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CLASS]); |
| 9373 verify([source]); | 9743 verify([source]); |
| 9374 } | 9744 } |
| 9375 void test_undefinedConstructorInInitializer_explicit_named() { | 9745 void test_undefinedConstructorInInitializer_explicit_named() { |
| 9376 Source source = addSource(EngineTestCase.createSource([ | 9746 Source source = addSource(EngineTestCase.createSource([ |
| 9377 "class A {}", | 9747 "class A {}", |
| 9378 "class B extends A {", | 9748 "class B extends A {", |
| 9379 " B() : super.named();", | 9749 " B() : super.named();", |
| 9380 "}"])); | 9750 "}"])); |
| 9381 resolve(source); | 9751 resolve(source); |
| 9382 assertErrors([CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]); | 9752 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER]); |
| 9383 } | 9753 } |
| 9384 void test_undefinedConstructorInInitializer_explicit_unnamed() { | 9754 void test_undefinedConstructorInInitializer_explicit_unnamed() { |
| 9385 Source source = addSource(EngineTestCase.createSource([ | 9755 Source source = addSource(EngineTestCase.createSource([ |
| 9386 "class A {", | 9756 "class A {", |
| 9387 " A.named() {}", | 9757 " A.named() {}", |
| 9388 "}", | 9758 "}", |
| 9389 "class B extends A {", | 9759 "class B extends A {", |
| 9390 " B() : super();", | 9760 " B() : super();", |
| 9391 "}"])); | 9761 "}"])); |
| 9392 resolve(source); | 9762 resolve(source); |
| 9393 assertErrors([CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFA
ULT]); | 9763 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER_DEFAULT]); |
| 9394 verify([source]); | 9764 verify([source]); |
| 9395 } | 9765 } |
| 9396 void test_undefinedConstructorInInitializer_implicit() { | 9766 void test_undefinedConstructorInInitializer_implicit() { |
| 9397 Source source = addSource(EngineTestCase.createSource([ | 9767 Source source = addSource(EngineTestCase.createSource([ |
| 9398 "class A {", | 9768 "class A {", |
| 9399 " A.named() {}", | 9769 " A.named() {}", |
| 9400 "}", | 9770 "}", |
| 9401 "class B extends A {", | 9771 "class B extends A {", |
| 9402 " B();", | 9772 " B();", |
| 9403 "}"])); | 9773 "}"])); |
| 9404 resolve(source); | 9774 resolve(source); |
| 9405 assertErrors([CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFA
ULT]); | 9775 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI
ZER_DEFAULT]); |
| 9406 verify([source]); | 9776 verify([source]); |
| 9407 } | 9777 } |
| 9408 void test_undefinedFunction() { | 9778 void test_undefinedFunction() { |
| 9409 Source source = addSource(EngineTestCase.createSource(["void f() {", " g();
", "}"])); | 9779 Source source = addSource(EngineTestCase.createSource(["void f() {", " g();
", "}"])); |
| 9410 resolve(source); | 9780 resolve(source); |
| 9411 assertErrors([CompileTimeErrorCode.UNDEFINED_FUNCTION]); | 9781 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]); |
| 9412 } | 9782 } |
| 9413 void test_undefinedFunction_hasImportPrefix() { | 9783 void test_undefinedFunction_hasImportPrefix() { |
| 9414 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
f;", "main() { return f(); }"])); | 9784 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
f;", "main() { return f(); }"])); |
| 9415 addSource2("/lib.dart", "library lib;"); | 9785 addSource2("/lib.dart", "library lib;"); |
| 9416 resolve(source); | 9786 resolve(source); |
| 9417 assertErrors([CompileTimeErrorCode.UNDEFINED_FUNCTION]); | 9787 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]); |
| 9418 } | 9788 } |
| 9419 void test_undefinedFunction_inCatch() { | 9789 void test_undefinedFunction_inCatch() { |
| 9420 Source source = addSource(EngineTestCase.createSource([ | 9790 Source source = addSource(EngineTestCase.createSource([ |
| 9421 "void f() {", | 9791 "void f() {", |
| 9422 " try {", | 9792 " try {", |
| 9423 " } on Object {", | 9793 " } on Object {", |
| 9424 " g();", | 9794 " g();", |
| 9425 " }", | 9795 " }", |
| 9426 "}"])); | 9796 "}"])); |
| 9427 resolve(source); | 9797 resolve(source); |
| 9428 assertErrors([CompileTimeErrorCode.UNDEFINED_FUNCTION]); | 9798 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]); |
| 9429 } | 9799 } |
| 9430 void test_undefinedNamedParameter() { | 9800 void test_undefinedNamedParameter() { |
| 9431 Source source = addSource(EngineTestCase.createSource([ | 9801 Source source = addSource(EngineTestCase.createSource([ |
| 9432 "class A {", | 9802 "class A {", |
| 9433 " const A();", | 9803 " const A();", |
| 9434 "}", | 9804 "}", |
| 9435 "main() {", | 9805 "main() {", |
| 9436 " const A(p: 0);", | 9806 " const A(p: 0);", |
| 9437 "}"])); | 9807 "}"])); |
| 9438 resolve(source); | 9808 resolve(source); |
| 9439 assertErrors([CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER]); | 9809 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER]); |
| 9440 } | 9810 } |
| 9441 void test_uriDoesNotExist_export() { | 9811 void test_uriDoesNotExist_export() { |
| 9442 Source source = addSource(EngineTestCase.createSource(["export 'unknown.dart
';"])); | 9812 Source source = addSource(EngineTestCase.createSource(["export 'unknown.dart
';"])); |
| 9443 resolve(source); | 9813 resolve(source); |
| 9444 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 9814 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 9445 } | 9815 } |
| 9446 void test_uriDoesNotExist_import() { | 9816 void test_uriDoesNotExist_import() { |
| 9447 Source source = addSource(EngineTestCase.createSource(["import 'unknown.dart
';"])); | 9817 Source source = addSource(EngineTestCase.createSource(["import 'unknown.dart
';"])); |
| 9448 resolve(source); | 9818 resolve(source); |
| 9449 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 9819 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 9450 } | 9820 } |
| 9451 void test_uriDoesNotExist_part() { | 9821 void test_uriDoesNotExist_part() { |
| 9452 Source source = addSource(EngineTestCase.createSource(["part 'unknown.dart';
"])); | 9822 Source source = addSource(EngineTestCase.createSource(["part 'unknown.dart';
"])); |
| 9453 resolve(source); | 9823 resolve(source); |
| 9454 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 9824 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 9455 } | 9825 } |
| 9456 void test_uriWithInterpolation_constant() { | 9826 void test_uriWithInterpolation_constant() { |
| 9457 Source source = addSource(EngineTestCase.createSource(["import 'stuff_\$plat
form.dart';"])); | 9827 Source source = addSource(EngineTestCase.createSource(["import 'stuff_\$plat
form.dart';"])); |
| 9458 resolve(source); | 9828 resolve(source); |
| 9459 assertErrors([ | 9829 assertErrors(source, [ |
| 9460 CompileTimeErrorCode.URI_WITH_INTERPOLATION, | 9830 CompileTimeErrorCode.URI_WITH_INTERPOLATION, |
| 9461 StaticWarningCode.UNDEFINED_IDENTIFIER]); | 9831 StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 9462 } | 9832 } |
| 9463 void test_uriWithInterpolation_nonConstant() { | 9833 void test_uriWithInterpolation_nonConstant() { |
| 9464 Source source = addSource(EngineTestCase.createSource(["library lib;", "part
'\${'a'}.dart';"])); | 9834 Source source = addSource(EngineTestCase.createSource(["library lib;", "part
'\${'a'}.dart';"])); |
| 9465 resolve(source); | 9835 resolve(source); |
| 9466 assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION]); | 9836 assertErrors(source, [CompileTimeErrorCode.URI_WITH_INTERPOLATION]); |
| 9467 } | 9837 } |
| 9468 void test_wrongNumberOfParametersForOperator_minus() { | 9838 void test_wrongNumberOfParametersForOperator_minus() { |
| 9469 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor -(a, b) {}", "}"])); | 9839 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor -(a, b) {}", "}"])); |
| 9470 resolve(source); | 9840 resolve(source); |
| 9471 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_M
INUS]); | 9841 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OP
ERATOR_MINUS]); |
| 9472 verify([source]); | 9842 verify([source]); |
| 9473 reset(); | 9843 reset(); |
| 9474 } | 9844 } |
| 9475 void test_wrongNumberOfParametersForOperator_tilde() { | 9845 void test_wrongNumberOfParametersForOperator_tilde() { |
| 9476 check_wrongNumberOfParametersForOperator("~", "a"); | 9846 check_wrongNumberOfParametersForOperator("~", "a"); |
| 9477 check_wrongNumberOfParametersForOperator("~", "a, b"); | 9847 check_wrongNumberOfParametersForOperator("~", "a, b"); |
| 9478 } | 9848 } |
| 9479 void test_wrongNumberOfParametersForOperator1() { | 9849 void test_wrongNumberOfParametersForOperator1() { |
| 9480 check_wrongNumberOfParametersForOperator1("<"); | 9850 check_wrongNumberOfParametersForOperator1("<"); |
| 9481 check_wrongNumberOfParametersForOperator1(">"); | 9851 check_wrongNumberOfParametersForOperator1(">"); |
| 9482 check_wrongNumberOfParametersForOperator1("<="); | 9852 check_wrongNumberOfParametersForOperator1("<="); |
| 9483 check_wrongNumberOfParametersForOperator1(">="); | 9853 check_wrongNumberOfParametersForOperator1(">="); |
| 9484 check_wrongNumberOfParametersForOperator1("+"); | 9854 check_wrongNumberOfParametersForOperator1("+"); |
| 9485 check_wrongNumberOfParametersForOperator1("/"); | 9855 check_wrongNumberOfParametersForOperator1("/"); |
| 9486 check_wrongNumberOfParametersForOperator1("~/"); | 9856 check_wrongNumberOfParametersForOperator1("~/"); |
| 9487 check_wrongNumberOfParametersForOperator1("*"); | 9857 check_wrongNumberOfParametersForOperator1("*"); |
| 9488 check_wrongNumberOfParametersForOperator1("%"); | 9858 check_wrongNumberOfParametersForOperator1("%"); |
| 9489 check_wrongNumberOfParametersForOperator1("|"); | 9859 check_wrongNumberOfParametersForOperator1("|"); |
| 9490 check_wrongNumberOfParametersForOperator1("^"); | 9860 check_wrongNumberOfParametersForOperator1("^"); |
| 9491 check_wrongNumberOfParametersForOperator1("&"); | 9861 check_wrongNumberOfParametersForOperator1("&"); |
| 9492 check_wrongNumberOfParametersForOperator1("<<"); | 9862 check_wrongNumberOfParametersForOperator1("<<"); |
| 9493 check_wrongNumberOfParametersForOperator1(">>"); | 9863 check_wrongNumberOfParametersForOperator1(">>"); |
| 9494 check_wrongNumberOfParametersForOperator1("[]"); | 9864 check_wrongNumberOfParametersForOperator1("[]"); |
| 9495 } | 9865 } |
| 9496 void test_wrongNumberOfParametersForSetter_function_named() { | 9866 void test_wrongNumberOfParametersForSetter_function_named() { |
| 9497 Source source = addSource("set x({p}) {}"); | 9867 Source source = addSource("set x({p}) {}"); |
| 9498 resolve(source); | 9868 resolve(source); |
| 9499 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); | 9869 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 9500 verify([source]); | 9870 verify([source]); |
| 9501 } | 9871 } |
| 9502 void test_wrongNumberOfParametersForSetter_function_optional() { | 9872 void test_wrongNumberOfParametersForSetter_function_optional() { |
| 9503 Source source = addSource("set x([p]) {}"); | 9873 Source source = addSource("set x([p]) {}"); |
| 9504 resolve(source); | 9874 resolve(source); |
| 9505 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); | 9875 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 9506 verify([source]); | 9876 verify([source]); |
| 9507 } | 9877 } |
| 9508 void test_wrongNumberOfParametersForSetter_function_tooFew() { | 9878 void test_wrongNumberOfParametersForSetter_function_tooFew() { |
| 9509 Source source = addSource("set x() {}"); | 9879 Source source = addSource("set x() {}"); |
| 9510 resolve(source); | 9880 resolve(source); |
| 9511 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); | 9881 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 9512 verify([source]); | 9882 verify([source]); |
| 9513 } | 9883 } |
| 9514 void test_wrongNumberOfParametersForSetter_function_tooMany() { | 9884 void test_wrongNumberOfParametersForSetter_function_tooMany() { |
| 9515 Source source = addSource("set x(a, b) {}"); | 9885 Source source = addSource("set x(a, b) {}"); |
| 9516 resolve(source); | 9886 resolve(source); |
| 9517 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); | 9887 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 9518 verify([source]); | 9888 verify([source]); |
| 9519 } | 9889 } |
| 9520 void test_wrongNumberOfParametersForSetter_method_named() { | 9890 void test_wrongNumberOfParametersForSetter_method_named() { |
| 9521 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
({p}) {}", "}"])); | 9891 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
({p}) {}", "}"])); |
| 9522 resolve(source); | 9892 resolve(source); |
| 9523 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); | 9893 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 9524 verify([source]); | 9894 verify([source]); |
| 9525 } | 9895 } |
| 9526 void test_wrongNumberOfParametersForSetter_method_optional() { | 9896 void test_wrongNumberOfParametersForSetter_method_optional() { |
| 9527 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
([p]) {}", "}"])); | 9897 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
([p]) {}", "}"])); |
| 9528 resolve(source); | 9898 resolve(source); |
| 9529 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); | 9899 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 9530 verify([source]); | 9900 verify([source]); |
| 9531 } | 9901 } |
| 9532 void test_wrongNumberOfParametersForSetter_method_tooFew() { | 9902 void test_wrongNumberOfParametersForSetter_method_tooFew() { |
| 9533 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
() {}", "}"])); | 9903 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
() {}", "}"])); |
| 9534 resolve(source); | 9904 resolve(source); |
| 9535 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); | 9905 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 9536 verify([source]); | 9906 verify([source]); |
| 9537 } | 9907 } |
| 9538 void test_wrongNumberOfParametersForSetter_method_tooMany() { | 9908 void test_wrongNumberOfParametersForSetter_method_tooMany() { |
| 9539 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(a, b) {}", "}"])); | 9909 Source source = addSource(EngineTestCase.createSource(["class A {", " set x
(a, b) {}", "}"])); |
| 9540 resolve(source); | 9910 resolve(source); |
| 9541 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); | 9911 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE
TTER]); |
| 9542 verify([source]); | 9912 verify([source]); |
| 9543 } | 9913 } |
| 9544 void check_constEvalThrowsException_binary_null(String expr, bool resolved) { | 9914 void check_constEvalThrowsException_binary_null(String expr, bool resolved) { |
| 9545 Source source = addSource("const C = ${expr};"); | 9915 Source source = addSource("const C = ${expr};"); |
| 9546 resolve(source); | 9916 resolve(source); |
| 9547 if (resolved) { | 9917 if (resolved) { |
| 9548 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); | 9918 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); |
| 9549 verify([source]); | 9919 verify([source]); |
| 9550 } else { | 9920 } else { |
| 9551 assertErrors([ | 9921 assertErrors(source, [ |
| 9552 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, | 9922 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, |
| 9553 StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 9923 StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 9554 } | 9924 } |
| 9555 reset(); | 9925 reset(); |
| 9556 } | 9926 } |
| 9557 void check_constEvalTypeBool_withParameter_binary(String expr) { | 9927 void check_constEvalTypeBool_withParameter_binary(String expr) { |
| 9558 Source source = addSource(EngineTestCase.createSource([ | 9928 Source source = addSource(EngineTestCase.createSource([ |
| 9559 "class A {", | 9929 "class A {", |
| 9560 " final a;", | 9930 " final a;", |
| 9561 " const A(bool p) : a = ${expr};", | 9931 " const A(bool p) : a = ${expr};", |
| 9562 "}"])); | 9932 "}"])); |
| 9563 resolve(source); | 9933 resolve(source); |
| 9564 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); | 9934 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]); |
| 9565 verify([source]); | 9935 verify([source]); |
| 9566 reset(); | 9936 reset(); |
| 9567 } | 9937 } |
| 9568 void check_constEvalTypeInt_withParameter_binary(String expr) { | 9938 void check_constEvalTypeInt_withParameter_binary(String expr) { |
| 9569 Source source = addSource(EngineTestCase.createSource([ | 9939 Source source = addSource(EngineTestCase.createSource([ |
| 9570 "class A {", | 9940 "class A {", |
| 9571 " final a;", | 9941 " final a;", |
| 9572 " const A(int p) : a = ${expr};", | 9942 " const A(int p) : a = ${expr};", |
| 9573 "}"])); | 9943 "}"])); |
| 9574 resolve(source); | 9944 resolve(source); |
| 9575 assertErrors([ | 9945 assertErrors(source, [ |
| 9576 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, | 9946 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, |
| 9577 CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 9947 CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 9578 verify([source]); | 9948 verify([source]); |
| 9579 reset(); | 9949 reset(); |
| 9580 } | 9950 } |
| 9581 void check_constEvalTypeNum_withParameter_binary(String expr) { | 9951 void check_constEvalTypeNum_withParameter_binary(String expr) { |
| 9582 Source source = addSource(EngineTestCase.createSource([ | 9952 Source source = addSource(EngineTestCase.createSource([ |
| 9583 "class A {", | 9953 "class A {", |
| 9584 " final a;", | 9954 " final a;", |
| 9585 " const A(num p) : a = ${expr};", | 9955 " const A(num p) : a = ${expr};", |
| 9586 "}"])); | 9956 "}"])); |
| 9587 resolve(source); | 9957 resolve(source); |
| 9588 assertErrors([ | 9958 assertErrors(source, [ |
| 9589 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, | 9959 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, |
| 9590 CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 9960 CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 9591 verify([source]); | 9961 verify([source]); |
| 9592 reset(); | 9962 reset(); |
| 9593 } | 9963 } |
| 9594 void check_wrongNumberOfParametersForOperator(String name, String parameters)
{ | 9964 void check_wrongNumberOfParametersForOperator(String name, String parameters)
{ |
| 9595 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor ${name}(${parameters}) {}", "}"])); | 9965 Source source = addSource(EngineTestCase.createSource(["class A {", " opera
tor ${name}(${parameters}) {}", "}"])); |
| 9596 resolve(source); | 9966 resolve(source); |
| 9597 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR])
; | 9967 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OP
ERATOR]); |
| 9598 verify([source]); | 9968 verify([source]); |
| 9599 reset(); | 9969 reset(); |
| 9600 } | 9970 } |
| 9601 void check_wrongNumberOfParametersForOperator1(String name) { | 9971 void check_wrongNumberOfParametersForOperator1(String name) { |
| 9602 check_wrongNumberOfParametersForOperator(name, ""); | 9972 check_wrongNumberOfParametersForOperator(name, ""); |
| 9603 check_wrongNumberOfParametersForOperator(name, "a, b"); | 9973 check_wrongNumberOfParametersForOperator(name, "a, b"); |
| 9604 } | 9974 } |
| 9605 static dartSuite() { | 9975 static dartSuite() { |
| 9606 _ut.group('CompileTimeErrorCodeTest', () { | 9976 _ut.group('CompileTimeErrorCodeTest', () { |
| 9607 _ut.test('test_ambiguousExport', () { | 9977 _ut.test('test_ambiguousExport', () { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 9625 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_const_super); | 9995 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_const_super); |
| 9626 }); | 9996 }); |
| 9627 _ut.test('test_builtInIdentifierAsType', () { | 9997 _ut.test('test_builtInIdentifierAsType', () { |
| 9628 final __test = new CompileTimeErrorCodeTest(); | 9998 final __test = new CompileTimeErrorCodeTest(); |
| 9629 runJUnitTest(__test, __test.test_builtInIdentifierAsType); | 9999 runJUnitTest(__test, __test.test_builtInIdentifierAsType); |
| 9630 }); | 10000 }); |
| 9631 _ut.test('test_builtInIdentifierAsTypeName', () { | 10001 _ut.test('test_builtInIdentifierAsTypeName', () { |
| 9632 final __test = new CompileTimeErrorCodeTest(); | 10002 final __test = new CompileTimeErrorCodeTest(); |
| 9633 runJUnitTest(__test, __test.test_builtInIdentifierAsTypeName); | 10003 runJUnitTest(__test, __test.test_builtInIdentifierAsTypeName); |
| 9634 }); | 10004 }); |
| 9635 _ut.test('test_builtInIdentifierAsTypeVariableName', () { | 10005 _ut.test('test_builtInIdentifierAsTypeParameterName', () { |
| 9636 final __test = new CompileTimeErrorCodeTest(); | 10006 final __test = new CompileTimeErrorCodeTest(); |
| 9637 runJUnitTest(__test, __test.test_builtInIdentifierAsTypeVariableName); | 10007 runJUnitTest(__test, __test.test_builtInIdentifierAsTypeParameterName); |
| 9638 }); | 10008 }); |
| 9639 _ut.test('test_builtInIdentifierAsTypedefName_classTypeAlias', () { | 10009 _ut.test('test_builtInIdentifierAsTypedefName_classTypeAlias', () { |
| 9640 final __test = new CompileTimeErrorCodeTest(); | 10010 final __test = new CompileTimeErrorCodeTest(); |
| 9641 runJUnitTest(__test, __test.test_builtInIdentifierAsTypedefName_classTyp
eAlias); | 10011 runJUnitTest(__test, __test.test_builtInIdentifierAsTypedefName_classTyp
eAlias); |
| 9642 }); | 10012 }); |
| 9643 _ut.test('test_builtInIdentifierAsTypedefName_functionTypeAlias', () { | 10013 _ut.test('test_builtInIdentifierAsTypedefName_functionTypeAlias', () { |
| 9644 final __test = new CompileTimeErrorCodeTest(); | 10014 final __test = new CompileTimeErrorCodeTest(); |
| 9645 runJUnitTest(__test, __test.test_builtInIdentifierAsTypedefName_function
TypeAlias); | 10015 runJUnitTest(__test, __test.test_builtInIdentifierAsTypedefName_function
TypeAlias); |
| 9646 }); | 10016 }); |
| 9647 _ut.test('test_caseExpressionTypeImplementsEquals', () { | 10017 _ut.test('test_caseExpressionTypeImplementsEquals', () { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10001 runJUnitTest(__test, __test.test_finalInitializedMultipleTimes_initializ
ers); | 10371 runJUnitTest(__test, __test.test_finalInitializedMultipleTimes_initializ
ers); |
| 10002 }); | 10372 }); |
| 10003 _ut.test('test_finalInitializedMultipleTimes_initializingFormal_initialize
r', () { | 10373 _ut.test('test_finalInitializedMultipleTimes_initializingFormal_initialize
r', () { |
| 10004 final __test = new CompileTimeErrorCodeTest(); | 10374 final __test = new CompileTimeErrorCodeTest(); |
| 10005 runJUnitTest(__test, __test.test_finalInitializedMultipleTimes_initializ
ingFormal_initializer); | 10375 runJUnitTest(__test, __test.test_finalInitializedMultipleTimes_initializ
ingFormal_initializer); |
| 10006 }); | 10376 }); |
| 10007 _ut.test('test_finalInitializedMultipleTimes_initializingFormals', () { | 10377 _ut.test('test_finalInitializedMultipleTimes_initializingFormals', () { |
| 10008 final __test = new CompileTimeErrorCodeTest(); | 10378 final __test = new CompileTimeErrorCodeTest(); |
| 10009 runJUnitTest(__test, __test.test_finalInitializedMultipleTimes_initializ
ingFormals); | 10379 runJUnitTest(__test, __test.test_finalInitializedMultipleTimes_initializ
ingFormals); |
| 10010 }); | 10380 }); |
| 10381 _ut.test('test_finalNotInitialized_instanceField_const_static', () { |
| 10382 final __test = new CompileTimeErrorCodeTest(); |
| 10383 runJUnitTest(__test, __test.test_finalNotInitialized_instanceField_const
_static); |
| 10384 }); |
| 10385 _ut.test('test_finalNotInitialized_library_const', () { |
| 10386 final __test = new CompileTimeErrorCodeTest(); |
| 10387 runJUnitTest(__test, __test.test_finalNotInitialized_library_const); |
| 10388 }); |
| 10389 _ut.test('test_finalNotInitialized_local_const', () { |
| 10390 final __test = new CompileTimeErrorCodeTest(); |
| 10391 runJUnitTest(__test, __test.test_finalNotInitialized_local_const); |
| 10392 }); |
| 10011 _ut.test('test_getterAndMethodWithSameName', () { | 10393 _ut.test('test_getterAndMethodWithSameName', () { |
| 10012 final __test = new CompileTimeErrorCodeTest(); | 10394 final __test = new CompileTimeErrorCodeTest(); |
| 10013 runJUnitTest(__test, __test.test_getterAndMethodWithSameName); | 10395 runJUnitTest(__test, __test.test_getterAndMethodWithSameName); |
| 10014 }); | 10396 }); |
| 10015 _ut.test('test_implementsDisallowedClass_Null', () { | 10397 _ut.test('test_implementsDisallowedClass_Null', () { |
| 10016 final __test = new CompileTimeErrorCodeTest(); | 10398 final __test = new CompileTimeErrorCodeTest(); |
| 10017 runJUnitTest(__test, __test.test_implementsDisallowedClass_Null); | 10399 runJUnitTest(__test, __test.test_implementsDisallowedClass_Null); |
| 10018 }); | 10400 }); |
| 10019 _ut.test('test_implementsDisallowedClass_String', () { | 10401 _ut.test('test_implementsDisallowedClass_String', () { |
| 10020 final __test = new CompileTimeErrorCodeTest(); | 10402 final __test = new CompileTimeErrorCodeTest(); |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10992 class StrictModeTest extends ResolverTestCase { | 11374 class StrictModeTest extends ResolverTestCase { |
| 10993 void fail_for() { | 11375 void fail_for() { |
| 10994 Source source = addSource(EngineTestCase.createSource([ | 11376 Source source = addSource(EngineTestCase.createSource([ |
| 10995 "int f(List<int> list) {", | 11377 "int f(List<int> list) {", |
| 10996 " num sum = 0;", | 11378 " num sum = 0;", |
| 10997 " for (num i = 0; i < list.length; i++) {", | 11379 " for (num i = 0; i < list.length; i++) {", |
| 10998 " sum += list[i];", | 11380 " sum += list[i];", |
| 10999 " }", | 11381 " }", |
| 11000 "}"])); | 11382 "}"])); |
| 11001 resolve(source); | 11383 resolve(source); |
| 11002 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11384 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11003 } | 11385 } |
| 11004 void setUp() { | 11386 void setUp() { |
| 11005 super.setUp(); | 11387 super.setUp(); |
| 11006 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 11388 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 11007 options.strictMode = true; | 11389 options.strictMode = true; |
| 11390 options.hint = false; |
| 11008 analysisContext.analysisOptions = options; | 11391 analysisContext.analysisOptions = options; |
| 11009 } | 11392 } |
| 11010 void test_assert_is() { | 11393 void test_assert_is() { |
| 11011 Source source = addSource(EngineTestCase.createSource([ | 11394 Source source = addSource(EngineTestCase.createSource([ |
| 11012 "int f(num n) {", | 11395 "int f(num n) {", |
| 11013 " assert (n is int);", | 11396 " assert (n is int);", |
| 11014 " return n & 0x0F;", | 11397 " return n & 0x0F;", |
| 11015 "}"])); | 11398 "}"])); |
| 11016 resolve(source); | 11399 resolve(source); |
| 11017 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11400 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11018 } | 11401 } |
| 11019 void test_conditional_and_is() { | 11402 void test_conditional_and_is() { |
| 11020 Source source = addSource(EngineTestCase.createSource([ | 11403 Source source = addSource(EngineTestCase.createSource([ |
| 11021 "int f(num n) {", | 11404 "int f(num n) {", |
| 11022 " return (n is int && n > 0) ? n & 0x0F : 0;", | 11405 " return (n is int && n > 0) ? n & 0x0F : 0;", |
| 11023 "}"])); | 11406 "}"])); |
| 11024 resolve(source); | 11407 resolve(source); |
| 11025 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11408 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11026 } | 11409 } |
| 11027 void test_conditional_is() { | 11410 void test_conditional_is() { |
| 11028 Source source = addSource(EngineTestCase.createSource([ | 11411 Source source = addSource(EngineTestCase.createSource([ |
| 11029 "int f(num n) {", | 11412 "int f(num n) {", |
| 11030 " return (n is int) ? n & 0x0F : 0;", | 11413 " return (n is int) ? n & 0x0F : 0;", |
| 11031 "}"])); | 11414 "}"])); |
| 11032 resolve(source); | 11415 resolve(source); |
| 11033 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11416 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11034 } | 11417 } |
| 11035 void test_conditional_isNot() { | 11418 void test_conditional_isNot() { |
| 11036 Source source = addSource(EngineTestCase.createSource([ | 11419 Source source = addSource(EngineTestCase.createSource([ |
| 11037 "int f(num n) {", | 11420 "int f(num n) {", |
| 11038 " return (n is! int) ? 0 : n & 0x0F;", | 11421 " return (n is! int) ? 0 : n & 0x0F;", |
| 11039 "}"])); | 11422 "}"])); |
| 11040 resolve(source); | 11423 resolve(source); |
| 11041 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11424 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11042 } | 11425 } |
| 11043 void test_conditional_or_is() { | 11426 void test_conditional_or_is() { |
| 11044 Source source = addSource(EngineTestCase.createSource([ | 11427 Source source = addSource(EngineTestCase.createSource([ |
| 11045 "int f(num n) {", | 11428 "int f(num n) {", |
| 11046 " return (n is! int || n < 0) ? 0 : n & 0x0F;", | 11429 " return (n is! int || n < 0) ? 0 : n & 0x0F;", |
| 11047 "}"])); | 11430 "}"])); |
| 11048 resolve(source); | 11431 resolve(source); |
| 11049 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11432 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11050 } | 11433 } |
| 11051 void test_forEach() { | 11434 void test_forEach() { |
| 11052 Source source = addSource(EngineTestCase.createSource([ | 11435 Source source = addSource(EngineTestCase.createSource([ |
| 11053 "int f(List<int> list) {", | 11436 "int f(List<int> list) {", |
| 11054 " num sum = 0;", | 11437 " num sum = 0;", |
| 11055 " for (num n in list) {", | 11438 " for (num n in list) {", |
| 11056 " sum += n & 0x0F;", | 11439 " sum += n & 0x0F;", |
| 11057 " }", | 11440 " }", |
| 11058 "}"])); | 11441 "}"])); |
| 11059 resolve(source); | 11442 resolve(source); |
| 11060 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11443 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11061 } | 11444 } |
| 11062 void test_if_and_is() { | 11445 void test_if_and_is() { |
| 11063 Source source = addSource(EngineTestCase.createSource([ | 11446 Source source = addSource(EngineTestCase.createSource([ |
| 11064 "int f(num n) {", | 11447 "int f(num n) {", |
| 11065 " if (n is int && n > 0) {", | 11448 " if (n is int && n > 0) {", |
| 11066 " return n & 0x0F;", | 11449 " return n & 0x0F;", |
| 11067 " }", | 11450 " }", |
| 11068 " return 0;", | 11451 " return 0;", |
| 11069 "}"])); | 11452 "}"])); |
| 11070 resolve(source); | 11453 resolve(source); |
| 11071 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11454 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11072 } | 11455 } |
| 11073 void test_if_is() { | 11456 void test_if_is() { |
| 11074 Source source = addSource(EngineTestCase.createSource([ | 11457 Source source = addSource(EngineTestCase.createSource([ |
| 11075 "int f(num n) {", | 11458 "int f(num n) {", |
| 11076 " if (n is int) {", | 11459 " if (n is int) {", |
| 11077 " return n & 0x0F;", | 11460 " return n & 0x0F;", |
| 11078 " }", | 11461 " }", |
| 11079 " return 0;", | 11462 " return 0;", |
| 11080 "}"])); | 11463 "}"])); |
| 11081 resolve(source); | 11464 resolve(source); |
| 11082 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11465 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11083 } | 11466 } |
| 11084 void test_if_isNot() { | 11467 void test_if_isNot() { |
| 11085 Source source = addSource(EngineTestCase.createSource([ | 11468 Source source = addSource(EngineTestCase.createSource([ |
| 11086 "int f(num n) {", | 11469 "int f(num n) {", |
| 11087 " if (n is! int) {", | 11470 " if (n is! int) {", |
| 11088 " return 0;", | 11471 " return 0;", |
| 11089 " } else {", | 11472 " } else {", |
| 11090 " return n & 0x0F;", | 11473 " return n & 0x0F;", |
| 11091 " }", | 11474 " }", |
| 11092 "}"])); | 11475 "}"])); |
| 11093 resolve(source); | 11476 resolve(source); |
| 11094 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11477 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11095 } | 11478 } |
| 11096 void test_if_isNot_abrupt() { | 11479 void test_if_isNot_abrupt() { |
| 11097 Source source = addSource(EngineTestCase.createSource([ | 11480 Source source = addSource(EngineTestCase.createSource([ |
| 11098 "int f(num n) {", | 11481 "int f(num n) {", |
| 11099 " if (n is! int) {", | 11482 " if (n is! int) {", |
| 11100 " return 0;", | 11483 " return 0;", |
| 11101 " }", | 11484 " }", |
| 11102 " return n & 0x0F;", | 11485 " return n & 0x0F;", |
| 11103 "}"])); | 11486 "}"])); |
| 11104 resolve(source); | 11487 resolve(source); |
| 11105 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11488 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11106 } | 11489 } |
| 11107 void test_if_or_is() { | 11490 void test_if_or_is() { |
| 11108 Source source = addSource(EngineTestCase.createSource([ | 11491 Source source = addSource(EngineTestCase.createSource([ |
| 11109 "int f(num n) {", | 11492 "int f(num n) {", |
| 11110 " if (n is! int || n < 0) {", | 11493 " if (n is! int || n < 0) {", |
| 11111 " return 0;", | 11494 " return 0;", |
| 11112 " } else {", | 11495 " } else {", |
| 11113 " return n & 0x0F;", | 11496 " return n & 0x0F;", |
| 11114 " }", | 11497 " }", |
| 11115 "}"])); | 11498 "}"])); |
| 11116 resolve(source); | 11499 resolve(source); |
| 11117 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11500 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11118 } | 11501 } |
| 11119 void test_localVar() { | 11502 void test_localVar() { |
| 11120 Source source = addSource(EngineTestCase.createSource(["int f() {", " num n
= 1234;", " return n & 0x0F;", "}"])); | 11503 Source source = addSource(EngineTestCase.createSource(["int f() {", " num n
= 1234;", " return n & 0x0F;", "}"])); |
| 11121 resolve(source); | 11504 resolve(source); |
| 11122 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); | 11505 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); |
| 11123 } | 11506 } |
| 11124 static dartSuite() { | 11507 static dartSuite() { |
| 11125 _ut.group('StrictModeTest', () { | 11508 _ut.group('StrictModeTest', () { |
| 11126 _ut.test('test_assert_is', () { | 11509 _ut.test('test_assert_is', () { |
| 11127 final __test = new StrictModeTest(); | 11510 final __test = new StrictModeTest(); |
| 11128 runJUnitTest(__test, __test.test_assert_is); | 11511 runJUnitTest(__test, __test.test_assert_is); |
| 11129 }); | 11512 }); |
| 11130 _ut.test('test_conditional_and_is', () { | 11513 _ut.test('test_conditional_and_is', () { |
| 11131 final __test = new StrictModeTest(); | 11514 final __test = new StrictModeTest(); |
| 11132 runJUnitTest(__test, __test.test_conditional_and_is); | 11515 runJUnitTest(__test, __test.test_conditional_and_is); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11562 } | 11945 } |
| 11563 void test_visitSuperConstructorInvocation() { | 11946 void test_visitSuperConstructorInvocation() { |
| 11564 ClassElementImpl superclass = ElementFactory.classElement2("A", []); | 11947 ClassElementImpl superclass = ElementFactory.classElement2("A", []); |
| 11565 ConstructorElementImpl superConstructor = ElementFactory.constructorElement(
superclass, null); | 11948 ConstructorElementImpl superConstructor = ElementFactory.constructorElement(
superclass, null); |
| 11566 superclass.constructors = <ConstructorElement> [superConstructor]; | 11949 superclass.constructors = <ConstructorElement> [superConstructor]; |
| 11567 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type
, []); | 11950 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type
, []); |
| 11568 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su
bclass, null); | 11951 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su
bclass, null); |
| 11569 subclass.constructors = <ConstructorElement> [subConstructor]; | 11952 subclass.constructors = <ConstructorElement> [subConstructor]; |
| 11570 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio
n([]); | 11953 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio
n([]); |
| 11571 resolveInClass(invocation, subclass); | 11954 resolveInClass(invocation, subclass); |
| 11572 JUnitTestCase.assertEquals(superConstructor, invocation.element); | 11955 JUnitTestCase.assertEquals(superConstructor, invocation.staticElement); |
| 11573 _listener.assertNoErrors(); | 11956 _listener.assertNoErrors(); |
| 11574 } | 11957 } |
| 11575 void test_visitSuperConstructorInvocation_namedParameter() { | 11958 void test_visitSuperConstructorInvocation_namedParameter() { |
| 11576 ClassElementImpl superclass = ElementFactory.classElement2("A", []); | 11959 ClassElementImpl superclass = ElementFactory.classElement2("A", []); |
| 11577 ConstructorElementImpl superConstructor = ElementFactory.constructorElement(
superclass, null); | 11960 ConstructorElementImpl superConstructor = ElementFactory.constructorElement(
superclass, null); |
| 11578 String parameterName = "p"; | 11961 String parameterName = "p"; |
| 11579 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 11962 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
| 11580 superConstructor.parameters = <ParameterElement> [parameter]; | 11963 superConstructor.parameters = <ParameterElement> [parameter]; |
| 11581 superclass.constructors = <ConstructorElement> [superConstructor]; | 11964 superclass.constructors = <ConstructorElement> [superConstructor]; |
| 11582 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type
, []); | 11965 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type
, []); |
| 11583 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su
bclass, null); | 11966 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su
bclass, null); |
| 11584 subclass.constructors = <ConstructorElement> [subConstructor]; | 11967 subclass.constructors = <ConstructorElement> [subConstructor]; |
| 11585 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio
n([ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); | 11968 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio
n([ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); |
| 11586 resolveInClass(invocation, subclass); | 11969 resolveInClass(invocation, subclass); |
| 11587 JUnitTestCase.assertEquals(superConstructor, invocation.element); | 11970 JUnitTestCase.assertEquals(superConstructor, invocation.staticElement); |
| 11588 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a
s NamedExpression)).name.label.staticElement); | 11971 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a
s NamedExpression)).name.label.staticElement); |
| 11589 _listener.assertNoErrors(); | 11972 _listener.assertNoErrors(); |
| 11590 } | 11973 } |
| 11591 | 11974 |
| 11592 /** | 11975 /** |
| 11593 * Create the resolver used by the tests. | 11976 * Create the resolver used by the tests. |
| 11594 * | 11977 * |
| 11595 * @return the resolver that was created | 11978 * @return the resolver that was created |
| 11596 */ | 11979 */ |
| 11597 ElementResolver createResolver() { | 11980 ElementResolver createResolver() { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11975 final __test = new TypeOverrideManagerTest(); | 12358 final __test = new TypeOverrideManagerTest(); |
| 11976 runJUnitTest(__test, __test.test_getType_noScope); | 12359 runJUnitTest(__test, __test.test_getType_noScope); |
| 11977 }); | 12360 }); |
| 11978 }); | 12361 }); |
| 11979 } | 12362 } |
| 11980 } | 12363 } |
| 11981 class PubSuggestionCodeTest extends ResolverTestCase { | 12364 class PubSuggestionCodeTest extends ResolverTestCase { |
| 11982 void test_import_package() { | 12365 void test_import_package() { |
| 11983 Source source = addSource(EngineTestCase.createSource(["import 'package:some
package/other.dart';"])); | 12366 Source source = addSource(EngineTestCase.createSource(["import 'package:some
package/other.dart';"])); |
| 11984 resolve(source); | 12367 resolve(source); |
| 11985 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST]); | 12368 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]); |
| 11986 } | 12369 } |
| 11987 void test_import_packageWithDotDot() { | 12370 void test_import_packageWithDotDot() { |
| 11988 Source source = addSource(EngineTestCase.createSource(["import 'package:some
package/../other.dart';"])); | 12371 Source source = addSource(EngineTestCase.createSource(["import 'package:some
package/../other.dart';"])); |
| 11989 resolve(source); | 12372 resolve(source); |
| 11990 assertErrors([ | 12373 assertErrors(source, [ |
| 11991 CompileTimeErrorCode.URI_DOES_NOT_EXIST, | 12374 CompileTimeErrorCode.URI_DOES_NOT_EXIST, |
| 11992 PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]); | 12375 PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]); |
| 11993 } | 12376 } |
| 11994 void test_import_packageWithLeadingDotDot() { | 12377 void test_import_packageWithLeadingDotDot() { |
| 11995 Source source = addSource(EngineTestCase.createSource(["import 'package:../o
ther.dart';"])); | 12378 Source source = addSource(EngineTestCase.createSource(["import 'package:../o
ther.dart';"])); |
| 11996 resolve(source); | 12379 resolve(source); |
| 11997 assertErrors([ | 12380 assertErrors(source, [ |
| 11998 CompileTimeErrorCode.URI_DOES_NOT_EXIST, | 12381 CompileTimeErrorCode.URI_DOES_NOT_EXIST, |
| 11999 PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]); | 12382 PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]); |
| 12000 } | 12383 } |
| 12001 void test_import_referenceIntoLibDirectory() { | 12384 void test_import_referenceIntoLibDirectory() { |
| 12002 cacheSource("/myproj/pubspec.yaml", ""); | 12385 cacheSource("/myproj/pubspec.yaml", ""); |
| 12003 cacheSource("/myproj/lib/other.dart", ""); | 12386 cacheSource("/myproj/lib/other.dart", ""); |
| 12004 Source source = addSource2("/myproj/web/test.dart", EngineTestCase.createSou
rce(["import '../lib/other.dart';"])); | 12387 Source source = addSource2("/myproj/web/test.dart", EngineTestCase.createSou
rce(["import '../lib/other.dart';"])); |
| 12005 resolve(source); | 12388 resolve(source); |
| 12006 assertErrors([PubSuggestionCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSI
DE]); | 12389 assertErrors(source, [PubSuggestionCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_F
ILE_INSIDE]); |
| 12007 } | 12390 } |
| 12008 void test_import_referenceIntoLibDirectory_no_pubspec() { | 12391 void test_import_referenceIntoLibDirectory_no_pubspec() { |
| 12009 cacheSource("/myproj/lib/other.dart", ""); | 12392 cacheSource("/myproj/lib/other.dart", ""); |
| 12010 Source source = addSource2("/myproj/web/test.dart", EngineTestCase.createSou
rce(["import '../lib/other.dart';"])); | 12393 Source source = addSource2("/myproj/web/test.dart", EngineTestCase.createSou
rce(["import '../lib/other.dart';"])); |
| 12011 resolve(source); | 12394 resolve(source); |
| 12012 assertNoErrors(); | 12395 assertNoErrors(source); |
| 12013 } | 12396 } |
| 12014 void test_import_referenceOutOfLibDirectory() { | 12397 void test_import_referenceOutOfLibDirectory() { |
| 12015 cacheSource("/myproj/pubspec.yaml", ""); | 12398 cacheSource("/myproj/pubspec.yaml", ""); |
| 12016 cacheSource("/myproj/web/other.dart", ""); | 12399 cacheSource("/myproj/web/other.dart", ""); |
| 12017 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import '../web/other.dart';"])); | 12400 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import '../web/other.dart';"])); |
| 12018 resolve(source); | 12401 resolve(source); |
| 12019 assertErrors([PubSuggestionCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSI
DE]); | 12402 assertErrors(source, [PubSuggestionCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FI
LE_OUTSIDE]); |
| 12020 } | 12403 } |
| 12021 void test_import_referenceOutOfLibDirectory_no_pubspec() { | 12404 void test_import_referenceOutOfLibDirectory_no_pubspec() { |
| 12022 cacheSource("/myproj/web/other.dart", ""); | 12405 cacheSource("/myproj/web/other.dart", ""); |
| 12023 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import '../web/other.dart';"])); | 12406 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import '../web/other.dart';"])); |
| 12024 resolve(source); | 12407 resolve(source); |
| 12025 assertNoErrors(); | 12408 assertNoErrors(source); |
| 12026 } | 12409 } |
| 12027 void test_import_valid_inside_lib1() { | 12410 void test_import_valid_inside_lib1() { |
| 12028 cacheSource("/myproj/pubspec.yaml", ""); | 12411 cacheSource("/myproj/pubspec.yaml", ""); |
| 12029 cacheSource("/myproj/lib/other.dart", ""); | 12412 cacheSource("/myproj/lib/other.dart", ""); |
| 12030 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import 'other.dart';"])); | 12413 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou
rce(["import 'other.dart';"])); |
| 12031 resolve(source); | 12414 resolve(source); |
| 12032 assertNoErrors(); | 12415 assertNoErrors(source); |
| 12033 } | 12416 } |
| 12034 void test_import_valid_inside_lib2() { | 12417 void test_import_valid_inside_lib2() { |
| 12035 cacheSource("/myproj/pubspec.yaml", ""); | 12418 cacheSource("/myproj/pubspec.yaml", ""); |
| 12036 cacheSource("/myproj/lib/bar/other.dart", ""); | 12419 cacheSource("/myproj/lib/bar/other.dart", ""); |
| 12037 Source source = addSource2("/myproj/lib/foo/test.dart", EngineTestCase.creat
eSource(["import '../bar/other.dart';"])); | 12420 Source source = addSource2("/myproj/lib/foo/test.dart", EngineTestCase.creat
eSource(["import '../bar/other.dart';"])); |
| 12038 resolve(source); | 12421 resolve(source); |
| 12039 assertNoErrors(); | 12422 assertNoErrors(source); |
| 12040 } | 12423 } |
| 12041 void test_import_valid_outside_lib() { | 12424 void test_import_valid_outside_lib() { |
| 12042 cacheSource("/myproj/pubspec.yaml", ""); | 12425 cacheSource("/myproj/pubspec.yaml", ""); |
| 12043 cacheSource("/myproj/web/other.dart", ""); | 12426 cacheSource("/myproj/web/other.dart", ""); |
| 12044 Source source = addSource2("/myproj/lib2/test.dart", EngineTestCase.createSo
urce(["import '../web/other.dart';"])); | 12427 Source source = addSource2("/myproj/lib2/test.dart", EngineTestCase.createSo
urce(["import '../web/other.dart';"])); |
| 12045 resolve(source); | 12428 resolve(source); |
| 12046 assertNoErrors(); | 12429 assertNoErrors(source); |
| 12047 } | 12430 } |
| 12048 static dartSuite() { | 12431 static dartSuite() { |
| 12049 _ut.group('PubSuggestionCodeTest', () { | 12432 _ut.group('PubSuggestionCodeTest', () { |
| 12050 _ut.test('test_import_package', () { | 12433 _ut.test('test_import_package', () { |
| 12051 final __test = new PubSuggestionCodeTest(); | 12434 final __test = new PubSuggestionCodeTest(); |
| 12052 runJUnitTest(__test, __test.test_import_package); | 12435 runJUnitTest(__test, __test.test_import_package); |
| 12053 }); | 12436 }); |
| 12054 _ut.test('test_import_packageWithDotDot', () { | 12437 _ut.test('test_import_packageWithDotDot', () { |
| 12055 final __test = new PubSuggestionCodeTest(); | 12438 final __test = new PubSuggestionCodeTest(); |
| 12056 runJUnitTest(__test, __test.test_import_packageWithDotDot); | 12439 runJUnitTest(__test, __test.test_import_packageWithDotDot); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12092 } | 12475 } |
| 12093 class StaticWarningCodeTest extends ResolverTestCase { | 12476 class StaticWarningCodeTest extends ResolverTestCase { |
| 12094 void fail_argumentTypeNotAssignable_invocation_functionParameter_generic() { | 12477 void fail_argumentTypeNotAssignable_invocation_functionParameter_generic() { |
| 12095 Source source = addSource(EngineTestCase.createSource([ | 12478 Source source = addSource(EngineTestCase.createSource([ |
| 12096 "class A<K, V> {", | 12479 "class A<K, V> {", |
| 12097 " m(f(K k), V v) {", | 12480 " m(f(K k), V v) {", |
| 12098 " f(v);", | 12481 " f(v);", |
| 12099 " }", | 12482 " }", |
| 12100 "}"])); | 12483 "}"])); |
| 12101 resolve(source); | 12484 resolve(source); |
| 12102 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12485 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12103 verify([source]); | 12486 verify([source]); |
| 12104 } | 12487 } |
| 12105 void fail_commentReferenceConstructorNotVisible() { | 12488 void fail_commentReferenceConstructorNotVisible() { |
| 12106 Source source = addSource(EngineTestCase.createSource([])); | 12489 Source source = addSource(EngineTestCase.createSource([])); |
| 12107 resolve(source); | 12490 resolve(source); |
| 12108 assertErrors([StaticWarningCode.COMMENT_REFERENCE_CONSTRUCTOR_NOT_VISIBLE]); | 12491 assertErrors(source, [StaticWarningCode.COMMENT_REFERENCE_CONSTRUCTOR_NOT_VI
SIBLE]); |
| 12109 verify([source]); | 12492 verify([source]); |
| 12110 } | 12493 } |
| 12111 void fail_commentReferenceIdentifierNotVisible() { | 12494 void fail_commentReferenceIdentifierNotVisible() { |
| 12112 Source source = addSource(EngineTestCase.createSource([])); | 12495 Source source = addSource(EngineTestCase.createSource([])); |
| 12113 resolve(source); | 12496 resolve(source); |
| 12114 assertErrors([StaticWarningCode.COMMENT_REFERENCE_IDENTIFIER_NOT_VISIBLE]); | 12497 assertErrors(source, [StaticWarningCode.COMMENT_REFERENCE_IDENTIFIER_NOT_VIS
IBLE]); |
| 12115 verify([source]); | 12498 verify([source]); |
| 12116 } | 12499 } |
| 12117 void fail_commentReferenceUndeclaredConstructor() { | 12500 void fail_commentReferenceUndeclaredConstructor() { |
| 12118 Source source = addSource(EngineTestCase.createSource([])); | 12501 Source source = addSource(EngineTestCase.createSource([])); |
| 12119 resolve(source); | 12502 resolve(source); |
| 12120 assertErrors([StaticWarningCode.COMMENT_REFERENCE_UNDECLARED_CONSTRUCTOR]); | 12503 assertErrors(source, [StaticWarningCode.COMMENT_REFERENCE_UNDECLARED_CONSTRU
CTOR]); |
| 12121 verify([source]); | 12504 verify([source]); |
| 12122 } | 12505 } |
| 12123 void fail_commentReferenceUndeclaredIdentifier() { | 12506 void fail_commentReferenceUndeclaredIdentifier() { |
| 12124 Source source = addSource(EngineTestCase.createSource([])); | 12507 Source source = addSource(EngineTestCase.createSource([])); |
| 12125 resolve(source); | 12508 resolve(source); |
| 12126 assertErrors([StaticWarningCode.COMMENT_REFERENCE_UNDECLARED_IDENTIFIER]); | 12509 assertErrors(source, [StaticWarningCode.COMMENT_REFERENCE_UNDECLARED_IDENTIF
IER]); |
| 12127 verify([source]); | 12510 verify([source]); |
| 12128 } | 12511 } |
| 12129 void fail_commentReferenceUriNotLibrary() { | 12512 void fail_commentReferenceUriNotLibrary() { |
| 12130 Source source = addSource(EngineTestCase.createSource([])); | 12513 Source source = addSource(EngineTestCase.createSource([])); |
| 12131 resolve(source); | 12514 resolve(source); |
| 12132 assertErrors([StaticWarningCode.COMMENT_REFERENCE_URI_NOT_LIBRARY]); | 12515 assertErrors(source, [StaticWarningCode.COMMENT_REFERENCE_URI_NOT_LIBRARY]); |
| 12133 verify([source]); | 12516 verify([source]); |
| 12134 } | 12517 } |
| 12135 void fail_mismatchedAccessorTypes_getterAndSuperSetter() { | 12518 void fail_mismatchedAccessorTypes_getterAndSuperSetter() { |
| 12136 Source source = addSource(EngineTestCase.createSource([ | 12519 Source source = addSource(EngineTestCase.createSource([ |
| 12137 "class A {", | 12520 "class A {", |
| 12138 " int get g { return 0; }", | 12521 " int get g { return 0; }", |
| 12139 " set g(int v) {}", | 12522 " set g(int v) {}", |
| 12140 "}", | 12523 "}", |
| 12141 "class B extends A {", | 12524 "class B extends A {", |
| 12142 " set g(String v) {}", | 12525 " set g(String v) {}", |
| 12143 "}"])); | 12526 "}"])); |
| 12144 resolve(source); | 12527 resolve(source); |
| 12145 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); | 12528 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; |
| 12146 verify([source]); | 12529 verify([source]); |
| 12147 } | 12530 } |
| 12148 void fail_mismatchedAccessorTypes_superGetterAndSetter() { | 12531 void fail_mismatchedAccessorTypes_superGetterAndSetter() { |
| 12149 Source source = addSource(EngineTestCase.createSource([ | 12532 Source source = addSource(EngineTestCase.createSource([ |
| 12150 "class A {", | 12533 "class A {", |
| 12151 " int get g { return 0; }", | 12534 " int get g { return 0; }", |
| 12152 " set g(int v) {}", | 12535 " set g(int v) {}", |
| 12153 "}", | 12536 "}", |
| 12154 "class B extends A {", | 12537 "class B extends A {", |
| 12155 " String get g { return ''; }", | 12538 " String get g { return ''; }", |
| 12156 "}"])); | 12539 "}"])); |
| 12157 resolve(source); | 12540 resolve(source); |
| 12158 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); | 12541 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; |
| 12159 verify([source]); | 12542 verify([source]); |
| 12160 } | 12543 } |
| 12161 void fail_undefinedGetter() { | 12544 void fail_undefinedGetter() { |
| 12162 Source source = addSource(EngineTestCase.createSource([])); | 12545 Source source = addSource(EngineTestCase.createSource([])); |
| 12163 resolve(source); | 12546 resolve(source); |
| 12164 assertErrors([StaticWarningCode.UNDEFINED_GETTER]); | 12547 assertErrors(source, [StaticWarningCode.UNDEFINED_GETTER]); |
| 12165 verify([source]); | 12548 verify([source]); |
| 12166 } | 12549 } |
| 12167 void fail_undefinedIdentifier_commentReference() { | 12550 void fail_undefinedIdentifier_commentReference() { |
| 12168 Source source = addSource(EngineTestCase.createSource(["/** [m] xxx [new B.c
] */", "class A {", "}"])); | 12551 Source source = addSource(EngineTestCase.createSource(["/** [m] xxx [new B.c
] */", "class A {", "}"])); |
| 12169 resolve(source); | 12552 resolve(source); |
| 12170 assertErrors([ | 12553 assertErrors(source, [ |
| 12171 StaticWarningCode.UNDEFINED_IDENTIFIER, | 12554 StaticWarningCode.UNDEFINED_IDENTIFIER, |
| 12172 StaticWarningCode.UNDEFINED_IDENTIFIER]); | 12555 StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 12173 } | 12556 } |
| 12174 void fail_undefinedSetter() { | 12557 void fail_undefinedSetter() { |
| 12175 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " C.m = 0;", "}"])); | 12558 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " C.m = 0;", "}"])); |
| 12176 resolve(source); | 12559 resolve(source); |
| 12177 assertErrors([StaticWarningCode.UNDEFINED_SETTER]); | 12560 assertErrors(source, [StaticWarningCode.UNDEFINED_SETTER]); |
| 12178 verify([source]); | 12561 verify([source]); |
| 12179 } | 12562 } |
| 12180 void fail_undefinedStaticMethodOrGetter_getter() { | 12563 void fail_undefinedStaticMethodOrGetter_getter() { |
| 12181 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " f(C.m);", "}"])); | 12564 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " f(C.m);", "}"])); |
| 12182 resolve(source); | 12565 resolve(source); |
| 12183 assertErrors([StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]); | 12566 assertErrors(source, [StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]); |
| 12184 verify([source]); | 12567 verify([source]); |
| 12185 } | 12568 } |
| 12186 void fail_undefinedStaticMethodOrGetter_method() { | 12569 void fail_undefinedStaticMethodOrGetter_method() { |
| 12187 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " f(C.m());", "}"])); | 12570 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var
p) {", " f(C.m());", "}"])); |
| 12188 resolve(source); | 12571 resolve(source); |
| 12189 assertErrors([StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]); | 12572 assertErrors(source, [StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]); |
| 12190 verify([source]); | 12573 verify([source]); |
| 12191 } | 12574 } |
| 12192 void test_ambiguousImport_as() { | 12575 void test_ambiguousImport_as() { |
| 12193 Source source = addSource(EngineTestCase.createSource([ | 12576 Source source = addSource(EngineTestCase.createSource([ |
| 12194 "import 'lib1.dart';", | 12577 "import 'lib1.dart';", |
| 12195 "import 'lib2.dart';", | 12578 "import 'lib2.dart';", |
| 12196 "f(p) {p as N;}"])); | 12579 "f(p) {p as N;}"])); |
| 12197 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 12580 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 12198 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 12581 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 12199 resolve(source); | 12582 resolve(source); |
| 12200 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]); | 12583 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 12201 } | 12584 } |
| 12202 void test_ambiguousImport_extends() { | 12585 void test_ambiguousImport_extends() { |
| 12203 Source source = addSource(EngineTestCase.createSource([ | 12586 Source source = addSource(EngineTestCase.createSource([ |
| 12204 "import 'lib1.dart';", | 12587 "import 'lib1.dart';", |
| 12205 "import 'lib2.dart';", | 12588 "import 'lib2.dart';", |
| 12206 "class A extends N {}"])); | 12589 "class A extends N {}"])); |
| 12207 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 12590 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 12208 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 12591 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 12209 resolve(source); | 12592 resolve(source); |
| 12210 assertErrors([ | 12593 assertErrors(source, [ |
| 12211 StaticWarningCode.AMBIGUOUS_IMPORT, | 12594 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 12212 CompileTimeErrorCode.EXTENDS_NON_CLASS]); | 12595 CompileTimeErrorCode.EXTENDS_NON_CLASS]); |
| 12213 } | 12596 } |
| 12214 void test_ambiguousImport_implements() { | 12597 void test_ambiguousImport_implements() { |
| 12215 Source source = addSource(EngineTestCase.createSource([ | 12598 Source source = addSource(EngineTestCase.createSource([ |
| 12216 "import 'lib1.dart';", | 12599 "import 'lib1.dart';", |
| 12217 "import 'lib2.dart';", | 12600 "import 'lib2.dart';", |
| 12218 "class A implements N {}"])); | 12601 "class A implements N {}"])); |
| 12219 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 12602 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 12220 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 12603 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 12221 resolve(source); | 12604 resolve(source); |
| 12222 assertErrors([ | 12605 assertErrors(source, [ |
| 12223 StaticWarningCode.AMBIGUOUS_IMPORT, | 12606 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 12224 CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); | 12607 CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); |
| 12225 } | 12608 } |
| 12226 void test_ambiguousImport_instanceCreation() { | 12609 void test_ambiguousImport_instanceCreation() { |
| 12227 Source source = addSource(EngineTestCase.createSource([ | 12610 Source source = addSource(EngineTestCase.createSource([ |
| 12228 "library L;", | 12611 "library L;", |
| 12229 "import 'lib1.dart';", | 12612 "import 'lib1.dart';", |
| 12230 "import 'lib2.dart';", | 12613 "import 'lib2.dart';", |
| 12231 "f() {new N();}"])); | 12614 "f() {new N();}"])); |
| 12232 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 12615 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 12233 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 12616 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 12234 resolve(source); | 12617 resolve(source); |
| 12235 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]); | 12618 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 12236 } | 12619 } |
| 12237 void test_ambiguousImport_is() { | 12620 void test_ambiguousImport_is() { |
| 12238 Source source = addSource(EngineTestCase.createSource([ | 12621 Source source = addSource(EngineTestCase.createSource([ |
| 12239 "import 'lib1.dart';", | 12622 "import 'lib1.dart';", |
| 12240 "import 'lib2.dart';", | 12623 "import 'lib2.dart';", |
| 12241 "f(p) {p is N;}"])); | 12624 "f(p) {p is N;}"])); |
| 12242 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 12625 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 12243 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 12626 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 12244 resolve(source); | 12627 resolve(source); |
| 12245 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]); | 12628 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 12246 } | 12629 } |
| 12247 void test_ambiguousImport_qualifier() { | 12630 void test_ambiguousImport_qualifier() { |
| 12248 Source source = addSource(EngineTestCase.createSource([ | 12631 Source source = addSource(EngineTestCase.createSource([ |
| 12249 "import 'lib1.dart';", | 12632 "import 'lib1.dart';", |
| 12250 "import 'lib2.dart';", | 12633 "import 'lib2.dart';", |
| 12251 "g() { N.FOO; }"])); | 12634 "g() { N.FOO; }"])); |
| 12252 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 12635 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 12253 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 12636 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 12254 resolve(source); | 12637 resolve(source); |
| 12255 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]); | 12638 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 12256 } | 12639 } |
| 12257 void test_ambiguousImport_typeAnnotation() { | 12640 void test_ambiguousImport_typeAnnotation() { |
| 12258 Source source = addSource(EngineTestCase.createSource([ | 12641 Source source = addSource(EngineTestCase.createSource([ |
| 12259 "import 'lib1.dart';", | 12642 "import 'lib1.dart';", |
| 12260 "import 'lib2.dart';", | 12643 "import 'lib2.dart';", |
| 12261 "typedef N FT(N p);", | 12644 "typedef N FT(N p);", |
| 12262 "N f(N p) {", | 12645 "N f(N p) {", |
| 12263 " N v;", | 12646 " N v;", |
| 12264 "}", | 12647 "}", |
| 12265 "class A {", | 12648 "class A {", |
| 12266 " N m() {}", | 12649 " N m() {}", |
| 12267 "}", | 12650 "}", |
| 12268 "class B<T extends N> {}"])); | 12651 "class B<T extends N> {}"])); |
| 12269 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 12652 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 12270 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 12653 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 12271 resolve(source); | 12654 resolve(source); |
| 12272 assertErrors([ | 12655 assertErrors(source, [ |
| 12273 StaticWarningCode.AMBIGUOUS_IMPORT, | 12656 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 12274 StaticWarningCode.AMBIGUOUS_IMPORT, | 12657 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 12275 StaticWarningCode.AMBIGUOUS_IMPORT, | 12658 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 12276 StaticWarningCode.AMBIGUOUS_IMPORT, | 12659 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 12277 StaticWarningCode.AMBIGUOUS_IMPORT, | 12660 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 12278 StaticWarningCode.AMBIGUOUS_IMPORT, | 12661 StaticWarningCode.AMBIGUOUS_IMPORT, |
| 12279 StaticWarningCode.AMBIGUOUS_IMPORT]); | 12662 StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 12280 } | 12663 } |
| 12281 void test_ambiguousImport_typeArgument_annotation() { | 12664 void test_ambiguousImport_typeArgument_annotation() { |
| 12282 Source source = addSource(EngineTestCase.createSource([ | 12665 Source source = addSource(EngineTestCase.createSource([ |
| 12283 "import 'lib1.dart';", | 12666 "import 'lib1.dart';", |
| 12284 "import 'lib2.dart';", | 12667 "import 'lib2.dart';", |
| 12285 "class A<T> {}", | 12668 "class A<T> {}", |
| 12286 "A<N> f() {}"])); | 12669 "A<N> f() {}"])); |
| 12287 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 12670 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 12288 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 12671 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 12289 resolve(source); | 12672 resolve(source); |
| 12290 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]); | 12673 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 12291 } | 12674 } |
| 12292 void test_ambiguousImport_typeArgument_instanceCreation() { | 12675 void test_ambiguousImport_typeArgument_instanceCreation() { |
| 12293 Source source = addSource(EngineTestCase.createSource([ | 12676 Source source = addSource(EngineTestCase.createSource([ |
| 12294 "import 'lib1.dart';", | 12677 "import 'lib1.dart';", |
| 12295 "import 'lib2.dart';", | 12678 "import 'lib2.dart';", |
| 12296 "class A<T> {}", | 12679 "class A<T> {}", |
| 12297 "f() {new A<N>();}"])); | 12680 "f() {new A<N>();}"])); |
| 12298 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); | 12681 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s N {}"])); |
| 12299 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); | 12682 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s N {}"])); |
| 12300 resolve(source); | 12683 resolve(source); |
| 12301 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]); | 12684 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 12302 } | 12685 } |
| 12303 void test_ambiguousImport_varRead() { | 12686 void test_ambiguousImport_varRead() { |
| 12304 Source source = addSource(EngineTestCase.createSource([ | 12687 Source source = addSource(EngineTestCase.createSource([ |
| 12305 "import 'lib1.dart';", | 12688 "import 'lib1.dart';", |
| 12306 "import 'lib2.dart';", | 12689 "import 'lib2.dart';", |
| 12307 "f() { g(v); }", | 12690 "f() { g(v); }", |
| 12308 "g(p) {}"])); | 12691 "g(p) {}"])); |
| 12309 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var
v;"])); | 12692 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var
v;"])); |
| 12310 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var
v;"])); | 12693 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var
v;"])); |
| 12311 resolve(source); | 12694 resolve(source); |
| 12312 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]); | 12695 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 12313 } | 12696 } |
| 12314 void test_ambiguousImport_varWrite() { | 12697 void test_ambiguousImport_varWrite() { |
| 12315 Source source = addSource(EngineTestCase.createSource([ | 12698 Source source = addSource(EngineTestCase.createSource([ |
| 12316 "import 'lib1.dart';", | 12699 "import 'lib1.dart';", |
| 12317 "import 'lib2.dart';", | 12700 "import 'lib2.dart';", |
| 12318 "f() { v = 0; }"])); | 12701 "f() { v = 0; }"])); |
| 12319 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var
v;"])); | 12702 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var
v;"])); |
| 12320 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var
v;"])); | 12703 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var
v;"])); |
| 12321 resolve(source); | 12704 resolve(source); |
| 12322 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]); | 12705 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 12323 } | 12706 } |
| 12324 void test_argumentTypeNotAssignable_annotation_namedConstructor() { | 12707 void test_argumentTypeNotAssignable_annotation_namedConstructor() { |
| 12325 Source source = addSource(EngineTestCase.createSource([ | 12708 Source source = addSource(EngineTestCase.createSource([ |
| 12326 "class A {", | 12709 "class A {", |
| 12327 " const A.fromInt(int p);", | 12710 " const A.fromInt(int p);", |
| 12328 "}", | 12711 "}", |
| 12329 "@A.fromInt('0')", | 12712 "@A.fromInt('0')", |
| 12330 "main() {", | 12713 "main() {", |
| 12331 "}"])); | 12714 "}"])); |
| 12332 resolve(source); | 12715 resolve(source); |
| 12333 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12716 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12334 verify([source]); | 12717 verify([source]); |
| 12335 } | 12718 } |
| 12336 void test_argumentTypeNotAssignable_annotation_unnamedConstructor() { | 12719 void test_argumentTypeNotAssignable_annotation_unnamedConstructor() { |
| 12337 Source source = addSource(EngineTestCase.createSource([ | 12720 Source source = addSource(EngineTestCase.createSource([ |
| 12338 "class A {", | 12721 "class A {", |
| 12339 " const A(int p);", | 12722 " const A(int p);", |
| 12340 "}", | 12723 "}", |
| 12341 "@A('0')", | 12724 "@A('0')", |
| 12342 "main() {", | 12725 "main() {", |
| 12343 "}"])); | 12726 "}"])); |
| 12344 resolve(source); | 12727 resolve(source); |
| 12345 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12728 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12346 verify([source]); | 12729 verify([source]); |
| 12347 } | 12730 } |
| 12348 void test_argumentTypeNotAssignable_binary() { | 12731 void test_argumentTypeNotAssignable_binary() { |
| 12349 Source source = addSource(EngineTestCase.createSource([ | 12732 Source source = addSource(EngineTestCase.createSource([ |
| 12350 "class A {", | 12733 "class A {", |
| 12351 " operator +(int p) {}", | 12734 " operator +(int p) {}", |
| 12352 "}", | 12735 "}", |
| 12353 "f(A a) {", | 12736 "f(A a) {", |
| 12354 " a + '0';", | 12737 " a + '0';", |
| 12355 "}"])); | 12738 "}"])); |
| 12356 resolve(source); | 12739 resolve(source); |
| 12357 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12740 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12358 verify([source]); | 12741 verify([source]); |
| 12359 } | 12742 } |
| 12360 void test_argumentTypeNotAssignable_index() { | 12743 void test_argumentTypeNotAssignable_index() { |
| 12361 Source source = addSource(EngineTestCase.createSource([ | 12744 Source source = addSource(EngineTestCase.createSource([ |
| 12362 "class A {", | 12745 "class A {", |
| 12363 " operator [](int index) {}", | 12746 " operator [](int index) {}", |
| 12364 "}", | 12747 "}", |
| 12365 "f(A a) {", | 12748 "f(A a) {", |
| 12366 " a['0'];", | 12749 " a['0'];", |
| 12367 "}"])); | 12750 "}"])); |
| 12368 resolve(source); | 12751 resolve(source); |
| 12369 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12752 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12370 verify([source]); | 12753 verify([source]); |
| 12371 } | 12754 } |
| 12372 void test_argumentTypeNotAssignable_invocation_callParameter() { | 12755 void test_argumentTypeNotAssignable_invocation_callParameter() { |
| 12373 Source source = addSource(EngineTestCase.createSource([ | 12756 Source source = addSource(EngineTestCase.createSource([ |
| 12374 "class A {", | 12757 "class A {", |
| 12375 " call(int p) {}", | 12758 " call(int p) {}", |
| 12376 "}", | 12759 "}", |
| 12377 "f(A a) {", | 12760 "f(A a) {", |
| 12378 " a('0');", | 12761 " a('0');", |
| 12379 "}"])); | 12762 "}"])); |
| 12380 resolve(source); | 12763 resolve(source); |
| 12381 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12764 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12382 verify([source]); | 12765 verify([source]); |
| 12383 } | 12766 } |
| 12384 void test_argumentTypeNotAssignable_invocation_callVariable() { | 12767 void test_argumentTypeNotAssignable_invocation_callVariable() { |
| 12385 Source source = addSource(EngineTestCase.createSource([ | 12768 Source source = addSource(EngineTestCase.createSource([ |
| 12386 "class A {", | 12769 "class A {", |
| 12387 " call(int p) {}", | 12770 " call(int p) {}", |
| 12388 "}", | 12771 "}", |
| 12389 "main() {", | 12772 "main() {", |
| 12390 " A a = new A();", | 12773 " A a = new A();", |
| 12391 " a('0');", | 12774 " a('0');", |
| 12392 "}"])); | 12775 "}"])); |
| 12393 resolve(source); | 12776 resolve(source); |
| 12394 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12777 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12395 verify([source]); | 12778 verify([source]); |
| 12396 } | 12779 } |
| 12397 void test_argumentTypeNotAssignable_invocation_functionParameter() { | 12780 void test_argumentTypeNotAssignable_invocation_functionParameter() { |
| 12398 Source source = addSource(EngineTestCase.createSource(["a(b(int p)) {", " b
('0');", "}"])); | 12781 Source source = addSource(EngineTestCase.createSource(["a(b(int p)) {", " b
('0');", "}"])); |
| 12399 resolve(source); | 12782 resolve(source); |
| 12400 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12783 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12401 verify([source]); | 12784 verify([source]); |
| 12402 } | 12785 } |
| 12403 void test_argumentTypeNotAssignable_invocation_functionTypes_optional() { | 12786 void test_argumentTypeNotAssignable_invocation_functionTypes_optional() { |
| 12404 Source source = addSource(EngineTestCase.createSource([ | 12787 Source source = addSource(EngineTestCase.createSource([ |
| 12405 "void acceptFunNumOptBool(void funNumOptBool([bool b])) {}", | 12788 "void acceptFunNumOptBool(void funNumOptBool([bool b])) {}", |
| 12406 "void funNumBool(bool b) {}", | 12789 "void funNumBool(bool b) {}", |
| 12407 "main() {", | 12790 "main() {", |
| 12408 " acceptFunNumOptBool(funNumBool);", | 12791 " acceptFunNumOptBool(funNumBool);", |
| 12409 "}"])); | 12792 "}"])); |
| 12410 resolve(source); | 12793 resolve(source); |
| 12411 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12794 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12412 verify([source]); | 12795 verify([source]); |
| 12413 } | 12796 } |
| 12414 void test_argumentTypeNotAssignable_invocation_generic() { | 12797 void test_argumentTypeNotAssignable_invocation_generic() { |
| 12415 Source source = addSource(EngineTestCase.createSource([ | 12798 Source source = addSource(EngineTestCase.createSource([ |
| 12416 "class A<T> {", | 12799 "class A<T> {", |
| 12417 " m(T t) {}", | 12800 " m(T t) {}", |
| 12418 "}", | 12801 "}", |
| 12419 "f(A<String> a) {", | 12802 "f(A<String> a) {", |
| 12420 " a.m(1);", | 12803 " a.m(1);", |
| 12421 "}"])); | 12804 "}"])); |
| 12422 resolve(source); | 12805 resolve(source); |
| 12423 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12806 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12424 verify([source]); | 12807 verify([source]); |
| 12425 } | 12808 } |
| 12426 void test_argumentTypeNotAssignable_invocation_named() { | 12809 void test_argumentTypeNotAssignable_invocation_named() { |
| 12427 Source source = addSource(EngineTestCase.createSource(["f({String p}) {}", "
main() {", " f(p: 42);", "}"])); | 12810 Source source = addSource(EngineTestCase.createSource(["f({String p}) {}", "
main() {", " f(p: 42);", "}"])); |
| 12428 resolve(source); | 12811 resolve(source); |
| 12429 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12812 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12430 verify([source]); | 12813 verify([source]); |
| 12431 } | 12814 } |
| 12432 void test_argumentTypeNotAssignable_invocation_optional() { | 12815 void test_argumentTypeNotAssignable_invocation_optional() { |
| 12433 Source source = addSource(EngineTestCase.createSource(["f([String p]) {}", "
main() {", " f(42);", "}"])); | 12816 Source source = addSource(EngineTestCase.createSource(["f([String p]) {}", "
main() {", " f(42);", "}"])); |
| 12434 resolve(source); | 12817 resolve(source); |
| 12435 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12818 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12436 verify([source]); | 12819 verify([source]); |
| 12437 } | 12820 } |
| 12438 void test_argumentTypeNotAssignable_invocation_required() { | 12821 void test_argumentTypeNotAssignable_invocation_required() { |
| 12439 Source source = addSource(EngineTestCase.createSource(["f(String p) {}", "ma
in() {", " f(42);", "}"])); | 12822 Source source = addSource(EngineTestCase.createSource(["f(String p) {}", "ma
in() {", " f(42);", "}"])); |
| 12440 resolve(source); | 12823 resolve(source); |
| 12441 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12824 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12442 verify([source]); | 12825 verify([source]); |
| 12443 } | 12826 } |
| 12444 void test_argumentTypeNotAssignable_invocation_typedef_generic() { | 12827 void test_argumentTypeNotAssignable_invocation_typedef_generic() { |
| 12445 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);",
"f(A<int> a) {", " a('1');", "}"])); | 12828 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);",
"f(A<int> a) {", " a('1');", "}"])); |
| 12446 resolve(source); | 12829 resolve(source); |
| 12447 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12830 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12448 verify([source]); | 12831 verify([source]); |
| 12449 } | 12832 } |
| 12450 void test_argumentTypeNotAssignable_invocation_typedef_local() { | 12833 void test_argumentTypeNotAssignable_invocation_typedef_local() { |
| 12451 Source source = addSource(EngineTestCase.createSource([ | 12834 Source source = addSource(EngineTestCase.createSource([ |
| 12452 "typedef A(int p);", | 12835 "typedef A(int p);", |
| 12453 "A getA() => null;", | 12836 "A getA() => null;", |
| 12454 "main() {", | 12837 "main() {", |
| 12455 " A a = getA();", | 12838 " A a = getA();", |
| 12456 " a('1');", | 12839 " a('1');", |
| 12457 "}"])); | 12840 "}"])); |
| 12458 resolve(source); | 12841 resolve(source); |
| 12459 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12842 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12460 verify([source]); | 12843 verify([source]); |
| 12461 } | 12844 } |
| 12462 void test_argumentTypeNotAssignable_invocation_typedef_parameter() { | 12845 void test_argumentTypeNotAssignable_invocation_typedef_parameter() { |
| 12463 Source source = addSource(EngineTestCase.createSource(["typedef A(int p);",
"f(A a) {", " a('1');", "}"])); | 12846 Source source = addSource(EngineTestCase.createSource(["typedef A(int p);",
"f(A a) {", " a('1');", "}"])); |
| 12464 resolve(source); | 12847 resolve(source); |
| 12465 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12848 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12466 verify([source]); | 12849 verify([source]); |
| 12467 } | 12850 } |
| 12468 void test_argumentTypeNotAssignable_new_generic() { | 12851 void test_argumentTypeNotAssignable_new_generic() { |
| 12469 Source source = addSource(EngineTestCase.createSource([ | 12852 Source source = addSource(EngineTestCase.createSource([ |
| 12470 "class A<T> {", | 12853 "class A<T> {", |
| 12471 " A(T p) {}", | 12854 " A(T p) {}", |
| 12472 "}", | 12855 "}", |
| 12473 "main() {", | 12856 "main() {", |
| 12474 " new A<String>(42);", | 12857 " new A<String>(42);", |
| 12475 "}"])); | 12858 "}"])); |
| 12476 resolve(source); | 12859 resolve(source); |
| 12477 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12860 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12478 verify([source]); | 12861 verify([source]); |
| 12479 } | 12862 } |
| 12480 void test_argumentTypeNotAssignable_new_optional() { | 12863 void test_argumentTypeNotAssignable_new_optional() { |
| 12481 Source source = addSource(EngineTestCase.createSource([ | 12864 Source source = addSource(EngineTestCase.createSource([ |
| 12482 "class A {", | 12865 "class A {", |
| 12483 " A([String p]) {}", | 12866 " A([String p]) {}", |
| 12484 "}", | 12867 "}", |
| 12485 "main() {", | 12868 "main() {", |
| 12486 " new A(42);", | 12869 " new A(42);", |
| 12487 "}"])); | 12870 "}"])); |
| 12488 resolve(source); | 12871 resolve(source); |
| 12489 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12872 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12490 verify([source]); | 12873 verify([source]); |
| 12491 } | 12874 } |
| 12492 void test_argumentTypeNotAssignable_new_required() { | 12875 void test_argumentTypeNotAssignable_new_required() { |
| 12493 Source source = addSource(EngineTestCase.createSource([ | 12876 Source source = addSource(EngineTestCase.createSource([ |
| 12494 "class A {", | 12877 "class A {", |
| 12495 " A(String p) {}", | 12878 " A(String p) {}", |
| 12496 "}", | 12879 "}", |
| 12497 "main() {", | 12880 "main() {", |
| 12498 " new A(42);", | 12881 " new A(42);", |
| 12499 "}"])); | 12882 "}"])); |
| 12500 resolve(source); | 12883 resolve(source); |
| 12501 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); | 12884 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); |
| 12502 verify([source]); | 12885 verify([source]); |
| 12503 } | 12886 } |
| 12504 void test_assignmentToConst_instanceVariable() { | 12887 void test_assignmentToConst_instanceVariable() { |
| 12505 Source source = addSource(EngineTestCase.createSource([ | 12888 Source source = addSource(EngineTestCase.createSource([ |
| 12506 "class A {", | 12889 "class A {", |
| 12507 " static const v = 0;", | 12890 " static const v = 0;", |
| 12508 "}", | 12891 "}", |
| 12509 "f() {", | 12892 "f() {", |
| 12510 " A.v = 1;", | 12893 " A.v = 1;", |
| 12511 "}"])); | 12894 "}"])); |
| 12512 resolve(source); | 12895 resolve(source); |
| 12513 assertErrors([StaticWarningCode.ASSIGNMENT_TO_CONST]); | 12896 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]); |
| 12514 verify([source]); | 12897 verify([source]); |
| 12515 } | 12898 } |
| 12516 void test_assignmentToConst_localVariable() { | 12899 void test_assignmentToConst_localVariable() { |
| 12517 Source source = addSource(EngineTestCase.createSource(["f() {", " const x =
0;", " x = 1;", "}"])); | 12900 Source source = addSource(EngineTestCase.createSource(["f() {", " const x =
0;", " x = 1;", "}"])); |
| 12518 resolve(source); | 12901 resolve(source); |
| 12519 assertErrors([StaticWarningCode.ASSIGNMENT_TO_CONST]); | 12902 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]); |
| 12520 verify([source]); | 12903 verify([source]); |
| 12521 } | 12904 } |
| 12522 void test_assignmentToFinal_instanceVariable() { | 12905 void test_assignmentToFinal_instanceVariable() { |
| 12523 Source source = addSource(EngineTestCase.createSource([ | 12906 Source source = addSource(EngineTestCase.createSource([ |
| 12524 "class A {", | 12907 "class A {", |
| 12525 " final v = 0;", | 12908 " final v = 0;", |
| 12526 "}", | 12909 "}", |
| 12527 "f() {", | 12910 "f() {", |
| 12528 " A a = new A();", | 12911 " A a = new A();", |
| 12529 " a.v = 1;", | 12912 " a.v = 1;", |
| 12530 "}"])); | 12913 "}"])); |
| 12531 resolve(source); | 12914 resolve(source); |
| 12532 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 12915 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 12533 verify([source]); | 12916 verify([source]); |
| 12534 } | 12917 } |
| 12535 void test_assignmentToFinal_localVariable() { | 12918 void test_assignmentToFinal_localVariable() { |
| 12536 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x = 1;", "}"])); | 12919 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x = 1;", "}"])); |
| 12537 resolve(source); | 12920 resolve(source); |
| 12538 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 12921 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 12539 verify([source]); | 12922 verify([source]); |
| 12540 } | 12923 } |
| 12541 void test_assignmentToFinal_prefixMinusMinus() { | 12924 void test_assignmentToFinal_prefixMinusMinus() { |
| 12542 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " --x;", "}"])); | 12925 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " --x;", "}"])); |
| 12543 resolve(source); | 12926 resolve(source); |
| 12544 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 12927 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 12545 verify([source]); | 12928 verify([source]); |
| 12546 } | 12929 } |
| 12547 void test_assignmentToFinal_prefixPlusPlus() { | 12930 void test_assignmentToFinal_prefixPlusPlus() { |
| 12548 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " ++x;", "}"])); | 12931 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " ++x;", "}"])); |
| 12549 resolve(source); | 12932 resolve(source); |
| 12550 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 12933 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 12551 verify([source]); | 12934 verify([source]); |
| 12552 } | 12935 } |
| 12553 void test_assignmentToFinal_propertyAccess() { | 12936 void test_assignmentToFinal_propertyAccess() { |
| 12554 Source source = addSource(EngineTestCase.createSource([ | 12937 Source source = addSource(EngineTestCase.createSource([ |
| 12555 "class A {", | 12938 "class A {", |
| 12556 " int get x => 0;", | 12939 " int get x => 0;", |
| 12557 "}", | 12940 "}", |
| 12558 "class B {", | 12941 "class B {", |
| 12559 " static A a;", | 12942 " static A a;", |
| 12560 "}", | 12943 "}", |
| 12561 "main() {", | 12944 "main() {", |
| 12562 " B.a.x = 0;", | 12945 " B.a.x = 0;", |
| 12563 "}"])); | 12946 "}"])); |
| 12564 resolve(source); | 12947 resolve(source); |
| 12565 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 12948 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 12566 verify([source]); | 12949 verify([source]); |
| 12567 } | 12950 } |
| 12568 void test_assignmentToFinal_suffixMinusMinus() { | 12951 void test_assignmentToFinal_suffixMinusMinus() { |
| 12569 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x--;", "}"])); | 12952 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x--;", "}"])); |
| 12570 resolve(source); | 12953 resolve(source); |
| 12571 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 12954 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 12572 verify([source]); | 12955 verify([source]); |
| 12573 } | 12956 } |
| 12574 void test_assignmentToFinal_suffixPlusPlus() { | 12957 void test_assignmentToFinal_suffixPlusPlus() { |
| 12575 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x++;", "}"])); | 12958 Source source = addSource(EngineTestCase.createSource(["f() {", " final x =
0;", " x++;", "}"])); |
| 12576 resolve(source); | 12959 resolve(source); |
| 12577 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 12960 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 12578 verify([source]); | 12961 verify([source]); |
| 12579 } | 12962 } |
| 12580 void test_assignmentToFinal_topLevelVariable() { | 12963 void test_assignmentToFinal_topLevelVariable() { |
| 12581 Source source = addSource(EngineTestCase.createSource(["final x = 0;", "f()
{ x = 1; }"])); | 12964 Source source = addSource(EngineTestCase.createSource(["final x = 0;", "f()
{ x = 1; }"])); |
| 12582 resolve(source); | 12965 resolve(source); |
| 12583 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]); | 12966 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]); |
| 12584 verify([source]); | 12967 verify([source]); |
| 12585 } | 12968 } |
| 12586 void test_assignmentToMethod() { | 12969 void test_assignmentToMethod() { |
| 12587 Source source = addSource(EngineTestCase.createSource([ | 12970 Source source = addSource(EngineTestCase.createSource([ |
| 12588 "class A {", | 12971 "class A {", |
| 12589 " m() {}", | 12972 " m() {}", |
| 12590 "}", | 12973 "}", |
| 12591 "f(A a) {", | 12974 "f(A a) {", |
| 12592 " a.m = () {};", | 12975 " a.m = () {};", |
| 12593 "}"])); | 12976 "}"])); |
| 12594 resolve(source); | 12977 resolve(source); |
| 12595 assertErrors([StaticWarningCode.ASSIGNMENT_TO_METHOD]); | 12978 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_METHOD]); |
| 12596 verify([source]); | 12979 verify([source]); |
| 12597 } | 12980 } |
| 12598 void test_caseBlockNotTerminated() { | 12981 void test_caseBlockNotTerminated() { |
| 12599 Source source = addSource(EngineTestCase.createSource([ | 12982 Source source = addSource(EngineTestCase.createSource([ |
| 12600 "f(int p) {", | 12983 "f(int p) {", |
| 12601 " switch (p) {", | 12984 " switch (p) {", |
| 12602 " case 0:", | 12985 " case 0:", |
| 12603 " f(p);", | 12986 " f(p);", |
| 12604 " case 1:", | 12987 " case 1:", |
| 12605 " break;", | 12988 " break;", |
| 12606 " }", | 12989 " }", |
| 12607 "}"])); | 12990 "}"])); |
| 12608 resolve(source); | 12991 resolve(source); |
| 12609 assertErrors([StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]); | 12992 assertErrors(source, [StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]); |
| 12610 verify([source]); | 12993 verify([source]); |
| 12611 } | 12994 } |
| 12612 void test_castToNonType() { | 12995 void test_castToNonType() { |
| 12613 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(Stri
ng s) { var x = s as A; }"])); | 12996 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(Stri
ng s) { var x = s as A; }"])); |
| 12614 resolve(source); | 12997 resolve(source); |
| 12615 assertErrors([StaticWarningCode.CAST_TO_NON_TYPE]); | 12998 assertErrors(source, [StaticWarningCode.CAST_TO_NON_TYPE]); |
| 12616 verify([source]); | 12999 verify([source]); |
| 12617 } | 13000 } |
| 12618 void test_concreteClassWithAbstractMember() { | 13001 void test_concreteClassWithAbstractMember() { |
| 12619 Source source = addSource(EngineTestCase.createSource(["class A {", " m();"
, "}"])); | 13002 Source source = addSource(EngineTestCase.createSource(["class A {", " m();"
, "}"])); |
| 12620 resolve(source); | 13003 resolve(source); |
| 12621 assertErrors([StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]); | 13004 assertErrors(source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]
); |
| 12622 verify([source]); | 13005 verify([source]); |
| 12623 } | 13006 } |
| 12624 void test_conflictingInstanceGetterAndSuperclassMember_direct_field() { | 13007 void test_conflictingInstanceGetterAndSuperclassMember_direct_field() { |
| 12625 Source source = addSource(EngineTestCase.createSource([ | 13008 Source source = addSource(EngineTestCase.createSource([ |
| 12626 "class A {", | 13009 "class A {", |
| 12627 " static int v;", | 13010 " static int v;", |
| 12628 "}", | 13011 "}", |
| 12629 "class B extends A {", | 13012 "class B extends A {", |
| 12630 " get v => 0;", | 13013 " get v => 0;", |
| 12631 "}"])); | 13014 "}"])); |
| 12632 resolve(source); | 13015 resolve(source); |
| 12633 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M
EMBER]); | 13016 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 12634 verify([source]); | 13017 verify([source]); |
| 12635 } | 13018 } |
| 12636 void test_conflictingInstanceGetterAndSuperclassMember_direct_getter() { | 13019 void test_conflictingInstanceGetterAndSuperclassMember_direct_getter() { |
| 12637 Source source = addSource(EngineTestCase.createSource([ | 13020 Source source = addSource(EngineTestCase.createSource([ |
| 12638 "class A {", | 13021 "class A {", |
| 12639 " static get v => 0;", | 13022 " static get v => 0;", |
| 12640 "}", | 13023 "}", |
| 12641 "class B extends A {", | 13024 "class B extends A {", |
| 12642 " get v => 0;", | 13025 " get v => 0;", |
| 12643 "}"])); | 13026 "}"])); |
| 12644 resolve(source); | 13027 resolve(source); |
| 12645 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M
EMBER]); | 13028 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 12646 verify([source]); | 13029 verify([source]); |
| 12647 } | 13030 } |
| 12648 void test_conflictingInstanceGetterAndSuperclassMember_direct_method() { | 13031 void test_conflictingInstanceGetterAndSuperclassMember_direct_method() { |
| 12649 Source source = addSource(EngineTestCase.createSource([ | 13032 Source source = addSource(EngineTestCase.createSource([ |
| 12650 "class A {", | 13033 "class A {", |
| 12651 " static v() {}", | 13034 " static v() {}", |
| 12652 "}", | 13035 "}", |
| 12653 "class B extends A {", | 13036 "class B extends A {", |
| 12654 " get v => 0;", | 13037 " get v => 0;", |
| 12655 "}"])); | 13038 "}"])); |
| 12656 resolve(source); | 13039 resolve(source); |
| 12657 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M
EMBER]); | 13040 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 12658 verify([source]); | 13041 verify([source]); |
| 12659 } | 13042 } |
| 12660 void test_conflictingInstanceGetterAndSuperclassMember_direct_setter() { | 13043 void test_conflictingInstanceGetterAndSuperclassMember_direct_setter() { |
| 12661 Source source = addSource(EngineTestCase.createSource([ | 13044 Source source = addSource(EngineTestCase.createSource([ |
| 12662 "class A {", | 13045 "class A {", |
| 12663 " static set v(x) {}", | 13046 " static set v(x) {}", |
| 12664 "}", | 13047 "}", |
| 12665 "class B extends A {", | 13048 "class B extends A {", |
| 12666 " get v => 0;", | 13049 " get v => 0;", |
| 12667 "}"])); | 13050 "}"])); |
| 12668 resolve(source); | 13051 resolve(source); |
| 12669 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M
EMBER]); | 13052 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 12670 verify([source]); | 13053 verify([source]); |
| 12671 } | 13054 } |
| 12672 void test_conflictingInstanceGetterAndSuperclassMember_indirect() { | 13055 void test_conflictingInstanceGetterAndSuperclassMember_indirect() { |
| 12673 Source source = addSource(EngineTestCase.createSource([ | 13056 Source source = addSource(EngineTestCase.createSource([ |
| 12674 "class A {", | 13057 "class A {", |
| 12675 " static int v;", | 13058 " static int v;", |
| 12676 "}", | 13059 "}", |
| 12677 "class B extends A {}", | 13060 "class B extends A {}", |
| 12678 "class C extends B {", | 13061 "class C extends B {", |
| 12679 " get v => 0;", | 13062 " get v => 0;", |
| 12680 "}"])); | 13063 "}"])); |
| 12681 resolve(source); | 13064 resolve(source); |
| 12682 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M
EMBER]); | 13065 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 12683 verify([source]); | 13066 verify([source]); |
| 12684 } | 13067 } |
| 12685 void test_conflictingInstanceGetterAndSuperclassMember_mixin() { | 13068 void test_conflictingInstanceGetterAndSuperclassMember_mixin() { |
| 12686 Source source = addSource(EngineTestCase.createSource([ | 13069 Source source = addSource(EngineTestCase.createSource([ |
| 12687 "class M {", | 13070 "class M {", |
| 12688 " static int v;", | 13071 " static int v;", |
| 12689 "}", | 13072 "}", |
| 12690 "class B extends Object with M {", | 13073 "class B extends Object with M {", |
| 12691 " get v => 0;", | 13074 " get v => 0;", |
| 12692 "}"])); | 13075 "}"])); |
| 12693 resolve(source); | 13076 resolve(source); |
| 12694 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M
EMBER]); | 13077 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE
RCLASS_MEMBER]); |
| 12695 verify([source]); | 13078 verify([source]); |
| 12696 } | 13079 } |
| 12697 void test_conflictingInstanceSetterAndSuperclassMember() { | 13080 void test_conflictingInstanceSetterAndSuperclassMember() { |
| 12698 Source source = addSource(EngineTestCase.createSource([ | 13081 Source source = addSource(EngineTestCase.createSource([ |
| 12699 "class A {", | 13082 "class A {", |
| 12700 " static int v;", | 13083 " static int v;", |
| 12701 "}", | 13084 "}", |
| 12702 "class B extends A {", | 13085 "class B extends A {", |
| 12703 " set v(x) {}", | 13086 " set v(x) {}", |
| 12704 "}"])); | 13087 "}"])); |
| 12705 resolve(source); | 13088 resolve(source); |
| 12706 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_M
EMBER]); | 13089 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPE
RCLASS_MEMBER]); |
| 12707 verify([source]); | 13090 verify([source]); |
| 12708 } | 13091 } |
| 12709 void test_conflictingStaticGetterAndInstanceSetter_mixin() { | 13092 void test_conflictingStaticGetterAndInstanceSetter_mixin() { |
| 12710 Source source = addSource(EngineTestCase.createSource([ | 13093 Source source = addSource(EngineTestCase.createSource([ |
| 12711 "class A {", | 13094 "class A {", |
| 12712 " set x(int p) {}", | 13095 " set x(int p) {}", |
| 12713 "}", | 13096 "}", |
| 12714 "class B extends Object with A {", | 13097 "class B extends Object with A {", |
| 12715 " static get x => 0;", | 13098 " static get x => 0;", |
| 12716 "}"])); | 13099 "}"])); |
| 12717 resolve(source); | 13100 resolve(source); |
| 12718 assertErrors([StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTE
R]); | 13101 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN
CE_SETTER]); |
| 12719 verify([source]); | 13102 verify([source]); |
| 12720 } | 13103 } |
| 12721 void test_conflictingStaticGetterAndInstanceSetter_superClass() { | 13104 void test_conflictingStaticGetterAndInstanceSetter_superClass() { |
| 12722 Source source = addSource(EngineTestCase.createSource([ | 13105 Source source = addSource(EngineTestCase.createSource([ |
| 12723 "class A {", | 13106 "class A {", |
| 12724 " set x(int p) {}", | 13107 " set x(int p) {}", |
| 12725 "}", | 13108 "}", |
| 12726 "class B extends A {", | 13109 "class B extends A {", |
| 12727 " static get x => 0;", | 13110 " static get x => 0;", |
| 12728 "}"])); | 13111 "}"])); |
| 12729 resolve(source); | 13112 resolve(source); |
| 12730 assertErrors([StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTE
R]); | 13113 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN
CE_SETTER]); |
| 12731 verify([source]); | 13114 verify([source]); |
| 12732 } | 13115 } |
| 12733 void test_conflictingStaticGetterAndInstanceSetter_thisClass() { | 13116 void test_conflictingStaticGetterAndInstanceSetter_thisClass() { |
| 12734 Source source = addSource(EngineTestCase.createSource([ | 13117 Source source = addSource(EngineTestCase.createSource([ |
| 12735 "class A {", | 13118 "class A {", |
| 12736 " static get x => 0;", | 13119 " static get x => 0;", |
| 12737 " set x(int p) {}", | 13120 " set x(int p) {}", |
| 12738 "}"])); | 13121 "}"])); |
| 12739 resolve(source); | 13122 resolve(source); |
| 12740 assertErrors([StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTE
R]); | 13123 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN
CE_SETTER]); |
| 12741 verify([source]); | 13124 verify([source]); |
| 12742 } | 13125 } |
| 12743 void test_conflictingStaticSetterAndInstanceMember_thisClass_getter() { | 13126 void test_conflictingStaticSetterAndInstanceMember_thisClass_getter() { |
| 12744 Source source = addSource(EngineTestCase.createSource([ | 13127 Source source = addSource(EngineTestCase.createSource([ |
| 12745 "class A {", | 13128 "class A {", |
| 12746 " get x => 0;", | 13129 " get x => 0;", |
| 12747 " static set x(int p) {}", | 13130 " static set x(int p) {}", |
| 12748 "}"])); | 13131 "}"])); |
| 12749 resolve(source); | 13132 resolve(source); |
| 12750 assertErrors([StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBE
R]); | 13133 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTAN
CE_MEMBER]); |
| 12751 verify([source]); | 13134 verify([source]); |
| 12752 } | 13135 } |
| 12753 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() { | 13136 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() { |
| 12754 Source source = addSource(EngineTestCase.createSource(["class A {", " x() {
}", " static set x(int p) {}", "}"])); | 13137 Source source = addSource(EngineTestCase.createSource(["class A {", " x() {
}", " static set x(int p) {}", "}"])); |
| 12755 resolve(source); | 13138 resolve(source); |
| 12756 assertErrors([StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBE
R]); | 13139 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTAN
CE_MEMBER]); |
| 12757 verify([source]); | 13140 verify([source]); |
| 12758 } | 13141 } |
| 12759 void test_constWithAbstractClass() { | 13142 void test_constWithAbstractClass() { |
| 12760 Source source = addSource(EngineTestCase.createSource([ | 13143 Source source = addSource(EngineTestCase.createSource([ |
| 12761 "abstract class A {", | 13144 "abstract class A {", |
| 12762 " const A();", | 13145 " const A();", |
| 12763 "}", | 13146 "}", |
| 12764 "void f() {", | 13147 "void f() {", |
| 12765 " A a = const A();", | 13148 " A a = const A();", |
| 12766 "}"])); | 13149 "}"])); |
| 12767 resolve(source); | 13150 resolve(source); |
| 12768 assertErrors([StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]); | 13151 assertErrors(source, [StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]); |
| 12769 verify([source]); | 13152 verify([source]); |
| 12770 } | 13153 } |
| 12771 void test_equalKeysInMap() { | 13154 void test_equalKeysInMap() { |
| 12772 Source source = addSource(EngineTestCase.createSource(["var m = {'a' : 0, 'b
' : 1, 'a' : 2};"])); | 13155 Source source = addSource(EngineTestCase.createSource(["var m = {'a' : 0, 'b
' : 1, 'a' : 2};"])); |
| 12773 resolve(source); | 13156 resolve(source); |
| 12774 assertErrors([StaticWarningCode.EQUAL_KEYS_IN_MAP]); | 13157 assertErrors(source, [StaticWarningCode.EQUAL_KEYS_IN_MAP]); |
| 12775 verify([source]); | 13158 verify([source]); |
| 12776 } | 13159 } |
| 12777 void test_exportDuplicatedLibraryName() { | 13160 void test_exportDuplicatedLibraryName() { |
| 12778 Source source = addSource(EngineTestCase.createSource([ | 13161 Source source = addSource(EngineTestCase.createSource([ |
| 12779 "library test;", | 13162 "library test;", |
| 12780 "export 'lib1.dart';", | 13163 "export 'lib1.dart';", |
| 12781 "export 'lib2.dart';"])); | 13164 "export 'lib2.dart';"])); |
| 12782 addSource2("/lib1.dart", "library lib;"); | 13165 addSource2("/lib1.dart", "library lib;"); |
| 12783 addSource2("/lib2.dart", "library lib;"); | 13166 addSource2("/lib2.dart", "library lib;"); |
| 12784 resolve(source); | 13167 resolve(source); |
| 12785 assertErrors([StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAME]); | 13168 assertErrors(source, [StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAME]); |
| 12786 verify([source]); | 13169 verify([source]); |
| 12787 } | 13170 } |
| 12788 void test_extraPositionalArguments() { | 13171 void test_extraPositionalArguments() { |
| 12789 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" f(0, 1, '2');", "}"])); | 13172 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" f(0, 1, '2');", "}"])); |
| 12790 resolve(source); | 13173 resolve(source); |
| 12791 assertErrors([StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); | 13174 assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]); |
| 12792 verify([source]); | 13175 verify([source]); |
| 12793 } | 13176 } |
| 12794 void test_fieldInitializedInInitializerAndDeclaration_final() { | 13177 void test_fieldInitializedInInitializerAndDeclaration_final() { |
| 12795 Source source = addSource(EngineTestCase.createSource([ | 13178 Source source = addSource(EngineTestCase.createSource([ |
| 12796 "class A {", | 13179 "class A {", |
| 12797 " final int x = 0;", | 13180 " final int x = 0;", |
| 12798 " A() : x = 1 {}", | 13181 " A() : x = 1 {}", |
| 12799 "}"])); | 13182 "}"])); |
| 12800 resolve(source); | 13183 resolve(source); |
| 12801 assertErrors([StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARA
TION]); | 13184 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND
_DECLARATION]); |
| 12802 verify([source]); | 13185 verify([source]); |
| 12803 } | 13186 } |
| 12804 void test_fieldInitializerNotAssignable() { | 13187 void test_fieldInitializerNotAssignable() { |
| 12805 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A() : x = '';", "}"])); | 13188 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A() : x = '';", "}"])); |
| 12806 resolve(source); | 13189 resolve(source); |
| 12807 assertErrors([StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]); | 13190 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]); |
| 12808 verify([source]); | 13191 verify([source]); |
| 12809 } | 13192 } |
| 12810 void test_fieldInitializingFormalNotAssignable() { | 13193 void test_fieldInitializingFormalNotAssignable() { |
| 12811 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(String this.x) {}", "}"])); | 13194 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(String this.x) {}", "}"])); |
| 12812 resolve(source); | 13195 resolve(source); |
| 12813 assertErrors([StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE]); | 13196 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGN
ABLE]); |
| 12814 verify([source]); | 13197 verify([source]); |
| 12815 } | 13198 } |
| 12816 | 13199 |
| 12817 /** | 13200 /** |
| 12818 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR
code, but tests the | 13201 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR
code, but tests the |
| 12819 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid
ed here to show | 13202 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid
ed here to show |
| 12820 * coverage over all of the permutations of initializers in constructor declar
ations. | 13203 * coverage over all of the permutations of initializers in constructor declar
ations. |
| 12821 * | 13204 * |
| 12822 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of | 13205 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of |
| 12823 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w
e use it instead of | 13206 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w
e use it instead of |
| 12824 * the broader code | 13207 * the broader code |
| 12825 */ | 13208 */ |
| 12826 void test_finalInitializedInDeclarationAndConstructor_initializers() { | 13209 void test_finalInitializedInDeclarationAndConstructor_initializers() { |
| 12827 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " A() : x = 0 {}", "}"])); | 13210 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " A() : x = 0 {}", "}"])); |
| 12828 resolve(source); | 13211 resolve(source); |
| 12829 assertErrors([StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARA
TION]); | 13212 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND
_DECLARATION]); |
| 12830 verify([source]); | 13213 verify([source]); |
| 12831 } | 13214 } |
| 12832 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { | 13215 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { |
| 12833 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " A(this.x) {}", "}"])); | 13216 Source source = addSource(EngineTestCase.createSource(["class A {", " final
x = 0;", " A(this.x) {}", "}"])); |
| 12834 resolve(source); | 13217 resolve(source); |
| 12835 assertErrors([StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRU
CTOR]); | 13218 assertErrors(source, [StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND
_CONSTRUCTOR]); |
| 12836 verify([source]); | 13219 verify([source]); |
| 12837 } | 13220 } |
| 12838 void test_finalNotInitialized_inConstructor() { | 13221 void test_finalNotInitialized_inConstructor() { |
| 12839 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() {}", "}"])); | 13222 Source source = addSource(EngineTestCase.createSource(["class A {", " final
int x;", " A() {}", "}"])); |
| 12840 resolve(source); | 13223 resolve(source); |
| 12841 assertErrors([StaticWarningCode.FINAL_NOT_INITIALIZED]); | 13224 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); |
| 12842 verify([source]); | |
| 12843 } | |
| 12844 void test_finalNotInitialized_instanceField_const_static() { | |
| 12845 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c const F;", "}"])); | |
| 12846 resolve(source); | |
| 12847 assertErrors([StaticWarningCode.FINAL_NOT_INITIALIZED]); | |
| 12848 verify([source]); | 13225 verify([source]); |
| 12849 } | 13226 } |
| 12850 void test_finalNotInitialized_instanceField_final() { | 13227 void test_finalNotInitialized_instanceField_final() { |
| 12851 Source source = addSource(EngineTestCase.createSource(["class A {", " final
F;", "}"])); | 13228 Source source = addSource(EngineTestCase.createSource(["class A {", " final
F;", "}"])); |
| 12852 resolve(source); | 13229 resolve(source); |
| 12853 assertErrors([StaticWarningCode.FINAL_NOT_INITIALIZED]); | 13230 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); |
| 12854 verify([source]); | 13231 verify([source]); |
| 12855 } | 13232 } |
| 12856 void test_finalNotInitialized_instanceField_final_static() { | 13233 void test_finalNotInitialized_instanceField_final_static() { |
| 12857 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c final F;", "}"])); | 13234 Source source = addSource(EngineTestCase.createSource(["class A {", " stati
c final F;", "}"])); |
| 12858 resolve(source); | 13235 resolve(source); |
| 12859 assertErrors([StaticWarningCode.FINAL_NOT_INITIALIZED]); | 13236 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); |
| 12860 verify([source]); | |
| 12861 } | |
| 12862 void test_finalNotInitialized_library_const() { | |
| 12863 Source source = addSource(EngineTestCase.createSource(["const F;"])); | |
| 12864 resolve(source); | |
| 12865 assertErrors([StaticWarningCode.FINAL_NOT_INITIALIZED]); | |
| 12866 verify([source]); | 13237 verify([source]); |
| 12867 } | 13238 } |
| 12868 void test_finalNotInitialized_library_final() { | 13239 void test_finalNotInitialized_library_final() { |
| 12869 Source source = addSource(EngineTestCase.createSource(["final F;"])); | 13240 Source source = addSource(EngineTestCase.createSource(["final F;"])); |
| 12870 resolve(source); | 13241 resolve(source); |
| 12871 assertErrors([StaticWarningCode.FINAL_NOT_INITIALIZED]); | 13242 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); |
| 12872 verify([source]); | |
| 12873 } | |
| 12874 void test_finalNotInitialized_local_const() { | |
| 12875 Source source = addSource(EngineTestCase.createSource(["f() {", " const int
x;", "}"])); | |
| 12876 resolve(source); | |
| 12877 assertErrors([StaticWarningCode.FINAL_NOT_INITIALIZED]); | |
| 12878 verify([source]); | 13243 verify([source]); |
| 12879 } | 13244 } |
| 12880 void test_finalNotInitialized_local_final() { | 13245 void test_finalNotInitialized_local_final() { |
| 12881 Source source = addSource(EngineTestCase.createSource(["f() {", " final int
x;", "}"])); | 13246 Source source = addSource(EngineTestCase.createSource(["f() {", " final int
x;", "}"])); |
| 12882 resolve(source); | 13247 resolve(source); |
| 12883 assertErrors([StaticWarningCode.FINAL_NOT_INITIALIZED]); | 13248 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]); |
| 12884 verify([source]); | 13249 verify([source]); |
| 12885 } | 13250 } |
| 12886 void test_importDuplicatedLibraryName() { | 13251 void test_importDuplicatedLibraryName() { |
| 12887 Source source = addSource(EngineTestCase.createSource([ | 13252 Source source = addSource(EngineTestCase.createSource([ |
| 12888 "library test;", | 13253 "library test;", |
| 12889 "import 'lib1.dart';", | 13254 "import 'lib1.dart';", |
| 12890 "import 'lib2.dart';"])); | 13255 "import 'lib2.dart';"])); |
| 12891 addSource2("/lib1.dart", "library lib;"); | 13256 addSource2("/lib1.dart", "library lib;"); |
| 12892 addSource2("/lib2.dart", "library lib;"); | 13257 addSource2("/lib2.dart", "library lib;"); |
| 12893 resolve(source); | 13258 resolve(source); |
| 12894 assertErrors([ | 13259 assertErrors(source, [ |
| 12895 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAME, | 13260 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAME, |
| 12896 HintCode.UNUSED_IMPORT, | 13261 HintCode.UNUSED_IMPORT, |
| 12897 HintCode.UNUSED_IMPORT]); | 13262 HintCode.UNUSED_IMPORT]); |
| 12898 verify([source]); | 13263 verify([source]); |
| 12899 } | 13264 } |
| 12900 void test_inconsistentMethodInheritanceGetterAndMethod() { | 13265 void test_inconsistentMethodInheritanceGetterAndMethod() { |
| 12901 Source source = addSource(EngineTestCase.createSource([ | 13266 Source source = addSource(EngineTestCase.createSource([ |
| 12902 "abstract class A {", | 13267 "abstract class A {", |
| 12903 " int x();", | 13268 " int x();", |
| 12904 "}", | 13269 "}", |
| 12905 "abstract class B {", | 13270 "abstract class B {", |
| 12906 " int get x;", | 13271 " int get x;", |
| 12907 "}", | 13272 "}", |
| 12908 "class C implements A, B {", | 13273 "class C implements A, B {", |
| 12909 "}"])); | 13274 "}"])); |
| 12910 resolve(source); | 13275 resolve(source); |
| 12911 assertErrors([StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_M
ETHOD]); | 13276 assertErrors(source, [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETT
ER_AND_METHOD]); |
| 12912 verify([source]); | 13277 verify([source]); |
| 12913 } | 13278 } |
| 12914 void test_instanceMethodNameCollidesWithSuperclassStatic_field() { | 13279 void test_instanceMethodNameCollidesWithSuperclassStatic_field() { |
| 12915 Source source = addSource(EngineTestCase.createSource([ | 13280 Source source = addSource(EngineTestCase.createSource([ |
| 12916 "class A {", | 13281 "class A {", |
| 12917 " static var n;", | 13282 " static var n;", |
| 12918 "}", | 13283 "}", |
| 12919 "class B extends A {", | 13284 "class B extends A {", |
| 12920 " void n() {}", | 13285 " void n() {}", |
| 12921 "}"])); | 13286 "}"])); |
| 12922 resolve(source); | 13287 resolve(source); |
| 12923 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS
S_STATIC]); | 13288 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 12924 verify([source]); | 13289 verify([source]); |
| 12925 } | 13290 } |
| 12926 void test_instanceMethodNameCollidesWithSuperclassStatic_field2() { | 13291 void test_instanceMethodNameCollidesWithSuperclassStatic_field2() { |
| 12927 Source source = addSource(EngineTestCase.createSource([ | 13292 Source source = addSource(EngineTestCase.createSource([ |
| 12928 "class A {", | 13293 "class A {", |
| 12929 " static var n;", | 13294 " static var n;", |
| 12930 "}", | 13295 "}", |
| 12931 "class B extends A {", | 13296 "class B extends A {", |
| 12932 "}", | 13297 "}", |
| 12933 "class C extends B {", | 13298 "class C extends B {", |
| 12934 " void n() {}", | 13299 " void n() {}", |
| 12935 "}"])); | 13300 "}"])); |
| 12936 resolve(source); | 13301 resolve(source); |
| 12937 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS
S_STATIC]); | 13302 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 12938 verify([source]); | 13303 verify([source]); |
| 12939 } | 13304 } |
| 12940 void test_instanceMethodNameCollidesWithSuperclassStatic_getter() { | 13305 void test_instanceMethodNameCollidesWithSuperclassStatic_getter() { |
| 12941 Source source = addSource(EngineTestCase.createSource([ | 13306 Source source = addSource(EngineTestCase.createSource([ |
| 12942 "class A {", | 13307 "class A {", |
| 12943 " static get n {return 0;}", | 13308 " static get n {return 0;}", |
| 12944 "}", | 13309 "}", |
| 12945 "class B extends A {", | 13310 "class B extends A {", |
| 12946 " void n() {}", | 13311 " void n() {}", |
| 12947 "}"])); | 13312 "}"])); |
| 12948 resolve(source); | 13313 resolve(source); |
| 12949 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS
S_STATIC]); | 13314 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 12950 verify([source]); | 13315 verify([source]); |
| 12951 } | 13316 } |
| 12952 void test_instanceMethodNameCollidesWithSuperclassStatic_getter2() { | 13317 void test_instanceMethodNameCollidesWithSuperclassStatic_getter2() { |
| 12953 Source source = addSource(EngineTestCase.createSource([ | 13318 Source source = addSource(EngineTestCase.createSource([ |
| 12954 "class A {", | 13319 "class A {", |
| 12955 " static get n {return 0;}", | 13320 " static get n {return 0;}", |
| 12956 "}", | 13321 "}", |
| 12957 "class B extends A {", | 13322 "class B extends A {", |
| 12958 "}", | 13323 "}", |
| 12959 "class C extends B {", | 13324 "class C extends B {", |
| 12960 " void n() {}", | 13325 " void n() {}", |
| 12961 "}"])); | 13326 "}"])); |
| 12962 resolve(source); | 13327 resolve(source); |
| 12963 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS
S_STATIC]); | 13328 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 12964 verify([source]); | 13329 verify([source]); |
| 12965 } | 13330 } |
| 12966 void test_instanceMethodNameCollidesWithSuperclassStatic_method() { | 13331 void test_instanceMethodNameCollidesWithSuperclassStatic_method() { |
| 12967 Source source = addSource(EngineTestCase.createSource([ | 13332 Source source = addSource(EngineTestCase.createSource([ |
| 12968 "class A {", | 13333 "class A {", |
| 12969 " static n () {}", | 13334 " static n () {}", |
| 12970 "}", | 13335 "}", |
| 12971 "class B extends A {", | 13336 "class B extends A {", |
| 12972 " void n() {}", | 13337 " void n() {}", |
| 12973 "}"])); | 13338 "}"])); |
| 12974 resolve(source); | 13339 resolve(source); |
| 12975 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS
S_STATIC]); | 13340 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 12976 verify([source]); | 13341 verify([source]); |
| 12977 } | 13342 } |
| 12978 void test_instanceMethodNameCollidesWithSuperclassStatic_method2() { | 13343 void test_instanceMethodNameCollidesWithSuperclassStatic_method2() { |
| 12979 Source source = addSource(EngineTestCase.createSource([ | 13344 Source source = addSource(EngineTestCase.createSource([ |
| 12980 "class A {", | 13345 "class A {", |
| 12981 " static n () {}", | 13346 " static n () {}", |
| 12982 "}", | 13347 "}", |
| 12983 "class B extends A {", | 13348 "class B extends A {", |
| 12984 "}", | 13349 "}", |
| 12985 "class C extends B {", | 13350 "class C extends B {", |
| 12986 " void n() {}", | 13351 " void n() {}", |
| 12987 "}"])); | 13352 "}"])); |
| 12988 resolve(source); | 13353 resolve(source); |
| 12989 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS
S_STATIC]); | 13354 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 12990 verify([source]); | 13355 verify([source]); |
| 12991 } | 13356 } |
| 12992 void test_instanceMethodNameCollidesWithSuperclassStatic_setter() { | 13357 void test_instanceMethodNameCollidesWithSuperclassStatic_setter() { |
| 12993 Source source = addSource(EngineTestCase.createSource([ | 13358 Source source = addSource(EngineTestCase.createSource([ |
| 12994 "class A {", | 13359 "class A {", |
| 12995 " static set n(int x) {}", | 13360 " static set n(int x) {}", |
| 12996 "}", | 13361 "}", |
| 12997 "class B extends A {", | 13362 "class B extends A {", |
| 12998 " void n() {}", | 13363 " void n() {}", |
| 12999 "}"])); | 13364 "}"])); |
| 13000 resolve(source); | 13365 resolve(source); |
| 13001 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS
S_STATIC]); | 13366 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 13002 verify([source]); | 13367 verify([source]); |
| 13003 } | 13368 } |
| 13004 void test_instanceMethodNameCollidesWithSuperclassStatic_setter2() { | 13369 void test_instanceMethodNameCollidesWithSuperclassStatic_setter2() { |
| 13005 Source source = addSource(EngineTestCase.createSource([ | 13370 Source source = addSource(EngineTestCase.createSource([ |
| 13006 "class A {", | 13371 "class A {", |
| 13007 " static set n(int x) {}", | 13372 " static set n(int x) {}", |
| 13008 "}", | 13373 "}", |
| 13009 "class B extends A {", | 13374 "class B extends A {", |
| 13010 "}", | 13375 "}", |
| 13011 "class C extends B {", | 13376 "class C extends B {", |
| 13012 " void n() {}", | 13377 " void n() {}", |
| 13013 "}"])); | 13378 "}"])); |
| 13014 resolve(source); | 13379 resolve(source); |
| 13015 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS
S_STATIC]); | 13380 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S
UPERCLASS_STATIC]); |
| 13016 verify([source]); | 13381 verify([source]); |
| 13017 } | 13382 } |
| 13018 void test_invalidGetterOverrideReturnType() { | 13383 void test_invalidGetterOverrideReturnType() { |
| 13019 Source source = addSource(EngineTestCase.createSource([ | 13384 Source source = addSource(EngineTestCase.createSource([ |
| 13020 "class A {", | 13385 "class A {", |
| 13021 " int get g { return 0; }", | 13386 " int get g { return 0; }", |
| 13022 "}", | 13387 "}", |
| 13023 "class B extends A {", | 13388 "class B extends A {", |
| 13024 " String get g { return 'a'; }", | 13389 " String get g { return 'a'; }", |
| 13025 "}"])); | 13390 "}"])); |
| 13026 resolve(source); | 13391 resolve(source); |
| 13027 assertErrors([StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]); | 13392 assertErrors(source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]
); |
| 13028 verify([source]); | 13393 verify([source]); |
| 13029 } | 13394 } |
| 13030 void test_invalidGetterOverrideReturnType_implicit() { | 13395 void test_invalidGetterOverrideReturnType_implicit() { |
| 13031 Source source = addSource(EngineTestCase.createSource([ | 13396 Source source = addSource(EngineTestCase.createSource([ |
| 13032 "class A {", | 13397 "class A {", |
| 13033 " String f;", | 13398 " String f;", |
| 13034 "}", | 13399 "}", |
| 13035 "class B extends A {", | 13400 "class B extends A {", |
| 13036 " int f;", | 13401 " int f;", |
| 13037 "}"])); | 13402 "}"])); |
| 13038 resolve(source); | 13403 resolve(source); |
| 13039 assertErrors([ | 13404 assertErrors(source, [ |
| 13040 StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE, | 13405 StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE, |
| 13041 StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]); | 13406 StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]); |
| 13042 verify([source]); | 13407 verify([source]); |
| 13043 } | 13408 } |
| 13044 void test_invalidMethodOverrideNamedParamType() { | 13409 void test_invalidMethodOverrideNamedParamType() { |
| 13045 Source source = addSource(EngineTestCase.createSource([ | 13410 Source source = addSource(EngineTestCase.createSource([ |
| 13046 "class A {", | 13411 "class A {", |
| 13047 " m({int a}) {}", | 13412 " m({int a}) {}", |
| 13048 "}", | 13413 "}", |
| 13049 "class B implements A {", | 13414 "class B implements A {", |
| 13050 " m({String a}) {}", | 13415 " m({String a}) {}", |
| 13051 "}"])); | 13416 "}"])); |
| 13052 resolve(source); | 13417 resolve(source); |
| 13053 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE]); | 13418 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_
TYPE]); |
| 13054 verify([source]); | 13419 verify([source]); |
| 13055 } | 13420 } |
| 13056 void test_invalidMethodOverrideNormalParamType() { | 13421 void test_invalidMethodOverrideNormalParamType() { |
| 13057 Source source = addSource(EngineTestCase.createSource([ | 13422 Source source = addSource(EngineTestCase.createSource([ |
| 13058 "class A {", | 13423 "class A {", |
| 13059 " m(int a) {}", | 13424 " m(int a) {}", |
| 13060 "}", | 13425 "}", |
| 13061 "class B implements A {", | 13426 "class B implements A {", |
| 13062 " m(String a) {}", | 13427 " m(String a) {}", |
| 13063 "}"])); | 13428 "}"])); |
| 13064 resolve(source); | 13429 resolve(source); |
| 13065 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]); | 13430 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM
_TYPE]); |
| 13066 verify([source]); | 13431 verify([source]); |
| 13067 } | 13432 } |
| 13068 void test_invalidMethodOverrideOptionalParamType() { | 13433 void test_invalidMethodOverrideOptionalParamType() { |
| 13069 Source source = addSource(EngineTestCase.createSource([ | 13434 Source source = addSource(EngineTestCase.createSource([ |
| 13070 "class A {", | 13435 "class A {", |
| 13071 " m([int a]) {}", | 13436 " m([int a]) {}", |
| 13072 "}", | 13437 "}", |
| 13073 "class B implements A {", | 13438 "class B implements A {", |
| 13074 " m([String a]) {}", | 13439 " m([String a]) {}", |
| 13075 "}"])); | 13440 "}"])); |
| 13076 resolve(source); | 13441 resolve(source); |
| 13077 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE]
); | 13442 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PAR
AM_TYPE]); |
| 13078 verify([source]); | 13443 verify([source]); |
| 13079 } | 13444 } |
| 13080 void test_invalidMethodOverrideReturnType_interface() { | 13445 void test_invalidMethodOverrideReturnType_interface() { |
| 13081 Source source = addSource(EngineTestCase.createSource([ | 13446 Source source = addSource(EngineTestCase.createSource([ |
| 13082 "class A {", | 13447 "class A {", |
| 13083 " int m() { return 0; }", | 13448 " int m() { return 0; }", |
| 13084 "}", | 13449 "}", |
| 13085 "class B implements A {", | 13450 "class B implements A {", |
| 13086 " String m() { return 'a'; }", | 13451 " String m() { return 'a'; }", |
| 13087 "}"])); | 13452 "}"])); |
| 13088 resolve(source); | 13453 resolve(source); |
| 13089 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); | 13454 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 13090 verify([source]); | 13455 verify([source]); |
| 13091 } | 13456 } |
| 13092 void test_invalidMethodOverrideReturnType_interface2() { | 13457 void test_invalidMethodOverrideReturnType_interface2() { |
| 13093 Source source = addSource(EngineTestCase.createSource([ | 13458 Source source = addSource(EngineTestCase.createSource([ |
| 13094 "abstract class A {", | 13459 "abstract class A {", |
| 13095 " int m();", | 13460 " int m();", |
| 13096 "}", | 13461 "}", |
| 13097 "abstract class B implements A {", | 13462 "abstract class B implements A {", |
| 13098 "}", | 13463 "}", |
| 13099 "class C implements B {", | 13464 "class C implements B {", |
| 13100 " String m() { return 'a'; }", | 13465 " String m() { return 'a'; }", |
| 13101 "}"])); | 13466 "}"])); |
| 13102 resolve(source); | 13467 resolve(source); |
| 13103 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); | 13468 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 13104 verify([source]); | 13469 verify([source]); |
| 13105 } | 13470 } |
| 13106 void test_invalidMethodOverrideReturnType_mixin() { | 13471 void test_invalidMethodOverrideReturnType_mixin() { |
| 13107 Source source = addSource(EngineTestCase.createSource([ | 13472 Source source = addSource(EngineTestCase.createSource([ |
| 13108 "class A {", | 13473 "class A {", |
| 13109 " int m() { return 0; }", | 13474 " int m() { return 0; }", |
| 13110 "}", | 13475 "}", |
| 13111 "class B extends Object with A {", | 13476 "class B extends Object with A {", |
| 13112 " String m() { return 'a'; }", | 13477 " String m() { return 'a'; }", |
| 13113 "}"])); | 13478 "}"])); |
| 13114 resolve(source); | 13479 resolve(source); |
| 13115 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); | 13480 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 13116 verify([source]); | 13481 verify([source]); |
| 13117 } | 13482 } |
| 13118 void test_invalidMethodOverrideReturnType_superclass() { | 13483 void test_invalidMethodOverrideReturnType_superclass() { |
| 13119 Source source = addSource(EngineTestCase.createSource([ | 13484 Source source = addSource(EngineTestCase.createSource([ |
| 13120 "class A {", | 13485 "class A {", |
| 13121 " int m() { return 0; }", | 13486 " int m() { return 0; }", |
| 13122 "}", | 13487 "}", |
| 13123 "class B extends A {", | 13488 "class B extends A {", |
| 13124 " String m() { return 'a'; }", | 13489 " String m() { return 'a'; }", |
| 13125 "}"])); | 13490 "}"])); |
| 13126 resolve(source); | 13491 resolve(source); |
| 13127 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); | 13492 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 13128 verify([source]); | 13493 verify([source]); |
| 13129 } | 13494 } |
| 13130 void test_invalidMethodOverrideReturnType_superclass2() { | 13495 void test_invalidMethodOverrideReturnType_superclass2() { |
| 13131 Source source = addSource(EngineTestCase.createSource([ | 13496 Source source = addSource(EngineTestCase.createSource([ |
| 13132 "class A {", | 13497 "class A {", |
| 13133 " int m() { return 0; }", | 13498 " int m() { return 0; }", |
| 13134 "}", | 13499 "}", |
| 13135 "class B extends A {", | 13500 "class B extends A {", |
| 13136 "}", | 13501 "}", |
| 13137 "class C extends B {", | 13502 "class C extends B {", |
| 13138 " String m() { return 'a'; }", | 13503 " String m() { return 'a'; }", |
| 13139 "}"])); | 13504 "}"])); |
| 13140 resolve(source); | 13505 resolve(source); |
| 13141 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); | 13506 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 13142 verify([source]); | 13507 verify([source]); |
| 13143 } | 13508 } |
| 13144 void test_invalidMethodOverrideReturnType_void() { | 13509 void test_invalidMethodOverrideReturnType_void() { |
| 13145 Source source = addSource(EngineTestCase.createSource([ | 13510 Source source = addSource(EngineTestCase.createSource([ |
| 13146 "class A {", | 13511 "class A {", |
| 13147 " int m() {}", | 13512 " int m() {}", |
| 13148 "}", | 13513 "}", |
| 13149 "class B extends A {", | 13514 "class B extends A {", |
| 13150 " void m() {}", | 13515 " void m() {}", |
| 13151 "}"])); | 13516 "}"])); |
| 13152 resolve(source); | 13517 resolve(source); |
| 13153 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); | 13518 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]
); |
| 13154 verify([source]); | 13519 verify([source]); |
| 13155 } | 13520 } |
| 13156 void test_invalidOverrideDifferentDefaultValues_named() { | 13521 void test_invalidOverrideDifferentDefaultValues_named() { |
| 13157 Source source = addSource(EngineTestCase.createSource([ | 13522 Source source = addSource(EngineTestCase.createSource([ |
| 13158 "class A {", | 13523 "class A {", |
| 13159 " m({int p : 0}) {}", | 13524 " m({int p : 0}) {}", |
| 13160 "}", | 13525 "}", |
| 13161 "class B extends A {", | 13526 "class B extends A {", |
| 13162 " m({int p : 1}) {}", | 13527 " m({int p : 1}) {}", |
| 13163 "}"])); | 13528 "}"])); |
| 13164 resolve(source); | 13529 resolve(source); |
| 13165 assertErrors([StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NA
MED]); | 13530 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_V
ALUES_NAMED]); |
| 13166 verify([source]); | 13531 verify([source]); |
| 13167 } | 13532 } |
| 13168 void test_invalidOverrideDifferentDefaultValues_positional() { | 13533 void test_invalidOverrideDifferentDefaultValues_positional() { |
| 13169 Source source = addSource(EngineTestCase.createSource([ | 13534 Source source = addSource(EngineTestCase.createSource([ |
| 13170 "class A {", | 13535 "class A {", |
| 13171 " m([int p = 0]) {}", | 13536 " m([int p = 0]) {}", |
| 13172 "}", | 13537 "}", |
| 13173 "class B extends A {", | 13538 "class B extends A {", |
| 13174 " m([int p = 1]) {}", | 13539 " m([int p = 1]) {}", |
| 13175 "}"])); | 13540 "}"])); |
| 13176 resolve(source); | 13541 resolve(source); |
| 13177 assertErrors([StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_PO
SITIONAL]); | 13542 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_V
ALUES_POSITIONAL]); |
| 13178 verify([source]); | 13543 verify([source]); |
| 13179 } | 13544 } |
| 13180 void test_invalidOverrideNamed_fewerNamedParameters() { | 13545 void test_invalidOverrideNamed_fewerNamedParameters() { |
| 13181 Source source = addSource(EngineTestCase.createSource([ | 13546 Source source = addSource(EngineTestCase.createSource([ |
| 13182 "class A {", | 13547 "class A {", |
| 13183 " m({a, b}) {}", | 13548 " m({a, b}) {}", |
| 13184 "}", | 13549 "}", |
| 13185 "class B extends A {", | 13550 "class B extends A {", |
| 13186 " m({a}) {}", | 13551 " m({a}) {}", |
| 13187 "}"])); | 13552 "}"])); |
| 13188 resolve(source); | 13553 resolve(source); |
| 13189 assertErrors([StaticWarningCode.INVALID_OVERRIDE_NAMED]); | 13554 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]); |
| 13190 verify([source]); | 13555 verify([source]); |
| 13191 } | 13556 } |
| 13192 void test_invalidOverrideNamed_missingNamedParameter() { | 13557 void test_invalidOverrideNamed_missingNamedParameter() { |
| 13193 Source source = addSource(EngineTestCase.createSource([ | 13558 Source source = addSource(EngineTestCase.createSource([ |
| 13194 "class A {", | 13559 "class A {", |
| 13195 " m({a, b}) {}", | 13560 " m({a, b}) {}", |
| 13196 "}", | 13561 "}", |
| 13197 "class B extends A {", | 13562 "class B extends A {", |
| 13198 " m({a, c}) {}", | 13563 " m({a, c}) {}", |
| 13199 "}"])); | 13564 "}"])); |
| 13200 resolve(source); | 13565 resolve(source); |
| 13201 assertErrors([StaticWarningCode.INVALID_OVERRIDE_NAMED]); | 13566 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]); |
| 13202 verify([source]); | 13567 verify([source]); |
| 13203 } | 13568 } |
| 13204 void test_invalidOverridePositional() { | 13569 void test_invalidOverridePositional() { |
| 13205 Source source = addSource(EngineTestCase.createSource([ | 13570 Source source = addSource(EngineTestCase.createSource([ |
| 13206 "class A {", | 13571 "class A {", |
| 13207 " m([a, b]) {}", | 13572 " m([a, b]) {}", |
| 13208 "}", | 13573 "}", |
| 13209 "class B extends A {", | 13574 "class B extends A {", |
| 13210 " m([a]) {}", | 13575 " m([a]) {}", |
| 13211 "}"])); | 13576 "}"])); |
| 13212 resolve(source); | 13577 resolve(source); |
| 13213 assertErrors([StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); | 13578 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]); |
| 13214 verify([source]); | 13579 verify([source]); |
| 13215 } | 13580 } |
| 13216 void test_invalidOverrideRequired() { | 13581 void test_invalidOverrideRequired() { |
| 13217 Source source = addSource(EngineTestCase.createSource([ | 13582 Source source = addSource(EngineTestCase.createSource([ |
| 13218 "class A {", | 13583 "class A {", |
| 13219 " m(a) {}", | 13584 " m(a) {}", |
| 13220 "}", | 13585 "}", |
| 13221 "class B extends A {", | 13586 "class B extends A {", |
| 13222 " m(a, b) {}", | 13587 " m(a, b) {}", |
| 13223 "}"])); | 13588 "}"])); |
| 13224 resolve(source); | 13589 resolve(source); |
| 13225 assertErrors([StaticWarningCode.INVALID_OVERRIDE_REQUIRED]); | 13590 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_REQUIRED]); |
| 13226 verify([source]); | 13591 verify([source]); |
| 13227 } | 13592 } |
| 13228 void test_invalidSetterOverrideNormalParamType() { | 13593 void test_invalidSetterOverrideNormalParamType() { |
| 13229 Source source = addSource(EngineTestCase.createSource([ | 13594 Source source = addSource(EngineTestCase.createSource([ |
| 13230 "class A {", | 13595 "class A {", |
| 13231 " void set s(int v) {}", | 13596 " void set s(int v) {}", |
| 13232 "}", | 13597 "}", |
| 13233 "class B extends A {", | 13598 "class B extends A {", |
| 13234 " void set s(String v) {}", | 13599 " void set s(String v) {}", |
| 13235 "}"])); | 13600 "}"])); |
| 13236 resolve(source); | 13601 resolve(source); |
| 13237 assertErrors([StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]); | 13602 assertErrors(source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM
_TYPE]); |
| 13238 verify([source]); | 13603 verify([source]); |
| 13239 } | 13604 } |
| 13240 void test_listElementTypeNotAssignable() { | 13605 void test_listElementTypeNotAssignable() { |
| 13241 Source source = addSource(EngineTestCase.createSource(["var v = <String> [42
];"])); | 13606 Source source = addSource(EngineTestCase.createSource(["var v = <String> [42
];"])); |
| 13242 resolve(source); | 13607 resolve(source); |
| 13243 assertErrors([StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]); | 13608 assertErrors(source, [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]); |
| 13244 verify([source]); | 13609 verify([source]); |
| 13245 } | 13610 } |
| 13246 void test_mapKeyTypeNotAssignable() { | 13611 void test_mapKeyTypeNotAssignable() { |
| 13247 Source source = addSource(EngineTestCase.createSource(["var v = <String, int
> {1 : 2};"])); | 13612 Source source = addSource(EngineTestCase.createSource(["var v = <String, int
> {1 : 2};"])); |
| 13248 resolve(source); | 13613 resolve(source); |
| 13249 assertErrors([StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]); | 13614 assertErrors(source, [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]); |
| 13250 verify([source]); | 13615 verify([source]); |
| 13251 } | 13616 } |
| 13252 void test_mapValueTypeNotAssignable() { | 13617 void test_mapValueTypeNotAssignable() { |
| 13253 Source source = addSource(EngineTestCase.createSource(["var v = <String, Str
ing> {'a' : 2};"])); | 13618 Source source = addSource(EngineTestCase.createSource(["var v = <String, Str
ing> {'a' : 2};"])); |
| 13254 resolve(source); | 13619 resolve(source); |
| 13255 assertErrors([StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]); | 13620 assertErrors(source, [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]); |
| 13256 verify([source]); | 13621 verify([source]); |
| 13257 } | 13622 } |
| 13258 void test_mismatchedAccessorTypes_class() { | 13623 void test_mismatchedAccessorTypes_class() { |
| 13259 Source source = addSource(EngineTestCase.createSource([ | 13624 Source source = addSource(EngineTestCase.createSource([ |
| 13260 "class A {", | 13625 "class A {", |
| 13261 " int get g { return 0; }", | 13626 " int get g { return 0; }", |
| 13262 " set g(String v) {}", | 13627 " set g(String v) {}", |
| 13263 "}"])); | 13628 "}"])); |
| 13264 resolve(source); | 13629 resolve(source); |
| 13265 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); | 13630 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; |
| 13266 verify([source]); | 13631 verify([source]); |
| 13267 } | 13632 } |
| 13268 void test_mismatchedAccessorTypes_topLevel() { | 13633 void test_mismatchedAccessorTypes_topLevel() { |
| 13269 Source source = addSource(EngineTestCase.createSource(["int get g { return 0
; }", "set g(String v) {}"])); | 13634 Source source = addSource(EngineTestCase.createSource(["int get g { return 0
; }", "set g(String v) {}"])); |
| 13270 resolve(source); | 13635 resolve(source); |
| 13271 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); | 13636 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; |
| 13272 verify([source]); | 13637 verify([source]); |
| 13273 } | 13638 } |
| 13274 void test_newWithAbstractClass() { | 13639 void test_newWithAbstractClass() { |
| 13275 Source source = addSource(EngineTestCase.createSource([ | 13640 Source source = addSource(EngineTestCase.createSource([ |
| 13276 "abstract class A {}", | 13641 "abstract class A {}", |
| 13277 "void f() {", | 13642 "void f() {", |
| 13278 " A a = new A();", | 13643 " A a = new A();", |
| 13279 "}"])); | 13644 "}"])); |
| 13280 resolve(source); | 13645 resolve(source); |
| 13281 assertErrors([StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]); | 13646 assertErrors(source, [StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]); |
| 13282 verify([source]); | 13647 verify([source]); |
| 13283 } | 13648 } |
| 13284 void test_newWithInvalidTypeParameters() { | 13649 void test_newWithInvalidTypeParameters() { |
| 13285 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() {
return new A<A>(); }"])); | 13650 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() {
return new A<A>(); }"])); |
| 13286 resolve(source); | 13651 resolve(source); |
| 13287 assertErrors([StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); | 13652 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); |
| 13288 verify([source]); | 13653 verify([source]); |
| 13289 } | 13654 } |
| 13290 void test_newWithInvalidTypeParameters_tooFew() { | 13655 void test_newWithInvalidTypeParameters_tooFew() { |
| 13291 Source source = addSource(EngineTestCase.createSource([ | 13656 Source source = addSource(EngineTestCase.createSource([ |
| 13292 "class A {}", | 13657 "class A {}", |
| 13293 "class C<K, V> {}", | 13658 "class C<K, V> {}", |
| 13294 "f(p) {", | 13659 "f(p) {", |
| 13295 " return new C<A>();", | 13660 " return new C<A>();", |
| 13296 "}"])); | 13661 "}"])); |
| 13297 resolve(source); | 13662 resolve(source); |
| 13298 assertErrors([StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); | 13663 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); |
| 13299 verify([source]); | 13664 verify([source]); |
| 13300 } | 13665 } |
| 13301 void test_newWithInvalidTypeParameters_tooMany() { | 13666 void test_newWithInvalidTypeParameters_tooMany() { |
| 13302 Source source = addSource(EngineTestCase.createSource([ | 13667 Source source = addSource(EngineTestCase.createSource([ |
| 13303 "class A {}", | 13668 "class A {}", |
| 13304 "class C<E> {}", | 13669 "class C<E> {}", |
| 13305 "f(p) {", | 13670 "f(p) {", |
| 13306 " return new C<A, A>();", | 13671 " return new C<A, A>();", |
| 13307 "}"])); | 13672 "}"])); |
| 13308 resolve(source); | 13673 resolve(source); |
| 13309 assertErrors([StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); | 13674 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); |
| 13310 verify([source]); | 13675 verify([source]); |
| 13311 } | 13676 } |
| 13312 void test_newWithNonType() { | 13677 void test_newWithNonType() { |
| 13313 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "void f
() {", " var a = new A();", "}"])); | 13678 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "void f
() {", " var a = new A();", "}"])); |
| 13314 resolve(source); | 13679 resolve(source); |
| 13315 assertErrors([StaticWarningCode.NEW_WITH_NON_TYPE]); | 13680 assertErrors(source, [StaticWarningCode.NEW_WITH_NON_TYPE]); |
| 13316 verify([source]); | 13681 verify([source]); |
| 13317 } | 13682 } |
| 13318 void test_newWithNonType_fromLibrary() { | 13683 void test_newWithNonType_fromLibrary() { |
| 13319 Source source1 = addSource2("lib.dart", "class B {}"); | 13684 Source source1 = addSource2("lib.dart", "class B {}"); |
| 13320 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ | 13685 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ |
| 13321 "import 'lib.dart' as lib;", | 13686 "import 'lib.dart' as lib;", |
| 13322 "void f() {", | 13687 "void f() {", |
| 13323 " var a = new lib.A();", | 13688 " var a = new lib.A();", |
| 13324 "}", | 13689 "}", |
| 13325 "lib.B b;"])); | 13690 "lib.B b;"])); |
| 13326 resolve(source1); | 13691 resolve(source1); |
| 13327 resolve(source2); | 13692 resolve(source2); |
| 13328 assertErrors([StaticWarningCode.NEW_WITH_NON_TYPE]); | 13693 assertErrors(source2, [StaticWarningCode.NEW_WITH_NON_TYPE]); |
| 13329 verify([source1]); | 13694 verify([source1]); |
| 13330 } | 13695 } |
| 13331 void test_newWithUndefinedConstructor() { | 13696 void test_newWithUndefinedConstructor() { |
| 13332 Source source = addSource(EngineTestCase.createSource([ | 13697 Source source = addSource(EngineTestCase.createSource([ |
| 13333 "class A {", | 13698 "class A {", |
| 13334 " A() {}", | 13699 " A() {}", |
| 13335 "}", | 13700 "}", |
| 13336 "f() {", | 13701 "f() {", |
| 13337 " new A.name();", | 13702 " new A.name();", |
| 13338 "}"])); | 13703 "}"])); |
| 13339 resolve(source); | 13704 resolve(source); |
| 13340 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]); | 13705 assertErrors(source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]); |
| 13341 } | 13706 } |
| 13342 void test_newWithUndefinedConstructorDefault() { | 13707 void test_newWithUndefinedConstructorDefault() { |
| 13343 Source source = addSource(EngineTestCase.createSource([ | 13708 Source source = addSource(EngineTestCase.createSource([ |
| 13344 "class A {", | 13709 "class A {", |
| 13345 " A.name() {}", | 13710 " A.name() {}", |
| 13346 "}", | 13711 "}", |
| 13347 "f() {", | 13712 "f() {", |
| 13348 " new A();", | 13713 " new A();", |
| 13349 "}"])); | 13714 "}"])); |
| 13350 resolve(source); | 13715 resolve(source); |
| 13351 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]); | 13716 assertErrors(source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAU
LT]); |
| 13352 verify([source]); | 13717 verify([source]); |
| 13353 } | 13718 } |
| 13354 void test_nonAbstractClassInheritsAbstractMemberFivePlus() { | 13719 void test_nonAbstractClassInheritsAbstractMemberFivePlus() { |
| 13355 Source source = addSource(EngineTestCase.createSource([ | 13720 Source source = addSource(EngineTestCase.createSource([ |
| 13356 "abstract class A {", | 13721 "abstract class A {", |
| 13357 " m();", | 13722 " m();", |
| 13358 " n();", | 13723 " n();", |
| 13359 " o();", | 13724 " o();", |
| 13360 " p();", | 13725 " p();", |
| 13361 " q();", | 13726 " q();", |
| 13362 "}", | 13727 "}", |
| 13363 "class C extends A {", | 13728 "class C extends A {", |
| 13364 "}"])); | 13729 "}"])); |
| 13365 resolve(source); | 13730 resolve(source); |
| 13366 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
FIVE_PLUS]); | 13731 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_FIVE_PLUS]); |
| 13367 verify([source]); | 13732 verify([source]); |
| 13368 } | 13733 } |
| 13369 void test_nonAbstractClassInheritsAbstractMemberFour() { | 13734 void test_nonAbstractClassInheritsAbstractMemberFour() { |
| 13370 Source source = addSource(EngineTestCase.createSource([ | 13735 Source source = addSource(EngineTestCase.createSource([ |
| 13371 "abstract class A {", | 13736 "abstract class A {", |
| 13372 " m();", | 13737 " m();", |
| 13373 " n();", | 13738 " n();", |
| 13374 " o();", | 13739 " o();", |
| 13375 " p();", | 13740 " p();", |
| 13376 "}", | 13741 "}", |
| 13377 "class C extends A {", | 13742 "class C extends A {", |
| 13378 "}"])); | 13743 "}"])); |
| 13379 resolve(source); | 13744 resolve(source); |
| 13380 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
FOUR]); | 13745 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_FOUR]); |
| 13381 verify([source]); | 13746 verify([source]); |
| 13382 } | 13747 } |
| 13383 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterface() { | 13748 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterface() { |
| 13384 Source source = addSource(EngineTestCase.createSource([ | 13749 Source source = addSource(EngineTestCase.createSource([ |
| 13385 "class I {", | 13750 "class I {", |
| 13386 " int get g {return 1;}", | 13751 " int get g {return 1;}", |
| 13387 "}", | 13752 "}", |
| 13388 "class C implements I {", | 13753 "class C implements I {", |
| 13389 "}"])); | 13754 "}"])); |
| 13390 resolve(source); | 13755 resolve(source); |
| 13391 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
ONE]); | 13756 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 13392 verify([source]); | 13757 verify([source]); |
| 13393 } | 13758 } |
| 13394 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperclass() { | 13759 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperclass() { |
| 13395 Source source = addSource(EngineTestCase.createSource([ | 13760 Source source = addSource(EngineTestCase.createSource([ |
| 13396 "abstract class A {", | 13761 "abstract class A {", |
| 13397 " int get g;", | 13762 " int get g;", |
| 13398 "}", | 13763 "}", |
| 13399 "class C extends A {", | 13764 "class C extends A {", |
| 13400 "}"])); | 13765 "}"])); |
| 13401 resolve(source); | 13766 resolve(source); |
| 13402 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
ONE]); | 13767 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 13403 verify([source]); | 13768 verify([source]); |
| 13404 } | 13769 } |
| 13405 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterface() { | 13770 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterface() { |
| 13406 Source source = addSource(EngineTestCase.createSource([ | 13771 Source source = addSource(EngineTestCase.createSource([ |
| 13407 "class I {", | 13772 "class I {", |
| 13408 " m(p) {}", | 13773 " m(p) {}", |
| 13409 "}", | 13774 "}", |
| 13410 "class C implements I {", | 13775 "class C implements I {", |
| 13411 "}"])); | 13776 "}"])); |
| 13412 resolve(source); | 13777 resolve(source); |
| 13413 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
ONE]); | 13778 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 13414 verify([source]); | 13779 verify([source]); |
| 13415 } | 13780 } |
| 13416 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperclass() { | 13781 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperclass() { |
| 13417 Source source = addSource(EngineTestCase.createSource([ | 13782 Source source = addSource(EngineTestCase.createSource([ |
| 13418 "abstract class A {", | 13783 "abstract class A {", |
| 13419 " m(p);", | 13784 " m(p);", |
| 13420 "}", | 13785 "}", |
| 13421 "class C extends A {", | 13786 "class C extends A {", |
| 13422 "}"])); | 13787 "}"])); |
| 13423 resolve(source); | 13788 resolve(source); |
| 13424 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
ONE]); | 13789 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 13425 verify([source]); | 13790 verify([source]); |
| 13426 } | 13791 } |
| 13427 void test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount(
) { | 13792 void test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount(
) { |
| 13428 Source source = addSource(EngineTestCase.createSource([ | 13793 Source source = addSource(EngineTestCase.createSource([ |
| 13429 "abstract class A {", | 13794 "abstract class A {", |
| 13430 " int x(int a);", | 13795 " int x(int a);", |
| 13431 "}", | 13796 "}", |
| 13432 "abstract class B {", | 13797 "abstract class B {", |
| 13433 " int x(int a, [int b]);", | 13798 " int x(int a, [int b]);", |
| 13434 "}", | 13799 "}", |
| 13435 "class C implements A, B {", | 13800 "class C implements A, B {", |
| 13436 "}"])); | 13801 "}"])); |
| 13437 resolve(source); | 13802 resolve(source); |
| 13438 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
ONE]); | 13803 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 13439 verify([source]); | 13804 verify([source]); |
| 13440 } | 13805 } |
| 13441 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterface() { | 13806 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterface() { |
| 13442 Source source = addSource(EngineTestCase.createSource([ | 13807 Source source = addSource(EngineTestCase.createSource([ |
| 13443 "class I {", | 13808 "class I {", |
| 13444 " set s(int i) {}", | 13809 " set s(int i) {}", |
| 13445 "}", | 13810 "}", |
| 13446 "class C implements I {", | 13811 "class C implements I {", |
| 13447 "}"])); | 13812 "}"])); |
| 13448 resolve(source); | 13813 resolve(source); |
| 13449 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
ONE]); | 13814 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 13450 verify([source]); | 13815 verify([source]); |
| 13451 } | 13816 } |
| 13452 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() { | 13817 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() { |
| 13453 Source source = addSource(EngineTestCase.createSource([ | 13818 Source source = addSource(EngineTestCase.createSource([ |
| 13454 "abstract class A {", | 13819 "abstract class A {", |
| 13455 " set s(int i);", | 13820 " set s(int i);", |
| 13456 "}", | 13821 "}", |
| 13457 "class C extends A {", | 13822 "class C extends A {", |
| 13458 "}"])); | 13823 "}"])); |
| 13459 resolve(source); | 13824 resolve(source); |
| 13460 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
ONE]); | 13825 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 13461 verify([source]); | 13826 verify([source]); |
| 13462 } | 13827 } |
| 13463 void test_nonAbstractClassInheritsAbstractMemberOne_superclasses_interface() { | 13828 void test_nonAbstractClassInheritsAbstractMemberOne_superclasses_interface() { |
| 13464 Source source = addSource(EngineTestCase.createSource([ | 13829 Source source = addSource(EngineTestCase.createSource([ |
| 13465 "class A {", | 13830 "class A {", |
| 13466 " get a => 'a';", | 13831 " get a => 'a';", |
| 13467 "}", | 13832 "}", |
| 13468 "abstract class B implements A {", | 13833 "abstract class B implements A {", |
| 13469 " get b => 'b';", | 13834 " get b => 'b';", |
| 13470 "}", | 13835 "}", |
| 13471 "class C extends B {", | 13836 "class C extends B {", |
| 13472 "}"])); | 13837 "}"])); |
| 13473 resolve(source); | 13838 resolve(source); |
| 13474 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
ONE]); | 13839 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_ONE]); |
| 13475 verify([source]); | 13840 verify([source]); |
| 13476 } | 13841 } |
| 13477 void test_nonAbstractClassInheritsAbstractMemberThree() { | 13842 void test_nonAbstractClassInheritsAbstractMemberThree() { |
| 13478 Source source = addSource(EngineTestCase.createSource([ | 13843 Source source = addSource(EngineTestCase.createSource([ |
| 13479 "abstract class A {", | 13844 "abstract class A {", |
| 13480 " m();", | 13845 " m();", |
| 13481 " n();", | 13846 " n();", |
| 13482 " o();", | 13847 " o();", |
| 13483 "}", | 13848 "}", |
| 13484 "class C extends A {", | 13849 "class C extends A {", |
| 13485 "}"])); | 13850 "}"])); |
| 13486 resolve(source); | 13851 resolve(source); |
| 13487 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
THREE]); | 13852 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_THREE]); |
| 13488 verify([source]); | 13853 verify([source]); |
| 13489 } | 13854 } |
| 13490 void test_nonAbstractClassInheritsAbstractMemberTwo() { | 13855 void test_nonAbstractClassInheritsAbstractMemberTwo() { |
| 13491 Source source = addSource(EngineTestCase.createSource([ | 13856 Source source = addSource(EngineTestCase.createSource([ |
| 13492 "abstract class A {", | 13857 "abstract class A {", |
| 13493 " m();", | 13858 " m();", |
| 13494 " n();", | 13859 " n();", |
| 13495 "}", | 13860 "}", |
| 13496 "class C extends A {", | 13861 "class C extends A {", |
| 13497 "}"])); | 13862 "}"])); |
| 13498 resolve(source); | 13863 resolve(source); |
| 13499 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_
TWO]); | 13864 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT
_MEMBER_TWO]); |
| 13500 verify([source]); | 13865 verify([source]); |
| 13501 } | 13866 } |
| 13502 void test_nonTypeInCatchClause_noElement() { | 13867 void test_nonTypeInCatchClause_noElement() { |
| 13503 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", "
} on T catch (e) {", " }", "}"])); | 13868 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", "
} on T catch (e) {", " }", "}"])); |
| 13504 resolve(source); | 13869 resolve(source); |
| 13505 assertErrors([StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); | 13870 assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); |
| 13506 verify([source]); | 13871 verify([source]); |
| 13507 } | 13872 } |
| 13508 void test_nonTypeInCatchClause_notType() { | 13873 void test_nonTypeInCatchClause_notType() { |
| 13509 Source source = addSource(EngineTestCase.createSource([ | 13874 Source source = addSource(EngineTestCase.createSource([ |
| 13510 "var T = 0;", | 13875 "var T = 0;", |
| 13511 "f() {", | 13876 "f() {", |
| 13512 " try {", | 13877 " try {", |
| 13513 " } on T catch (e) {", | 13878 " } on T catch (e) {", |
| 13514 " }", | 13879 " }", |
| 13515 "}"])); | 13880 "}"])); |
| 13516 resolve(source); | 13881 resolve(source); |
| 13517 assertErrors([StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); | 13882 assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); |
| 13518 verify([source]); | 13883 verify([source]); |
| 13519 } | 13884 } |
| 13520 void test_nonVoidReturnForOperator() { | 13885 void test_nonVoidReturnForOperator() { |
| 13521 Source source = addSource(EngineTestCase.createSource(["class A {", " int o
perator []=(a, b) {}", "}"])); | 13886 Source source = addSource(EngineTestCase.createSource(["class A {", " int o
perator []=(a, b) {}", "}"])); |
| 13522 resolve(source); | 13887 resolve(source); |
| 13523 assertErrors([StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]); | 13888 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]); |
| 13524 verify([source]); | 13889 verify([source]); |
| 13525 } | 13890 } |
| 13526 void test_nonVoidReturnForSetter_function() { | 13891 void test_nonVoidReturnForSetter_function() { |
| 13527 Source source = addSource(EngineTestCase.createSource(["int set x(int v) {",
" return 42;", "}"])); | 13892 Source source = addSource(EngineTestCase.createSource(["int set x(int v) {",
" return 42;", "}"])); |
| 13528 resolve(source); | 13893 resolve(source); |
| 13529 assertErrors([StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]); | 13894 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]); |
| 13530 verify([source]); | 13895 verify([source]); |
| 13531 } | 13896 } |
| 13532 void test_nonVoidReturnForSetter_method() { | 13897 void test_nonVoidReturnForSetter_method() { |
| 13533 Source source = addSource(EngineTestCase.createSource([ | 13898 Source source = addSource(EngineTestCase.createSource([ |
| 13534 "class A {", | 13899 "class A {", |
| 13535 " int set x(int v) {", | 13900 " int set x(int v) {", |
| 13536 " return 42;", | 13901 " return 42;", |
| 13537 " }", | 13902 " }", |
| 13538 "}"])); | 13903 "}"])); |
| 13539 resolve(source); | 13904 resolve(source); |
| 13540 assertErrors([StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]); | 13905 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]); |
| 13541 verify([source]); | 13906 verify([source]); |
| 13542 } | 13907 } |
| 13543 void test_notAType() { | 13908 void test_notAType() { |
| 13544 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" f v = null;", "}"])); | 13909 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {",
" f v = null;", "}"])); |
| 13545 resolve(source); | 13910 resolve(source); |
| 13546 assertErrors([StaticWarningCode.NOT_A_TYPE]); | 13911 assertErrors(source, [StaticWarningCode.NOT_A_TYPE]); |
| 13547 verify([source]); | 13912 verify([source]); |
| 13548 } | 13913 } |
| 13549 void test_notEnoughRequiredArguments() { | 13914 void test_notEnoughRequiredArguments() { |
| 13550 Source source = addSource(EngineTestCase.createSource(["f(int a, String b) {
}", "main() {", " f();", "}"])); | 13915 Source source = addSource(EngineTestCase.createSource(["f(int a, String b) {
}", "main() {", " f();", "}"])); |
| 13551 resolve(source); | 13916 resolve(source); |
| 13552 assertErrors([StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); | 13917 assertErrors(source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); |
| 13553 verify([source]); | 13918 verify([source]); |
| 13554 } | 13919 } |
| 13555 void test_partOfDifferentLibrary() { | 13920 void test_partOfDifferentLibrary() { |
| 13556 Source source = addSource(EngineTestCase.createSource(["library lib;", "part
'part.dart';"])); | 13921 Source source = addSource(EngineTestCase.createSource(["library lib;", "part
'part.dart';"])); |
| 13557 addSource2("/part.dart", EngineTestCase.createSource(["part of lub;"])); | 13922 addSource2("/part.dart", EngineTestCase.createSource(["part of lub;"])); |
| 13558 resolve(source); | 13923 resolve(source); |
| 13559 assertErrors([StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]); | 13924 assertErrors(source, [StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]); |
| 13560 verify([source]); | 13925 verify([source]); |
| 13561 } | 13926 } |
| 13562 void test_redirectToInvalidFunctionType() { | 13927 void test_redirectToInvalidFunctionType() { |
| 13563 Source source = addSource(EngineTestCase.createSource([ | 13928 Source source = addSource(EngineTestCase.createSource([ |
| 13564 "class A implements B {", | 13929 "class A implements B {", |
| 13565 " A(int p) {}", | 13930 " A(int p) {}", |
| 13566 "}", | 13931 "}", |
| 13567 "class B {", | 13932 "class B {", |
| 13568 " factory B() = A;", | 13933 " factory B() = A;", |
| 13569 "}"])); | 13934 "}"])); |
| 13570 resolve(source); | 13935 resolve(source); |
| 13571 assertErrors([StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE]); | 13936 assertErrors(source, [StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE]); |
| 13572 verify([source]); | 13937 verify([source]); |
| 13573 } | 13938 } |
| 13574 void test_redirectToInvalidReturnType() { | 13939 void test_redirectToInvalidReturnType() { |
| 13575 Source source = addSource(EngineTestCase.createSource([ | 13940 Source source = addSource(EngineTestCase.createSource([ |
| 13576 "class A {", | 13941 "class A {", |
| 13577 " A() {}", | 13942 " A() {}", |
| 13578 "}", | 13943 "}", |
| 13579 "class B {", | 13944 "class B {", |
| 13580 " factory B() = A;", | 13945 " factory B() = A;", |
| 13581 "}"])); | 13946 "}"])); |
| 13582 resolve(source); | 13947 resolve(source); |
| 13583 assertErrors([StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]); | 13948 assertErrors(source, [StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]); |
| 13584 verify([source]); | 13949 verify([source]); |
| 13585 } | 13950 } |
| 13586 void test_redirectToMissingConstructor_named() { | 13951 void test_redirectToMissingConstructor_named() { |
| 13587 Source source = addSource(EngineTestCase.createSource([ | 13952 Source source = addSource(EngineTestCase.createSource([ |
| 13588 "class A implements B{", | 13953 "class A implements B{", |
| 13589 " A() {}", | 13954 " A() {}", |
| 13590 "}", | 13955 "}", |
| 13591 "class B {", | 13956 "class B {", |
| 13592 " factory B() = A.name;", | 13957 " factory B() = A.name;", |
| 13593 "}"])); | 13958 "}"])); |
| 13594 resolve(source); | 13959 resolve(source); |
| 13595 assertErrors([StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); | 13960 assertErrors(source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); |
| 13596 } | 13961 } |
| 13597 void test_redirectToMissingConstructor_unnamed() { | 13962 void test_redirectToMissingConstructor_unnamed() { |
| 13598 Source source = addSource(EngineTestCase.createSource([ | 13963 Source source = addSource(EngineTestCase.createSource([ |
| 13599 "class A implements B{", | 13964 "class A implements B{", |
| 13600 " A.name() {}", | 13965 " A.name() {}", |
| 13601 "}", | 13966 "}", |
| 13602 "class B {", | 13967 "class B {", |
| 13603 " factory B() = A;", | 13968 " factory B() = A;", |
| 13604 "}"])); | 13969 "}"])); |
| 13605 resolve(source); | 13970 resolve(source); |
| 13606 assertErrors([StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); | 13971 assertErrors(source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); |
| 13607 } | 13972 } |
| 13608 void test_redirectToNonClass_notAType() { | 13973 void test_redirectToNonClass_notAType() { |
| 13609 Source source = addSource(EngineTestCase.createSource(["class B {", " int A
;", " factory B() = A;", "}"])); | 13974 Source source = addSource(EngineTestCase.createSource(["class B {", " int A
;", " factory B() = A;", "}"])); |
| 13610 resolve(source); | 13975 resolve(source); |
| 13611 assertErrors([StaticWarningCode.REDIRECT_TO_NON_CLASS]); | 13976 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); |
| 13612 verify([source]); | 13977 verify([source]); |
| 13613 } | 13978 } |
| 13614 void test_redirectToNonClass_undefinedIdentifier() { | 13979 void test_redirectToNonClass_undefinedIdentifier() { |
| 13615 Source source = addSource(EngineTestCase.createSource(["class B {", " facto
ry B() = A;", "}"])); | 13980 Source source = addSource(EngineTestCase.createSource(["class B {", " facto
ry B() = A;", "}"])); |
| 13616 resolve(source); | 13981 resolve(source); |
| 13617 assertErrors([StaticWarningCode.REDIRECT_TO_NON_CLASS]); | 13982 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]); |
| 13618 verify([source]); | 13983 verify([source]); |
| 13619 } | 13984 } |
| 13620 void test_returnWithoutValue() { | 13985 void test_returnWithoutValue() { |
| 13621 Source source = addSource(EngineTestCase.createSource(["int f() { return; }"
])); | 13986 Source source = addSource(EngineTestCase.createSource(["int f() { return; }"
])); |
| 13622 resolve(source); | 13987 resolve(source); |
| 13623 assertErrors([StaticWarningCode.RETURN_WITHOUT_VALUE]); | 13988 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]); |
| 13624 verify([source]); | 13989 verify([source]); |
| 13625 } | 13990 } |
| 13626 void test_staticAccessToInstanceMember_method_invocation() { | 13991 void test_staticAccessToInstanceMember_method_invocation() { |
| 13627 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", "}", "main() {", " A.m();", "}"])); | 13992 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", "}", "main() {", " A.m();", "}"])); |
| 13628 resolve(source); | 13993 resolve(source); |
| 13629 assertErrors([StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); | 13994 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); |
| 13630 verify([source]); | 13995 verify([source]); |
| 13631 } | 13996 } |
| 13632 void test_staticAccessToInstanceMember_method_reference() { | 13997 void test_staticAccessToInstanceMember_method_reference() { |
| 13633 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", "}", "main() {", " A.m;", "}"])); | 13998 Source source = addSource(EngineTestCase.createSource(["class A {", " m() {
}", "}", "main() {", " A.m;", "}"])); |
| 13634 resolve(source); | 13999 resolve(source); |
| 13635 assertErrors([StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); | 14000 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); |
| 13636 verify([source]); | 14001 verify([source]); |
| 13637 } | 14002 } |
| 13638 void test_staticAccessToInstanceMember_propertyAccess_field() { | 14003 void test_staticAccessToInstanceMember_propertyAccess_field() { |
| 13639 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
;", "}", "main() {", " A.f;", "}"])); | 14004 Source source = addSource(EngineTestCase.createSource(["class A {", " var f
;", "}", "main() {", " A.f;", "}"])); |
| 13640 resolve(source); | 14005 resolve(source); |
| 13641 assertErrors([StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); | 14006 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); |
| 13642 verify([source]); | 14007 verify([source]); |
| 13643 } | 14008 } |
| 13644 void test_staticAccessToInstanceMember_propertyAccess_getter() { | 14009 void test_staticAccessToInstanceMember_propertyAccess_getter() { |
| 13645 Source source = addSource(EngineTestCase.createSource([ | 14010 Source source = addSource(EngineTestCase.createSource([ |
| 13646 "class A {", | 14011 "class A {", |
| 13647 " get f => 42;", | 14012 " get f => 42;", |
| 13648 "}", | 14013 "}", |
| 13649 "main() {", | 14014 "main() {", |
| 13650 " A.f;", | 14015 " A.f;", |
| 13651 "}"])); | 14016 "}"])); |
| 13652 resolve(source); | 14017 resolve(source); |
| 13653 assertErrors([StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); | 14018 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); |
| 13654 verify([source]); | 14019 verify([source]); |
| 13655 } | 14020 } |
| 13656 void test_staticAccessToInstanceMember_propertyAccess_setter() { | 14021 void test_staticAccessToInstanceMember_propertyAccess_setter() { |
| 13657 Source source = addSource(EngineTestCase.createSource([ | 14022 Source source = addSource(EngineTestCase.createSource([ |
| 13658 "class A {", | 14023 "class A {", |
| 13659 " set f(x) {}", | 14024 " set f(x) {}", |
| 13660 "}", | 14025 "}", |
| 13661 "main() {", | 14026 "main() {", |
| 13662 " A.f = 42;", | 14027 " A.f = 42;", |
| 13663 "}"])); | 14028 "}"])); |
| 13664 resolve(source); | 14029 resolve(source); |
| 13665 assertErrors([StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); | 14030 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]); |
| 13666 verify([source]); | 14031 verify([source]); |
| 13667 } | 14032 } |
| 13668 void test_switchExpressionNotAssignable() { | 14033 void test_switchExpressionNotAssignable() { |
| 13669 Source source = addSource(EngineTestCase.createSource([ | 14034 Source source = addSource(EngineTestCase.createSource([ |
| 13670 "f(int p) {", | 14035 "f(int p) {", |
| 13671 " switch (p) {", | 14036 " switch (p) {", |
| 13672 " case 'a': break;", | 14037 " case 'a': break;", |
| 13673 " }", | 14038 " }", |
| 13674 "}"])); | 14039 "}"])); |
| 13675 resolve(source); | 14040 resolve(source); |
| 13676 assertErrors([StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]); | 14041 assertErrors(source, [StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]); |
| 13677 verify([source]); | 14042 verify([source]); |
| 13678 } | 14043 } |
| 13679 void test_typeParameterReferencedByStatic_field() { | 14044 void test_typeParameterReferencedByStatic_field() { |
| 13680 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K k;", "}"])); | 14045 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K k;", "}"])); |
| 13681 resolve(source); | 14046 resolve(source); |
| 13682 assertErrors([StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 14047 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 13683 verify([source]); | 14048 verify([source]); |
| 13684 } | 14049 } |
| 13685 void test_typeParameterReferencedByStatic_getter() { | 14050 void test_typeParameterReferencedByStatic_getter() { |
| 13686 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K get k => 0;", "}"])); | 14051 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K get k => 0;", "}"])); |
| 13687 resolve(source); | 14052 resolve(source); |
| 13688 assertErrors([StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 14053 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 13689 verify([source]); | 14054 verify([source]); |
| 13690 } | 14055 } |
| 13691 void test_typeParameterReferencedByStatic_methodBodyReference() { | 14056 void test_typeParameterReferencedByStatic_methodBodyReference() { |
| 13692 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic m() {", " K k;", " }", "}"])); | 14057 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic m() {", " K k;", " }", "}"])); |
| 13693 resolve(source); | 14058 resolve(source); |
| 13694 assertErrors([StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 14059 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 13695 verify([source]); | 14060 verify([source]); |
| 13696 } | 14061 } |
| 13697 void test_typeParameterReferencedByStatic_methodParameter() { | 14062 void test_typeParameterReferencedByStatic_methodParameter() { |
| 13698 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic m(K k) {}", "}"])); | 14063 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic m(K k) {}", "}"])); |
| 13699 resolve(source); | 14064 resolve(source); |
| 13700 assertErrors([StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 14065 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 13701 verify([source]); | 14066 verify([source]); |
| 13702 } | 14067 } |
| 13703 void test_typeParameterReferencedByStatic_methodReturn() { | 14068 void test_typeParameterReferencedByStatic_methodReturn() { |
| 13704 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K m() {}", "}"])); | 14069 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic K m() {}", "}"])); |
| 13705 resolve(source); | 14070 resolve(source); |
| 13706 assertErrors([StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 14071 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 13707 verify([source]); | 14072 verify([source]); |
| 13708 } | 14073 } |
| 13709 void test_typeParameterReferencedByStatic_setter() { | 14074 void test_typeParameterReferencedByStatic_setter() { |
| 13710 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic set s(K k) {}", "}"])); | 14075 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st
atic set s(K k) {}", "}"])); |
| 13711 resolve(source); | 14076 resolve(source); |
| 13712 assertErrors([StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]); | 14077 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]
); |
| 13713 verify([source]); | 14078 verify([source]); |
| 13714 } | 14079 } |
| 13715 void test_typeTestNonType() { | 14080 void test_typeTestNonType() { |
| 13716 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(var
p) {", " if (p is A) {", " }", "}"])); | 14081 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(var
p) {", " if (p is A) {", " }", "}"])); |
| 13717 resolve(source); | 14082 resolve(source); |
| 13718 assertErrors([StaticWarningCode.TYPE_TEST_NON_TYPE]); | 14083 assertErrors(source, [StaticWarningCode.TYPE_TEST_NON_TYPE]); |
| 13719 verify([source]); | 14084 verify([source]); |
| 13720 } | 14085 } |
| 13721 void test_undefinedClass_instanceCreation() { | 14086 void test_undefinedClass_instanceCreation() { |
| 13722 Source source = addSource(EngineTestCase.createSource(["f() { new C(); }"]))
; | 14087 Source source = addSource(EngineTestCase.createSource(["f() { new C(); }"]))
; |
| 13723 resolve(source); | 14088 resolve(source); |
| 13724 assertErrors([StaticWarningCode.UNDEFINED_CLASS]); | 14089 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]); |
| 13725 } | 14090 } |
| 13726 void test_undefinedClass_variableDeclaration() { | 14091 void test_undefinedClass_variableDeclaration() { |
| 13727 Source source = addSource(EngineTestCase.createSource(["f() { C c; }"])); | 14092 Source source = addSource(EngineTestCase.createSource(["f() { C c; }"])); |
| 13728 resolve(source); | 14093 resolve(source); |
| 13729 assertErrors([StaticWarningCode.UNDEFINED_CLASS]); | 14094 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]); |
| 13730 } | 14095 } |
| 13731 void test_undefinedClassBoolean_variableDeclaration() { | 14096 void test_undefinedClassBoolean_variableDeclaration() { |
| 13732 Source source = addSource(EngineTestCase.createSource(["f() { boolean v; }"]
)); | 14097 Source source = addSource(EngineTestCase.createSource(["f() { boolean v; }"]
)); |
| 13733 resolve(source); | 14098 resolve(source); |
| 13734 assertErrors([StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]); | 14099 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]); |
| 13735 } | 14100 } |
| 13736 void test_undefinedGetter_fromLibrary() { | 14101 void test_undefinedGetter_fromLibrary() { |
| 13737 Source source1 = addSource2("lib.dart", ""); | 14102 Source source1 = addSource2("lib.dart", ""); |
| 13738 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ | 14103 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ |
| 13739 "import 'lib.dart' as lib;", | 14104 "import 'lib.dart' as lib;", |
| 13740 "void f() {", | 14105 "void f() {", |
| 13741 " var g = lib.gg;", | 14106 " var g = lib.gg;", |
| 13742 "}"])); | 14107 "}"])); |
| 13743 resolve(source1); | 14108 resolve(source1); |
| 13744 resolve(source2); | 14109 resolve(source2); |
| 13745 assertErrors([StaticWarningCode.UNDEFINED_GETTER]); | 14110 assertErrors(source2, [StaticWarningCode.UNDEFINED_GETTER]); |
| 13746 verify([source1]); | 14111 verify([source1]); |
| 13747 } | 14112 } |
| 14113 void test_undefinedIdentifier_for() { |
| 14114 Source source = addSource(EngineTestCase.createSource(["f(var l) {", " for
(e in l) {", " }", "}"])); |
| 14115 resolve(source); |
| 14116 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 14117 } |
| 13748 void test_undefinedIdentifier_function() { | 14118 void test_undefinedIdentifier_function() { |
| 13749 Source source = addSource(EngineTestCase.createSource(["int a() => b;"])); | 14119 Source source = addSource(EngineTestCase.createSource(["int a() => b;"])); |
| 13750 resolve(source); | 14120 resolve(source); |
| 13751 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); | 14121 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 13752 } | 14122 } |
| 13753 void test_undefinedIdentifier_function_prefix() { | 14123 void test_undefinedIdentifier_function_prefix() { |
| 13754 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
C {}"])); | 14124 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
C {}"])); |
| 13755 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
b;", "", "int a() => b;", "b.C c;"])); | 14125 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
b;", "", "int a() => b;", "b.C c;"])); |
| 13756 resolve(source); | 14126 resolve(source); |
| 13757 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); | 14127 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 13758 verify([source]); | 14128 verify([source]); |
| 13759 } | 14129 } |
| 13760 void test_undefinedIdentifier_hideInBlock_function() { | 14130 void test_undefinedIdentifier_hideInBlock_function() { |
| 13761 Source source = addSource(EngineTestCase.createSource([ | 14131 Source source = addSource(EngineTestCase.createSource([ |
| 13762 "var v = 1;", | 14132 "var v = 1;", |
| 13763 "main() {", | 14133 "main() {", |
| 13764 " print(v);", | 14134 " print(v);", |
| 13765 " v() {}", | 14135 " v() {}", |
| 13766 "}", | 14136 "}", |
| 13767 "print(x) {}"])); | 14137 "print(x) {}"])); |
| 13768 resolve(source); | 14138 resolve(source); |
| 13769 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); | 14139 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 13770 } | 14140 } |
| 13771 void test_undefinedIdentifier_hideInBlock_local() { | 14141 void test_undefinedIdentifier_hideInBlock_local() { |
| 13772 Source source = addSource(EngineTestCase.createSource([ | 14142 Source source = addSource(EngineTestCase.createSource([ |
| 13773 "var v = 1;", | 14143 "var v = 1;", |
| 13774 "main() {", | 14144 "main() {", |
| 13775 " print(v);", | 14145 " print(v);", |
| 13776 " var v = 2;", | 14146 " var v = 2;", |
| 13777 "}", | 14147 "}", |
| 13778 "print(x) {}"])); | 14148 "print(x) {}"])); |
| 13779 resolve(source); | 14149 resolve(source); |
| 13780 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); | 14150 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 13781 } | 14151 } |
| 13782 void test_undefinedIdentifier_hideInBlock_subBlock() { | 14152 void test_undefinedIdentifier_hideInBlock_subBlock() { |
| 13783 Source source = addSource(EngineTestCase.createSource([ | 14153 Source source = addSource(EngineTestCase.createSource([ |
| 13784 "var v = 1;", | 14154 "var v = 1;", |
| 13785 "main() {", | 14155 "main() {", |
| 13786 " {", | 14156 " {", |
| 13787 " print(v);", | 14157 " print(v);", |
| 13788 " }", | 14158 " }", |
| 13789 " var v = 2;", | 14159 " var v = 2;", |
| 13790 "}", | 14160 "}", |
| 13791 "print(x) {}"])); | 14161 "print(x) {}"])); |
| 13792 resolve(source); | 14162 resolve(source); |
| 13793 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); | 14163 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 13794 } | 14164 } |
| 13795 void test_undefinedIdentifier_initializer() { | 14165 void test_undefinedIdentifier_initializer() { |
| 13796 Source source = addSource(EngineTestCase.createSource(["var a = b;"])); | 14166 Source source = addSource(EngineTestCase.createSource(["var a = b;"])); |
| 13797 resolve(source); | 14167 resolve(source); |
| 13798 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); | 14168 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 13799 } | 14169 } |
| 13800 void test_undefinedIdentifier_initializer_prefix() { | 14170 void test_undefinedIdentifier_initializer_prefix() { |
| 13801 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
C {}"])); | 14171 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class
C {}"])); |
| 13802 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
b;", "", "var a = b;", "b.C c;"])); | 14172 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as
b;", "", "var a = b;", "b.C c;"])); |
| 13803 resolve(source); | 14173 resolve(source); |
| 13804 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); | 14174 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 13805 } | 14175 } |
| 13806 void test_undefinedIdentifier_metadata() { | 14176 void test_undefinedIdentifier_metadata() { |
| 13807 Source source = addSource(EngineTestCase.createSource(["@undefined class A {
}"])); | 14177 Source source = addSource(EngineTestCase.createSource(["@undefined class A {
}"])); |
| 13808 resolve(source); | 14178 resolve(source); |
| 13809 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); | 14179 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 13810 } | 14180 } |
| 13811 void test_undefinedIdentifier_methodInvocation() { | 14181 void test_undefinedIdentifier_methodInvocation() { |
| 13812 Source source = addSource(EngineTestCase.createSource(["f() { C.m(); }"])); | 14182 Source source = addSource(EngineTestCase.createSource(["f() { C.m(); }"])); |
| 13813 resolve(source); | 14183 resolve(source); |
| 13814 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); | 14184 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
| 13815 } | 14185 } |
| 13816 void test_undefinedNamedParameter() { | 14186 void test_undefinedNamedParameter() { |
| 13817 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main
() {", " f(c: 1);", "}"])); | 14187 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main
() {", " f(c: 1);", "}"])); |
| 13818 resolve(source); | 14188 resolve(source); |
| 13819 assertErrors([StaticWarningCode.UNDEFINED_NAMED_PARAMETER]); | 14189 assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]); |
| 13820 } | 14190 } |
| 13821 void test_undefinedSetter() { | 14191 void test_undefinedSetter() { |
| 13822 Source source1 = addSource2("lib.dart", ""); | 14192 Source source1 = addSource2("lib.dart", ""); |
| 13823 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ | 14193 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([ |
| 13824 "import 'lib.dart' as lib;", | 14194 "import 'lib.dart' as lib;", |
| 13825 "void f() {", | 14195 "void f() {", |
| 13826 " lib.gg = null;", | 14196 " lib.gg = null;", |
| 13827 "}"])); | 14197 "}"])); |
| 13828 resolve(source1); | 14198 resolve(source1); |
| 13829 resolve(source2); | 14199 resolve(source2); |
| 13830 assertErrors([StaticWarningCode.UNDEFINED_SETTER]); | 14200 assertErrors(source2, [StaticWarningCode.UNDEFINED_SETTER]); |
| 13831 } | 14201 } |
| 13832 static dartSuite() { | 14202 static dartSuite() { |
| 13833 _ut.group('StaticWarningCodeTest', () { | 14203 _ut.group('StaticWarningCodeTest', () { |
| 13834 _ut.test('test_ambiguousImport_as', () { | 14204 _ut.test('test_ambiguousImport_as', () { |
| 13835 final __test = new StaticWarningCodeTest(); | 14205 final __test = new StaticWarningCodeTest(); |
| 13836 runJUnitTest(__test, __test.test_ambiguousImport_as); | 14206 runJUnitTest(__test, __test.test_ambiguousImport_as); |
| 13837 }); | 14207 }); |
| 13838 _ut.test('test_ambiguousImport_extends', () { | 14208 _ut.test('test_ambiguousImport_extends', () { |
| 13839 final __test = new StaticWarningCodeTest(); | 14209 final __test = new StaticWarningCodeTest(); |
| 13840 runJUnitTest(__test, __test.test_ambiguousImport_extends); | 14210 runJUnitTest(__test, __test.test_ambiguousImport_extends); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14084 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru
ctor_initializers); | 14454 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru
ctor_initializers); |
| 14085 }); | 14455 }); |
| 14086 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializingFor
mal', () { | 14456 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializingFor
mal', () { |
| 14087 final __test = new StaticWarningCodeTest(); | 14457 final __test = new StaticWarningCodeTest(); |
| 14088 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru
ctor_initializingFormal); | 14458 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru
ctor_initializingFormal); |
| 14089 }); | 14459 }); |
| 14090 _ut.test('test_finalNotInitialized_inConstructor', () { | 14460 _ut.test('test_finalNotInitialized_inConstructor', () { |
| 14091 final __test = new StaticWarningCodeTest(); | 14461 final __test = new StaticWarningCodeTest(); |
| 14092 runJUnitTest(__test, __test.test_finalNotInitialized_inConstructor); | 14462 runJUnitTest(__test, __test.test_finalNotInitialized_inConstructor); |
| 14093 }); | 14463 }); |
| 14094 _ut.test('test_finalNotInitialized_instanceField_const_static', () { | |
| 14095 final __test = new StaticWarningCodeTest(); | |
| 14096 runJUnitTest(__test, __test.test_finalNotInitialized_instanceField_const
_static); | |
| 14097 }); | |
| 14098 _ut.test('test_finalNotInitialized_instanceField_final', () { | 14464 _ut.test('test_finalNotInitialized_instanceField_final', () { |
| 14099 final __test = new StaticWarningCodeTest(); | 14465 final __test = new StaticWarningCodeTest(); |
| 14100 runJUnitTest(__test, __test.test_finalNotInitialized_instanceField_final
); | 14466 runJUnitTest(__test, __test.test_finalNotInitialized_instanceField_final
); |
| 14101 }); | 14467 }); |
| 14102 _ut.test('test_finalNotInitialized_instanceField_final_static', () { | 14468 _ut.test('test_finalNotInitialized_instanceField_final_static', () { |
| 14103 final __test = new StaticWarningCodeTest(); | 14469 final __test = new StaticWarningCodeTest(); |
| 14104 runJUnitTest(__test, __test.test_finalNotInitialized_instanceField_final
_static); | 14470 runJUnitTest(__test, __test.test_finalNotInitialized_instanceField_final
_static); |
| 14105 }); | 14471 }); |
| 14106 _ut.test('test_finalNotInitialized_library_const', () { | |
| 14107 final __test = new StaticWarningCodeTest(); | |
| 14108 runJUnitTest(__test, __test.test_finalNotInitialized_library_const); | |
| 14109 }); | |
| 14110 _ut.test('test_finalNotInitialized_library_final', () { | 14472 _ut.test('test_finalNotInitialized_library_final', () { |
| 14111 final __test = new StaticWarningCodeTest(); | 14473 final __test = new StaticWarningCodeTest(); |
| 14112 runJUnitTest(__test, __test.test_finalNotInitialized_library_final); | 14474 runJUnitTest(__test, __test.test_finalNotInitialized_library_final); |
| 14113 }); | 14475 }); |
| 14114 _ut.test('test_finalNotInitialized_local_const', () { | |
| 14115 final __test = new StaticWarningCodeTest(); | |
| 14116 runJUnitTest(__test, __test.test_finalNotInitialized_local_const); | |
| 14117 }); | |
| 14118 _ut.test('test_finalNotInitialized_local_final', () { | 14476 _ut.test('test_finalNotInitialized_local_final', () { |
| 14119 final __test = new StaticWarningCodeTest(); | 14477 final __test = new StaticWarningCodeTest(); |
| 14120 runJUnitTest(__test, __test.test_finalNotInitialized_local_final); | 14478 runJUnitTest(__test, __test.test_finalNotInitialized_local_final); |
| 14121 }); | 14479 }); |
| 14122 _ut.test('test_importDuplicatedLibraryName', () { | 14480 _ut.test('test_importDuplicatedLibraryName', () { |
| 14123 final __test = new StaticWarningCodeTest(); | 14481 final __test = new StaticWarningCodeTest(); |
| 14124 runJUnitTest(__test, __test.test_importDuplicatedLibraryName); | 14482 runJUnitTest(__test, __test.test_importDuplicatedLibraryName); |
| 14125 }); | 14483 }); |
| 14126 _ut.test('test_inconsistentMethodInheritanceGetterAndMethod', () { | 14484 _ut.test('test_inconsistentMethodInheritanceGetterAndMethod', () { |
| 14127 final __test = new StaticWarningCodeTest(); | 14485 final __test = new StaticWarningCodeTest(); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14452 runJUnitTest(__test, __test.test_undefinedClass_instanceCreation); | 14810 runJUnitTest(__test, __test.test_undefinedClass_instanceCreation); |
| 14453 }); | 14811 }); |
| 14454 _ut.test('test_undefinedClass_variableDeclaration', () { | 14812 _ut.test('test_undefinedClass_variableDeclaration', () { |
| 14455 final __test = new StaticWarningCodeTest(); | 14813 final __test = new StaticWarningCodeTest(); |
| 14456 runJUnitTest(__test, __test.test_undefinedClass_variableDeclaration); | 14814 runJUnitTest(__test, __test.test_undefinedClass_variableDeclaration); |
| 14457 }); | 14815 }); |
| 14458 _ut.test('test_undefinedGetter_fromLibrary', () { | 14816 _ut.test('test_undefinedGetter_fromLibrary', () { |
| 14459 final __test = new StaticWarningCodeTest(); | 14817 final __test = new StaticWarningCodeTest(); |
| 14460 runJUnitTest(__test, __test.test_undefinedGetter_fromLibrary); | 14818 runJUnitTest(__test, __test.test_undefinedGetter_fromLibrary); |
| 14461 }); | 14819 }); |
| 14820 _ut.test('test_undefinedIdentifier_for', () { |
| 14821 final __test = new StaticWarningCodeTest(); |
| 14822 runJUnitTest(__test, __test.test_undefinedIdentifier_for); |
| 14823 }); |
| 14462 _ut.test('test_undefinedIdentifier_function', () { | 14824 _ut.test('test_undefinedIdentifier_function', () { |
| 14463 final __test = new StaticWarningCodeTest(); | 14825 final __test = new StaticWarningCodeTest(); |
| 14464 runJUnitTest(__test, __test.test_undefinedIdentifier_function); | 14826 runJUnitTest(__test, __test.test_undefinedIdentifier_function); |
| 14465 }); | 14827 }); |
| 14466 _ut.test('test_undefinedIdentifier_function_prefix', () { | 14828 _ut.test('test_undefinedIdentifier_function_prefix', () { |
| 14467 final __test = new StaticWarningCodeTest(); | 14829 final __test = new StaticWarningCodeTest(); |
| 14468 runJUnitTest(__test, __test.test_undefinedIdentifier_function_prefix); | 14830 runJUnitTest(__test, __test.test_undefinedIdentifier_function_prefix); |
| 14469 }); | 14831 }); |
| 14470 _ut.test('test_undefinedIdentifier_hideInBlock_function', () { | 14832 _ut.test('test_undefinedIdentifier_hideInBlock_function', () { |
| 14471 final __test = new StaticWarningCodeTest(); | 14833 final __test = new StaticWarningCodeTest(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14513 " void m(int i) {", | 14875 " void m(int i) {", |
| 14514 " switch (i) {", | 14876 " switch (i) {", |
| 14515 " l: case 0:", | 14877 " l: case 0:", |
| 14516 " break;", | 14878 " break;", |
| 14517 " case 1:", | 14879 " case 1:", |
| 14518 " break l;", | 14880 " break l;", |
| 14519 " }", | 14881 " }", |
| 14520 " }", | 14882 " }", |
| 14521 "}"])); | 14883 "}"])); |
| 14522 resolve(source); | 14884 resolve(source); |
| 14523 assertErrors([ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]); | 14885 assertErrors(source, [ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]); |
| 14524 verify([source]); | 14886 verify([source]); |
| 14525 } | 14887 } |
| 14526 void test_continueLabelOnSwitch() { | 14888 void test_continueLabelOnSwitch() { |
| 14527 Source source = addSource(EngineTestCase.createSource([ | 14889 Source source = addSource(EngineTestCase.createSource([ |
| 14528 "class A {", | 14890 "class A {", |
| 14529 " void m(int i) {", | 14891 " void m(int i) {", |
| 14530 " l: switch (i) {", | 14892 " l: switch (i) {", |
| 14531 " case 0:", | 14893 " case 0:", |
| 14532 " continue l;", | 14894 " continue l;", |
| 14533 " }", | 14895 " }", |
| 14534 " }", | 14896 " }", |
| 14535 "}"])); | 14897 "}"])); |
| 14536 resolve(source); | 14898 resolve(source); |
| 14537 assertErrors([ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]); | 14899 assertErrors(source, [ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]); |
| 14538 verify([source]); | 14900 verify([source]); |
| 14539 } | 14901 } |
| 14540 static dartSuite() { | 14902 static dartSuite() { |
| 14541 _ut.group('ErrorResolverTest', () { | 14903 _ut.group('ErrorResolverTest', () { |
| 14542 _ut.test('test_breakLabelOnSwitchMember', () { | 14904 _ut.test('test_breakLabelOnSwitchMember', () { |
| 14543 final __test = new ErrorResolverTest(); | 14905 final __test = new ErrorResolverTest(); |
| 14544 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember); | 14906 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember); |
| 14545 }); | 14907 }); |
| 14546 _ut.test('test_continueLabelOnSwitch', () { | 14908 _ut.test('test_continueLabelOnSwitch', () { |
| 14547 final __test = new ErrorResolverTest(); | 14909 final __test = new ErrorResolverTest(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14673 InterfaceType get intType { | 15035 InterfaceType get intType { |
| 14674 if (_intType == null) { | 15036 if (_intType == null) { |
| 14675 initializeNumericTypes(); | 15037 initializeNumericTypes(); |
| 14676 } | 15038 } |
| 14677 return _intType; | 15039 return _intType; |
| 14678 } | 15040 } |
| 14679 InterfaceType get iterableType { | 15041 InterfaceType get iterableType { |
| 14680 if (_iterableType == null) { | 15042 if (_iterableType == null) { |
| 14681 ClassElementImpl iterableElement = ElementFactory.classElement2("Iterable"
, ["E"]); | 15043 ClassElementImpl iterableElement = ElementFactory.classElement2("Iterable"
, ["E"]); |
| 14682 _iterableType = iterableElement.type; | 15044 _iterableType = iterableElement.type; |
| 14683 Type2 eType = iterableElement.typeVariables[0].type; | 15045 Type2 eType = iterableElement.typeParameters[0].type; |
| 14684 iterableElement.accessors = <PropertyAccessorElement> [ | 15046 iterableElement.accessors = <PropertyAccessorElement> [ |
| 14685 ElementFactory.getterElement("iterator", false, iteratorType.substitut
e4(<Type2> [eType])), | 15047 ElementFactory.getterElement("iterator", false, iteratorType.substitut
e4(<Type2> [eType])), |
| 14686 ElementFactory.getterElement("last", false, eType)]; | 15048 ElementFactory.getterElement("last", false, eType)]; |
| 14687 propagateTypeArguments(iterableElement); | 15049 propagateTypeArguments(iterableElement); |
| 14688 } | 15050 } |
| 14689 return _iterableType; | 15051 return _iterableType; |
| 14690 } | 15052 } |
| 14691 InterfaceType get iteratorType { | 15053 InterfaceType get iteratorType { |
| 14692 if (_iteratorType == null) { | 15054 if (_iteratorType == null) { |
| 14693 ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator"
, ["E"]); | 15055 ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator"
, ["E"]); |
| 14694 _iteratorType = iteratorElement.type; | 15056 _iteratorType = iteratorElement.type; |
| 14695 Type2 eType = iteratorElement.typeVariables[0].type; | 15057 Type2 eType = iteratorElement.typeParameters[0].type; |
| 14696 iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.gett
erElement("current", false, eType)]; | 15058 iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.gett
erElement("current", false, eType)]; |
| 14697 propagateTypeArguments(iteratorElement); | 15059 propagateTypeArguments(iteratorElement); |
| 14698 } | 15060 } |
| 14699 return _iteratorType; | 15061 return _iteratorType; |
| 14700 } | 15062 } |
| 14701 InterfaceType get listType { | 15063 InterfaceType get listType { |
| 14702 if (_listType == null) { | 15064 if (_listType == null) { |
| 14703 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"])
; | 15065 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"])
; |
| 14704 listElement.constructors = <ConstructorElement> [ElementFactory.constructo
rElement(listElement, null)]; | 15066 listElement.constructors = <ConstructorElement> [ElementFactory.constructo
rElement(listElement, null)]; |
| 14705 _listType = listElement.type; | 15067 _listType = listElement.type; |
| 14706 Type2 eType = listElement.typeVariables[0].type; | 15068 Type2 eType = listElement.typeParameters[0].type; |
| 14707 InterfaceType iterableType = this.iterableType.substitute4(<Type2> [eType]
); | 15069 InterfaceType iterableType = this.iterableType.substitute4(<Type2> [eType]
); |
| 14708 listElement.interfaces = <InterfaceType> [iterableType]; | 15070 listElement.interfaces = <InterfaceType> [iterableType]; |
| 14709 listElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEl
ement("length", false, intType)]; | 15071 listElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEl
ement("length", false, intType)]; |
| 14710 listElement.methods = <MethodElement> [ | 15072 listElement.methods = <MethodElement> [ |
| 14711 ElementFactory.methodElement("[]", eType, [intType]), | 15073 ElementFactory.methodElement("[]", eType, [intType]), |
| 14712 ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [intType, e
Type]), | 15074 ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [intType, e
Type]), |
| 14713 ElementFactory.methodElement("add", VoidTypeImpl.instance, [eType])]; | 15075 ElementFactory.methodElement("add", VoidTypeImpl.instance, [eType])]; |
| 14714 propagateTypeArguments(listElement); | 15076 propagateTypeArguments(listElement); |
| 14715 } | 15077 } |
| 14716 return _listType; | 15078 return _listType; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14869 ElementFactory.methodElement("toString", _stringType, [])]; | 15231 ElementFactory.methodElement("toString", _stringType, [])]; |
| 14870 } | 15232 } |
| 14871 | 15233 |
| 14872 /** | 15234 /** |
| 14873 * Given a class element representing a class with type parameters, propagate
those type | 15235 * Given a class element representing a class with type parameters, propagate
those type |
| 14874 * parameters to all of the accessors, methods and constructors defined for th
e class. | 15236 * parameters to all of the accessors, methods and constructors defined for th
e class. |
| 14875 * | 15237 * |
| 14876 * @param classElement the element representing the class with type parameters | 15238 * @param classElement the element representing the class with type parameters |
| 14877 */ | 15239 */ |
| 14878 void propagateTypeArguments(ClassElementImpl classElement) { | 15240 void propagateTypeArguments(ClassElementImpl classElement) { |
| 14879 List<Type2> typeArguments = TypeVariableTypeImpl.getTypes(classElement.typeV
ariables); | 15241 List<Type2> typeArguments = TypeParameterTypeImpl.getTypes(classElement.type
Parameters); |
| 14880 for (PropertyAccessorElement accessor in classElement.accessors) { | 15242 for (PropertyAccessorElement accessor in classElement.accessors) { |
| 14881 FunctionTypeImpl functionType = accessor.type as FunctionTypeImpl; | 15243 FunctionTypeImpl functionType = accessor.type as FunctionTypeImpl; |
| 14882 functionType.typeArguments = typeArguments; | 15244 functionType.typeArguments = typeArguments; |
| 14883 } | 15245 } |
| 14884 for (MethodElement method in classElement.methods) { | 15246 for (MethodElement method in classElement.methods) { |
| 14885 FunctionTypeImpl functionType = method.type as FunctionTypeImpl; | 15247 FunctionTypeImpl functionType = method.type as FunctionTypeImpl; |
| 14886 functionType.typeArguments = typeArguments; | 15248 functionType.typeArguments = typeArguments; |
| 14887 } | 15249 } |
| 14888 for (ConstructorElement constructor in classElement.constructors) { | 15250 for (ConstructorElement constructor in classElement.constructors) { |
| 14889 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl; | 15251 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl; |
| 14890 functionType.typeArguments = typeArguments; | 15252 functionType.typeArguments = typeArguments; |
| 14891 } | 15253 } |
| 14892 } | 15254 } |
| 14893 } | 15255 } |
| 14894 /** | 15256 /** |
| 14895 * The class `AnalysisContextFactory` defines utility methods used to create ana
lysis contexts | 15257 * The class `AnalysisContextFactory` defines utility methods used to create ana
lysis contexts |
| 14896 * for testing purposes. | 15258 * for testing purposes. |
| 14897 */ | 15259 */ |
| 14898 class AnalysisContextFactory { | 15260 class AnalysisContextFactory { |
| 14899 | 15261 |
| 14900 /** | 15262 /** |
| 14901 * Create an analysis context that has a fake core library already resolved. | 15263 * Create an analysis context that has a fake core library already resolved. |
| 14902 * | 15264 * |
| 14903 * Added in order to test AnalysisContextImpl2. | |
| 14904 * | |
| 14905 * @return the analysis context that was created | |
| 14906 */ | |
| 14907 static AnalysisContextImpl2 context2WithCore() { | |
| 14908 AnalysisContextImpl2 sdkContext = DirectoryBasedDartSdk.defaultSdk2.context
as AnalysisContextImpl2; | |
| 14909 SourceFactory sourceFactory = sdkContext.sourceFactory; | |
| 14910 TestTypeProvider provider = new TestTypeProvider(); | |
| 14911 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d
art"); | |
| 14912 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); | |
| 14913 sdkContext.setContents(coreSource, ""); | |
| 14914 coreUnit.source = coreSource; | |
| 14915 coreUnit.types = <ClassElement> [ | |
| 14916 provider.boolType.element, | |
| 14917 provider.doubleType.element, | |
| 14918 provider.functionType.element, | |
| 14919 provider.intType.element, | |
| 14920 provider.listType.element, | |
| 14921 provider.mapType.element, | |
| 14922 provider.nullType.element, | |
| 14923 provider.numType.element, | |
| 14924 provider.objectType.element, | |
| 14925 provider.stackTraceType.element, | |
| 14926 provider.stringType.element, | |
| 14927 provider.typeType.element]; | |
| 14928 LibraryElementImpl coreLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "core"])); | |
| 14929 coreLibrary.definingCompilationUnit = coreUnit; | |
| 14930 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d
artium.dart"); | |
| 14931 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | |
| 14932 sdkContext.setContents(htmlSource, ""); | |
| 14933 htmlUnit.source = htmlSource; | |
| 14934 ClassElementImpl elementElement = ElementFactory.classElement2("Element", []
); | |
| 14935 InterfaceType elementType = elementElement.type; | |
| 14936 ClassElementImpl documentElement = ElementFactory.classElement("Document", e
lementType, []); | |
| 14937 ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocu
ment", documentElement.type, []); | |
| 14938 htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement(
"query", elementType, <Type2> [provider.stringType])]; | |
| 14939 htmlUnit.types = <ClassElement> [ | |
| 14940 ElementFactory.classElement("AnchorElement", elementType, []), | |
| 14941 ElementFactory.classElement("BodyElement", elementType, []), | |
| 14942 ElementFactory.classElement("ButtonElement", elementType, []), | |
| 14943 ElementFactory.classElement("DivElement", elementType, []), | |
| 14944 documentElement, | |
| 14945 elementElement, | |
| 14946 htmlDocumentElement, | |
| 14947 ElementFactory.classElement("InputElement", elementType, []), | |
| 14948 ElementFactory.classElement("SelectElement", elementType, [])]; | |
| 14949 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que
ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI
mpl.EMPTY_ARRAY)]; | |
| 14950 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen
t3("document", true, htmlDocumentElement.type); | |
| 14951 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document]; | |
| 14952 htmlUnit.accessors = <PropertyAccessorElement> [document.getter]; | |
| 14953 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "dom", "html"])); | |
| 14954 htmlLibrary.definingCompilationUnit = htmlUnit; | |
| 14955 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); | |
| 14956 elementMap[coreSource] = coreLibrary; | |
| 14957 elementMap[htmlSource] = htmlLibrary; | |
| 14958 sdkContext.recordLibraryElements(elementMap); | |
| 14959 AnalysisContextImpl2 context = new DelegatingAnalysisContextImpl2(); | |
| 14960 sourceFactory = new SourceFactory.con2([ | |
| 14961 new DartUriResolver(sdkContext.sourceFactory.dartSdk), | |
| 14962 new FileUriResolver()]); | |
| 14963 context.sourceFactory = sourceFactory; | |
| 14964 return context; | |
| 14965 } | |
| 14966 | |
| 14967 /** | |
| 14968 * Create an analysis context that has a fake core library already resolved. | |
| 14969 * | |
| 14970 * @return the analysis context that was created | 15265 * @return the analysis context that was created |
| 14971 */ | 15266 */ |
| 14972 static AnalysisContextImpl contextWithCore() { | 15267 static AnalysisContextImpl contextWithCore() { |
| 14973 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as
AnalysisContextImpl; | 15268 AnalysisContext sdkContext = DirectoryBasedDartSdk.defaultSdk.context; |
| 14974 SourceFactory sourceFactory = sdkContext.sourceFactory; | 15269 SourceFactory sourceFactory = sdkContext.sourceFactory; |
| 14975 TestTypeProvider provider = new TestTypeProvider(); | 15270 TestTypeProvider provider = new TestTypeProvider(); |
| 14976 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d
art"); | 15271 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d
art"); |
| 14977 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); | 15272 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
| 14978 sdkContext.setContents(coreSource, ""); | 15273 sdkContext.setContents(coreSource, ""); |
| 14979 coreUnit.source = coreSource; | 15274 coreUnit.source = coreSource; |
| 14980 coreUnit.types = <ClassElement> [ | 15275 coreUnit.types = <ClassElement> [ |
| 14981 provider.boolType.element, | 15276 provider.boolType.element, |
| 14982 provider.doubleType.element, | 15277 provider.doubleType.element, |
| 14983 provider.functionType.element, | 15278 provider.functionType.element, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 15013 ElementFactory.classElement("SelectElement", elementType, [])]; | 15308 ElementFactory.classElement("SelectElement", elementType, [])]; |
| 15014 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que
ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI
mpl.EMPTY_ARRAY)]; | 15309 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que
ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI
mpl.EMPTY_ARRAY)]; |
| 15015 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen
t3("document", true, htmlDocumentElement.type); | 15310 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen
t3("document", true, htmlDocumentElement.type); |
| 15016 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document]; | 15311 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document]; |
| 15017 htmlUnit.accessors = <PropertyAccessorElement> [document.getter]; | 15312 htmlUnit.accessors = <PropertyAccessorElement> [document.getter]; |
| 15018 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "dom", "html"])); | 15313 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto
ry.libraryIdentifier2(["dart", "dom", "html"])); |
| 15019 htmlLibrary.definingCompilationUnit = htmlUnit; | 15314 htmlLibrary.definingCompilationUnit = htmlUnit; |
| 15020 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); | 15315 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); |
| 15021 elementMap[coreSource] = coreLibrary; | 15316 elementMap[coreSource] = coreLibrary; |
| 15022 elementMap[htmlSource] = htmlLibrary; | 15317 elementMap[htmlSource] = htmlLibrary; |
| 15023 sdkContext.recordLibraryElements(elementMap); | 15318 ((sdkContext as AnalysisContextImpl)).recordLibraryElements(elementMap); |
| 15024 AnalysisContextImpl context = new DelegatingAnalysisContextImpl(); | 15319 AnalysisContextImpl context = new DelegatingAnalysisContextImpl(); |
| 15025 sourceFactory = new SourceFactory.con2([ | 15320 sourceFactory = new SourceFactory.con2([ |
| 15026 new DartUriResolver(sdkContext.sourceFactory.dartSdk), | 15321 new DartUriResolver(sdkContext.sourceFactory.dartSdk), |
| 15027 new FileUriResolver()]); | 15322 new FileUriResolver()]); |
| 15028 context.sourceFactory = sourceFactory; | 15323 context.sourceFactory = sourceFactory; |
| 15029 return context; | 15324 return context; |
| 15030 } | 15325 } |
| 15031 } | 15326 } |
| 15032 class LibraryImportScopeTest extends ResolverTestCase { | 15327 class LibraryImportScopeTest extends ResolverTestCase { |
| 15033 void test_conflictingImports() { | 15328 void test_conflictingImports() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 15051 GatheringErrorListener errorListener = new GatheringErrorListener(); | 15346 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 15052 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | 15347 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
| 15053 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(type
NameA), importingLibrary)); | 15348 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(type
NameA), importingLibrary)); |
| 15054 errorListener.assertNoErrors(); | 15349 errorListener.assertNoErrors(); |
| 15055 JUnitTestCase.assertEquals(typeC, scope.lookup(ASTFactory.identifier3(type
NameC), importingLibrary)); | 15350 JUnitTestCase.assertEquals(typeC, scope.lookup(ASTFactory.identifier3(type
NameC), importingLibrary)); |
| 15056 errorListener.assertNoErrors(); | 15351 errorListener.assertNoErrors(); |
| 15057 Element element = scope.lookup(ASTFactory.identifier3(typeNameB), importin
gLibrary); | 15352 Element element = scope.lookup(ASTFactory.identifier3(typeNameB), importin
gLibrary); |
| 15058 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]); | 15353 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 15059 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); | 15354 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); |
| 15060 List<Element> conflictingElements = ((element as MultiplyDefinedElement)).
conflictingElements; | 15355 List<Element> conflictingElements = ((element as MultiplyDefinedElement)).
conflictingElements; |
| 15061 JUnitTestCase.assertEquals(typeB1, conflictingElements[0]); | 15356 EngineTestCase.assertLength(2, conflictingElements); |
| 15062 JUnitTestCase.assertEquals(typeB2, conflictingElements[1]); | 15357 if (identical(conflictingElements[0], typeB1)) { |
| 15063 JUnitTestCase.assertEquals(2, conflictingElements.length); | 15358 JUnitTestCase.assertSame(typeB2, conflictingElements[1]); |
| 15359 } else if (identical(conflictingElements[0], typeB2)) { |
| 15360 JUnitTestCase.assertSame(typeB1, conflictingElements[1]); |
| 15361 } else { |
| 15362 JUnitTestCase.assertSame(typeB1, conflictingElements[0]); |
| 15363 } |
| 15064 } | 15364 } |
| 15065 { | 15365 { |
| 15066 GatheringErrorListener errorListener = new GatheringErrorListener(); | 15366 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 15067 Scope scope = new LibraryImportScope(importingLibrary, errorListener); | 15367 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
| 15068 Identifier identifier = ASTFactory.identifier3(typeNameB); | 15368 Identifier identifier = ASTFactory.identifier3(typeNameB); |
| 15069 ASTFactory.methodDeclaration(null, ASTFactory.typeName3(identifier, []), n
ull, null, ASTFactory.identifier3("foo"), null); | 15369 ASTFactory.methodDeclaration(null, ASTFactory.typeName3(identifier, []), n
ull, null, ASTFactory.identifier3("foo"), null); |
| 15070 Element element = scope.lookup(identifier, importingLibrary); | 15370 Element element = scope.lookup(identifier, importingLibrary); |
| 15071 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]); | 15371 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]); |
| 15072 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); | 15372 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); |
| 15073 } | 15373 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 15096 GatheringErrorListener errorListener = new GatheringErrorListener(); | 15396 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 15097 LibraryImportScope scope = new LibraryImportScope(definingLibrary, errorList
ener); | 15397 LibraryImportScope scope = new LibraryImportScope(definingLibrary, errorList
ener); |
| 15098 JUnitTestCase.assertEquals(definingLibrary, scope.definingLibrary); | 15398 JUnitTestCase.assertEquals(definingLibrary, scope.definingLibrary); |
| 15099 } | 15399 } |
| 15100 void test_getErrorListener() { | 15400 void test_getErrorListener() { |
| 15101 LibraryElement definingLibrary = createTestLibrary(); | 15401 LibraryElement definingLibrary = createTestLibrary(); |
| 15102 GatheringErrorListener errorListener = new GatheringErrorListener(); | 15402 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 15103 LibraryImportScope scope = new LibraryImportScope(definingLibrary, errorList
ener); | 15403 LibraryImportScope scope = new LibraryImportScope(definingLibrary, errorList
ener); |
| 15104 JUnitTestCase.assertEquals(errorListener, scope.errorListener); | 15404 JUnitTestCase.assertEquals(errorListener, scope.errorListener); |
| 15105 } | 15405 } |
| 15406 void test_nonConflictingImports_fromSdk() { |
| 15407 AnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 15408 String typeName = "List"; |
| 15409 ClassElement type = ElementFactory.classElement2(typeName, []); |
| 15410 LibraryElement importedLibrary = createTestLibrary2(context, "lib", []); |
| 15411 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty
pes = <ClassElement> [type]; |
| 15412 ImportElementImpl importCore = ElementFactory.importFor(context.getLibraryEl
ement(context.sourceFactory.forUri("dart:core")), null, []); |
| 15413 ImportElementImpl importLib = ElementFactory.importFor(importedLibrary, null
, []); |
| 15414 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing
", []); |
| 15415 importingLibrary.imports = <ImportElement> [importCore, importLib]; |
| 15416 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 15417 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
| 15418 JUnitTestCase.assertEquals(type, scope.lookup(ASTFactory.identifier3(typeNam
e), importingLibrary)); |
| 15419 errorListener.assertNoErrors(); |
| 15420 } |
| 15421 void test_nonConflictingImports_sameElement() { |
| 15422 AnalysisContext context = new AnalysisContextImpl(); |
| 15423 String typeNameA = "A"; |
| 15424 String typeNameB = "B"; |
| 15425 ClassElement typeA = ElementFactory.classElement2(typeNameA, []); |
| 15426 ClassElement typeB = ElementFactory.classElement2(typeNameB, []); |
| 15427 LibraryElement importedLibrary = createTestLibrary2(context, "imported", [])
; |
| 15428 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty
pes = <ClassElement> [typeA, typeB]; |
| 15429 ImportElementImpl import1 = ElementFactory.importFor(importedLibrary, null,
[]); |
| 15430 ImportElementImpl import2 = ElementFactory.importFor(importedLibrary, null,
[]); |
| 15431 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing
", []); |
| 15432 importingLibrary.imports = <ImportElement> [import1, import2]; |
| 15433 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 15434 Scope scope = new LibraryImportScope(importingLibrary, errorListener); |
| 15435 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(typeNa
meA), importingLibrary)); |
| 15436 errorListener.assertNoErrors(); |
| 15437 JUnitTestCase.assertEquals(typeB, scope.lookup(ASTFactory.identifier3(typeNa
meB), importingLibrary)); |
| 15438 errorListener.assertNoErrors(); |
| 15439 } |
| 15106 void test_prefixedAndNonPrefixed() { | 15440 void test_prefixedAndNonPrefixed() { |
| 15107 AnalysisContext context = new AnalysisContextImpl(); | 15441 AnalysisContext context = new AnalysisContextImpl(); |
| 15108 String typeName = "C"; | 15442 String typeName = "C"; |
| 15109 String prefixName = "p"; | 15443 String prefixName = "p"; |
| 15110 ClassElement prefixedType = ElementFactory.classElement2(typeName, []); | 15444 ClassElement prefixedType = ElementFactory.classElement2(typeName, []); |
| 15111 ClassElement nonPrefixedType = ElementFactory.classElement2(typeName, []); | 15445 ClassElement nonPrefixedType = ElementFactory.classElement2(typeName, []); |
| 15112 LibraryElement prefixedLibrary = createTestLibrary2(context, "import.prefixe
d", []); | 15446 LibraryElement prefixedLibrary = createTestLibrary2(context, "import.prefixe
d", []); |
| 15113 ((prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty
pes = <ClassElement> [prefixedType]; | 15447 ((prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty
pes = <ClassElement> [prefixedType]; |
| 15114 ImportElementImpl prefixedImport = ElementFactory.importFor(prefixedLibrary,
ElementFactory.prefix(prefixName), []); | 15448 ImportElementImpl prefixedImport = ElementFactory.importFor(prefixedLibrary,
ElementFactory.prefix(prefixName), []); |
| 15115 LibraryElement nonPrefixedLibrary = createTestLibrary2(context, "import.nonP
refixed", []); | 15449 LibraryElement nonPrefixedLibrary = createTestLibrary2(context, "import.nonP
refixed", []); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 15141 runJUnitTest(__test, __test.test_creation_nonEmpty); | 15475 runJUnitTest(__test, __test.test_creation_nonEmpty); |
| 15142 }); | 15476 }); |
| 15143 _ut.test('test_getDefiningLibrary', () { | 15477 _ut.test('test_getDefiningLibrary', () { |
| 15144 final __test = new LibraryImportScopeTest(); | 15478 final __test = new LibraryImportScopeTest(); |
| 15145 runJUnitTest(__test, __test.test_getDefiningLibrary); | 15479 runJUnitTest(__test, __test.test_getDefiningLibrary); |
| 15146 }); | 15480 }); |
| 15147 _ut.test('test_getErrorListener', () { | 15481 _ut.test('test_getErrorListener', () { |
| 15148 final __test = new LibraryImportScopeTest(); | 15482 final __test = new LibraryImportScopeTest(); |
| 15149 runJUnitTest(__test, __test.test_getErrorListener); | 15483 runJUnitTest(__test, __test.test_getErrorListener); |
| 15150 }); | 15484 }); |
| 15485 _ut.test('test_nonConflictingImports_fromSdk', () { |
| 15486 final __test = new LibraryImportScopeTest(); |
| 15487 runJUnitTest(__test, __test.test_nonConflictingImports_fromSdk); |
| 15488 }); |
| 15489 _ut.test('test_nonConflictingImports_sameElement', () { |
| 15490 final __test = new LibraryImportScopeTest(); |
| 15491 runJUnitTest(__test, __test.test_nonConflictingImports_sameElement); |
| 15492 }); |
| 15151 _ut.test('test_prefixedAndNonPrefixed', () { | 15493 _ut.test('test_prefixedAndNonPrefixed', () { |
| 15152 final __test = new LibraryImportScopeTest(); | 15494 final __test = new LibraryImportScopeTest(); |
| 15153 runJUnitTest(__test, __test.test_prefixedAndNonPrefixed); | 15495 runJUnitTest(__test, __test.test_prefixedAndNonPrefixed); |
| 15154 }); | 15496 }); |
| 15155 }); | 15497 }); |
| 15156 } | 15498 } |
| 15157 } | 15499 } |
| 15158 /** | 15500 /** |
| 15159 * Instances of the class `ResolutionVerifier` verify that all of the nodes in a
n AST | 15501 * Instances of the class `ResolutionVerifier` verify that all of the nodes in a
n AST |
| 15160 * structure that should have been resolved were resolved. | 15502 * structure that should have been resolved were resolved. |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15570 Expression node = ASTFactory.doubleLiteral(4.33); | 15912 Expression node = ASTFactory.doubleLiteral(4.33); |
| 15571 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); | 15913 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node)); |
| 15572 _listener.assertNoErrors(); | 15914 _listener.assertNoErrors(); |
| 15573 } | 15915 } |
| 15574 void test_visitFunctionExpression_named_block() { | 15916 void test_visitFunctionExpression_named_block() { |
| 15575 Type2 dynamicType = _typeProvider.dynamicType; | 15917 Type2 dynamicType = _typeProvider.dynamicType; |
| 15576 FormalParameter p1 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p1"), resolvedInteger(0)); | 15918 FormalParameter p1 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p1"), resolvedInteger(0)); |
| 15577 setType(p1, dynamicType); | 15919 setType(p1, dynamicType); |
| 15578 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); | 15920 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); |
| 15579 setType(p2, dynamicType); | 15921 setType(p2, dynamicType); |
| 15580 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); | 15922 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); |
| 15581 analyze3(p1); | 15923 analyze3(p1); |
| 15582 analyze3(p2); | 15924 analyze3(p2); |
| 15583 Type2 resultType = analyze(node); | 15925 Type2 resultType = analyze(node); |
| 15584 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 15926 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
| 15585 expectedNamedTypes["p1"] = dynamicType; | 15927 expectedNamedTypes["p1"] = dynamicType; |
| 15586 expectedNamedTypes["p2"] = dynamicType; | 15928 expectedNamedTypes["p2"] = dynamicType; |
| 15587 assertFunctionType(dynamicType, null, null, expectedNamedTypes, resultType); | 15929 assertFunctionType(dynamicType, null, null, expectedNamedTypes, resultType); |
| 15588 _listener.assertNoErrors(); | 15930 _listener.assertNoErrors(); |
| 15589 } | 15931 } |
| 15590 void test_visitFunctionExpression_named_expression() { | 15932 void test_visitFunctionExpression_named_expression() { |
| 15591 Type2 dynamicType = _typeProvider.dynamicType; | 15933 Type2 dynamicType = _typeProvider.dynamicType; |
| 15592 FormalParameter p = ASTFactory.namedFormalParameter(ASTFactory.simpleFormalP
arameter3("p"), resolvedInteger(0)); | 15934 FormalParameter p = ASTFactory.namedFormalParameter(ASTFactory.simpleFormalP
arameter3("p"), resolvedInteger(0)); |
| 15593 setType(p, dynamicType); | 15935 setType(p, dynamicType); |
| 15594 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 15936 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
| 15595 analyze3(p); | 15937 analyze3(p); |
| 15596 Type2 resultType = analyze(node); | 15938 Type2 resultType = analyze(node); |
| 15597 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 15939 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
| 15598 expectedNamedTypes["p"] = dynamicType; | 15940 expectedNamedTypes["p"] = dynamicType; |
| 15599 assertFunctionType(_typeProvider.intType, null, null, expectedNamedTypes, re
sultType); | 15941 assertFunctionType(_typeProvider.intType, null, null, expectedNamedTypes, re
sultType); |
| 15600 _listener.assertNoErrors(); | 15942 _listener.assertNoErrors(); |
| 15601 } | 15943 } |
| 15602 void test_visitFunctionExpression_normal_block() { | 15944 void test_visitFunctionExpression_normal_block() { |
| 15603 Type2 dynamicType = _typeProvider.dynamicType; | 15945 Type2 dynamicType = _typeProvider.dynamicType; |
| 15604 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 15946 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
| 15605 setType(p1, dynamicType); | 15947 setType(p1, dynamicType); |
| 15606 FormalParameter p2 = ASTFactory.simpleFormalParameter3("p2"); | 15948 FormalParameter p2 = ASTFactory.simpleFormalParameter3("p2"); |
| 15607 setType(p2, dynamicType); | 15949 setType(p2, dynamicType); |
| 15608 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); | 15950 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); |
| 15609 analyze3(p1); | 15951 analyze3(p1); |
| 15610 analyze3(p2); | 15952 analyze3(p2); |
| 15611 Type2 resultType = analyze(node); | 15953 Type2 resultType = analyze(node); |
| 15612 assertFunctionType(dynamicType, <Type2> [dynamicType, dynamicType], null, nu
ll, resultType); | 15954 assertFunctionType(dynamicType, <Type2> [dynamicType, dynamicType], null, nu
ll, resultType); |
| 15613 _listener.assertNoErrors(); | 15955 _listener.assertNoErrors(); |
| 15614 } | 15956 } |
| 15615 void test_visitFunctionExpression_normal_expression() { | 15957 void test_visitFunctionExpression_normal_expression() { |
| 15616 Type2 dynamicType = _typeProvider.dynamicType; | 15958 Type2 dynamicType = _typeProvider.dynamicType; |
| 15617 FormalParameter p = ASTFactory.simpleFormalParameter3("p"); | 15959 FormalParameter p = ASTFactory.simpleFormalParameter3("p"); |
| 15618 setType(p, dynamicType); | 15960 setType(p, dynamicType); |
| 15619 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 15961 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
| 15620 analyze3(p); | 15962 analyze3(p); |
| 15621 Type2 resultType = analyze(node); | 15963 Type2 resultType = analyze(node); |
| 15622 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, null,
resultType); | 15964 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, null,
resultType); |
| 15623 _listener.assertNoErrors(); | 15965 _listener.assertNoErrors(); |
| 15624 } | 15966 } |
| 15625 void test_visitFunctionExpression_normalAndNamed_block() { | 15967 void test_visitFunctionExpression_normalAndNamed_block() { |
| 15626 Type2 dynamicType = _typeProvider.dynamicType; | 15968 Type2 dynamicType = _typeProvider.dynamicType; |
| 15627 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 15969 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
| 15628 setType(p1, dynamicType); | 15970 setType(p1, dynamicType); |
| 15629 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); | 15971 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); |
| 15630 setType(p2, dynamicType); | 15972 setType(p2, dynamicType); |
| 15631 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); | 15973 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); |
| 15632 analyze3(p2); | 15974 analyze3(p2); |
| 15633 Type2 resultType = analyze(node); | 15975 Type2 resultType = analyze(node); |
| 15634 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 15976 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
| 15635 expectedNamedTypes["p2"] = dynamicType; | 15977 expectedNamedTypes["p2"] = dynamicType; |
| 15636 assertFunctionType(dynamicType, <Type2> [dynamicType], null, expectedNamedTy
pes, resultType); | 15978 assertFunctionType(dynamicType, <Type2> [dynamicType], null, expectedNamedTy
pes, resultType); |
| 15637 _listener.assertNoErrors(); | 15979 _listener.assertNoErrors(); |
| 15638 } | 15980 } |
| 15639 void test_visitFunctionExpression_normalAndNamed_expression() { | 15981 void test_visitFunctionExpression_normalAndNamed_expression() { |
| 15640 Type2 dynamicType = _typeProvider.dynamicType; | 15982 Type2 dynamicType = _typeProvider.dynamicType; |
| 15641 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 15983 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
| 15642 setType(p1, dynamicType); | 15984 setType(p1, dynamicType); |
| 15643 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); | 15985 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal
Parameter3("p2"), resolvedInteger(0)); |
| 15644 setType(p2, dynamicType); | 15986 setType(p2, dynamicType); |
| 15645 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 15987 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
| 15646 analyze3(p2); | 15988 analyze3(p2); |
| 15647 Type2 resultType = analyze(node); | 15989 Type2 resultType = analyze(node); |
| 15648 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); | 15990 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>(); |
| 15649 expectedNamedTypes["p2"] = dynamicType; | 15991 expectedNamedTypes["p2"] = dynamicType; |
| 15650 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, expec
tedNamedTypes, resultType); | 15992 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, expec
tedNamedTypes, resultType); |
| 15651 _listener.assertNoErrors(); | 15993 _listener.assertNoErrors(); |
| 15652 } | 15994 } |
| 15653 void test_visitFunctionExpression_normalAndPositional_block() { | 15995 void test_visitFunctionExpression_normalAndPositional_block() { |
| 15654 Type2 dynamicType = _typeProvider.dynamicType; | 15996 Type2 dynamicType = _typeProvider.dynamicType; |
| 15655 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 15997 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
| 15656 setType(p1, dynamicType); | 15998 setType(p1, dynamicType); |
| 15657 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); | 15999 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); |
| 15658 setType(p2, dynamicType); | 16000 setType(p2, dynamicType); |
| 15659 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); | 16001 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); |
| 15660 analyze3(p1); | 16002 analyze3(p1); |
| 15661 analyze3(p2); | 16003 analyze3(p2); |
| 15662 Type2 resultType = analyze(node); | 16004 Type2 resultType = analyze(node); |
| 15663 assertFunctionType(dynamicType, <Type2> [dynamicType], <Type2> [dynamicType]
, null, resultType); | 16005 assertFunctionType(dynamicType, <Type2> [dynamicType], <Type2> [dynamicType]
, null, resultType); |
| 15664 _listener.assertNoErrors(); | 16006 _listener.assertNoErrors(); |
| 15665 } | 16007 } |
| 15666 void test_visitFunctionExpression_normalAndPositional_expression() { | 16008 void test_visitFunctionExpression_normalAndPositional_expression() { |
| 15667 Type2 dynamicType = _typeProvider.dynamicType; | 16009 Type2 dynamicType = _typeProvider.dynamicType; |
| 15668 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); | 16010 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1"); |
| 15669 setType(p1, dynamicType); | 16011 setType(p1, dynamicType); |
| 15670 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); | 16012 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); |
| 15671 setType(p2, dynamicType); | 16013 setType(p2, dynamicType); |
| 15672 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); | 16014 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); |
| 15673 analyze3(p1); | 16015 analyze3(p1); |
| 15674 analyze3(p2); | 16016 analyze3(p2); |
| 15675 Type2 resultType = analyze(node); | 16017 Type2 resultType = analyze(node); |
| 15676 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], <Type2> [dy
namicType], null, resultType); | 16018 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], <Type2> [dy
namicType], null, resultType); |
| 15677 _listener.assertNoErrors(); | 16019 _listener.assertNoErrors(); |
| 15678 } | 16020 } |
| 15679 void test_visitFunctionExpression_positional_block() { | 16021 void test_visitFunctionExpression_positional_block() { |
| 15680 Type2 dynamicType = _typeProvider.dynamicType; | 16022 Type2 dynamicType = _typeProvider.dynamicType; |
| 15681 FormalParameter p1 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p1"), resolvedInteger(0)); | 16023 FormalParameter p1 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p1"), resolvedInteger(0)); |
| 15682 setType(p1, dynamicType); | 16024 setType(p1, dynamicType); |
| 15683 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); | 16025 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF
ormalParameter3("p2"), resolvedInteger(0)); |
| 15684 setType(p2, dynamicType); | 16026 setType(p2, dynamicType); |
| 15685 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody([])); | 16027 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame
terList([p1, p2]), ASTFactory.blockFunctionBody2([])); |
| 15686 analyze3(p1); | 16028 analyze3(p1); |
| 15687 analyze3(p2); | 16029 analyze3(p2); |
| 15688 Type2 resultType = analyze(node); | 16030 Type2 resultType = analyze(node); |
| 15689 assertFunctionType(dynamicType, null, <Type2> [dynamicType, dynamicType], nu
ll, resultType); | 16031 assertFunctionType(dynamicType, null, <Type2> [dynamicType, dynamicType], nu
ll, resultType); |
| 15690 _listener.assertNoErrors(); | 16032 _listener.assertNoErrors(); |
| 15691 } | 16033 } |
| 15692 void test_visitFunctionExpression_positional_expression() { | 16034 void test_visitFunctionExpression_positional_expression() { |
| 15693 Type2 dynamicType = _typeProvider.dynamicType; | 16035 Type2 dynamicType = _typeProvider.dynamicType; |
| 15694 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo
rmalParameter3("p"), resolvedInteger(0)); | 16036 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo
rmalParameter3("p"), resolvedInteger(0)); |
| 15695 setType(p, dynamicType); | 16037 setType(p, dynamicType); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15747 } | 16089 } |
| 15748 void test_visitInstanceCreationExpression_named() { | 16090 void test_visitInstanceCreationExpression_named() { |
| 15749 ClassElementImpl classElement = ElementFactory.classElement2("C", []); | 16091 ClassElementImpl classElement = ElementFactory.classElement2("C", []); |
| 15750 String constructorName = "m"; | 16092 String constructorName = "m"; |
| 15751 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
Element, constructorName); | 16093 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
Element, constructorName); |
| 15752 constructor.returnType = classElement.type; | 16094 constructor.returnType = classElement.type; |
| 15753 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); | 16095 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); |
| 15754 constructor.type = constructorType; | 16096 constructor.type = constructorType; |
| 15755 classElement.constructors = <ConstructorElement> [constructor]; | 16097 classElement.constructors = <ConstructorElement> [constructor]; |
| 15756 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam
e)]); | 16098 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam
e)]); |
| 15757 node.element = constructor; | 16099 node.staticElement = constructor; |
| 15758 JUnitTestCase.assertSame(classElement.type, analyze(node)); | 16100 JUnitTestCase.assertSame(classElement.type, analyze(node)); |
| 15759 _listener.assertNoErrors(); | 16101 _listener.assertNoErrors(); |
| 15760 } | 16102 } |
| 15761 void test_visitInstanceCreationExpression_typeParameters() { | 16103 void test_visitInstanceCreationExpression_typeParameters() { |
| 15762 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]); | 16104 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]); |
| 15763 ClassElementImpl elementI = ElementFactory.classElement2("I", []); | 16105 ClassElementImpl elementI = ElementFactory.classElement2("I", []); |
| 15764 ConstructorElementImpl constructor = ElementFactory.constructorElement(eleme
ntC, null); | 16106 ConstructorElementImpl constructor = ElementFactory.constructorElement(eleme
ntC, null); |
| 15765 elementC.constructors = <ConstructorElement> [constructor]; | 16107 elementC.constructors = <ConstructorElement> [constructor]; |
| 15766 constructor.returnType = elementC.type; | 16108 constructor.returnType = elementC.type; |
| 15767 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); | 16109 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); |
| 15768 constructor.type = constructorType; | 16110 constructor.type = constructorType; |
| 15769 TypeName typeName = ASTFactory.typeName(elementC, [ASTFactory.typeName(eleme
ntI, [])]); | 16111 TypeName typeName = ASTFactory.typeName(elementC, [ASTFactory.typeName(eleme
ntI, [])]); |
| 15770 typeName.type = elementC.type.substitute4(<Type2> [elementI.type]); | 16112 typeName.type = elementC.type.substitute4(<Type2> [elementI.type]); |
| 15771 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, typeName, []); | 16113 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, typeName, []); |
| 15772 node.element = constructor; | 16114 node.staticElement = constructor; |
| 15773 InterfaceType interfaceType = analyze(node) as InterfaceType; | 16115 InterfaceType interfaceType = analyze(node) as InterfaceType; |
| 15774 List<Type2> typeArgs = interfaceType.typeArguments; | 16116 List<Type2> typeArgs = interfaceType.typeArguments; |
| 15775 JUnitTestCase.assertEquals(1, typeArgs.length); | 16117 JUnitTestCase.assertEquals(1, typeArgs.length); |
| 15776 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]); | 16118 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]); |
| 15777 _listener.assertNoErrors(); | 16119 _listener.assertNoErrors(); |
| 15778 } | 16120 } |
| 15779 void test_visitInstanceCreationExpression_unnamed() { | 16121 void test_visitInstanceCreationExpression_unnamed() { |
| 15780 ClassElementImpl classElement = ElementFactory.classElement2("C", []); | 16122 ClassElementImpl classElement = ElementFactory.classElement2("C", []); |
| 15781 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
Element, null); | 16123 ConstructorElementImpl constructor = ElementFactory.constructorElement(class
Element, null); |
| 15782 constructor.returnType = classElement.type; | 16124 constructor.returnType = classElement.type; |
| 15783 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); | 16125 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); |
| 15784 constructor.type = constructorType; | 16126 constructor.type = constructorType; |
| 15785 classElement.constructors = <ConstructorElement> [constructor]; | 16127 classElement.constructors = <ConstructorElement> [constructor]; |
| 15786 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, ASTFactory.typeName(classElement, []), []); | 16128 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul
l, ASTFactory.typeName(classElement, []), []); |
| 15787 node.element = constructor; | 16129 node.staticElement = constructor; |
| 15788 JUnitTestCase.assertSame(classElement.type, analyze(node)); | 16130 JUnitTestCase.assertSame(classElement.type, analyze(node)); |
| 15789 _listener.assertNoErrors(); | 16131 _listener.assertNoErrors(); |
| 15790 } | 16132 } |
| 15791 void test_visitIntegerLiteral() { | 16133 void test_visitIntegerLiteral() { |
| 15792 Expression node = resolvedInteger(42); | 16134 Expression node = resolvedInteger(42); |
| 15793 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); | 16135 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); |
| 15794 _listener.assertNoErrors(); | 16136 _listener.assertNoErrors(); |
| 15795 } | 16137 } |
| 15796 void test_visitIsExpression_negated() { | 16138 void test_visitIsExpression_negated() { |
| 15797 Expression node = ASTFactory.isExpression(resolvedString("a"), true, ASTFact
ory.typeName4("String", [])); | 16139 Expression node = ASTFactory.isExpression(resolvedString("a"), true, ASTFact
ory.typeName4("String", [])); |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16467 runJUnitTest(__test, __test.test_visitThrowExpression_withValue); | 16809 runJUnitTest(__test, __test.test_visitThrowExpression_withValue); |
| 16468 }); | 16810 }); |
| 16469 _ut.test('test_visitThrowExpression_withoutValue', () { | 16811 _ut.test('test_visitThrowExpression_withoutValue', () { |
| 16470 final __test = new StaticTypeAnalyzerTest(); | 16812 final __test = new StaticTypeAnalyzerTest(); |
| 16471 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue); | 16813 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue); |
| 16472 }); | 16814 }); |
| 16473 }); | 16815 }); |
| 16474 } | 16816 } |
| 16475 } | 16817 } |
| 16476 class NonHintCodeTest extends ResolverTestCase { | 16818 class NonHintCodeTest extends ResolverTestCase { |
| 16819 void test_deadCode_deadBlock_conditionalElse_debugConst() { |
| 16820 Source source = addSource(EngineTestCase.createSource([ |
| 16821 "const bool DEBUG = true;", |
| 16822 "f() {", |
| 16823 " DEBUG ? 1 : 2;", |
| 16824 "}"])); |
| 16825 resolve(source); |
| 16826 assertNoErrors(source); |
| 16827 verify([source]); |
| 16828 } |
| 16829 void test_deadCode_deadBlock_conditionalIf_debugConst() { |
| 16830 Source source = addSource(EngineTestCase.createSource([ |
| 16831 "const bool DEBUG = false;", |
| 16832 "f() {", |
| 16833 " DEBUG ? 1 : 2;", |
| 16834 "}"])); |
| 16835 resolve(source); |
| 16836 assertNoErrors(source); |
| 16837 verify([source]); |
| 16838 } |
| 16839 void test_deadCode_deadBlock_else() { |
| 16840 Source source = addSource(EngineTestCase.createSource([ |
| 16841 "const bool DEBUG = true;", |
| 16842 "f() {", |
| 16843 " if(DEBUG) {} else {}", |
| 16844 "}"])); |
| 16845 resolve(source); |
| 16846 assertNoErrors(source); |
| 16847 verify([source]); |
| 16848 } |
| 16849 void test_deadCode_deadBlock_if_debugConst_prefixedIdentifier() { |
| 16850 Source source = addSource(EngineTestCase.createSource([ |
| 16851 "class A {", |
| 16852 " static const bool DEBUG = false;", |
| 16853 "}", |
| 16854 "f() {", |
| 16855 " if(A.DEBUG) {}", |
| 16856 "}"])); |
| 16857 resolve(source); |
| 16858 assertNoErrors(source); |
| 16859 verify([source]); |
| 16860 } |
| 16861 void test_deadCode_deadBlock_if_debugConst_prefixedIdentifier2() { |
| 16862 Source source = addSource(EngineTestCase.createSource([ |
| 16863 "library L;", |
| 16864 "import 'lib2.dart';", |
| 16865 "f() {", |
| 16866 " if(A.DEBUG) {}", |
| 16867 "}"])); |
| 16868 addSource2("/lib2.dart", EngineTestCase.createSource([ |
| 16869 "library lib2;", |
| 16870 "class A {", |
| 16871 " static const bool DEBUG = false;", |
| 16872 "}"])); |
| 16873 resolve(source); |
| 16874 assertNoErrors(source); |
| 16875 verify([source]); |
| 16876 } |
| 16877 void test_deadCode_deadBlock_if_debugConst_propertyAccessor() { |
| 16878 Source source = addSource(EngineTestCase.createSource([ |
| 16879 "library L;", |
| 16880 "import 'lib2.dart' as LIB;", |
| 16881 "f() {", |
| 16882 " if(LIB.A.DEBUG) {}", |
| 16883 "}"])); |
| 16884 addSource2("/lib2.dart", EngineTestCase.createSource([ |
| 16885 "library lib2;", |
| 16886 "class A {", |
| 16887 " static const bool DEBUG = false;", |
| 16888 "}"])); |
| 16889 resolve(source); |
| 16890 assertNoErrors(source); |
| 16891 verify([source]); |
| 16892 } |
| 16893 void test_deadCode_deadBlock_if_debugConst_simpleIdentifier() { |
| 16894 Source source = addSource(EngineTestCase.createSource([ |
| 16895 "const bool DEBUG = false;", |
| 16896 "f() {", |
| 16897 " if(DEBUG) {}", |
| 16898 "}"])); |
| 16899 resolve(source); |
| 16900 assertNoErrors(source); |
| 16901 verify([source]); |
| 16902 } |
| 16903 void test_deadCode_deadBlock_while_debugConst() { |
| 16904 Source source = addSource(EngineTestCase.createSource([ |
| 16905 "const bool DEBUG = false;", |
| 16906 "f() {", |
| 16907 " while(DEBUG) {}", |
| 16908 "}"])); |
| 16909 resolve(source); |
| 16910 assertNoErrors(source); |
| 16911 verify([source]); |
| 16912 } |
| 16477 void test_deadCode_deadCatch_onCatchSubtype() { | 16913 void test_deadCode_deadCatch_onCatchSubtype() { |
| 16478 Source source = addSource(EngineTestCase.createSource([ | 16914 Source source = addSource(EngineTestCase.createSource([ |
| 16479 "class A {}", | 16915 "class A {}", |
| 16480 "class B extends A {}", | 16916 "class B extends A {}", |
| 16481 "f() {", | 16917 "f() {", |
| 16482 " try {} on B catch (e) {} on A catch (e) {} catch (e) {}", | 16918 " try {} on B catch (e) {} on A catch (e) {} catch (e) {}", |
| 16483 "}"])); | 16919 "}"])); |
| 16484 resolve(source); | 16920 resolve(source); |
| 16485 assertNoErrors(); | 16921 assertNoErrors(source); |
| 16922 verify([source]); |
| 16923 } |
| 16924 void test_deadCode_deadOperandLHS_and_debugConst() { |
| 16925 Source source = addSource(EngineTestCase.createSource([ |
| 16926 "const bool DEBUG = false;", |
| 16927 "f() {", |
| 16928 " bool b = DEBUG && false;", |
| 16929 "}"])); |
| 16930 resolve(source); |
| 16931 assertNoErrors(source); |
| 16932 verify([source]); |
| 16933 } |
| 16934 void test_deadCode_deadOperandLHS_or_debugConst() { |
| 16935 Source source = addSource(EngineTestCase.createSource([ |
| 16936 "const bool DEBUG = true;", |
| 16937 "f() {", |
| 16938 " bool b = DEBUG || true;", |
| 16939 "}"])); |
| 16940 resolve(source); |
| 16941 assertNoErrors(source); |
| 16942 verify([source]); |
| 16943 } |
| 16944 void test_divisionOptimization() { |
| 16945 Source source = addSource(EngineTestCase.createSource(["f(int x, int y) {",
" var v = x / y.toInt();", "}"])); |
| 16946 resolve(source); |
| 16947 assertNoErrors(source); |
| 16948 verify([source]); |
| 16949 } |
| 16950 void test_divisionOptimization_supressIfDivisionNotDefinedInCore() { |
| 16951 Source source = addSource(EngineTestCase.createSource(["f(x, y) {", " var v
= (x / y).toInt();", "}"])); |
| 16952 resolve(source); |
| 16953 assertNoErrors(source); |
| 16954 verify([source]); |
| 16955 } |
| 16956 void test_divisionOptimization_supressIfDivisionOverridden() { |
| 16957 Source source = addSource(EngineTestCase.createSource([ |
| 16958 "class A {", |
| 16959 " num operator /(x) {}", |
| 16960 "}", |
| 16961 "f(A x, A y) {", |
| 16962 " var v = (x / y).toInt();", |
| 16963 "}"])); |
| 16964 resolve(source); |
| 16965 assertNoErrors(source); |
| 16966 verify([source]); |
| 16967 } |
| 16968 void test_duplicateImport_as() { |
| 16969 Source source = addSource(EngineTestCase.createSource([ |
| 16970 "library L;", |
| 16971 "import 'lib1.dart';", |
| 16972 "import 'lib1.dart' as one;", |
| 16973 "A a;", |
| 16974 "one.A a2;"])); |
| 16975 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}"])); |
| 16976 resolve(source); |
| 16977 assertNoErrors(source); |
| 16978 verify([source]); |
| 16979 } |
| 16980 void test_duplicateImport_hide() { |
| 16981 Source source = addSource(EngineTestCase.createSource([ |
| 16982 "library L;", |
| 16983 "import 'lib1.dart';", |
| 16984 "import 'lib1.dart' hide A;", |
| 16985 "A a;", |
| 16986 "B b;"])); |
| 16987 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}", "class B {}"])); |
| 16988 resolve(source); |
| 16989 assertNoErrors(source); |
| 16990 verify([source]); |
| 16991 } |
| 16992 void test_duplicateImport_show() { |
| 16993 Source source = addSource(EngineTestCase.createSource([ |
| 16994 "library L;", |
| 16995 "import 'lib1.dart';", |
| 16996 "import 'lib1.dart' show A;", |
| 16997 "A a;", |
| 16998 "B b;"])); |
| 16999 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s A {}", "class B {}"])); |
| 17000 resolve(source); |
| 17001 assertNoErrors(source); |
| 17002 verify([source]); |
| 17003 } |
| 17004 void test_overriddingPrivateMember_sameLibrary() { |
| 17005 Source source = addSource(EngineTestCase.createSource([ |
| 17006 "class A {", |
| 17007 " _m(int x) => 0;", |
| 17008 "}", |
| 17009 "class B extends A {", |
| 17010 " _m(int x) => 0;", |
| 17011 "}"])); |
| 17012 resolve(source); |
| 17013 assertNoErrors(source); |
| 17014 verify([source]); |
| 17015 } |
| 17016 void test_overrideEqualsButNotHashCode() { |
| 17017 Source source = addSource(EngineTestCase.createSource([ |
| 17018 "class A {", |
| 17019 " bool operator ==(x) {}", |
| 17020 " get hashCode => 0;", |
| 17021 "}"])); |
| 17022 resolve(source); |
| 17023 assertNoErrors(source); |
| 17024 verify([source]); |
| 17025 } |
| 17026 void test_unnecessaryCast_dynamic_type() { |
| 17027 Source source = addSource(EngineTestCase.createSource(["m(v) {", " var b =
v as Object;", "}"])); |
| 17028 resolve(source); |
| 17029 assertNoErrors(source); |
| 17030 verify([source]); |
| 17031 } |
| 17032 void test_unnecessaryCast_type_dynamic() { |
| 17033 Source source = addSource(EngineTestCase.createSource(["m(v) {", " var b =
Object as dynamic;", "}"])); |
| 17034 resolve(source); |
| 17035 assertNoErrors(source); |
| 17036 verify([source]); |
| 17037 } |
| 17038 void test_unusedImport_core_library() { |
| 17039 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'dart:core';"])); |
| 17040 resolve(source); |
| 17041 assertNoErrors(source); |
| 16486 verify([source]); | 17042 verify([source]); |
| 16487 } | 17043 } |
| 16488 void test_unusedImport_export() { | 17044 void test_unusedImport_export() { |
| 16489 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Two two;"])); | 17045 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Two two;"])); |
| 16490 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); | 17046 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); |
| 16491 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s Two {}"])); | 17047 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas
s Two {}"])); |
| 16492 resolve(source); | 17048 resolve(source); |
| 16493 assertNoErrors(); | 17049 assertNoErrors(source); |
| 16494 verify([source]); | 17050 verify([source]); |
| 16495 } | 17051 } |
| 16496 void test_unusedImport_export_infiniteLoop() { | 17052 void test_unusedImport_export_infiniteLoop() { |
| 16497 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Two two;"])); | 17053 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Two two;"])); |
| 16498 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); | 17054 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); |
| 16499 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "expo
rt 'lib3.dart';", "class Two {}"])); | 17055 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "expo
rt 'lib3.dart';", "class Two {}"])); |
| 16500 addSource2("/lib3.dart", EngineTestCase.createSource(["library lib3;", "expo
rt 'lib2.dart';", "class Three {}"])); | 17056 addSource2("/lib3.dart", EngineTestCase.createSource(["library lib3;", "expo
rt 'lib2.dart';", "class Three {}"])); |
| 16501 resolve(source); | 17057 resolve(source); |
| 16502 assertNoErrors(); | 17058 assertNoErrors(source); |
| 16503 verify([source]); | 17059 verify([source]); |
| 16504 } | 17060 } |
| 16505 void test_unusedImport_export2() { | 17061 void test_unusedImport_export2() { |
| 16506 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Three three;"])); | 17062 Source source = addSource(EngineTestCase.createSource(["library L;", "import
'lib1.dart';", "Three three;"])); |
| 16507 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); | 17063 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo
rt 'lib2.dart';", "class One {}"])); |
| 16508 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "expo
rt 'lib3.dart';", "class Two {}"])); | 17064 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "expo
rt 'lib3.dart';", "class Two {}"])); |
| 16509 addSource2("/lib3.dart", EngineTestCase.createSource(["library lib3;", "clas
s Three {}"])); | 17065 addSource2("/lib3.dart", EngineTestCase.createSource(["library lib3;", "clas
s Three {}"])); |
| 16510 resolve(source); | 17066 resolve(source); |
| 16511 assertNoErrors(); | 17067 assertNoErrors(source); |
| 16512 verify([source]); | 17068 verify([source]); |
| 16513 } | 17069 } |
| 16514 void test_unusedImport_prefix_topLevelFunction() { | 17070 void test_unusedImport_prefix_topLevelFunction() { |
| 16515 Source source = addSource(EngineTestCase.createSource([ | 17071 Source source = addSource(EngineTestCase.createSource([ |
| 16516 "library L;", | 17072 "library L;", |
| 16517 "import 'lib1.dart' hide topLevelFunction;", | 17073 "import 'lib1.dart' hide topLevelFunction;", |
| 16518 "import 'lib1.dart' as one show topLevelFunction;", | 17074 "import 'lib1.dart' as one show topLevelFunction;", |
| 16519 "class A {", | 17075 "class A {", |
| 16520 " static void x() {", | 17076 " static void x() {", |
| 16521 " One o;", | 17077 " One o;", |
| 16522 " one.topLevelFunction();", | 17078 " one.topLevelFunction();", |
| 16523 " }", | 17079 " }", |
| 16524 "}"])); | 17080 "}"])); |
| 16525 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s One {}", "topLevelFunction() {}"])); | 17081 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas
s One {}", "topLevelFunction() {}"])); |
| 16526 resolve(source); | 17082 resolve(source); |
| 16527 assertNoErrors(); | 17083 assertNoErrors(source); |
| 16528 verify([source]); | 17084 verify([source]); |
| 16529 } | 17085 } |
| 16530 static dartSuite() { | 17086 static dartSuite() { |
| 16531 _ut.group('NonHintCodeTest', () { | 17087 _ut.group('NonHintCodeTest', () { |
| 17088 _ut.test('test_deadCode_deadBlock_conditionalElse_debugConst', () { |
| 17089 final __test = new NonHintCodeTest(); |
| 17090 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse_debu
gConst); |
| 17091 }); |
| 17092 _ut.test('test_deadCode_deadBlock_conditionalIf_debugConst', () { |
| 17093 final __test = new NonHintCodeTest(); |
| 17094 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalIf_debugC
onst); |
| 17095 }); |
| 17096 _ut.test('test_deadCode_deadBlock_else', () { |
| 17097 final __test = new NonHintCodeTest(); |
| 17098 runJUnitTest(__test, __test.test_deadCode_deadBlock_else); |
| 17099 }); |
| 17100 _ut.test('test_deadCode_deadBlock_if_debugConst_prefixedIdentifier', () { |
| 17101 final __test = new NonHintCodeTest(); |
| 17102 runJUnitTest(__test, __test.test_deadCode_deadBlock_if_debugConst_prefix
edIdentifier); |
| 17103 }); |
| 17104 _ut.test('test_deadCode_deadBlock_if_debugConst_prefixedIdentifier2', () { |
| 17105 final __test = new NonHintCodeTest(); |
| 17106 runJUnitTest(__test, __test.test_deadCode_deadBlock_if_debugConst_prefix
edIdentifier2); |
| 17107 }); |
| 17108 _ut.test('test_deadCode_deadBlock_if_debugConst_propertyAccessor', () { |
| 17109 final __test = new NonHintCodeTest(); |
| 17110 runJUnitTest(__test, __test.test_deadCode_deadBlock_if_debugConst_proper
tyAccessor); |
| 17111 }); |
| 17112 _ut.test('test_deadCode_deadBlock_if_debugConst_simpleIdentifier', () { |
| 17113 final __test = new NonHintCodeTest(); |
| 17114 runJUnitTest(__test, __test.test_deadCode_deadBlock_if_debugConst_simple
Identifier); |
| 17115 }); |
| 17116 _ut.test('test_deadCode_deadBlock_while_debugConst', () { |
| 17117 final __test = new NonHintCodeTest(); |
| 17118 runJUnitTest(__test, __test.test_deadCode_deadBlock_while_debugConst); |
| 17119 }); |
| 16532 _ut.test('test_deadCode_deadCatch_onCatchSubtype', () { | 17120 _ut.test('test_deadCode_deadCatch_onCatchSubtype', () { |
| 16533 final __test = new NonHintCodeTest(); | 17121 final __test = new NonHintCodeTest(); |
| 16534 runJUnitTest(__test, __test.test_deadCode_deadCatch_onCatchSubtype); | 17122 runJUnitTest(__test, __test.test_deadCode_deadCatch_onCatchSubtype); |
| 16535 }); | 17123 }); |
| 17124 _ut.test('test_deadCode_deadOperandLHS_and_debugConst', () { |
| 17125 final __test = new NonHintCodeTest(); |
| 17126 runJUnitTest(__test, __test.test_deadCode_deadOperandLHS_and_debugConst)
; |
| 17127 }); |
| 17128 _ut.test('test_deadCode_deadOperandLHS_or_debugConst', () { |
| 17129 final __test = new NonHintCodeTest(); |
| 17130 runJUnitTest(__test, __test.test_deadCode_deadOperandLHS_or_debugConst); |
| 17131 }); |
| 17132 _ut.test('test_divisionOptimization', () { |
| 17133 final __test = new NonHintCodeTest(); |
| 17134 runJUnitTest(__test, __test.test_divisionOptimization); |
| 17135 }); |
| 17136 _ut.test('test_divisionOptimization_supressIfDivisionNotDefinedInCore', ()
{ |
| 17137 final __test = new NonHintCodeTest(); |
| 17138 runJUnitTest(__test, __test.test_divisionOptimization_supressIfDivisionN
otDefinedInCore); |
| 17139 }); |
| 17140 _ut.test('test_divisionOptimization_supressIfDivisionOverridden', () { |
| 17141 final __test = new NonHintCodeTest(); |
| 17142 runJUnitTest(__test, __test.test_divisionOptimization_supressIfDivisionO
verridden); |
| 17143 }); |
| 17144 _ut.test('test_duplicateImport_as', () { |
| 17145 final __test = new NonHintCodeTest(); |
| 17146 runJUnitTest(__test, __test.test_duplicateImport_as); |
| 17147 }); |
| 17148 _ut.test('test_duplicateImport_hide', () { |
| 17149 final __test = new NonHintCodeTest(); |
| 17150 runJUnitTest(__test, __test.test_duplicateImport_hide); |
| 17151 }); |
| 17152 _ut.test('test_duplicateImport_show', () { |
| 17153 final __test = new NonHintCodeTest(); |
| 17154 runJUnitTest(__test, __test.test_duplicateImport_show); |
| 17155 }); |
| 17156 _ut.test('test_overriddingPrivateMember_sameLibrary', () { |
| 17157 final __test = new NonHintCodeTest(); |
| 17158 runJUnitTest(__test, __test.test_overriddingPrivateMember_sameLibrary); |
| 17159 }); |
| 17160 _ut.test('test_overrideEqualsButNotHashCode', () { |
| 17161 final __test = new NonHintCodeTest(); |
| 17162 runJUnitTest(__test, __test.test_overrideEqualsButNotHashCode); |
| 17163 }); |
| 17164 _ut.test('test_unnecessaryCast_dynamic_type', () { |
| 17165 final __test = new NonHintCodeTest(); |
| 17166 runJUnitTest(__test, __test.test_unnecessaryCast_dynamic_type); |
| 17167 }); |
| 17168 _ut.test('test_unnecessaryCast_type_dynamic', () { |
| 17169 final __test = new NonHintCodeTest(); |
| 17170 runJUnitTest(__test, __test.test_unnecessaryCast_type_dynamic); |
| 17171 }); |
| 17172 _ut.test('test_unusedImport_core_library', () { |
| 17173 final __test = new NonHintCodeTest(); |
| 17174 runJUnitTest(__test, __test.test_unusedImport_core_library); |
| 17175 }); |
| 16536 _ut.test('test_unusedImport_export', () { | 17176 _ut.test('test_unusedImport_export', () { |
| 16537 final __test = new NonHintCodeTest(); | 17177 final __test = new NonHintCodeTest(); |
| 16538 runJUnitTest(__test, __test.test_unusedImport_export); | 17178 runJUnitTest(__test, __test.test_unusedImport_export); |
| 16539 }); | 17179 }); |
| 16540 _ut.test('test_unusedImport_export2', () { | 17180 _ut.test('test_unusedImport_export2', () { |
| 16541 final __test = new NonHintCodeTest(); | 17181 final __test = new NonHintCodeTest(); |
| 16542 runJUnitTest(__test, __test.test_unusedImport_export2); | 17182 runJUnitTest(__test, __test.test_unusedImport_export2); |
| 16543 }); | 17183 }); |
| 16544 _ut.test('test_unusedImport_export_infiniteLoop', () { | 17184 _ut.test('test_unusedImport_export_infiniteLoop', () { |
| 16545 final __test = new NonHintCodeTest(); | 17185 final __test = new NonHintCodeTest(); |
| 16546 runJUnitTest(__test, __test.test_unusedImport_export_infiniteLoop); | 17186 runJUnitTest(__test, __test.test_unusedImport_export_infiniteLoop); |
| 16547 }); | 17187 }); |
| 16548 _ut.test('test_unusedImport_prefix_topLevelFunction', () { | 17188 _ut.test('test_unusedImport_prefix_topLevelFunction', () { |
| 16549 final __test = new NonHintCodeTest(); | 17189 final __test = new NonHintCodeTest(); |
| 16550 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction); | 17190 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction); |
| 16551 }); | 17191 }); |
| 16552 }); | 17192 }); |
| 16553 } | 17193 } |
| 16554 } | 17194 } |
| 16555 class EnclosedScopeTest extends ResolverTestCase { | 17195 class EnclosedScopeTest extends ResolverTestCase { |
| 16556 void test_define_duplicate() { | 17196 void test_define_duplicate() { |
| 16557 LibraryElement definingLibrary2 = createTestLibrary(); | 17197 LibraryElement definingLibrary2 = createTestLibrary(); |
| 16558 GatheringErrorListener errorListener2 = new GatheringErrorListener(); | 17198 GatheringErrorListener errorListener2 = new GatheringErrorListener(); |
| 16559 Scope rootScope = new Scope_23(definingLibrary2, errorListener2); | 17199 Scope rootScope = new Scope_20(definingLibrary2, errorListener2); |
| 16560 EnclosedScope scope = new EnclosedScope(rootScope); | 17200 EnclosedScope scope = new EnclosedScope(rootScope); |
| 16561 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); | 17201 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); |
| 16562 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); | 17202 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); |
| 16563 scope.define(element1); | 17203 scope.define(element1); |
| 16564 scope.define(element2); | 17204 scope.define(element2); |
| 16565 errorListener2.assertErrors3([ErrorSeverity.ERROR]); | 17205 errorListener2.assertErrors3([ErrorSeverity.ERROR]); |
| 16566 } | 17206 } |
| 16567 void test_define_normal() { | 17207 void test_define_normal() { |
| 16568 LibraryElement definingLibrary3 = createTestLibrary(); | 17208 LibraryElement definingLibrary3 = createTestLibrary(); |
| 16569 GatheringErrorListener errorListener3 = new GatheringErrorListener(); | 17209 GatheringErrorListener errorListener3 = new GatheringErrorListener(); |
| 16570 Scope rootScope = new Scope_24(definingLibrary3, errorListener3); | 17210 Scope rootScope = new Scope_21(definingLibrary3, errorListener3); |
| 16571 EnclosedScope outerScope = new EnclosedScope(rootScope); | 17211 EnclosedScope outerScope = new EnclosedScope(rootScope); |
| 16572 EnclosedScope innerScope = new EnclosedScope(outerScope); | 17212 EnclosedScope innerScope = new EnclosedScope(outerScope); |
| 16573 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); | 17213 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v1")); |
| 16574 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v2")); | 17214 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id
entifier3("v2")); |
| 16575 outerScope.define(element1); | 17215 outerScope.define(element1); |
| 16576 innerScope.define(element2); | 17216 innerScope.define(element2); |
| 16577 errorListener3.assertNoErrors(); | 17217 errorListener3.assertNoErrors(); |
| 16578 } | 17218 } |
| 16579 static dartSuite() { | 17219 static dartSuite() { |
| 16580 _ut.group('EnclosedScopeTest', () { | 17220 _ut.group('EnclosedScopeTest', () { |
| 16581 _ut.test('test_define_duplicate', () { | 17221 _ut.test('test_define_duplicate', () { |
| 16582 final __test = new EnclosedScopeTest(); | 17222 final __test = new EnclosedScopeTest(); |
| 16583 runJUnitTest(__test, __test.test_define_duplicate); | 17223 runJUnitTest(__test, __test.test_define_duplicate); |
| 16584 }); | 17224 }); |
| 16585 _ut.test('test_define_normal', () { | 17225 _ut.test('test_define_normal', () { |
| 16586 final __test = new EnclosedScopeTest(); | 17226 final __test = new EnclosedScopeTest(); |
| 16587 runJUnitTest(__test, __test.test_define_normal); | 17227 runJUnitTest(__test, __test.test_define_normal); |
| 16588 }); | 17228 }); |
| 16589 }); | 17229 }); |
| 16590 } | 17230 } |
| 16591 } | 17231 } |
| 16592 class Scope_23 extends Scope { | 17232 class Scope_20 extends Scope { |
| 16593 LibraryElement definingLibrary2; | 17233 LibraryElement definingLibrary2; |
| 16594 GatheringErrorListener errorListener2; | 17234 GatheringErrorListener errorListener2; |
| 16595 Scope_23(this.definingLibrary2, this.errorListener2) : super(); | 17235 Scope_20(this.definingLibrary2, this.errorListener2) : super(); |
| 16596 LibraryElement get definingLibrary => definingLibrary2; | 17236 LibraryElement get definingLibrary => definingLibrary2; |
| 16597 AnalysisErrorListener get errorListener => errorListener2; | 17237 AnalysisErrorListener get errorListener => errorListener2; |
| 16598 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) => null; | 17238 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) => null; |
| 16599 } | 17239 } |
| 16600 class Scope_24 extends Scope { | 17240 class Scope_21 extends Scope { |
| 16601 LibraryElement definingLibrary3; | 17241 LibraryElement definingLibrary3; |
| 16602 GatheringErrorListener errorListener3; | 17242 GatheringErrorListener errorListener3; |
| 16603 Scope_24(this.definingLibrary3, this.errorListener3) : super(); | 17243 Scope_21(this.definingLibrary3, this.errorListener3) : super(); |
| 16604 LibraryElement get definingLibrary => definingLibrary3; | 17244 LibraryElement get definingLibrary => definingLibrary3; |
| 16605 AnalysisErrorListener get errorListener => errorListener3; | 17245 AnalysisErrorListener get errorListener => errorListener3; |
| 16606 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) => null; | 17246 Element lookup3(Identifier identifier, String name, LibraryElement referencing
Library) => null; |
| 16607 } | 17247 } |
| 16608 class LibraryElementBuilderTest extends EngineTestCase { | 17248 class LibraryElementBuilderTest extends EngineTestCase { |
| 16609 | 17249 |
| 16610 /** | 17250 /** |
| 16611 * The source factory used to create [Source]. | 17251 * The source factory used to create [Source]. |
| 16612 */ | 17252 */ |
| 16613 SourceFactory _sourceFactory; | 17253 SourceFactory _sourceFactory; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16886 Source source = addSource(EngineTestCase.createSource([ | 17526 Source source = addSource(EngineTestCase.createSource([ |
| 16887 "class A {", | 17527 "class A {", |
| 16888 " static int get g => (a,b) => 0;", | 17528 " static int get g => (a,b) => 0;", |
| 16889 "}", | 17529 "}", |
| 16890 "class B {", | 17530 "class B {", |
| 16891 " f() {", | 17531 " f() {", |
| 16892 " A.g(1,0);", | 17532 " A.g(1,0);", |
| 16893 " }", | 17533 " }", |
| 16894 "}"])); | 17534 "}"])); |
| 16895 resolve(source); | 17535 resolve(source); |
| 16896 assertNoErrors(); | 17536 assertNoErrors(source); |
| 16897 verify([source]); | 17537 verify([source]); |
| 16898 } | 17538 } |
| 16899 void test_argumentResolution_required_matching() { | 17539 void test_argumentResolution_required_matching() { |
| 16900 Source source = addSource(EngineTestCase.createSource([ | 17540 Source source = addSource(EngineTestCase.createSource([ |
| 16901 "class A {", | 17541 "class A {", |
| 16902 " void f() {", | 17542 " void f() {", |
| 16903 " g(1, 2, 3);", | 17543 " g(1, 2, 3);", |
| 16904 " }", | 17544 " }", |
| 16905 " void g(a, b, c) {}", | 17545 " void g(a, b, c) {}", |
| 16906 "}"])); | 17546 "}"])); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16988 } | 17628 } |
| 16989 void test_class_definesCall() { | 17629 void test_class_definesCall() { |
| 16990 Source source = addSource(EngineTestCase.createSource([ | 17630 Source source = addSource(EngineTestCase.createSource([ |
| 16991 "class A {", | 17631 "class A {", |
| 16992 " int call(int x) { return x; }", | 17632 " int call(int x) { return x; }", |
| 16993 "}", | 17633 "}", |
| 16994 "int f(A a) {", | 17634 "int f(A a) {", |
| 16995 " return a(0);", | 17635 " return a(0);", |
| 16996 "}"])); | 17636 "}"])); |
| 16997 resolve(source); | 17637 resolve(source); |
| 16998 assertNoErrors(); | 17638 assertNoErrors(source); |
| 16999 verify([source]); | 17639 verify([source]); |
| 17000 } | 17640 } |
| 17001 void test_class_extends_implements() { | 17641 void test_class_extends_implements() { |
| 17002 Source source = addSource(EngineTestCase.createSource([ | 17642 Source source = addSource(EngineTestCase.createSource([ |
| 17003 "class A extends B implements C {}", | 17643 "class A extends B implements C {}", |
| 17004 "class B {}", | 17644 "class B {}", |
| 17005 "class C {}"])); | 17645 "class C {}"])); |
| 17006 resolve(source); | 17646 resolve(source); |
| 17007 assertNoErrors(); | 17647 assertNoErrors(source); |
| 17008 verify([source]); | 17648 verify([source]); |
| 17009 } | 17649 } |
| 17010 void test_commentReference_class() { | 17650 void test_commentReference_class() { |
| 17011 Source source = addSource(EngineTestCase.createSource([ | 17651 Source source = addSource(EngineTestCase.createSource([ |
| 17012 "f() {}", | 17652 "f() {}", |
| 17013 "/** [A] [new A] [A.n] [new A.n] [m] [f] */", | 17653 "/** [A] [new A] [A.n] [new A.n] [m] [f] */", |
| 17014 "class A {", | 17654 "class A {", |
| 17015 " A() {}", | 17655 " A() {}", |
| 17016 " A.n() {}", | 17656 " A.n() {}", |
| 17017 " m() {}", | 17657 " m() {}", |
| 17018 "}"])); | 17658 "}"])); |
| 17019 resolve(source); | 17659 resolve(source); |
| 17020 assertNoErrors(); | 17660 assertNoErrors(source); |
| 17021 verify([source]); | 17661 verify([source]); |
| 17022 } | 17662 } |
| 17023 void test_commentReference_parameter() { | 17663 void test_commentReference_parameter() { |
| 17024 Source source = addSource(EngineTestCase.createSource([ | 17664 Source source = addSource(EngineTestCase.createSource([ |
| 17025 "class A {", | 17665 "class A {", |
| 17026 " A() {}", | 17666 " A() {}", |
| 17027 " A.n() {}", | 17667 " A.n() {}", |
| 17028 " /** [e] [f] */", | 17668 " /** [e] [f] */", |
| 17029 " m(e, f()) {}", | 17669 " m(e, f()) {}", |
| 17030 "}"])); | 17670 "}"])); |
| 17031 resolve(source); | 17671 resolve(source); |
| 17032 assertNoErrors(); | 17672 assertNoErrors(source); |
| 17033 verify([source]); | 17673 verify([source]); |
| 17034 } | 17674 } |
| 17035 void test_commentReference_singleLine() { | 17675 void test_commentReference_singleLine() { |
| 17036 Source source = addSource(EngineTestCase.createSource(["/// [A]", "class A {
}"])); | 17676 Source source = addSource(EngineTestCase.createSource(["/// [A]", "class A {
}"])); |
| 17037 resolve(source); | 17677 resolve(source); |
| 17038 assertNoErrors(); | 17678 assertNoErrors(source); |
| 17039 verify([source]); | 17679 verify([source]); |
| 17040 } | 17680 } |
| 17041 void test_empty() { | 17681 void test_empty() { |
| 17042 Source source = addSource(""); | 17682 Source source = addSource(""); |
| 17043 resolve(source); | 17683 resolve(source); |
| 17044 assertNoErrors(); | 17684 assertNoErrors(source); |
| 17045 verify([source]); | 17685 verify([source]); |
| 17046 } | 17686 } |
| 17047 void test_extractedMethodAsConstant() { | 17687 void test_extractedMethodAsConstant() { |
| 17048 Source source = addSource(EngineTestCase.createSource([ | 17688 Source source = addSource(EngineTestCase.createSource([ |
| 17049 "abstract class Comparable<T> {", | 17689 "abstract class Comparable<T> {", |
| 17050 " int compareTo(T other);", | 17690 " int compareTo(T other);", |
| 17051 " static int compare(Comparable a, Comparable b) => a.compareTo(b);", | 17691 " static int compare(Comparable a, Comparable b) => a.compareTo(b);", |
| 17052 "}", | 17692 "}", |
| 17053 "class A {", | 17693 "class A {", |
| 17054 " void sort([compare = Comparable.compare]) {}", | 17694 " void sort([compare = Comparable.compare]) {}", |
| 17055 "}"])); | 17695 "}"])); |
| 17056 resolve(source); | 17696 resolve(source); |
| 17057 assertNoErrors(); | 17697 assertNoErrors(source); |
| 17058 verify([source]); | 17698 verify([source]); |
| 17059 } | 17699 } |
| 17060 void test_fieldFormalParameter() { | 17700 void test_fieldFormalParameter() { |
| 17061 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); | 17701 Source source = addSource(EngineTestCase.createSource(["class A {", " int x
;", " A(this.x) {}", "}"])); |
| 17062 resolve(source); | 17702 resolve(source); |
| 17063 assertNoErrors(); | 17703 assertNoErrors(source); |
| 17064 verify([source]); | 17704 verify([source]); |
| 17065 } | 17705 } |
| 17066 void test_forEachLoops_nonConflicting() { | 17706 void test_forEachLoops_nonConflicting() { |
| 17067 Source source = addSource(EngineTestCase.createSource([ | 17707 Source source = addSource(EngineTestCase.createSource([ |
| 17068 "f() {", | 17708 "f() {", |
| 17069 " List list = [1,2,3];", | 17709 " List list = [1,2,3];", |
| 17070 " for (int x in list) {}", | 17710 " for (int x in list) {}", |
| 17071 " for (int x in list) {}", | 17711 " for (int x in list) {}", |
| 17072 "}"])); | 17712 "}"])); |
| 17073 resolve(source); | 17713 resolve(source); |
| 17074 assertNoErrors(); | 17714 assertNoErrors(source); |
| 17075 verify([source]); | 17715 verify([source]); |
| 17076 } | 17716 } |
| 17077 void test_forLoops_nonConflicting() { | 17717 void test_forLoops_nonConflicting() { |
| 17078 Source source = addSource(EngineTestCase.createSource([ | 17718 Source source = addSource(EngineTestCase.createSource([ |
| 17079 "f() {", | 17719 "f() {", |
| 17080 " for (int i = 0; i < 3; i++) {", | 17720 " for (int i = 0; i < 3; i++) {", |
| 17081 " }", | 17721 " }", |
| 17082 " for (int i = 0; i < 3; i++) {", | 17722 " for (int i = 0; i < 3; i++) {", |
| 17083 " }", | 17723 " }", |
| 17084 "}"])); | 17724 "}"])); |
| 17085 resolve(source); | 17725 resolve(source); |
| 17086 assertNoErrors(); | 17726 assertNoErrors(source); |
| 17087 verify([source]); | 17727 verify([source]); |
| 17088 } | 17728 } |
| 17089 void test_functionTypeAlias() { | 17729 void test_functionTypeAlias() { |
| 17090 Source source = addSource(EngineTestCase.createSource([ | 17730 Source source = addSource(EngineTestCase.createSource([ |
| 17091 "typedef bool P(e);", | 17731 "typedef bool P(e);", |
| 17092 "class A {", | 17732 "class A {", |
| 17093 " P p;", | 17733 " P p;", |
| 17094 " m(e) {", | 17734 " m(e) {", |
| 17095 " if (p(e)) {}", | 17735 " if (p(e)) {}", |
| 17096 " }", | 17736 " }", |
| 17097 "}"])); | 17737 "}"])); |
| 17098 resolve(source); | 17738 resolve(source); |
| 17099 assertNoErrors(); | 17739 assertNoErrors(source); |
| 17100 verify([source]); | 17740 verify([source]); |
| 17101 } | 17741 } |
| 17102 void test_getterAndSetterWithDifferentTypes() { | 17742 void test_getterAndSetterWithDifferentTypes() { |
| 17103 Source source = addSource(EngineTestCase.createSource([ | 17743 Source source = addSource(EngineTestCase.createSource([ |
| 17104 "class A {", | 17744 "class A {", |
| 17105 " int get f => 0;", | 17745 " int get f => 0;", |
| 17106 " void set f(String s) {}", | 17746 " void set f(String s) {}", |
| 17107 "}", | 17747 "}", |
| 17108 "g (A a) {", | 17748 "g (A a) {", |
| 17109 " a.f = a.f.toString();", | 17749 " a.f = a.f.toString();", |
| 17110 "}"])); | 17750 "}"])); |
| 17111 resolve(source); | 17751 resolve(source); |
| 17112 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); | 17752 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES])
; |
| 17113 verify([source]); | 17753 verify([source]); |
| 17114 } | 17754 } |
| 17115 void test_hasReferenceToSuper() { | 17755 void test_hasReferenceToSuper() { |
| 17116 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B {toString() => super.toString();}"])); | 17756 Source source = addSource(EngineTestCase.createSource(["class A {}", "class
B {toString() => super.toString();}"])); |
| 17117 LibraryElement library = resolve(source); | 17757 LibraryElement library = resolve(source); |
| 17118 JUnitTestCase.assertNotNull(library); | 17758 JUnitTestCase.assertNotNull(library); |
| 17119 CompilationUnitElement unit = library.definingCompilationUnit; | 17759 CompilationUnitElement unit = library.definingCompilationUnit; |
| 17120 JUnitTestCase.assertNotNull(unit); | 17760 JUnitTestCase.assertNotNull(unit); |
| 17121 List<ClassElement> classes = unit.types; | 17761 List<ClassElement> classes = unit.types; |
| 17122 EngineTestCase.assertLength(2, classes); | 17762 EngineTestCase.assertLength(2, classes); |
| 17123 JUnitTestCase.assertFalse(classes[0].hasReferenceToSuper()); | 17763 JUnitTestCase.assertFalse(classes[0].hasReferenceToSuper()); |
| 17124 JUnitTestCase.assertTrue(classes[1].hasReferenceToSuper()); | 17764 JUnitTestCase.assertTrue(classes[1].hasReferenceToSuper()); |
| 17125 assertNoErrors(); | 17765 assertNoErrors(source); |
| 17126 verify([source]); | 17766 verify([source]); |
| 17127 } | 17767 } |
| 17128 void test_import_hide() { | 17768 void test_import_hide() { |
| 17129 addSource2("lib1.dart", EngineTestCase.createSource(["library lib1;", "set f
oo(value) {}", "class A {}"])); | 17769 addSource2("lib1.dart", EngineTestCase.createSource(["library lib1;", "set f
oo(value) {}", "class A {}"])); |
| 17130 addSource2("lib2.dart", EngineTestCase.createSource(["library lib2;", "set f
oo(value) {}"])); | 17770 addSource2("lib2.dart", EngineTestCase.createSource(["library lib2;", "set f
oo(value) {}"])); |
| 17131 Source source = addSource2("lib3.dart", EngineTestCase.createSource([ | 17771 Source source = addSource2("lib3.dart", EngineTestCase.createSource([ |
| 17132 "import 'lib1.dart' hide foo;", | 17772 "import 'lib1.dart' hide foo;", |
| 17133 "import 'lib2.dart';", | 17773 "import 'lib2.dart';", |
| 17134 "", | 17774 "", |
| 17135 "main() {", | 17775 "main() {", |
| 17136 " foo = 0;", | 17776 " foo = 0;", |
| 17137 "}", | 17777 "}", |
| 17138 "A a;"])); | 17778 "A a;"])); |
| 17139 resolve(source); | 17779 resolve(source); |
| 17140 assertNoErrors(); | 17780 assertNoErrors(source); |
| 17141 verify([source]); | 17781 verify([source]); |
| 17142 } | 17782 } |
| 17143 void test_import_prefix() { | 17783 void test_import_prefix() { |
| 17144 addSource2("/two.dart", EngineTestCase.createSource(["library two;", "f(int
x) {", " return x * x;", "}"])); | 17784 addSource2("/two.dart", EngineTestCase.createSource(["library two;", "f(int
x) {", " return x * x;", "}"])); |
| 17145 Source source = addSource2("/one.dart", EngineTestCase.createSource([ | 17785 Source source = addSource2("/one.dart", EngineTestCase.createSource([ |
| 17146 "library one;", | 17786 "library one;", |
| 17147 "import 'two.dart' as _two;", | 17787 "import 'two.dart' as _two;", |
| 17148 "main() {", | 17788 "main() {", |
| 17149 " _two.f(0);", | 17789 " _two.f(0);", |
| 17150 "}"])); | 17790 "}"])); |
| 17151 resolve(source); | 17791 resolve(source); |
| 17152 assertNoErrors(); | 17792 assertNoErrors(source); |
| 17153 verify([source]); | 17793 verify([source]); |
| 17154 } | 17794 } |
| 17155 void test_import_spaceInUri() { | 17795 void test_import_spaceInUri() { |
| 17156 addSource2("sub folder/lib.dart", EngineTestCase.createSource(["library lib;
", "foo() {}"])); | 17796 addSource2("sub folder/lib.dart", EngineTestCase.createSource(["library lib;
", "foo() {}"])); |
| 17157 Source source = addSource2("app.dart", EngineTestCase.createSource([ | 17797 Source source = addSource2("app.dart", EngineTestCase.createSource([ |
| 17158 "import 'sub folder/lib.dart';", | 17798 "import 'sub folder/lib.dart';", |
| 17159 "", | 17799 "", |
| 17160 "main() {", | 17800 "main() {", |
| 17161 " foo();", | 17801 " foo();", |
| 17162 "}"])); | 17802 "}"])); |
| 17163 resolve(source); | 17803 resolve(source); |
| 17164 assertNoErrors(); | 17804 assertNoErrors(source); |
| 17165 verify([source]); | 17805 verify([source]); |
| 17166 } | 17806 } |
| 17167 void test_indexExpression_typeParameters() { | 17807 void test_indexExpression_typeParameters() { |
| 17168 Source source = addSource(EngineTestCase.createSource([ | 17808 Source source = addSource(EngineTestCase.createSource([ |
| 17169 "f() {", | 17809 "f() {", |
| 17170 " List<int> a;", | 17810 " List<int> a;", |
| 17171 " a[0];", | 17811 " a[0];", |
| 17172 " List<List<int>> b;", | 17812 " List<List<int>> b;", |
| 17173 " b[0][0];", | 17813 " b[0][0];", |
| 17174 " List<List<List<int>>> c;", | 17814 " List<List<List<int>>> c;", |
| 17175 " c[0][0][0];", | 17815 " c[0][0][0];", |
| 17176 "}"])); | 17816 "}"])); |
| 17177 resolve(source); | 17817 resolve(source); |
| 17178 assertNoErrors(); | 17818 assertNoErrors(source); |
| 17179 verify([source]); | 17819 verify([source]); |
| 17180 } | 17820 } |
| 17181 void test_indexExpression_typeParameters_invalidAssignmentWarning() { | 17821 void test_indexExpression_typeParameters_invalidAssignmentWarning() { |
| 17182 Source source = addSource(EngineTestCase.createSource(["f() {", " List<List
<int>> b;", " b[0][0] = 'hi';", "}"])); | 17822 Source source = addSource(EngineTestCase.createSource(["f() {", " List<List
<int>> b;", " b[0][0] = 'hi';", "}"])); |
| 17183 resolve(source); | 17823 resolve(source); |
| 17184 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 17824 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); |
| 17185 verify([source]); | 17825 verify([source]); |
| 17186 } | 17826 } |
| 17187 void test_indirectOperatorThroughCall() { | 17827 void test_indirectOperatorThroughCall() { |
| 17188 Source source = addSource(EngineTestCase.createSource([ | 17828 Source source = addSource(EngineTestCase.createSource([ |
| 17189 "class A {", | 17829 "class A {", |
| 17190 " B call() { return new B(); }", | 17830 " B call() { return new B(); }", |
| 17191 "}", | 17831 "}", |
| 17192 "", | 17832 "", |
| 17193 "class B {", | 17833 "class B {", |
| 17194 " int operator [](int i) { return i; }", | 17834 " int operator [](int i) { return i; }", |
| 17195 "}", | 17835 "}", |
| 17196 "", | 17836 "", |
| 17197 "A f = new A();", | 17837 "A f = new A();", |
| 17198 "", | 17838 "", |
| 17199 "g(int x) {}", | 17839 "g(int x) {}", |
| 17200 "", | 17840 "", |
| 17201 "main() {", | 17841 "main() {", |
| 17202 " g(f()[0]);", | 17842 " g(f()[0]);", |
| 17203 "}"])); | 17843 "}"])); |
| 17204 resolve(source); | 17844 resolve(source); |
| 17205 assertNoErrors(); | 17845 assertNoErrors(source); |
| 17206 verify([source]); | 17846 verify([source]); |
| 17207 } | 17847 } |
| 17208 void test_invoke_dynamicThroughGetter() { | 17848 void test_invoke_dynamicThroughGetter() { |
| 17209 Source source = addSource(EngineTestCase.createSource([ | 17849 Source source = addSource(EngineTestCase.createSource([ |
| 17210 "class A {", | 17850 "class A {", |
| 17211 " List get X => [() => 0];", | 17851 " List get X => [() => 0];", |
| 17212 " m(A a) {", | 17852 " m(A a) {", |
| 17213 " X.last;", | 17853 " X.last;", |
| 17214 " }", | 17854 " }", |
| 17215 "}"])); | 17855 "}"])); |
| 17216 resolve(source); | 17856 resolve(source); |
| 17217 assertNoErrors(); | 17857 assertNoErrors(source); |
| 17218 verify([source]); | 17858 verify([source]); |
| 17219 } | 17859 } |
| 17220 void test_isValidMixin_badSuperclass() { | 17860 void test_isValidMixin_badSuperclass() { |
| 17221 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B {}"])); | 17861 Source source = addSource(EngineTestCase.createSource(["class A extends B {}
", "class B {}"])); |
| 17222 LibraryElement library = resolve(source); | 17862 LibraryElement library = resolve(source); |
| 17223 JUnitTestCase.assertNotNull(library); | 17863 JUnitTestCase.assertNotNull(library); |
| 17224 CompilationUnitElement unit = library.definingCompilationUnit; | 17864 CompilationUnitElement unit = library.definingCompilationUnit; |
| 17225 JUnitTestCase.assertNotNull(unit); | 17865 JUnitTestCase.assertNotNull(unit); |
| 17226 List<ClassElement> classes = unit.types; | 17866 List<ClassElement> classes = unit.types; |
| 17227 EngineTestCase.assertLength(2, classes); | 17867 EngineTestCase.assertLength(2, classes); |
| 17228 JUnitTestCase.assertFalse(classes[0].isValidMixin); | 17868 JUnitTestCase.assertFalse(classes[0].isValidMixin); |
| 17229 assertNoErrors(); | 17869 assertNoErrors(source); |
| 17230 verify([source]); | 17870 verify([source]); |
| 17231 } | 17871 } |
| 17232 void test_isValidMixin_constructor() { | 17872 void test_isValidMixin_constructor() { |
| 17233 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}"])); | 17873 Source source = addSource(EngineTestCase.createSource(["class A {", " A() {
}", "}"])); |
| 17234 LibraryElement library = resolve(source); | 17874 LibraryElement library = resolve(source); |
| 17235 JUnitTestCase.assertNotNull(library); | 17875 JUnitTestCase.assertNotNull(library); |
| 17236 CompilationUnitElement unit = library.definingCompilationUnit; | 17876 CompilationUnitElement unit = library.definingCompilationUnit; |
| 17237 JUnitTestCase.assertNotNull(unit); | 17877 JUnitTestCase.assertNotNull(unit); |
| 17238 List<ClassElement> classes = unit.types; | 17878 List<ClassElement> classes = unit.types; |
| 17239 EngineTestCase.assertLength(1, classes); | 17879 EngineTestCase.assertLength(1, classes); |
| 17240 JUnitTestCase.assertFalse(classes[0].isValidMixin); | 17880 JUnitTestCase.assertFalse(classes[0].isValidMixin); |
| 17241 assertNoErrors(); | 17881 assertNoErrors(source); |
| 17242 verify([source]); | 17882 verify([source]); |
| 17243 } | 17883 } |
| 17244 void test_isValidMixin_super() { | 17884 void test_isValidMixin_super() { |
| 17245 Source source = addSource(EngineTestCase.createSource([ | 17885 Source source = addSource(EngineTestCase.createSource([ |
| 17246 "class A {", | 17886 "class A {", |
| 17247 " toString() {", | 17887 " toString() {", |
| 17248 " return super.toString();", | 17888 " return super.toString();", |
| 17249 " }", | 17889 " }", |
| 17250 "}"])); | 17890 "}"])); |
| 17251 LibraryElement library = resolve(source); | 17891 LibraryElement library = resolve(source); |
| 17252 JUnitTestCase.assertNotNull(library); | 17892 JUnitTestCase.assertNotNull(library); |
| 17253 CompilationUnitElement unit = library.definingCompilationUnit; | 17893 CompilationUnitElement unit = library.definingCompilationUnit; |
| 17254 JUnitTestCase.assertNotNull(unit); | 17894 JUnitTestCase.assertNotNull(unit); |
| 17255 List<ClassElement> classes = unit.types; | 17895 List<ClassElement> classes = unit.types; |
| 17256 EngineTestCase.assertLength(1, classes); | 17896 EngineTestCase.assertLength(1, classes); |
| 17257 JUnitTestCase.assertFalse(classes[0].isValidMixin); | 17897 JUnitTestCase.assertFalse(classes[0].isValidMixin); |
| 17258 assertNoErrors(); | 17898 assertNoErrors(source); |
| 17259 verify([source]); | 17899 verify([source]); |
| 17260 } | 17900 } |
| 17261 void test_isValidMixin_valid() { | 17901 void test_isValidMixin_valid() { |
| 17262 Source source = addSource(EngineTestCase.createSource(["class A {}"])); | 17902 Source source = addSource(EngineTestCase.createSource(["class A {}"])); |
| 17263 LibraryElement library = resolve(source); | 17903 LibraryElement library = resolve(source); |
| 17264 JUnitTestCase.assertNotNull(library); | 17904 JUnitTestCase.assertNotNull(library); |
| 17265 CompilationUnitElement unit = library.definingCompilationUnit; | 17905 CompilationUnitElement unit = library.definingCompilationUnit; |
| 17266 JUnitTestCase.assertNotNull(unit); | 17906 JUnitTestCase.assertNotNull(unit); |
| 17267 List<ClassElement> classes = unit.types; | 17907 List<ClassElement> classes = unit.types; |
| 17268 EngineTestCase.assertLength(1, classes); | 17908 EngineTestCase.assertLength(1, classes); |
| 17269 JUnitTestCase.assertTrue(classes[0].isValidMixin); | 17909 JUnitTestCase.assertTrue(classes[0].isValidMixin); |
| 17270 assertNoErrors(); | 17910 assertNoErrors(source); |
| 17271 verify([source]); | 17911 verify([source]); |
| 17272 } | 17912 } |
| 17273 void test_labels_switch() { | 17913 void test_labels_switch() { |
| 17274 Source source = addSource(EngineTestCase.createSource([ | 17914 Source source = addSource(EngineTestCase.createSource([ |
| 17275 "void doSwitch(int target) {", | 17915 "void doSwitch(int target) {", |
| 17276 " switch (target) {", | 17916 " switch (target) {", |
| 17277 " l0: case 0:", | 17917 " l0: case 0:", |
| 17278 " continue l1;", | 17918 " continue l1;", |
| 17279 " l1: case 1:", | 17919 " l1: case 1:", |
| 17280 " continue l0;", | 17920 " continue l0;", |
| 17281 " default:", | 17921 " default:", |
| 17282 " continue l1;", | 17922 " continue l1;", |
| 17283 " }", | 17923 " }", |
| 17284 "}"])); | 17924 "}"])); |
| 17285 LibraryElement library = resolve(source); | 17925 LibraryElement library = resolve(source); |
| 17286 JUnitTestCase.assertNotNull(library); | 17926 JUnitTestCase.assertNotNull(library); |
| 17287 assertNoErrors(); | 17927 assertNoErrors(source); |
| 17288 verify([source]); | 17928 verify([source]); |
| 17289 } | 17929 } |
| 17290 void test_metadata_class() { | 17930 void test_metadata_class() { |
| 17291 Source source = addSource(EngineTestCase.createSource(["const A = null;", "@
A class C {}"])); | 17931 Source source = addSource(EngineTestCase.createSource(["const A = null;", "@
A class C {}"])); |
| 17292 LibraryElement library = resolve(source); | 17932 LibraryElement library = resolve(source); |
| 17293 JUnitTestCase.assertNotNull(library); | 17933 JUnitTestCase.assertNotNull(library); |
| 17294 CompilationUnitElement unit = library.definingCompilationUnit; | 17934 CompilationUnitElement unit = library.definingCompilationUnit; |
| 17295 JUnitTestCase.assertNotNull(unit); | 17935 JUnitTestCase.assertNotNull(unit); |
| 17296 List<ClassElement> classes = unit.types; | 17936 List<ClassElement> classes = unit.types; |
| 17297 EngineTestCase.assertLength(1, classes); | 17937 EngineTestCase.assertLength(1, classes); |
| 17298 List<ElementAnnotation> annotations = classes[0].metadata; | 17938 List<ElementAnnotation> annotations = classes[0].metadata; |
| 17299 EngineTestCase.assertLength(1, annotations); | 17939 EngineTestCase.assertLength(1, annotations); |
| 17300 assertNoErrors(); | 17940 assertNoErrors(source); |
| 17301 verify([source]); | 17941 verify([source]); |
| 17302 } | 17942 } |
| 17303 void test_metadata_field() { | 17943 void test_metadata_field() { |
| 17304 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c
lass C {", " @A int f;", "}"])); | 17944 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c
lass C {", " @A int f;", "}"])); |
| 17305 LibraryElement library = resolve(source); | 17945 LibraryElement library = resolve(source); |
| 17306 JUnitTestCase.assertNotNull(library); | 17946 JUnitTestCase.assertNotNull(library); |
| 17307 CompilationUnitElement unit = library.definingCompilationUnit; | 17947 CompilationUnitElement unit = library.definingCompilationUnit; |
| 17308 JUnitTestCase.assertNotNull(unit); | 17948 JUnitTestCase.assertNotNull(unit); |
| 17309 List<ClassElement> classes = unit.types; | 17949 List<ClassElement> classes = unit.types; |
| 17310 EngineTestCase.assertLength(1, classes); | 17950 EngineTestCase.assertLength(1, classes); |
| 17311 FieldElement field = classes[0].fields[0]; | 17951 FieldElement field = classes[0].fields[0]; |
| 17312 List<ElementAnnotation> annotations = field.metadata; | 17952 List<ElementAnnotation> annotations = field.metadata; |
| 17313 EngineTestCase.assertLength(1, annotations); | 17953 EngineTestCase.assertLength(1, annotations); |
| 17314 assertNoErrors(); | 17954 assertNoErrors(source); |
| 17315 verify([source]); | 17955 verify([source]); |
| 17316 } | 17956 } |
| 17317 void test_metadata_libraryDirective() { | 17957 void test_metadata_libraryDirective() { |
| 17318 Source source = addSource(EngineTestCase.createSource(["@A library lib;", "c
onst A = null;"])); | 17958 Source source = addSource(EngineTestCase.createSource(["@A library lib;", "c
onst A = null;"])); |
| 17319 LibraryElement library = resolve(source); | 17959 LibraryElement library = resolve(source); |
| 17320 JUnitTestCase.assertNotNull(library); | 17960 JUnitTestCase.assertNotNull(library); |
| 17321 List<ElementAnnotation> annotations = library.metadata; | 17961 List<ElementAnnotation> annotations = library.metadata; |
| 17322 EngineTestCase.assertLength(1, annotations); | 17962 EngineTestCase.assertLength(1, annotations); |
| 17323 assertNoErrors(); | 17963 assertNoErrors(source); |
| 17324 verify([source]); | 17964 verify([source]); |
| 17325 } | 17965 } |
| 17326 void test_metadata_method() { | 17966 void test_metadata_method() { |
| 17327 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c
lass C {", " @A void m() {}", "}"])); | 17967 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c
lass C {", " @A void m() {}", "}"])); |
| 17328 LibraryElement library = resolve(source); | 17968 LibraryElement library = resolve(source); |
| 17329 JUnitTestCase.assertNotNull(library); | 17969 JUnitTestCase.assertNotNull(library); |
| 17330 CompilationUnitElement unit = library.definingCompilationUnit; | 17970 CompilationUnitElement unit = library.definingCompilationUnit; |
| 17331 JUnitTestCase.assertNotNull(unit); | 17971 JUnitTestCase.assertNotNull(unit); |
| 17332 List<ClassElement> classes = unit.types; | 17972 List<ClassElement> classes = unit.types; |
| 17333 EngineTestCase.assertLength(1, classes); | 17973 EngineTestCase.assertLength(1, classes); |
| 17334 MethodElement method = classes[0].methods[0]; | 17974 MethodElement method = classes[0].methods[0]; |
| 17335 List<ElementAnnotation> annotations = method.metadata; | 17975 List<ElementAnnotation> annotations = method.metadata; |
| 17336 EngineTestCase.assertLength(1, annotations); | 17976 EngineTestCase.assertLength(1, annotations); |
| 17337 assertNoErrors(); | 17977 assertNoErrors(source); |
| 17338 verify([source]); | 17978 verify([source]); |
| 17339 } | 17979 } |
| 17340 void test_method_fromMixin() { | 17980 void test_method_fromMixin() { |
| 17341 Source source = addSource(EngineTestCase.createSource([ | 17981 Source source = addSource(EngineTestCase.createSource([ |
| 17342 "class B {", | 17982 "class B {", |
| 17343 " bar() => 1;", | 17983 " bar() => 1;", |
| 17344 "}", | 17984 "}", |
| 17345 "class A {", | 17985 "class A {", |
| 17346 " foo() => 2;", | 17986 " foo() => 2;", |
| 17347 "}", | 17987 "}", |
| 17348 "", | 17988 "", |
| 17349 "class C extends B with A {", | 17989 "class C extends B with A {", |
| 17350 " bar() => super.bar();", | 17990 " bar() => super.bar();", |
| 17351 " foo() => super.foo();", | 17991 " foo() => super.foo();", |
| 17352 "}"])); | 17992 "}"])); |
| 17353 resolve(source); | 17993 resolve(source); |
| 17354 assertNoErrors(); | 17994 assertNoErrors(source); |
| 17355 verify([source]); | 17995 verify([source]); |
| 17356 } | 17996 } |
| 17357 void test_method_fromSuperclassMixin() { | 17997 void test_method_fromSuperclassMixin() { |
| 17358 Source source = addSource(EngineTestCase.createSource([ | 17998 Source source = addSource(EngineTestCase.createSource([ |
| 17359 "class A {", | 17999 "class A {", |
| 17360 " void m1() {}", | 18000 " void m1() {}", |
| 17361 "}", | 18001 "}", |
| 17362 "class B extends Object with A {", | 18002 "class B extends Object with A {", |
| 17363 "}", | 18003 "}", |
| 17364 "class C extends B {", | 18004 "class C extends B {", |
| 17365 "}", | 18005 "}", |
| 17366 "f(C c) {", | 18006 "f(C c) {", |
| 17367 " c.m1();", | 18007 " c.m1();", |
| 17368 "}"])); | 18008 "}"])); |
| 17369 resolve(source); | 18009 resolve(source); |
| 17370 assertNoErrors(); | 18010 assertNoErrors(source); |
| 17371 verify([source]); | 18011 verify([source]); |
| 17372 } | 18012 } |
| 17373 void test_methodCascades() { | 18013 void test_methodCascades() { |
| 17374 Source source = addSource(EngineTestCase.createSource([ | 18014 Source source = addSource(EngineTestCase.createSource([ |
| 17375 "class A {", | 18015 "class A {", |
| 17376 " void m1() {}", | 18016 " void m1() {}", |
| 17377 " void m2() {}", | 18017 " void m2() {}", |
| 17378 " void m() {", | 18018 " void m() {", |
| 17379 " A a = new A();", | 18019 " A a = new A();", |
| 17380 " a..m1()", | 18020 " a..m1()", |
| 17381 " ..m2();", | 18021 " ..m2();", |
| 17382 " }", | 18022 " }", |
| 17383 "}"])); | 18023 "}"])); |
| 17384 resolve(source); | 18024 resolve(source); |
| 17385 assertNoErrors(); | 18025 assertNoErrors(source); |
| 17386 verify([source]); | 18026 verify([source]); |
| 17387 } | 18027 } |
| 17388 void test_methodCascades_withSetter() { | 18028 void test_methodCascades_withSetter() { |
| 17389 Source source = addSource(EngineTestCase.createSource([ | 18029 Source source = addSource(EngineTestCase.createSource([ |
| 17390 "class A {", | 18030 "class A {", |
| 17391 " String name;", | 18031 " String name;", |
| 17392 " void m1() {}", | 18032 " void m1() {}", |
| 17393 " void m2() {}", | 18033 " void m2() {}", |
| 17394 " void m() {", | 18034 " void m() {", |
| 17395 " A a = new A();", | 18035 " A a = new A();", |
| 17396 " a..m1()", | 18036 " a..m1()", |
| 17397 " ..name = 'name'", | 18037 " ..name = 'name'", |
| 17398 " ..m2();", | 18038 " ..m2();", |
| 17399 " }", | 18039 " }", |
| 17400 "}"])); | 18040 "}"])); |
| 17401 resolve(source); | 18041 resolve(source); |
| 17402 assertNoErrors(); | 18042 assertNoErrors(source); |
| 17403 verify([source]); | 18043 verify([source]); |
| 17404 } | 18044 } |
| 17405 void test_resolveAgainstNull() { | 18045 void test_resolveAgainstNull() { |
| 17406 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " retu
rn null == p;", "}"])); | 18046 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " retu
rn null == p;", "}"])); |
| 17407 resolve(source); | 18047 resolve(source); |
| 17408 assertNoErrors(); | 18048 assertNoErrors(source); |
| 17409 verify([source]); | 18049 verify([source]); |
| 17410 } | 18050 } |
| 17411 void test_setter_inherited() { | 18051 void test_setter_inherited() { |
| 17412 Source source = addSource(EngineTestCase.createSource([ | 18052 Source source = addSource(EngineTestCase.createSource([ |
| 17413 "class A {", | 18053 "class A {", |
| 17414 " int get x => 0;", | 18054 " int get x => 0;", |
| 17415 " set x(int p) {}", | 18055 " set x(int p) {}", |
| 17416 "}", | 18056 "}", |
| 17417 "class B extends A {", | 18057 "class B extends A {", |
| 17418 " int get x => super.x == null ? 0 : super.x;", | 18058 " int get x => super.x == null ? 0 : super.x;", |
| 17419 " int f() => x = 1;", | 18059 " int f() => x = 1;", |
| 17420 "}"])); | 18060 "}"])); |
| 17421 resolve(source); | 18061 resolve(source); |
| 17422 assertNoErrors(); | 18062 assertNoErrors(source); |
| 17423 verify([source]); | 18063 verify([source]); |
| 17424 } | 18064 } |
| 17425 void test_setter_static() { | 18065 void test_setter_static() { |
| 17426 Source source = addSource(EngineTestCase.createSource(["set s(x) {", "}", ""
, "main() {", " s = 123;", "}"])); | 18066 Source source = addSource(EngineTestCase.createSource(["set s(x) {", "}", ""
, "main() {", " s = 123;", "}"])); |
| 17427 resolve(source); | 18067 resolve(source); |
| 17428 assertNoErrors(); | 18068 assertNoErrors(source); |
| 17429 verify([source]); | 18069 verify([source]); |
| 17430 } | 18070 } |
| 17431 | 18071 |
| 17432 /** | 18072 /** |
| 17433 * Resolve the given source and verify that the arguments in a specific method
invocation were | 18073 * Resolve the given source and verify that the arguments in a specific method
invocation were |
| 17434 * correctly resolved. | 18074 * correctly resolved. |
| 17435 * | 18075 * |
| 17436 * The source is expected to be source for a compilation unit, the first decla
ration is expected | 18076 * The source is expected to be source for a compilation unit, the first decla
ration is expected |
| 17437 * to be a class, the first member of which is expected to be a method with a
block body, and the | 18077 * to be a class, the first member of which is expected to be a method with a
block body, and the |
| 17438 * first statement in the body is expected to be an expression statement whose
expression is a | 18078 * first statement in the body is expected to be an expression statement whose
expression is a |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17655 runJUnitTest(__test, __test.test_setter_inherited); | 18295 runJUnitTest(__test, __test.test_setter_inherited); |
| 17656 }); | 18296 }); |
| 17657 _ut.test('test_setter_static', () { | 18297 _ut.test('test_setter_static', () { |
| 17658 final __test = new SimpleResolverTest(); | 18298 final __test = new SimpleResolverTest(); |
| 17659 runJUnitTest(__test, __test.test_setter_static); | 18299 runJUnitTest(__test, __test.test_setter_static); |
| 17660 }); | 18300 }); |
| 17661 }); | 18301 }); |
| 17662 } | 18302 } |
| 17663 } | 18303 } |
| 17664 main() { | 18304 main() { |
| 17665 // ElementResolverTest.dartSuite(); | 18305 ElementResolverTest.dartSuite(); |
| 17666 // InheritanceManagerTest.dartSuite(); | 18306 InheritanceManagerTest.dartSuite(); |
| 17667 // LibraryElementBuilderTest.dartSuite(); | 18307 LibraryElementBuilderTest.dartSuite(); |
| 17668 // LibraryTest.dartSuite(); | 18308 LibraryTest.dartSuite(); |
| 17669 // StaticTypeAnalyzerTest.dartSuite(); | 18309 StaticTypeAnalyzerTest.dartSuite(); |
| 17670 // TypeOverrideManagerTest.dartSuite(); | 18310 TypeOverrideManagerTest.dartSuite(); |
| 17671 // TypeProviderImplTest.dartSuite(); | 18311 TypeProviderImplTest.dartSuite(); |
| 17672 // TypeResolverVisitorTest.dartSuite(); | 18312 TypeResolverVisitorTest.dartSuite(); |
| 17673 // EnclosedScopeTest.dartSuite(); | 18313 EnclosedScopeTest.dartSuite(); |
| 17674 // LibraryImportScopeTest.dartSuite(); | 18314 LibraryImportScopeTest.dartSuite(); |
| 17675 // LibraryScopeTest.dartSuite(); | 18315 LibraryScopeTest.dartSuite(); |
| 17676 // ScopeTest.dartSuite(); | 18316 ScopeTest.dartSuite(); |
| 17677 // CompileTimeErrorCodeTest.dartSuite(); | 18317 CompileTimeErrorCodeTest.dartSuite(); |
| 17678 // ErrorResolverTest.dartSuite(); | 18318 ErrorResolverTest.dartSuite(); |
| 17679 // HintCodeTest.dartSuite(); | 18319 HintCodeTest.dartSuite(); |
| 17680 // NonHintCodeTest.dartSuite(); | 18320 NonHintCodeTest.dartSuite(); |
| 17681 // NonErrorResolverTest.dartSuite(); | 18321 NonErrorResolverTest.dartSuite(); |
| 17682 // SimpleResolverTest.dartSuite(); | 18322 SimpleResolverTest.dartSuite(); |
| 17683 // StaticTypeWarningCodeTest.dartSuite(); | 18323 StaticTypeWarningCodeTest.dartSuite(); |
| 17684 // StaticWarningCodeTest.dartSuite(); | 18324 StaticWarningCodeTest.dartSuite(); |
| 17685 // StrictModeTest.dartSuite(); | 18325 StrictModeTest.dartSuite(); |
| 17686 // TypePropagationTest.dartSuite(); | 18326 TypePropagationTest.dartSuite(); |
| 17687 } | 18327 } |
| OLD | NEW |