| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library analyzer.test.src.task.dart_test; | 5 library analyzer.test.src.task.dart_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/dart/element/type.dart'; | 8 import 'package:analyzer/dart/element/type.dart'; |
| 9 import 'package:analyzer/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/dart/element/element.dart'; | 10 import 'package:analyzer/src/dart/element/element.dart'; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 new isInstanceOf<StrongModeVerifyUnitTask>(); | 140 new isInstanceOf<StrongModeVerifyUnitTask>(); |
| 141 isInstanceOf isVerifyUnitTask = new isInstanceOf<VerifyUnitTask>(); | 141 isInstanceOf isVerifyUnitTask = new isInstanceOf<VerifyUnitTask>(); |
| 142 | 142 |
| 143 final LintCode _testLintCode = new LintCode('test lint', 'test lint code'); | 143 final LintCode _testLintCode = new LintCode('test lint', 'test lint code'); |
| 144 | 144 |
| 145 @reflectiveTest | 145 @reflectiveTest |
| 146 class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { | 146 class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { |
| 147 Source source; | 147 Source source; |
| 148 LibrarySpecificUnit target; | 148 LibrarySpecificUnit target; |
| 149 | 149 |
| 150 test_created_resolved_unit() { |
| 151 Source source = newSource( |
| 152 '/test.dart', |
| 153 r''' |
| 154 library lib; |
| 155 class A {} |
| 156 '''); |
| 157 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 158 computeResult(target, RESOLVED_UNIT1); |
| 159 expect(outputs[RESOLVED_UNIT1], isNotNull); |
| 160 expect(outputs[CREATED_RESOLVED_UNIT1], isTrue); |
| 161 } |
| 162 |
| 150 test_perform_find_constants() { | 163 test_perform_find_constants() { |
| 151 _performBuildTask(''' | 164 _performBuildTask(''' |
| 152 const x = 1; | 165 const x = 1; |
| 153 class C { | 166 class C { |
| 154 static const y = 1; | 167 static const y = 1; |
| 155 const C([p = 1]); | 168 const C([p = 1]); |
| 156 } | 169 } |
| 157 @x | 170 @x |
| 158 f() { | 171 f() { |
| 159 const z = 1; | 172 const z = 1; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 182 library lib; | 195 library lib; |
| 183 import 'lib2.dart'; | 196 import 'lib2.dart'; |
| 184 export 'lib3.dart'; | 197 export 'lib3.dart'; |
| 185 part 'part.dart'; | 198 part 'part.dart'; |
| 186 final x = ''; | 199 final x = ''; |
| 187 class A { | 200 class A { |
| 188 static final y = 0; | 201 static final y = 0; |
| 189 } | 202 } |
| 190 class B = Object with A; | 203 class B = Object with A; |
| 191 '''); | 204 '''); |
| 192 expect(outputs, hasLength(3)); | 205 expect(outputs, hasLength(4)); |
| 193 expect(outputs[COMPILATION_UNIT_CONSTANTS], isNotNull); | 206 expect(outputs[COMPILATION_UNIT_CONSTANTS], isNotNull); |
| 194 expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); | 207 expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); |
| 195 expect(outputs[RESOLVED_UNIT1], isNotNull); | 208 expect(outputs[RESOLVED_UNIT1], isNotNull); |
| 209 expect(outputs[CREATED_RESOLVED_UNIT1], isTrue); |
| 196 } | 210 } |
| 197 | 211 |
| 198 test_perform_reuseElement() { | 212 test_perform_reuseElement() { |
| 199 _performBuildTask(r''' | 213 _performBuildTask(r''' |
| 200 library lib; | 214 library lib; |
| 201 class A {} | 215 class A {} |
| 202 class B = Object with A; | 216 class B = Object with A; |
| 203 '''); | 217 '''); |
| 204 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | 218 CompilationUnit unit = outputs[RESOLVED_UNIT1]; |
| 205 CompilationUnitElement unitElement = outputs[COMPILATION_UNIT_ELEMENT]; | 219 CompilationUnitElement unitElement = outputs[COMPILATION_UNIT_ELEMENT]; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 } | 477 } |
| 464 | 478 |
| 465 _getImportLibraryInput(Source source) { | 479 _getImportLibraryInput(Source source) { |
| 466 var key = BuildDirectiveElementsTask.IMPORTS_LIBRARY_ELEMENT_INPUT_NAME; | 480 var key = BuildDirectiveElementsTask.IMPORTS_LIBRARY_ELEMENT_INPUT_NAME; |
| 467 return task.inputs[key][source]; | 481 return task.inputs[key][source]; |
| 468 } | 482 } |
| 469 } | 483 } |
| 470 | 484 |
| 471 @reflectiveTest | 485 @reflectiveTest |
| 472 class BuildEnumMemberElementsTaskTest extends _AbstractDartTaskTest { | 486 class BuildEnumMemberElementsTaskTest extends _AbstractDartTaskTest { |
| 487 test_created_resolved_unit() { |
| 488 Source source = newSource( |
| 489 '/test.dart', |
| 490 r''' |
| 491 library lib; |
| 492 class A {} |
| 493 '''); |
| 494 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 495 computeResult(target, RESOLVED_UNIT2); |
| 496 expect(outputs[RESOLVED_UNIT2], isNotNull); |
| 497 expect(outputs[CREATED_RESOLVED_UNIT2], isTrue); |
| 498 } |
| 499 |
| 473 test_perform() { | 500 test_perform() { |
| 474 Source source = newSource( | 501 Source source = newSource( |
| 475 '/test.dart', | 502 '/test.dart', |
| 476 ''' | 503 ''' |
| 477 enum MyEnum { | 504 enum MyEnum { |
| 478 A, B | 505 A, B |
| 479 } | 506 } |
| 480 '''); | 507 '''); |
| 481 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT2, | 508 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT2, |
| 482 matcher: isBuildEnumMemberElementsTask); | 509 matcher: isBuildEnumMemberElementsTask); |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 @reflectiveTest | 1364 @reflectiveTest |
| 1338 class ComputeInferableStaticVariableDependenciesTaskTest | 1365 class ComputeInferableStaticVariableDependenciesTaskTest |
| 1339 extends _AbstractDartTaskTest { | 1366 extends _AbstractDartTaskTest { |
| 1340 @override | 1367 @override |
| 1341 void setUp() { | 1368 void setUp() { |
| 1342 super.setUp(); | 1369 super.setUp(); |
| 1343 // Variable dependencies are only available in strong mode. | 1370 // Variable dependencies are only available in strong mode. |
| 1344 enableStrongMode(); | 1371 enableStrongMode(); |
| 1345 } | 1372 } |
| 1346 | 1373 |
| 1374 test_created_resolved_unit() { |
| 1375 Source source = newSource( |
| 1376 '/test.dart', |
| 1377 r''' |
| 1378 library lib; |
| 1379 class A {} |
| 1380 '''); |
| 1381 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 1382 computeResult(target, RESOLVED_UNIT5); |
| 1383 expect(outputs[RESOLVED_UNIT5], isNotNull); |
| 1384 expect(outputs[CREATED_RESOLVED_UNIT5], isTrue); |
| 1385 } |
| 1386 |
| 1347 test_perform() { | 1387 test_perform() { |
| 1348 AnalysisTarget source = newSource( | 1388 AnalysisTarget source = newSource( |
| 1349 '/test.dart', | 1389 '/test.dart', |
| 1350 ''' | 1390 ''' |
| 1351 const a = b; | 1391 const a = b; |
| 1352 const b = 0; | 1392 const b = 0; |
| 1353 '''); | 1393 '''); |
| 1354 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 1394 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 1355 computeResult(target, RESOLVED_UNIT5); | 1395 computeResult(target, RESOLVED_UNIT5); |
| 1356 CompilationUnit unit = outputs[RESOLVED_UNIT5]; | 1396 CompilationUnit unit = outputs[RESOLVED_UNIT5]; |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2017 expect(outputs, hasLength(1)); | 2057 expect(outputs, hasLength(1)); |
| 2018 List<AnalysisError> errors = outputs[DART_ERRORS]; | 2058 List<AnalysisError> errors = outputs[DART_ERRORS]; |
| 2019 // This should contain only the errors in the part file, not the ones in the | 2059 // This should contain only the errors in the part file, not the ones in the |
| 2020 // library. | 2060 // library. |
| 2021 expect(errors, hasLength(1)); | 2061 expect(errors, hasLength(1)); |
| 2022 } | 2062 } |
| 2023 } | 2063 } |
| 2024 | 2064 |
| 2025 @reflectiveTest | 2065 @reflectiveTest |
| 2026 class EvaluateUnitConstantsTaskTest extends _AbstractDartTaskTest { | 2066 class EvaluateUnitConstantsTaskTest extends _AbstractDartTaskTest { |
| 2067 test_created_resolved_unit() { |
| 2068 Source source = newSource( |
| 2069 '/test.dart', |
| 2070 r''' |
| 2071 library lib; |
| 2072 class A {} |
| 2073 '''); |
| 2074 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 2075 computeResult(target, RESOLVED_UNIT11); |
| 2076 expect(outputs[RESOLVED_UNIT11], isNotNull); |
| 2077 expect(outputs[CREATED_RESOLVED_UNIT11], isTrue); |
| 2078 } |
| 2079 |
| 2027 test_perform() { | 2080 test_perform() { |
| 2028 Source source = newSource( | 2081 Source source = newSource( |
| 2029 '/test.dart', | 2082 '/test.dart', |
| 2030 ''' | 2083 ''' |
| 2031 class C { | 2084 class C { |
| 2032 const C(); | 2085 const C(); |
| 2033 } | 2086 } |
| 2034 | 2087 |
| 2035 @x | 2088 @x |
| 2036 f() {} | 2089 f() {} |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2481 } | 2534 } |
| 2482 } | 2535 } |
| 2483 | 2536 |
| 2484 class GenerateLintsTaskTest_TestLinter extends Linter { | 2537 class GenerateLintsTaskTest_TestLinter extends Linter { |
| 2485 @override | 2538 @override |
| 2486 AstVisitor getVisitor() => new GenerateLintsTaskTest_AstVisitor(this); | 2539 AstVisitor getVisitor() => new GenerateLintsTaskTest_AstVisitor(this); |
| 2487 } | 2540 } |
| 2488 | 2541 |
| 2489 @reflectiveTest | 2542 @reflectiveTest |
| 2490 class InferInstanceMembersInUnitTaskTest extends _AbstractDartTaskTest { | 2543 class InferInstanceMembersInUnitTaskTest extends _AbstractDartTaskTest { |
| 2544 test_created_resolved_unit() { |
| 2545 Source source = newSource( |
| 2546 '/test.dart', |
| 2547 r''' |
| 2548 library lib; |
| 2549 class A {} |
| 2550 '''); |
| 2551 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 2552 computeResult(target, RESOLVED_UNIT9); |
| 2553 expect(outputs[RESOLVED_UNIT9], isNotNull); |
| 2554 expect(outputs[CREATED_RESOLVED_UNIT9], isTrue); |
| 2555 } |
| 2556 |
| 2491 void test_perform() { | 2557 void test_perform() { |
| 2492 enableStrongMode(); | 2558 enableStrongMode(); |
| 2493 AnalysisTarget source = newSource( | 2559 AnalysisTarget source = newSource( |
| 2494 '/test.dart', | 2560 '/test.dart', |
| 2495 ''' | 2561 ''' |
| 2496 class A { | 2562 class A { |
| 2497 X f; | 2563 X f; |
| 2498 Y m(Z x) {} | 2564 Y m(Z x) {} |
| 2499 } | 2565 } |
| 2500 class B extends A { | 2566 class B extends A { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2582 | 2648 |
| 2583 InterfaceType stringType = context.typeProvider.stringType; | 2649 InterfaceType stringType = context.typeProvider.stringType; |
| 2584 expect(topLevel.type, stringType); | 2650 expect(topLevel.type, stringType); |
| 2585 expect(field.type, stringType); | 2651 expect(field.type, stringType); |
| 2586 expect(fieldDecl.initializer.staticType, stringType); | 2652 expect(fieldDecl.initializer.staticType, stringType); |
| 2587 } | 2653 } |
| 2588 } | 2654 } |
| 2589 | 2655 |
| 2590 @reflectiveTest | 2656 @reflectiveTest |
| 2591 class InferStaticVariableTypesInUnitTaskTest extends _AbstractDartTaskTest { | 2657 class InferStaticVariableTypesInUnitTaskTest extends _AbstractDartTaskTest { |
| 2658 test_created_resolved_unit() { |
| 2659 Source source = newSource( |
| 2660 '/test.dart', |
| 2661 r''' |
| 2662 library lib; |
| 2663 class A {} |
| 2664 '''); |
| 2665 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 2666 computeResult(target, RESOLVED_UNIT7); |
| 2667 expect(outputs[RESOLVED_UNIT7], isNotNull); |
| 2668 expect(outputs[CREATED_RESOLVED_UNIT7], isTrue); |
| 2669 } |
| 2670 |
| 2592 void test_perform_const_field() { | 2671 void test_perform_const_field() { |
| 2593 enableStrongMode(); | 2672 enableStrongMode(); |
| 2594 AnalysisTarget source = newSource( | 2673 AnalysisTarget source = newSource( |
| 2595 '/test.dart', | 2674 '/test.dart', |
| 2596 ''' | 2675 ''' |
| 2597 class M { | 2676 class M { |
| 2598 static const X = ""; | 2677 static const X = ""; |
| 2599 } | 2678 } |
| 2600 '''); | 2679 '''); |
| 2601 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT7, | 2680 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT7, |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 ConstructorDeclaration constructor = members[0]; | 3276 ConstructorDeclaration constructor = members[0]; |
| 3198 expectReference(constructor.body, false); | 3277 expectReference(constructor.body, false); |
| 3199 | 3278 |
| 3200 MethodDeclaration method = members[1]; | 3279 MethodDeclaration method = members[1]; |
| 3201 expectReference(method.body, false); | 3280 expectReference(method.body, false); |
| 3202 } | 3281 } |
| 3203 } | 3282 } |
| 3204 | 3283 |
| 3205 @reflectiveTest | 3284 @reflectiveTest |
| 3206 class PropagateVariableTypesInUnitTaskTest extends _AbstractDartTaskTest { | 3285 class PropagateVariableTypesInUnitTaskTest extends _AbstractDartTaskTest { |
| 3286 test_created_resolved_unit() { |
| 3287 Source source = newSource( |
| 3288 '/test.dart', |
| 3289 r''' |
| 3290 library lib; |
| 3291 class A {} |
| 3292 '''); |
| 3293 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 3294 computeResult(target, RESOLVED_UNIT6); |
| 3295 expect(outputs[RESOLVED_UNIT6], isNotNull); |
| 3296 expect(outputs[CREATED_RESOLVED_UNIT6], isTrue); |
| 3297 } |
| 3298 |
| 3207 void test_perform_cycle() { | 3299 void test_perform_cycle() { |
| 3208 AnalysisTarget source = newSource( | 3300 AnalysisTarget source = newSource( |
| 3209 '/test.dart', | 3301 '/test.dart', |
| 3210 ''' | 3302 ''' |
| 3211 final piFirst = true; | 3303 final piFirst = true; |
| 3212 final pi = piFirst ? 3.14 : tau / 2; | 3304 final pi = piFirst ? 3.14 : tau / 2; |
| 3213 final tau = piFirst ? pi * 2 : 6.28; | 3305 final tau = piFirst ? pi * 2 : 6.28; |
| 3214 '''); | 3306 '''); |
| 3215 // compute | 3307 // compute |
| 3216 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT6, | 3308 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT6, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3322 } | 3414 } |
| 3323 | 3415 |
| 3324 @reflectiveTest | 3416 @reflectiveTest |
| 3325 class ResolveInstanceFieldsInUnitTaskTest extends _AbstractDartTaskTest { | 3417 class ResolveInstanceFieldsInUnitTaskTest extends _AbstractDartTaskTest { |
| 3326 @override | 3418 @override |
| 3327 void setUp() { | 3419 void setUp() { |
| 3328 super.setUp(); | 3420 super.setUp(); |
| 3329 enableStrongMode(); | 3421 enableStrongMode(); |
| 3330 } | 3422 } |
| 3331 | 3423 |
| 3424 test_created_resolved_unit() { |
| 3425 Source source = newSource( |
| 3426 '/test.dart', |
| 3427 r''' |
| 3428 library lib; |
| 3429 class A {} |
| 3430 '''); |
| 3431 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 3432 computeResult(target, RESOLVED_UNIT8); |
| 3433 expect(outputs[RESOLVED_UNIT8], isNotNull); |
| 3434 expect(outputs[CREATED_RESOLVED_UNIT8], isTrue); |
| 3435 } |
| 3436 |
| 3332 // Test inference of instance fields across units | 3437 // Test inference of instance fields across units |
| 3333 void test_perform_inference_cross_unit_instance() { | 3438 void test_perform_inference_cross_unit_instance() { |
| 3334 List<Source> sources = newSources({ | 3439 List<Source> sources = newSources({ |
| 3335 '/a.dart': ''' | 3440 '/a.dart': ''' |
| 3336 import 'b.dart'; | 3441 import 'b.dart'; |
| 3337 class A { | 3442 class A { |
| 3338 final a2 = new B().b2; | 3443 final a2 = new B().b2; |
| 3339 } | 3444 } |
| 3340 ''', | 3445 ''', |
| 3341 '/b.dart': ''' | 3446 '/b.dart': ''' |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3416 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT8); | 3521 new LibrarySpecificUnit(sources[0], sources[0]), RESOLVED_UNIT8); |
| 3417 CompilationUnit unit0 = outputs[RESOLVED_UNIT8]; | 3522 CompilationUnit unit0 = outputs[RESOLVED_UNIT8]; |
| 3418 | 3523 |
| 3419 // A.a2 should now be resolved on the rhs, but not yet inferred. | 3524 // A.a2 should now be resolved on the rhs, but not yet inferred. |
| 3420 assertVariableDeclarationTypes( | 3525 assertVariableDeclarationTypes( |
| 3421 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 3526 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3422 | 3527 |
| 3423 computeResult( | 3528 computeResult( |
| 3424 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT8); | 3529 new LibrarySpecificUnit(sources[2], sources[2]), RESOLVED_UNIT8); |
| 3425 | 3530 |
| 3426 // A.a2 should now be fully resolved and inferred. | 3531 // A.a2 should now be fully resolved and inferred (but not re-resolved). |
| 3427 assertVariableDeclarationTypes( | 3532 assertVariableDeclarationTypes( |
| 3428 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 3533 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3429 } | 3534 } |
| 3430 | 3535 |
| 3431 // Test inference of instance fields across units with cycles | 3536 // Test inference of instance fields across units with cycles |
| 3432 void test_perform_inference_cross_unit_static_instance() { | 3537 void test_perform_inference_cross_unit_static_instance() { |
| 3433 List<Source> sources = newSources({ | 3538 List<Source> sources = newSources({ |
| 3434 '/a.dart': ''' | 3539 '/a.dart': ''' |
| 3435 import 'b.dart'; | 3540 import 'b.dart'; |
| 3436 class A { | 3541 class A { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3528 assertVariableDeclarationTypes( | 3633 assertVariableDeclarationTypes( |
| 3529 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 3634 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3530 | 3635 |
| 3531 // B.b2 shoud be resolved on the rhs, but not yet inferred. | 3636 // B.b2 shoud be resolved on the rhs, but not yet inferred. |
| 3532 assertVariableDeclarationTypes( | 3637 assertVariableDeclarationTypes( |
| 3533 AstFinder.getFieldInClass(unit0, "B", "b2"), dynamicType, intType); | 3638 AstFinder.getFieldInClass(unit0, "B", "b2"), dynamicType, intType); |
| 3534 | 3639 |
| 3535 computeResult( | 3640 computeResult( |
| 3536 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT8); | 3641 new LibrarySpecificUnit(sources[1], sources[1]), RESOLVED_UNIT8); |
| 3537 | 3642 |
| 3538 // A.a2 should now be fully resolved and inferred. | 3643 // A.a2 should now be fully resolved and inferred (but not re-resolved). |
| 3539 assertVariableDeclarationTypes( | 3644 assertVariableDeclarationTypes( |
| 3540 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); | 3645 AstFinder.getFieldInClass(unit0, "A", "a2"), dynamicType, dynamicType); |
| 3541 | 3646 |
| 3542 // B.b2 should now be fully resolved and inferred. | 3647 // B.b2 should now be fully resolved and inferred. |
| 3543 assertVariableDeclarationTypes( | 3648 assertVariableDeclarationTypes( |
| 3544 AstFinder.getFieldInClass(unit0, "B", "b2"), intType, intType); | 3649 AstFinder.getFieldInClass(unit0, "B", "b2"), intType, intType); |
| 3545 } | 3650 } |
| 3546 } | 3651 } |
| 3547 | 3652 |
| 3548 @reflectiveTest | 3653 @reflectiveTest |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3627 ClassElement clazz = library.getType('A'); | 3732 ClassElement clazz = library.getType('A'); |
| 3628 expect(clazz.displayName, 'A'); | 3733 expect(clazz.displayName, 'A'); |
| 3629 clazz = clazz.supertype.element; | 3734 clazz = clazz.supertype.element; |
| 3630 expect(clazz.displayName, 'B'); | 3735 expect(clazz.displayName, 'B'); |
| 3631 } | 3736 } |
| 3632 } | 3737 } |
| 3633 } | 3738 } |
| 3634 | 3739 |
| 3635 @reflectiveTest | 3740 @reflectiveTest |
| 3636 class ResolveUnitTaskTest extends _AbstractDartTaskTest { | 3741 class ResolveUnitTaskTest extends _AbstractDartTaskTest { |
| 3742 test_created_resolved_unit() { |
| 3743 Source source = newSource( |
| 3744 '/test.dart', |
| 3745 r''' |
| 3746 library lib; |
| 3747 class A {} |
| 3748 '''); |
| 3749 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 3750 computeResult(target, RESOLVED_UNIT10); |
| 3751 expect(outputs[RESOLVED_UNIT10], isNotNull); |
| 3752 expect(outputs[CREATED_RESOLVED_UNIT10], isTrue); |
| 3753 } |
| 3754 |
| 3637 void test_perform() { | 3755 void test_perform() { |
| 3638 AnalysisTarget source = newSource( | 3756 AnalysisTarget source = newSource( |
| 3639 '/test.dart', | 3757 '/test.dart', |
| 3640 ''' | 3758 ''' |
| 3641 void f() { | 3759 void f() { |
| 3642 var c = new C(); | 3760 var c = new C(); |
| 3643 c.m(); | 3761 c.m(); |
| 3644 } | 3762 } |
| 3645 class C { | 3763 class C { |
| 3646 void m() { | 3764 void m() { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3690 | 3808 |
| 3691 void _assertResolved(FunctionBody body) { | 3809 void _assertResolved(FunctionBody body) { |
| 3692 ResolutionVerifier verifier = new ResolutionVerifier(); | 3810 ResolutionVerifier verifier = new ResolutionVerifier(); |
| 3693 body.accept(verifier); | 3811 body.accept(verifier); |
| 3694 verifier.assertResolved(); | 3812 verifier.assertResolved(); |
| 3695 } | 3813 } |
| 3696 } | 3814 } |
| 3697 | 3815 |
| 3698 @reflectiveTest | 3816 @reflectiveTest |
| 3699 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { | 3817 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { |
| 3818 test_created_resolved_unit() { |
| 3819 Source source = newSource( |
| 3820 '/test.dart', |
| 3821 r''' |
| 3822 library lib; |
| 3823 class A {} |
| 3824 '''); |
| 3825 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 3826 computeResult(target, RESOLVED_UNIT3); |
| 3827 expect(outputs[RESOLVED_UNIT3], isNotNull); |
| 3828 expect(outputs[CREATED_RESOLVED_UNIT3], isTrue); |
| 3829 } |
| 3830 |
| 3700 test_perform() { | 3831 test_perform() { |
| 3701 Source source = newSource( | 3832 Source source = newSource( |
| 3702 '/test.dart', | 3833 '/test.dart', |
| 3703 ''' | 3834 ''' |
| 3704 class A {} | 3835 class A {} |
| 3705 class B extends A {} | 3836 class B extends A {} |
| 3706 int f(String p) => p.length; | 3837 int f(String p) => p.length; |
| 3707 '''); | 3838 '''); |
| 3708 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 3839 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 3709 computeResult(target, RESOLVED_UNIT3, matcher: isResolveUnitTypeNamesTask); | 3840 computeResult(target, RESOLVED_UNIT3, matcher: isResolveUnitTypeNamesTask); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3789 /** | 3920 /** |
| 3790 * Verify that the mutated states of the given [variable] correspond to the | 3921 * Verify that the mutated states of the given [variable] correspond to the |
| 3791 * [mutatedInClosure] and [mutatedInScope] matchers. | 3922 * [mutatedInClosure] and [mutatedInScope] matchers. |
| 3792 */ | 3923 */ |
| 3793 void expectMutated(VariableElement variable, Matcher mutatedInClosure, | 3924 void expectMutated(VariableElement variable, Matcher mutatedInClosure, |
| 3794 Matcher mutatedInScope) { | 3925 Matcher mutatedInScope) { |
| 3795 expect(variable.isPotentiallyMutatedInClosure, mutatedInClosure); | 3926 expect(variable.isPotentiallyMutatedInClosure, mutatedInClosure); |
| 3796 expect(variable.isPotentiallyMutatedInScope, mutatedInScope); | 3927 expect(variable.isPotentiallyMutatedInScope, mutatedInScope); |
| 3797 } | 3928 } |
| 3798 | 3929 |
| 3930 test_created_resolved_unit() { |
| 3931 Source source = newSource( |
| 3932 '/test.dart', |
| 3933 r''' |
| 3934 library lib; |
| 3935 class A {} |
| 3936 '''); |
| 3937 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 3938 computeResult(target, RESOLVED_UNIT4); |
| 3939 expect(outputs[RESOLVED_UNIT4], isNotNull); |
| 3940 expect(outputs[CREATED_RESOLVED_UNIT4], isTrue); |
| 3941 } |
| 3942 |
| 3799 test_perform_buildClosureLibraryElements() { | 3943 test_perform_buildClosureLibraryElements() { |
| 3800 Source source = newSource( | 3944 Source source = newSource( |
| 3801 '/test.dart', | 3945 '/test.dart', |
| 3802 ''' | 3946 ''' |
| 3803 main() { | 3947 main() { |
| 3804 } | 3948 } |
| 3805 '''); | 3949 '''); |
| 3806 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 3950 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 3807 computeResult(target, RESOLVED_UNIT4, | 3951 computeResult(target, RESOLVED_UNIT4, |
| 3808 matcher: isResolveVariableReferencesTask); | 3952 matcher: isResolveVariableReferencesTask); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4407 } | 4551 } |
| 4408 | 4552 |
| 4409 @reflectiveTest | 4553 @reflectiveTest |
| 4410 class StrongModeVerifyUnitTaskTest extends _AbstractDartTaskTest { | 4554 class StrongModeVerifyUnitTaskTest extends _AbstractDartTaskTest { |
| 4411 @override | 4555 @override |
| 4412 void setUp() { | 4556 void setUp() { |
| 4413 super.setUp(); | 4557 super.setUp(); |
| 4414 enableStrongMode(); | 4558 enableStrongMode(); |
| 4415 } | 4559 } |
| 4416 | 4560 |
| 4561 test_created_resolved_unit() { |
| 4562 Source source = newSource( |
| 4563 '/test.dart', |
| 4564 r''' |
| 4565 library lib; |
| 4566 class A {} |
| 4567 '''); |
| 4568 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 4569 computeResult(target, RESOLVED_UNIT); |
| 4570 expect(outputs[RESOLVED_UNIT], isNotNull); |
| 4571 expect(outputs[CREATED_RESOLVED_UNIT], isTrue); |
| 4572 } |
| 4573 |
| 4417 void test_perform_recordDynamicInvoke() { | 4574 void test_perform_recordDynamicInvoke() { |
| 4418 enableStrongMode(); | 4575 enableStrongMode(); |
| 4419 AnalysisTarget source = newSource( | 4576 AnalysisTarget source = newSource( |
| 4420 '/test.dart', | 4577 '/test.dart', |
| 4421 ''' | 4578 ''' |
| 4422 void main() { | 4579 void main() { |
| 4423 dynamic a = []; | 4580 dynamic a = []; |
| 4424 a[0]; | 4581 a[0]; |
| 4425 } | 4582 } |
| 4426 '''); | 4583 '''); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4654 /** | 4811 /** |
| 4655 * Fill [errorListener] with [result] errors in the current [task]. | 4812 * Fill [errorListener] with [result] errors in the current [task]. |
| 4656 */ | 4813 */ |
| 4657 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 4814 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
| 4658 List<AnalysisError> errors = task.outputs[result]; | 4815 List<AnalysisError> errors = task.outputs[result]; |
| 4659 expect(errors, isNotNull, reason: result.name); | 4816 expect(errors, isNotNull, reason: result.name); |
| 4660 errorListener = new GatheringErrorListener(); | 4817 errorListener = new GatheringErrorListener(); |
| 4661 errorListener.addAll(errors); | 4818 errorListener.addAll(errors); |
| 4662 } | 4819 } |
| 4663 } | 4820 } |
| OLD | NEW |