| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/src/dart/analysis/driver.dart'; | 8 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 @override | 32 @override |
| 33 bool get enableNewAnalysisDriver => true; | 33 bool get enableNewAnalysisDriver => true; |
| 34 | 34 |
| 35 test_initializer_additive() async { | 35 test_initializer_additive() async { |
| 36 await _assertErrorOnlyLeft(['+', '-']); | 36 await _assertErrorOnlyLeft(['+', '-']); |
| 37 } | 37 } |
| 38 | 38 |
| 39 test_initializer_assign() async { | 39 test_initializer_assign() async { |
| 40 var content = r''' | 40 var content = r''' |
| 41 var a = 1; | 41 var a = 1; |
| 42 var t1 = /*error:TOP_LEVEL_UNSUPPORTED*/a += 1; | 42 var t1 = a += 1; |
| 43 var t2 = (/*error:TOP_LEVEL_UNSUPPORTED*/a = 2); | 43 var t2 = a = 2; |
| 44 '''; | 44 '''; |
| 45 await checkFile(content); | 45 await checkFile(content); |
| 46 } | 46 } |
| 47 | 47 |
| 48 test_initializer_binary_onlyLeft() async { | 48 test_initializer_binary_onlyLeft() async { |
| 49 var content = r''' | 49 var content = r''' |
| 50 var a = 1; | 50 var a = 1; |
| 51 var t = (/*error:TOP_LEVEL_UNSUPPORTED*/a = 1) + (a = 2); | 51 var t = (a = 1) + (a = 2); |
| 52 '''; | 52 '''; |
| 53 await checkFile(content); | 53 await checkFile(content); |
| 54 } | 54 } |
| 55 | 55 |
| 56 test_initializer_bitwise() async { | 56 test_initializer_bitwise() async { |
| 57 await _assertErrorOnlyLeft(['&', '|', '^']); | 57 await _assertErrorOnlyLeft(['&', '|', '^']); |
| 58 } | 58 } |
| 59 | 59 |
| 60 test_initializer_boolean() async { | 60 test_initializer_boolean() async { |
| 61 var content = r''' | 61 var content = r''' |
| 62 var a = 1; | 62 var a = 1; |
| 63 var t1 = ((a = 1) == 0) || ((a = 2) == 0); | 63 var t1 = ((a = 1) == 0) || ((a = 2) == 0); |
| 64 var t2 = ((a = 1) == 0) && ((a = 2) == 0); | 64 var t2 = ((a = 1) == 0) && ((a = 2) == 0); |
| 65 var t3 = !((a = 1) == 0); | 65 var t3 = !((a = 1) == 0); |
| 66 '''; | 66 '''; |
| 67 await checkFile(content); | 67 await checkFile(content); |
| 68 } | 68 } |
| 69 | 69 |
| 70 test_initializer_cascade() async { | 70 test_initializer_cascade() async { |
| 71 var content = r''' | 71 var content = r''' |
| 72 var a = 0; | 72 var a = 0; |
| 73 var t = (/*error:TOP_LEVEL_UNSUPPORTED*/a = 1)..isEven; | 73 var t = (a = 1)..isEven; |
| 74 '''; | 74 '''; |
| 75 await checkFile(content); | 75 await checkFile(content); |
| 76 } | 76 } |
| 77 | 77 |
| 78 test_initializer_classField_instance_instanceCreation() async { | 78 test_initializer_classField_instance_instanceCreation() async { |
| 79 var content = r''' | 79 var content = r''' |
| 80 class A<T> {} | 80 class A<T> {} |
| 81 class B { | 81 class B { |
| 82 var t1 = new A<int>(); | 82 var t1 = new A<int>(); |
| 83 var t2 = /*info:INFERRED_TYPE_ALLOCATION*/new | 83 var t2 = /*info:INFERRED_TYPE_ALLOCATION*/new A(); |
| 84 /*error:TOP_LEVEL_TYPE_ARGUMENTS*/A(); | |
| 85 } | 84 } |
| 86 '''; | 85 '''; |
| 87 await checkFile(content); | 86 await checkFile(content); |
| 88 } | 87 } |
| 89 | 88 |
| 90 test_initializer_classField_static_instanceCreation() async { | 89 test_initializer_classField_static_instanceCreation() async { |
| 91 var content = r''' | 90 var content = r''' |
| 92 class A<T> {} | 91 class A<T> {} |
| 93 class B { | 92 class B { |
| 94 static var t1 = 1; | 93 static var t1 = 1; |
| 95 static var t2 = /*info:INFERRED_TYPE_ALLOCATION*/new | 94 static var t2 = /*info:INFERRED_TYPE_ALLOCATION*/new A(); |
| 96 /*error:TOP_LEVEL_TYPE_ARGUMENTS*/A(); | |
| 97 } | 95 } |
| 98 '''; | 96 '''; |
| 99 await checkFile(content); | 97 await checkFile(content); |
| 100 } | 98 } |
| 101 | 99 |
| 102 test_initializer_conditional() async { | 100 test_initializer_conditional() async { |
| 103 var content = r''' | 101 var content = r''' |
| 104 var a = 1; | 102 var a = 1; |
| 105 var b = true; | 103 var b = true; |
| 106 var t = b ? | 104 var t = b ? |
| 107 (/*error:TOP_LEVEL_UNSUPPORTED*/a = 1) : | 105 (a = 1) : |
| 108 (/*error:TOP_LEVEL_UNSUPPORTED*/a = 2); | 106 (a = 2); |
| 109 '''; | 107 '''; |
| 110 await checkFile(content); | 108 await checkFile(content); |
| 111 } | 109 } |
| 112 | 110 |
| 113 test_initializer_dependencyCycle() async { | 111 test_initializer_dependencyCycle() async { |
| 114 var content = r''' | 112 var content = r''' |
| 115 var a = /*error:TOP_LEVEL_CYCLE*/b; | 113 var a = /*error:TOP_LEVEL_CYCLE*/b; |
| 116 var b = /*error:TOP_LEVEL_CYCLE*/a; | 114 var b = /*error:TOP_LEVEL_CYCLE*/a; |
| 117 '''; | 115 '''; |
| 118 await checkFile(content); | 116 await checkFile(content); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 141 var t = /*error:TOP_LEVEL_FUNCTION_LITERAL_BLOCK*/ | 139 var t = /*error:TOP_LEVEL_FUNCTION_LITERAL_BLOCK*/ |
| 142 /*info:INFERRED_TYPE_CLOSURE*/ | 140 /*info:INFERRED_TYPE_CLOSURE*/ |
| 143 (int p) {}; | 141 (int p) {}; |
| 144 '''; | 142 '''; |
| 145 await checkFile(content); | 143 await checkFile(content); |
| 146 } | 144 } |
| 147 | 145 |
| 148 test_initializer_functionLiteral_expressionBody() async { | 146 test_initializer_functionLiteral_expressionBody() async { |
| 149 var content = r''' | 147 var content = r''' |
| 150 var a = 0; | 148 var a = 0; |
| 151 var t = (int p) => (/*error:TOP_LEVEL_UNSUPPORTED*/a = 1); | 149 var t = (int p) => (a = 1); |
| 152 '''; | 150 '''; |
| 153 await checkFile(content); | 151 await checkFile(content); |
| 154 } | 152 } |
| 155 | 153 |
| 156 test_initializer_functionLiteral_parameters_withoutType() async { | 154 test_initializer_functionLiteral_parameters_withoutType() async { |
| 157 var content = r''' | 155 var content = r''' |
| 158 var t = (int a, | 156 var t = (int a, b,int c, d) => 0; |
| 159 /*error:TOP_LEVEL_FUNCTION_LITERAL_PARAMETER*/b, | |
| 160 int c, | |
| 161 /*error:TOP_LEVEL_FUNCTION_LITERAL_PARAMETER*/d) => 0; | |
| 162 '''; | 157 '''; |
| 163 await checkFile(content); | 158 await checkFile(content); |
| 164 } | 159 } |
| 165 | 160 |
| 166 test_initializer_hasTypeAnnotation() async { | 161 test_initializer_hasTypeAnnotation() async { |
| 167 var content = r''' | 162 var content = r''' |
| 168 var a = 1; | 163 var a = 1; |
| 169 int t = (a = 1); | 164 int t = (a = 1); |
| 170 '''; | 165 '''; |
| 171 await checkFile(content); | 166 await checkFile(content); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 189 var t5 = A.static_getter; | 184 var t5 = A.static_getter; |
| 190 var t6 = A.static_method; | 185 var t6 = A.static_method; |
| 191 var t7 = new A().instance_method; | 186 var t7 = new A().instance_method; |
| 192 '''; | 187 '''; |
| 193 await checkFile(content); | 188 await checkFile(content); |
| 194 } | 189 } |
| 195 | 190 |
| 196 test_initializer_identifier_error() async { | 191 test_initializer_identifier_error() async { |
| 197 var content = r''' | 192 var content = r''' |
| 198 var a = 0; | 193 var a = 0; |
| 199 var b = (/*error:TOP_LEVEL_UNSUPPORTED*/a = 1); | 194 var b = (a = 1); |
| 200 var c = /*error:TOP_LEVEL_IDENTIFIER_NO_TYPE*/b; | 195 var c = b; |
| 201 '''; | 196 '''; |
| 202 await checkFile(content); | 197 await checkFile(content); |
| 203 } | 198 } |
| 204 | 199 |
| 205 test_initializer_ifNull() async { | 200 test_initializer_ifNull() async { |
| 206 var content = r''' | 201 var content = r''' |
| 207 var a = 1; | 202 var a = 1; |
| 208 var t = /*error:TOP_LEVEL_UNSUPPORTED*/a ?? 2; | 203 var t = a ?? 2; |
| 209 '''; | 204 '''; |
| 210 await checkFile(content); | 205 await checkFile(content); |
| 211 } | 206 } |
| 212 | 207 |
| 213 test_initializer_instanceCreation_withoutTypeParameters() async { | 208 test_initializer_instanceCreation_withoutTypeParameters() async { |
| 214 var content = r''' | 209 var content = r''' |
| 215 class A {} | 210 class A {} |
| 216 var t = new A(); | 211 var t = new A(); |
| 217 '''; | 212 '''; |
| 218 await checkFile(content); | 213 await checkFile(content); |
| 219 } | 214 } |
| 220 | 215 |
| 221 test_initializer_instanceCreation_withTypeParameters() async { | 216 test_initializer_instanceCreation_withTypeParameters() async { |
| 222 var content = r''' | 217 var content = r''' |
| 223 class A<T> {} | 218 class A<T> {} |
| 224 var t1 = new A<int>(); | 219 var t1 = new A<int>(); |
| 225 var t2 = /*info:INFERRED_TYPE_ALLOCATION*/new | 220 var t2 = /*info:INFERRED_TYPE_ALLOCATION*/new A(); |
| 226 /*error:TOP_LEVEL_TYPE_ARGUMENTS*/A(); | |
| 227 '''; | 221 '''; |
| 228 await checkFile(content); | 222 await checkFile(content); |
| 229 } | 223 } |
| 230 | 224 |
| 231 test_initializer_instanceGetter() async { | 225 test_initializer_instanceGetter() async { |
| 232 var content = r''' | 226 var content = r''' |
| 233 class A { | 227 class A { |
| 234 int f = 1; | 228 int f = 1; |
| 235 } | 229 } |
| 236 var a = new A()./*error:TOP_LEVEL_INSTANCE_GETTER*/f; | 230 var a = new A().f; |
| 237 '''; | 231 '''; |
| 238 await checkFile(content); | 232 await checkFile(content); |
| 239 } | 233 } |
| 240 | 234 |
| 241 test_initializer_methodInvocation_function() async { | 235 test_initializer_methodInvocation_function() async { |
| 242 var content = r''' | 236 var content = r''' |
| 243 int f1() => null; | 237 int f1() => null; |
| 244 T f2<T>() => null; | 238 T f2<T>() => null; |
| 245 var t1 = f1(); | 239 var t1 = f1(); |
| 246 var t2 = /*error:TOP_LEVEL_TYPE_ARGUMENTS*/f2(); | 240 var t2 = f2(); |
| 247 var t3 = f2<int>(); | 241 var t3 = f2<int>(); |
| 248 '''; | 242 '''; |
| 249 await checkFile(content); | 243 await checkFile(content); |
| 250 } | 244 } |
| 251 | 245 |
| 252 test_initializer_methodInvocation_method() async { | 246 test_initializer_methodInvocation_method() async { |
| 253 var content = r''' | 247 var content = r''' |
| 254 class A { | 248 class A { |
| 255 int m1() => null; | 249 int m1() => null; |
| 256 T m2<T>() => null; | 250 T m2<T>() => null; |
| 257 } | 251 } |
| 258 var a = new A(); | 252 var a = new A(); |
| 259 var t1 = a.m1(); | 253 var t1 = a.m1(); |
| 260 var t2 = a./*error:TOP_LEVEL_TYPE_ARGUMENTS*/m2(); | 254 var t2 = a.m2(); |
| 261 var t3 = a.m2<int>(); | 255 var t3 = a.m2<int>(); |
| 262 '''; | 256 '''; |
| 263 await checkFile(content); | 257 await checkFile(content); |
| 264 } | 258 } |
| 265 | 259 |
| 266 test_initializer_multiplicative() async { | 260 test_initializer_multiplicative() async { |
| 267 await _assertErrorOnlyLeft(['*', '/', '%', '~/']); | 261 await _assertErrorOnlyLeft(['*', '/', '%', '~/']); |
| 268 } | 262 } |
| 269 | 263 |
| 270 test_initializer_postfixIncDec() async { | 264 test_initializer_postfixIncDec() async { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 var a = 1; | 300 var a = 1; |
| 307 var t = <int, int>{(a = 1) : (a = 2)}; | 301 var t = <int, int>{(a = 1) : (a = 2)}; |
| 308 '''; | 302 '''; |
| 309 await checkFile(content); | 303 await checkFile(content); |
| 310 } | 304 } |
| 311 | 305 |
| 312 test_initializer_untypedList() async { | 306 test_initializer_untypedList() async { |
| 313 var content = r''' | 307 var content = r''' |
| 314 var a = 1; | 308 var a = 1; |
| 315 var t = /*info:INFERRED_TYPE_LITERAL*/[ | 309 var t = /*info:INFERRED_TYPE_LITERAL*/[ |
| 316 /*error:TOP_LEVEL_UNSUPPORTED*/a = 1, | 310 a = 1, |
| 317 2, 3]; | 311 2, 3]; |
| 318 '''; | 312 '''; |
| 319 await checkFile(content); | 313 await checkFile(content); |
| 320 } | 314 } |
| 321 | 315 |
| 322 test_initializer_untypedMap() async { | 316 test_initializer_untypedMap() async { |
| 323 var content = r''' | 317 var content = r''' |
| 324 var a = 1; | 318 var a = 1; |
| 325 var t = /*info:INFERRED_TYPE_LITERAL*/{ | 319 var t = /*info:INFERRED_TYPE_LITERAL*/{ |
| 326 (/*error:TOP_LEVEL_UNSUPPORTED*/a = 1) : | 320 (a = 1) : |
| 327 (/*error:TOP_LEVEL_UNSUPPORTED*/a = 2)}; | 321 (a = 2)}; |
| 328 '''; | 322 '''; |
| 329 await checkFile(content); | 323 await checkFile(content); |
| 330 } | 324 } |
| 331 | 325 |
| 332 test_override_conflictFieldType() async { | 326 test_override_conflictFieldType() async { |
| 333 var content = r''' | 327 var content = r''' |
| 334 abstract class A { | 328 abstract class A { |
| 335 int aaa; | 329 int aaa; |
| 336 } | 330 } |
| 337 abstract class B { | 331 abstract class B { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 354 void mmm(String a); | 348 void mmm(String a); |
| 355 } | 349 } |
| 356 class C implements A, B { | 350 class C implements A, B { |
| 357 void mmm(/*error:TOP_LEVEL_INFERENCE_ERROR*/a) {} | 351 void mmm(/*error:TOP_LEVEL_INFERENCE_ERROR*/a) {} |
| 358 } | 352 } |
| 359 '''; | 353 '''; |
| 360 await checkFile(content); | 354 await checkFile(content); |
| 361 } | 355 } |
| 362 | 356 |
| 363 Future<Null> _assertErrorOnlyLeft(List<String> operators) async { | 357 Future<Null> _assertErrorOnlyLeft(List<String> operators) async { |
| 364 var err = '/*error:TOP_LEVEL_UNSUPPORTED*/'; | |
| 365 String code = 'var a = 1;\n'; | 358 String code = 'var a = 1;\n'; |
| 366 for (var i = 0; i < operators.length; i++) { | 359 for (var i = 0; i < operators.length; i++) { |
| 367 String operator = operators[i]; | 360 String operator = operators[i]; |
| 368 code += 'var t$i = (${err}a = 1) $operator (a = 2);\n'; | 361 code += 'var t$i = (a = 1) $operator (a = 2);\n'; |
| 369 } | 362 } |
| 370 await checkFile(code); | 363 await checkFile(code); |
| 371 } | 364 } |
| 372 } | 365 } |
| 373 | 366 |
| 374 @reflectiveTest | 367 @reflectiveTest |
| 375 class TopLevelInferenceTest extends BaseAnalysisDriverTest { | 368 class TopLevelInferenceTest extends BaseAnalysisDriverTest { |
| 376 void addFile(String path, String code) { | 369 void addFile(String path, String code) { |
| 377 provider.newFile(_p(path), code); | 370 provider.newFile(_p(path), code); |
| 378 } | 371 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 402 | 395 |
| 403 test_initializer_as() async { | 396 test_initializer_as() async { |
| 404 var library = await _encodeDecodeLibrary(r''' | 397 var library = await _encodeDecodeLibrary(r''' |
| 405 var V = 1 as num; | 398 var V = 1 as num; |
| 406 '''); | 399 '''); |
| 407 checkElementText(library, r''' | 400 checkElementText(library, r''' |
| 408 num V; | 401 num V; |
| 409 '''); | 402 '''); |
| 410 } | 403 } |
| 411 | 404 |
| 412 test_initializer_await() async { | 405 test_initializer_assign() async { |
| 413 var library = await _encodeDecodeLibrary(r''' | |
| 414 import 'dart:async'; | |
| 415 int fValue() => 42; | |
| 416 Future<int> fFuture() async => 42; | |
| 417 var uValue = () async => await fValue(); | |
| 418 var uFuture = () async => await fFuture(); | |
| 419 '''); | |
| 420 checkElementText(library, r''' | |
| 421 import 'dart:async'; | |
| 422 () → Future<int> uValue; | |
| 423 () → Future<int> uFuture; | |
| 424 int fValue() {} | |
| 425 Future<int> fFuture() async {} | |
| 426 '''); | |
| 427 } | |
| 428 | |
| 429 test_initializer_bitwise() async { | |
| 430 var library = await _encodeDecodeLibrary(r''' | |
| 431 var vBitXor = 1 ^ 2; | |
| 432 var vBitAnd = 1 & 2; | |
| 433 var vBitOr = 1 | 2; | |
| 434 var vBitShiftLeft = 1 << 2; | |
| 435 var vBitShiftRight = 1 >> 2; | |
| 436 '''); | |
| 437 checkElementText(library, r''' | |
| 438 int vBitXor; | |
| 439 int vBitAnd; | |
| 440 int vBitOr; | |
| 441 int vBitShiftLeft; | |
| 442 int vBitShiftRight; | |
| 443 '''); | |
| 444 } | |
| 445 | |
| 446 test_initializer_cascade() async { | |
| 447 var library = await _encodeDecodeLibrary(r''' | |
| 448 class A { | |
| 449 int a; | |
| 450 void m() {} | |
| 451 } | |
| 452 var vSetField = new A()..a = 1; | |
| 453 var vInvokeMethod = new A()..m(); | |
| 454 var vBoth = new A()..a = 1..m(); | |
| 455 '''); | |
| 456 checkElementText(library, r''' | |
| 457 class A { | |
| 458 int a; | |
| 459 void m() {} | |
| 460 } | |
| 461 A vSetField; | |
| 462 A vInvokeMethod; | |
| 463 A vBoth; | |
| 464 '''); | |
| 465 } | |
| 466 | |
| 467 test_initializer_conditional() async { | |
| 468 var library = await _encodeDecodeLibrary(r''' | |
| 469 var V = true ? 1 : 2.3; | |
| 470 '''); | |
| 471 checkElementText(library, r''' | |
| 472 num V; | |
| 473 '''); | |
| 474 } | |
| 475 | |
| 476 test_initializer_equality() async { | |
| 477 var library = await _encodeDecodeLibrary(r''' | |
| 478 var vEq = 1 == 2; | |
| 479 var vNotEq = 1 != 2; | |
| 480 '''); | |
| 481 checkElementText(library, r''' | |
| 482 bool vEq; | |
| 483 bool vNotEq; | |
| 484 '''); | |
| 485 } | |
| 486 | |
| 487 test_initializer_error_assign() async { | |
| 488 var library = await _encodeDecodeLibrary(r''' | 406 var library = await _encodeDecodeLibrary(r''' |
| 489 var a = 1; | 407 var a = 1; |
| 490 var t1 = (a = 2); | 408 var t1 = (a = 2); |
| 491 var t2 = (a += 2); | 409 var t2 = (a += 2); |
| 492 '''); | 410 '''); |
| 493 checkElementText(library, r''' | 411 checkElementText(library, r''' |
| 494 int a; | 412 int a; |
| 495 dynamic t1/*error: assignment*/; | 413 int t1; |
| 496 dynamic t2/*error: assignment*/; | 414 int t2; |
| 497 '''); | 415 '''); |
| 498 } | 416 } |
| 499 | 417 |
| 500 test_initializer_error_assign_prefixed() async { | 418 test_initializer_assign_indexed() async { |
| 419 var library = await _encodeDecodeLibrary(r''' |
| 420 var a = [0]; |
| 421 var t1 = (a[0] = 2); |
| 422 var t2 = (a[0] += 2); |
| 423 '''); |
| 424 checkElementText(library, r''' |
| 425 List<int> a; |
| 426 int t1; |
| 427 int t2; |
| 428 '''); |
| 429 } |
| 430 |
| 431 test_initializer_assign_prefixed() async { |
| 501 var library = await _encodeDecodeLibrary(r''' | 432 var library = await _encodeDecodeLibrary(r''' |
| 502 class A { | 433 class A { |
| 503 int f; | 434 int f; |
| 504 } | 435 } |
| 505 var a = new A(); | 436 var a = new A(); |
| 506 var t1 = (a.f = 1); | 437 var t1 = (a.f = 1); |
| 507 var t2 = (a.f += 2); | 438 var t2 = (a.f += 2); |
| 508 '''); | 439 '''); |
| 509 checkElementText(library, r''' | 440 checkElementText(library, r''' |
| 510 class A { | 441 class A { |
| 511 int f; | 442 int f; |
| 512 } | 443 } |
| 513 A a; | 444 A a; |
| 514 dynamic t1/*error: assignment*/; | 445 int t1; |
| 515 dynamic t2/*error: assignment*/; | 446 int t2; |
| 516 '''); | 447 '''); |
| 517 } | 448 } |
| 518 | 449 |
| 519 test_initializer_error_assign_prefixed_viaInterface() async { | 450 test_initializer_assign_prefixed_viaInterface() async { |
| 520 var library = await _encodeDecodeLibrary(r''' | 451 var library = await _encodeDecodeLibrary(r''' |
| 521 class I { | 452 class I { |
| 522 int f; | 453 int f; |
| 523 } | 454 } |
| 524 abstract class C implements I {} | 455 abstract class C implements I {} |
| 525 C c; | 456 C c; |
| 526 var t1 = (c.f = 1); | 457 var t1 = (c.f = 1); |
| 527 var t2 = (c.f += 2); | 458 var t2 = (c.f += 2); |
| 528 '''); | 459 '''); |
| 529 checkElementText(library, r''' | 460 checkElementText(library, r''' |
| 530 class I { | 461 class I { |
| 531 int f; | 462 int f; |
| 532 } | 463 } |
| 533 abstract class C implements I { | 464 abstract class C implements I { |
| 534 } | 465 } |
| 535 C c; | 466 C c; |
| 536 dynamic t1/*error: assignment*/; | 467 int t1; |
| 537 dynamic t2/*error: assignment*/; | 468 int t2; |
| 538 '''); | 469 '''); |
| 539 } | 470 } |
| 540 | 471 |
| 541 test_initializer_error_assign_viaInterface() async { | 472 test_initializer_assign_viaInterface() async { |
| 542 var library = await _encodeDecodeLibrary(r''' | 473 var library = await _encodeDecodeLibrary(r''' |
| 543 class I { | 474 class I { |
| 544 int f; | 475 int f; |
| 545 } | 476 } |
| 546 abstract class C implements I {} | 477 abstract class C implements I {} |
| 547 C getC() => null; | 478 C getC() => null; |
| 548 var t1 = (getC().f = 1); | 479 var t1 = (getC().f = 1); |
| 549 var t2 = (getC().f += 2); | 480 var t2 = (getC().f += 2); |
| 550 '''); | 481 '''); |
| 551 checkElementText(library, r''' | 482 checkElementText(library, r''' |
| 552 class I { | 483 class I { |
| 553 int f; | 484 int f; |
| 554 } | 485 } |
| 555 abstract class C implements I { | 486 abstract class C implements I { |
| 556 } | 487 } |
| 557 dynamic t1/*error: assignment*/; | 488 int t1; |
| 558 dynamic t2/*error: assignment*/; | 489 int t2; |
| 559 C getC() {} | 490 C getC() {} |
| 560 '''); | 491 '''); |
| 561 } | 492 } |
| 562 | 493 |
| 494 test_initializer_await() async { |
| 495 var library = await _encodeDecodeLibrary(r''' |
| 496 import 'dart:async'; |
| 497 int fValue() => 42; |
| 498 Future<int> fFuture() async => 42; |
| 499 var uValue = () async => await fValue(); |
| 500 var uFuture = () async => await fFuture(); |
| 501 '''); |
| 502 checkElementText(library, r''' |
| 503 import 'dart:async'; |
| 504 () → Future<int> uValue; |
| 505 () → Future<int> uFuture; |
| 506 int fValue() {} |
| 507 Future<int> fFuture() async {} |
| 508 '''); |
| 509 } |
| 510 |
| 511 test_initializer_bitwise() async { |
| 512 var library = await _encodeDecodeLibrary(r''' |
| 513 var vBitXor = 1 ^ 2; |
| 514 var vBitAnd = 1 & 2; |
| 515 var vBitOr = 1 | 2; |
| 516 var vBitShiftLeft = 1 << 2; |
| 517 var vBitShiftRight = 1 >> 2; |
| 518 '''); |
| 519 checkElementText(library, r''' |
| 520 int vBitXor; |
| 521 int vBitAnd; |
| 522 int vBitOr; |
| 523 int vBitShiftLeft; |
| 524 int vBitShiftRight; |
| 525 '''); |
| 526 } |
| 527 |
| 528 test_initializer_cascade() async { |
| 529 var library = await _encodeDecodeLibrary(r''' |
| 530 class A { |
| 531 int a; |
| 532 void m() {} |
| 533 } |
| 534 var vSetField = new A()..a = 1; |
| 535 var vInvokeMethod = new A()..m(); |
| 536 var vBoth = new A()..a = 1..m(); |
| 537 '''); |
| 538 checkElementText(library, r''' |
| 539 class A { |
| 540 int a; |
| 541 void m() {} |
| 542 } |
| 543 A vSetField; |
| 544 A vInvokeMethod; |
| 545 A vBoth; |
| 546 '''); |
| 547 } |
| 548 |
| 563 /** | 549 /** |
| 564 * A simple or qualified identifier referring to a top level function, static | 550 * A simple or qualified identifier referring to a top level function, static |
| 565 * variable, field, getter; or a static class variable, static getter or | 551 * variable, field, getter; or a static class variable, static getter or |
| 566 * method; or an instance method; has the inferred type of the identifier. | 552 * method; or an instance method; has the inferred type of the identifier. |
| 567 * | 553 * |
| 568 * Note: specifically, references to instance fields and instance getters are | |
| 569 * disallowed here. | |
| 570 */ | 554 */ |
| 571 test_initializer_error_classField_useInstanceGetter() async { | 555 test_initializer_classField_useInstanceGetter() async { |
| 572 var library = await _encodeDecodeLibrary(r''' | 556 var library = await _encodeDecodeLibrary(r''' |
| 573 class A { | 557 class A { |
| 574 int f = 1; | 558 int f = 1; |
| 575 } | 559 } |
| 576 class B { | 560 class B { |
| 577 A a; | 561 A a; |
| 578 } | 562 } |
| 579 class C { | 563 class C { |
| 580 B b; | 564 B b; |
| 581 } | 565 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 604 class B { | 588 class B { |
| 605 A a; | 589 A a; |
| 606 } | 590 } |
| 607 class C { | 591 class C { |
| 608 B b; | 592 B b; |
| 609 } | 593 } |
| 610 class X { | 594 class X { |
| 611 A a; | 595 A a; |
| 612 B b; | 596 B b; |
| 613 C c; | 597 C c; |
| 614 dynamic t01/*error: instanceGetter*/; | 598 int t01; |
| 615 dynamic t02/*error: instanceGetter*/; | 599 int t02; |
| 616 dynamic t03/*error: instanceGetter*/; | 600 int t03; |
| 617 dynamic t11/*error: instanceGetter*/; | 601 int t11; |
| 618 dynamic t12/*error: instanceGetter*/; | 602 int t12; |
| 619 dynamic t13/*error: instanceGetter*/; | 603 int t13; |
| 620 dynamic t21/*error: instanceGetter*/; | 604 int t21; |
| 621 dynamic t22/*error: instanceGetter*/; | 605 int t22; |
| 622 dynamic t23/*error: instanceGetter*/; | 606 int t23; |
| 623 } | 607 } |
| 624 A newA() {} | 608 A newA() {} |
| 625 B newB() {} | 609 B newB() {} |
| 626 C newC() {} | 610 C newC() {} |
| 627 '''); | 611 '''); |
| 628 } | 612 } |
| 629 | 613 |
| 630 test_initializer_error_extractProperty() async { | 614 test_initializer_conditional() async { |
| 615 var library = await _encodeDecodeLibrary(r''' |
| 616 var V = true ? 1 : 2.3; |
| 617 '''); |
| 618 checkElementText(library, r''' |
| 619 num V; |
| 620 '''); |
| 621 } |
| 622 |
| 623 test_initializer_equality() async { |
| 624 var library = await _encodeDecodeLibrary(r''' |
| 625 var vEq = 1 == 2; |
| 626 var vNotEq = 1 != 2; |
| 627 '''); |
| 628 checkElementText(library, r''' |
| 629 bool vEq; |
| 630 bool vNotEq; |
| 631 '''); |
| 632 } |
| 633 |
| 634 test_initializer_error_methodInvocation_cycle_topLevel() async { |
| 635 var library = await _encodeDecodeLibrary(r''' |
| 636 var a = b.foo(); |
| 637 var b = a.foo(); |
| 638 '''); |
| 639 checkElementText(library, r''' |
| 640 dynamic a/*error: dependencyCycle*/; |
| 641 dynamic b/*error: dependencyCycle*/; |
| 642 '''); |
| 643 } |
| 644 |
| 645 test_initializer_error_methodInvocation_cycle_topLevel_self() async { |
| 646 var library = await _encodeDecodeLibrary(r''' |
| 647 var a = a.foo(); |
| 648 '''); |
| 649 checkElementText(library, r''' |
| 650 dynamic a/*error: dependencyCycle*/; |
| 651 '''); |
| 652 } |
| 653 |
| 654 test_initializer_extractIndex() async { |
| 655 var library = await _encodeDecodeLibrary(r''' |
| 656 var a = [0, 1.2]; |
| 657 var b0 = a[0]; |
| 658 var b1 = a[1]; |
| 659 '''); |
| 660 checkElementText(library, r''' |
| 661 List<num> a; |
| 662 num b0; |
| 663 num b1; |
| 664 '''); |
| 665 } |
| 666 |
| 667 test_initializer_extractProperty() async { |
| 631 var library = await _encodeDecodeLibrary(r''' | 668 var library = await _encodeDecodeLibrary(r''' |
| 632 class C { | 669 class C { |
| 633 bool b; | 670 bool b; |
| 634 } | 671 } |
| 635 C f() => null; | 672 C f() => null; |
| 636 var x = f().b; | 673 var x = f().b; |
| 637 '''); | 674 '''); |
| 638 checkElementText(library, r''' | 675 checkElementText(library, r''' |
| 639 class C { | 676 class C { |
| 640 bool b; | 677 bool b; |
| 641 } | 678 } |
| 642 dynamic x/*error: instanceGetter*/; | 679 bool x; |
| 643 C f() {} | 680 C f() {} |
| 644 '''); | 681 '''); |
| 645 } | 682 } |
| 646 | 683 |
| 647 test_initializer_error_extractProperty_inOtherLibraryCycle() async { | 684 test_initializer_extractProperty_inOtherLibraryCycle() async { |
| 648 addFile('/a.dart', r''' | 685 addFile('/a.dart', r''' |
| 649 import 'b.dart'; | 686 import 'b.dart'; |
| 650 var x = new C().f; | 687 var x = new C().f; |
| 651 '''); | 688 '''); |
| 652 addFile('/b.dart', r''' | 689 addFile('/b.dart', r''' |
| 653 class C { | 690 class C { |
| 654 var f = 0; | 691 var f = 0; |
| 655 } | 692 } |
| 656 '''); | 693 '''); |
| 657 var library = await _encodeDecodeLibrary(r''' | 694 var library = await _encodeDecodeLibrary(r''' |
| 658 import 'a.dart'; | 695 import 'a.dart'; |
| 659 var t1 = x; | 696 var t1 = x; |
| 660 '''); | 697 '''); |
| 661 checkElementText(library, r''' | 698 checkElementText(library, r''' |
| 662 import 'a.dart'; | 699 import 'a.dart'; |
| 663 dynamic t1; | 700 int t1; |
| 664 '''); | 701 '''); |
| 665 } | 702 } |
| 666 | 703 |
| 667 test_initializer_error_extractProperty_inStaticField() async { | 704 test_initializer_extractProperty_inStaticField() async { |
| 668 var library = await _encodeDecodeLibrary(r''' | 705 var library = await _encodeDecodeLibrary(r''' |
| 669 class A { | 706 class A { |
| 670 int f; | 707 int f; |
| 671 } | 708 } |
| 672 class B { | 709 class B { |
| 673 static var t = new A().f; | 710 static var t = new A().f; |
| 674 } | 711 } |
| 675 '''); | 712 '''); |
| 676 checkElementText(library, r''' | 713 checkElementText(library, r''' |
| 677 class A { | 714 class A { |
| 678 int f; | 715 int f; |
| 679 } | 716 } |
| 680 class B { | 717 class B { |
| 681 static dynamic t/*error: instanceGetter*/; | 718 static int t; |
| 682 } | 719 } |
| 683 '''); | 720 '''); |
| 684 } | 721 } |
| 685 | 722 |
| 686 test_initializer_error_extractProperty_prefixedIdentifier() async { | 723 test_initializer_extractProperty_prefixedIdentifier() async { |
| 687 var library = await _encodeDecodeLibrary(r''' | 724 var library = await _encodeDecodeLibrary(r''' |
| 688 class C { | 725 class C { |
| 689 bool b; | 726 bool b; |
| 690 } | 727 } |
| 691 C c; | 728 C c; |
| 692 var x = c.b; | 729 var x = c.b; |
| 693 '''); | 730 '''); |
| 694 checkElementText(library, r''' | 731 checkElementText(library, r''' |
| 695 class C { | 732 class C { |
| 696 bool b; | 733 bool b; |
| 697 } | 734 } |
| 698 C c; | 735 C c; |
| 699 dynamic x/*error: instanceGetter*/; | 736 bool x; |
| 700 '''); | 737 '''); |
| 701 } | 738 } |
| 702 | 739 |
| 703 test_initializer_error_extractProperty_prefixedIdentifier_viaInterface() async
{ | 740 test_initializer_extractProperty_prefixedIdentifier_viaInterface() async { |
| 704 var library = await _encodeDecodeLibrary(r''' | 741 var library = await _encodeDecodeLibrary(r''' |
| 705 class I { | 742 class I { |
| 706 bool b; | 743 bool b; |
| 707 } | 744 } |
| 708 abstract class C implements I {} | 745 abstract class C implements I {} |
| 709 C c; | 746 C c; |
| 710 var x = c.b; | 747 var x = c.b; |
| 711 '''); | 748 '''); |
| 712 checkElementText(library, r''' | 749 checkElementText(library, r''' |
| 713 class I { | 750 class I { |
| 714 bool b; | 751 bool b; |
| 715 } | 752 } |
| 716 abstract class C implements I { | 753 abstract class C implements I { |
| 717 } | 754 } |
| 718 C c; | 755 C c; |
| 719 dynamic x/*error: instanceGetter*/; | 756 bool x; |
| 720 '''); | 757 '''); |
| 721 } | 758 } |
| 722 | 759 |
| 723 test_initializer_error_extractProperty_viaInterface() async { | 760 test_initializer_extractProperty_viaInterface() async { |
| 724 var library = await _encodeDecodeLibrary(r''' | 761 var library = await _encodeDecodeLibrary(r''' |
| 725 class I { | 762 class I { |
| 726 bool b; | 763 bool b; |
| 727 } | 764 } |
| 728 abstract class C implements I {} | 765 abstract class C implements I {} |
| 729 C f() => null; | 766 C f() => null; |
| 730 var x = f().b; | 767 var x = f().b; |
| 731 '''); | 768 '''); |
| 732 checkElementText(library, r''' | 769 checkElementText(library, r''' |
| 733 class I { | 770 class I { |
| 734 bool b; | 771 bool b; |
| 735 } | 772 } |
| 736 abstract class C implements I { | 773 abstract class C implements I { |
| 737 } | 774 } |
| 738 dynamic x/*error: instanceGetter*/; | 775 bool x; |
| 739 C f() {} | 776 C f() {} |
| 740 '''); | 777 '''); |
| 741 } | 778 } |
| 742 | 779 |
| 743 test_initializer_error_instanceGetterOfObject() async { | |
| 744 var library = await _encodeDecodeLibrary(r''' | |
| 745 dynamic f() => null; | |
| 746 var s = f().toString(); | |
| 747 var h = f().hashCode; | |
| 748 '''); | |
| 749 checkElementText(library, r''' | |
| 750 String s; | |
| 751 dynamic h/*error: instanceGetter*/; | |
| 752 dynamic f() {} | |
| 753 '''); | |
| 754 } | |
| 755 | |
| 756 test_initializer_error_instanceGetterOfObject_prefixed() async { | |
| 757 var library = await _encodeDecodeLibrary(r''' | |
| 758 dynamic d; | |
| 759 var s = d.toString(); | |
| 760 var h = d.hashCode; | |
| 761 '''); | |
| 762 checkElementText(library, r''' | |
| 763 dynamic d; | |
| 764 String s; | |
| 765 dynamic h/*error: instanceGetter*/; | |
| 766 '''); | |
| 767 } | |
| 768 | |
| 769 test_initializer_error_methodInvocation_cycle_topLevel() async { | |
| 770 var library = await _encodeDecodeLibrary(r''' | |
| 771 var a = b.foo(); | |
| 772 var b = a.foo(); | |
| 773 '''); | |
| 774 checkElementText(library, r''' | |
| 775 dynamic a/*error: dependencyCycle*/; | |
| 776 dynamic b/*error: dependencyCycle*/; | |
| 777 '''); | |
| 778 } | |
| 779 | |
| 780 test_initializer_error_methodInvocation_cycle_topLevel_self() async { | |
| 781 var library = await _encodeDecodeLibrary(r''' | |
| 782 var a = a.foo(); | |
| 783 '''); | |
| 784 checkElementText(library, r''' | |
| 785 dynamic a/*error: dependencyCycle*/; | |
| 786 '''); | |
| 787 } | |
| 788 | |
| 789 test_initializer_error_referenceToFieldOfStaticField() async { | |
| 790 var library = await _encodeDecodeLibrary(r''' | |
| 791 class C { | |
| 792 static D d; | |
| 793 } | |
| 794 class D { | |
| 795 int i; | |
| 796 } | |
| 797 final x = C.d.i; | |
| 798 '''); | |
| 799 checkElementText(library, r''' | |
| 800 class C { | |
| 801 static D d; | |
| 802 } | |
| 803 class D { | |
| 804 int i; | |
| 805 } | |
| 806 final dynamic x/*error: instanceGetter*/; | |
| 807 '''); | |
| 808 } | |
| 809 | |
| 810 test_initializer_error_referenceToFieldOfStaticGetter() async { | |
| 811 var library = await _encodeDecodeLibrary(r''' | |
| 812 class C { | |
| 813 static D get d => null; | |
| 814 } | |
| 815 class D { | |
| 816 int i; | |
| 817 } | |
| 818 var x = C.d.i; | |
| 819 '''); | |
| 820 checkElementText(library, r''' | |
| 821 class C { | |
| 822 static D get d {} | |
| 823 } | |
| 824 class D { | |
| 825 int i; | |
| 826 } | |
| 827 dynamic x/*error: instanceGetter*/; | |
| 828 '''); | |
| 829 } | |
| 830 | |
| 831 test_initializer_extractIndex() async { | |
| 832 var library = await _encodeDecodeLibrary(r''' | |
| 833 var a = [0, 1.2]; | |
| 834 var b0 = a[0]; | |
| 835 var b1 = a[1]; | |
| 836 '''); | |
| 837 checkElementText(library, r''' | |
| 838 List<num> a; | |
| 839 num b0; | |
| 840 num b1; | |
| 841 '''); | |
| 842 } | |
| 843 | |
| 844 test_initializer_functionExpression() async { | 780 test_initializer_functionExpression() async { |
| 845 var library = await _encodeDecodeLibrary(r''' | 781 var library = await _encodeDecodeLibrary(r''' |
| 846 import 'dart:async'; | 782 import 'dart:async'; |
| 847 var vFuture = new Future<int>(42); | 783 var vFuture = new Future<int>(42); |
| 848 var v_noParameters_inferredReturnType = () => 42; | 784 var v_noParameters_inferredReturnType = () => 42; |
| 849 var v_hasParameter_withType_inferredReturnType = (String a) => 42; | 785 var v_hasParameter_withType_inferredReturnType = (String a) => 42; |
| 850 var v_hasParameter_withType_returnParameter = (String a) => a; | 786 var v_hasParameter_withType_returnParameter = (String a) => a; |
| 851 var v_async_returnValue = () async => 42; | 787 var v_async_returnValue = () async => 42; |
| 852 var v_async_returnFuture = () async => vFuture; | 788 var v_async_returnFuture = () async => vFuture; |
| 853 '''); | 789 '''); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 class A {} | 954 class A {} |
| 1019 var a = new A(); | 955 var a = new A(); |
| 1020 '''); | 956 '''); |
| 1021 checkElementText(library, r''' | 957 checkElementText(library, r''' |
| 1022 class A { | 958 class A { |
| 1023 } | 959 } |
| 1024 A a; | 960 A a; |
| 1025 '''); | 961 '''); |
| 1026 } | 962 } |
| 1027 | 963 |
| 964 test_initializer_instanceGetterOfObject() async { |
| 965 var library = await _encodeDecodeLibrary(r''' |
| 966 dynamic f() => null; |
| 967 var s = f().toString(); |
| 968 var h = f().hashCode; |
| 969 '''); |
| 970 checkElementText(library, r''' |
| 971 String s; |
| 972 int h; |
| 973 dynamic f() {} |
| 974 '''); |
| 975 } |
| 976 |
| 977 test_initializer_instanceGetterOfObject_prefixed() async { |
| 978 var library = await _encodeDecodeLibrary(r''' |
| 979 dynamic d; |
| 980 var s = d.toString(); |
| 981 var h = d.hashCode; |
| 982 '''); |
| 983 checkElementText(library, r''' |
| 984 dynamic d; |
| 985 String s; |
| 986 int h; |
| 987 '''); |
| 988 } |
| 989 |
| 1028 test_initializer_is() async { | 990 test_initializer_is() async { |
| 1029 var library = await _encodeDecodeLibrary(r''' | 991 var library = await _encodeDecodeLibrary(r''' |
| 1030 var a = 1.2; | 992 var a = 1.2; |
| 1031 var b = a is int; | 993 var b = a is int; |
| 1032 '''); | 994 '''); |
| 1033 checkElementText(library, r''' | 995 checkElementText(library, r''' |
| 1034 double a; | 996 double a; |
| 1035 bool b; | 997 bool b; |
| 1036 '''); | 998 '''); |
| 1037 } | 999 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 double vMultiplyDoubleInt; | 1185 double vMultiplyDoubleInt; |
| 1224 double vMultiplyDoubleDouble; | 1186 double vMultiplyDoubleDouble; |
| 1225 double vDivideIntInt; | 1187 double vDivideIntInt; |
| 1226 double vDivideIntDouble; | 1188 double vDivideIntDouble; |
| 1227 double vDivideDoubleInt; | 1189 double vDivideDoubleInt; |
| 1228 double vDivideDoubleDouble; | 1190 double vDivideDoubleDouble; |
| 1229 int vFloorDivide; | 1191 int vFloorDivide; |
| 1230 '''); | 1192 '''); |
| 1231 } | 1193 } |
| 1232 | 1194 |
| 1233 @failingTest | |
| 1234 test_initializer_onlyLeft() async { | 1195 test_initializer_onlyLeft() async { |
| 1235 var library = await _encodeDecodeLibrary(r''' | 1196 var library = await _encodeDecodeLibrary(r''' |
| 1236 var a = 1; | 1197 var a = 1; |
| 1237 var vEq = a == ((a = 2) == 0); | 1198 var vEq = a == ((a = 2) == 0); |
| 1238 var vNotEq = a != ((a = 2) == 0); | 1199 var vNotEq = a != ((a = 2) == 0); |
| 1239 '''); | 1200 '''); |
| 1240 checkElementText(library, r''' | 1201 checkElementText(library, r''' |
| 1241 int a; | 1202 int a; |
| 1242 bool vEq; | 1203 bool vEq; |
| 1243 bool vNotEq; | 1204 bool vNotEq; |
| 1244 '''); | 1205 '''); |
| 1245 } | 1206 } |
| 1246 | 1207 |
| 1247 test_initializer_parenthesized() async { | 1208 test_initializer_parenthesized() async { |
| 1248 var library = await _encodeDecodeLibrary(r''' | 1209 var library = await _encodeDecodeLibrary(r''' |
| 1249 var V = (42); | 1210 var V = (42); |
| 1250 '''); | 1211 '''); |
| 1251 checkElementText(library, r''' | 1212 checkElementText(library, r''' |
| 1252 int V; | 1213 int V; |
| 1253 '''); | 1214 '''); |
| 1254 } | 1215 } |
| 1255 | 1216 |
| 1256 @failingTest | |
| 1257 test_initializer_postfix() async { | 1217 test_initializer_postfix() async { |
| 1258 var library = await _encodeDecodeLibrary(r''' | 1218 var library = await _encodeDecodeLibrary(r''' |
| 1259 var vInt = 1; | 1219 var vInt = 1; |
| 1260 var vDouble = 2; | 1220 var vDouble = 2.0; |
| 1261 var vIncInt = vInt++; | 1221 var vIncInt = vInt++; |
| 1262 var vDecInt = vInt--; | 1222 var vDecInt = vInt--; |
| 1263 var vIncDouble = vDouble++; | 1223 var vIncDouble = vDouble++; |
| 1264 var vDecDouble = vDouble--; | 1224 var vDecDouble = vDouble--; |
| 1265 '''); | 1225 '''); |
| 1266 checkElementText(library, r''' | 1226 checkElementText(library, r''' |
| 1267 int vInt; | 1227 int vInt; |
| 1268 int vDouble; | 1228 double vDouble; |
| 1269 int vIncInt; | 1229 int vIncInt; |
| 1270 int vDecInt; | 1230 int vDecInt; |
| 1271 double vIncDouble; | 1231 double vIncDouble; |
| 1232 double vDecDouble; |
| 1233 '''); |
| 1234 } |
| 1235 |
| 1236 test_initializer_postfix_indexed() async { |
| 1237 var library = await _encodeDecodeLibrary(r''' |
| 1238 var vInt = [1]; |
| 1239 var vDouble = [2.0]; |
| 1240 var vIncInt = vInt[0]++; |
| 1241 var vDecInt = vInt[0]--; |
| 1242 var vIncDouble = vDouble[0]++; |
| 1243 var vDecDouble = vDouble[0]--; |
| 1244 '''); |
| 1245 checkElementText(library, r''' |
| 1246 List<int> vInt; |
| 1247 List<double> vDouble; |
| 1248 int vIncInt; |
| 1249 int vDecInt; |
| 1250 double vIncDouble; |
| 1272 double vDecDouble; | 1251 double vDecDouble; |
| 1273 '''); | 1252 '''); |
| 1274 } | 1253 } |
| 1275 | 1254 |
| 1276 @failingTest | |
| 1277 test_initializer_prefix_incDec() async { | 1255 test_initializer_prefix_incDec() async { |
| 1278 var library = await _encodeDecodeLibrary(r''' | 1256 var library = await _encodeDecodeLibrary(r''' |
| 1279 var vInt = 1; | 1257 var vInt = 1; |
| 1280 var vDouble = 2.0; | 1258 var vDouble = 2.0; |
| 1281 var vIncInt = ++vInt; | 1259 var vIncInt = ++vInt; |
| 1282 var vDecInt = --vInt; | 1260 var vDecInt = --vInt; |
| 1283 var vIncDouble = ++vDouble; | 1261 var vIncDouble = ++vDouble; |
| 1284 var vDecInt = --vDouble; | 1262 var vDecInt = --vDouble; |
| 1285 '''); | 1263 '''); |
| 1286 checkElementText(library, r''' | 1264 checkElementText(library, r''' |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1304 var vInc = ++a; | 1282 var vInc = ++a; |
| 1305 var vDec = --a; | 1283 var vDec = --a; |
| 1306 '''); | 1284 '''); |
| 1307 checkElementText(library, r''' | 1285 checkElementText(library, r''' |
| 1308 A a; | 1286 A a; |
| 1309 B vInc; | 1287 B vInc; |
| 1310 B vDec; | 1288 B vDec; |
| 1311 '''); | 1289 '''); |
| 1312 } | 1290 } |
| 1313 | 1291 |
| 1292 test_initializer_prefix_incDec_indexed() async { |
| 1293 var library = await _encodeDecodeLibrary(r''' |
| 1294 var vInt = [1]; |
| 1295 var vDouble = [2.0]; |
| 1296 var vIncInt = ++vInt[0]; |
| 1297 var vDecInt = --vInt[0]; |
| 1298 var vIncDouble = ++vDouble[0]; |
| 1299 var vDecInt = --vDouble[0]; |
| 1300 '''); |
| 1301 checkElementText(library, r''' |
| 1302 List<int> vInt; |
| 1303 List<double> vDouble; |
| 1304 int vIncInt; |
| 1305 int vDecInt; |
| 1306 double vIncDouble; |
| 1307 double vDecInt; |
| 1308 '''); |
| 1309 } |
| 1310 |
| 1314 test_initializer_prefix_not() async { | 1311 test_initializer_prefix_not() async { |
| 1315 var library = await _encodeDecodeLibrary(r''' | 1312 var library = await _encodeDecodeLibrary(r''' |
| 1316 var vNot = !true; | 1313 var vNot = !true; |
| 1317 '''); | 1314 '''); |
| 1318 checkElementText(library, r''' | 1315 checkElementText(library, r''' |
| 1319 bool vNot; | 1316 bool vNot; |
| 1320 '''); | 1317 '''); |
| 1321 } | 1318 } |
| 1322 | 1319 |
| 1323 test_initializer_prefix_other() async { | 1320 test_initializer_prefix_other() async { |
| 1324 var library = await _encodeDecodeLibrary(r''' | 1321 var library = await _encodeDecodeLibrary(r''' |
| 1325 var vNegateInt = -1; | 1322 var vNegateInt = -1; |
| 1326 var vNegateDouble = -1.0; | 1323 var vNegateDouble = -1.0; |
| 1327 var vComplement = ~1; | 1324 var vComplement = ~1; |
| 1328 '''); | 1325 '''); |
| 1329 checkElementText(library, r''' | 1326 checkElementText(library, r''' |
| 1330 int vNegateInt; | 1327 int vNegateInt; |
| 1331 double vNegateDouble; | 1328 double vNegateDouble; |
| 1332 int vComplement; | 1329 int vComplement; |
| 1333 '''); | 1330 '''); |
| 1334 } | 1331 } |
| 1335 | 1332 |
| 1333 test_initializer_referenceToFieldOfStaticField() async { |
| 1334 var library = await _encodeDecodeLibrary(r''' |
| 1335 class C { |
| 1336 static D d; |
| 1337 } |
| 1338 class D { |
| 1339 int i; |
| 1340 } |
| 1341 final x = C.d.i; |
| 1342 '''); |
| 1343 checkElementText(library, r''' |
| 1344 class C { |
| 1345 static D d; |
| 1346 } |
| 1347 class D { |
| 1348 int i; |
| 1349 } |
| 1350 final int x; |
| 1351 '''); |
| 1352 } |
| 1353 |
| 1354 test_initializer_referenceToFieldOfStaticGetter() async { |
| 1355 var library = await _encodeDecodeLibrary(r''' |
| 1356 class C { |
| 1357 static D get d => null; |
| 1358 } |
| 1359 class D { |
| 1360 int i; |
| 1361 } |
| 1362 var x = C.d.i; |
| 1363 '''); |
| 1364 checkElementText(library, r''' |
| 1365 class C { |
| 1366 static D get d {} |
| 1367 } |
| 1368 class D { |
| 1369 int i; |
| 1370 } |
| 1371 int x; |
| 1372 '''); |
| 1373 } |
| 1374 |
| 1336 test_initializer_relational() async { | 1375 test_initializer_relational() async { |
| 1337 var library = await _encodeDecodeLibrary(r''' | 1376 var library = await _encodeDecodeLibrary(r''' |
| 1338 var vLess = 1 < 2; | 1377 var vLess = 1 < 2; |
| 1339 var vLessOrEqual = 1 <= 2; | 1378 var vLessOrEqual = 1 <= 2; |
| 1340 var vGreater = 1 > 2; | 1379 var vGreater = 1 > 2; |
| 1341 var vGreaterOrEqual = 1 >= 2; | 1380 var vGreaterOrEqual = 1 >= 2; |
| 1342 '''); | 1381 '''); |
| 1343 checkElementText(library, r''' | 1382 checkElementText(library, r''' |
| 1344 bool vLess; | 1383 bool vLess; |
| 1345 bool vLessOrEqual; | 1384 bool vLessOrEqual; |
| (...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2591 | 2630 |
| 2592 Future<LibraryElement> _encodeDecodeLibrary(String text) async { | 2631 Future<LibraryElement> _encodeDecodeLibrary(String text) async { |
| 2593 String path = _p('/test.dart'); | 2632 String path = _p('/test.dart'); |
| 2594 provider.newFile(path, text); | 2633 provider.newFile(path, text); |
| 2595 UnitElementResult result = await driver.getUnitElement(path); | 2634 UnitElementResult result = await driver.getUnitElement(path); |
| 2596 return result.element.library; | 2635 return result.element.library; |
| 2597 } | 2636 } |
| 2598 | 2637 |
| 2599 String _p(String path) => provider.convertPath(path); | 2638 String _p(String path) => provider.convertPath(path); |
| 2600 } | 2639 } |
| OLD | NEW |