| 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 test.src.task.dart_test; | 5 library test.src.task.dart_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 runReflectiveTests(BuildLibraryConstructorsTaskTest); | 41 runReflectiveTests(BuildLibraryConstructorsTaskTest); |
| 42 runReflectiveTests(BuildLibraryElementTaskTest); | 42 runReflectiveTests(BuildLibraryElementTaskTest); |
| 43 runReflectiveTests(BuildPublicNamespaceTaskTest); | 43 runReflectiveTests(BuildPublicNamespaceTaskTest); |
| 44 runReflectiveTests(BuildTypeProviderTaskTest); | 44 runReflectiveTests(BuildTypeProviderTaskTest); |
| 45 runReflectiveTests(ParseDartTaskTest); | 45 runReflectiveTests(ParseDartTaskTest); |
| 46 runReflectiveTests(ResolveUnitTypeNamesTaskTest); | 46 runReflectiveTests(ResolveUnitTypeNamesTaskTest); |
| 47 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); | 47 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); |
| 48 runReflectiveTests(ResolveReferencesTaskTest); | 48 runReflectiveTests(ResolveReferencesTaskTest); |
| 49 runReflectiveTests(ResolveVariableReferencesTaskTest); | 49 runReflectiveTests(ResolveVariableReferencesTaskTest); |
| 50 runReflectiveTests(ScanDartTaskTest); | 50 runReflectiveTests(ScanDartTaskTest); |
| 51 runReflectiveTests(VerifyUnitTaskTest); |
| 51 } | 52 } |
| 52 | 53 |
| 53 @reflectiveTest | 54 @reflectiveTest |
| 54 class BuildClassConstructorsTaskTest extends _AbstractDartTaskTest { | 55 class BuildClassConstructorsTaskTest extends _AbstractDartTaskTest { |
| 55 test_perform_ClassDeclaration_errors_mixinHasNoConstructors() { | 56 test_perform_ClassDeclaration_errors_mixinHasNoConstructors() { |
| 56 Source source = _newSource('/test.dart', ''' | 57 Source source = _newSource('/test.dart', ''' |
| 57 class B { | 58 class B { |
| 58 B({x}); | 59 B({x}); |
| 59 } | 60 } |
| 60 class M {} | 61 class M {} |
| (...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 expect(outputs[TOKEN_STREAM], isNotNull); | 1429 expect(outputs[TOKEN_STREAM], isNotNull); |
| 1429 } | 1430 } |
| 1430 | 1431 |
| 1431 void _performScanTask(String content) { | 1432 void _performScanTask(String content) { |
| 1432 AnalysisTarget target = _newSource('/test.dart', content); | 1433 AnalysisTarget target = _newSource('/test.dart', content); |
| 1433 _computeResult(target, TOKEN_STREAM); | 1434 _computeResult(target, TOKEN_STREAM); |
| 1434 expect(task, new isInstanceOf<ScanDartTask>()); | 1435 expect(task, new isInstanceOf<ScanDartTask>()); |
| 1435 } | 1436 } |
| 1436 } | 1437 } |
| 1437 | 1438 |
| 1439 @reflectiveTest |
| 1440 class VerifyUnitTaskTest extends _AbstractDartTaskTest { |
| 1441 test_perform_directiveError() { |
| 1442 // TODO(scheglov) uncomment when GetContentTask handles not |
| 1443 // existing sources correctly. |
| 1444 // Source source = _newSource('/test.dart', ''' |
| 1445 //library lib; |
| 1446 //part '/does/not/exist.dart'; |
| 1447 //'''); |
| 1448 // LibraryUnitTarget target = new LibraryUnitTarget(source, source); |
| 1449 // _computeResult(target, VERIFY_ERRORS); |
| 1450 // expect(task, new isInstanceOf<VerifyUnitTask>()); |
| 1451 // // validate |
| 1452 // _fillErrorListener(VERIFY_ERRORS); |
| 1453 // errorListener.assertErrorsWithCodes( |
| 1454 // <ErrorCode>[StaticTypeWarningCode.NON_BOOL_CONDITION]); |
| 1455 } |
| 1456 |
| 1457 test_perform_verifyError() { |
| 1458 Source source = _newSource('/test.dart', ''' |
| 1459 main() { |
| 1460 if (42) { |
| 1461 print('Not bool!'); |
| 1462 } |
| 1463 } |
| 1464 '''); |
| 1465 LibraryUnitTarget target = new LibraryUnitTarget(source, source); |
| 1466 _computeResult(target, VERIFY_ERRORS); |
| 1467 expect(task, new isInstanceOf<VerifyUnitTask>()); |
| 1468 // validate |
| 1469 _fillErrorListener(VERIFY_ERRORS); |
| 1470 errorListener.assertErrorsWithCodes( |
| 1471 <ErrorCode>[StaticTypeWarningCode.NON_BOOL_CONDITION]); |
| 1472 } |
| 1473 } |
| 1474 |
| 1438 class _AbstractDartTaskTest extends EngineTestCase { | 1475 class _AbstractDartTaskTest extends EngineTestCase { |
| 1439 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); | 1476 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); |
| 1440 Source emptySource; | 1477 Source emptySource; |
| 1441 | 1478 |
| 1442 DartSdk sdk = new MockSdk(); | 1479 DartSdk sdk = new MockSdk(); |
| 1443 _MockContext context = new _MockContext(); | 1480 _MockContext context = new _MockContext(); |
| 1444 Map<AnalysisTarget, CacheEntry> entryMap = <AnalysisTarget, CacheEntry>{}; | 1481 Map<AnalysisTarget, CacheEntry> entryMap = <AnalysisTarget, CacheEntry>{}; |
| 1445 | 1482 |
| 1446 TaskManager taskManager = new TaskManager(); | 1483 TaskManager taskManager = new TaskManager(); |
| 1447 AnalysisDriver analysisDriver; | 1484 AnalysisDriver analysisDriver; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1473 taskManager.addTaskDescriptor(BuildDirectiveElementsTask.DESCRIPTOR); | 1510 taskManager.addTaskDescriptor(BuildDirectiveElementsTask.DESCRIPTOR); |
| 1474 taskManager.addTaskDescriptor(BuildExportSourceClosureTask.DESCRIPTOR); | 1511 taskManager.addTaskDescriptor(BuildExportSourceClosureTask.DESCRIPTOR); |
| 1475 taskManager.addTaskDescriptor(BuildExportNamespaceTask.DESCRIPTOR); | 1512 taskManager.addTaskDescriptor(BuildExportNamespaceTask.DESCRIPTOR); |
| 1476 taskManager.addTaskDescriptor(BuildTypeProviderTask.DESCRIPTOR); | 1513 taskManager.addTaskDescriptor(BuildTypeProviderTask.DESCRIPTOR); |
| 1477 taskManager.addTaskDescriptor(BuildEnumMemberElementsTask.DESCRIPTOR); | 1514 taskManager.addTaskDescriptor(BuildEnumMemberElementsTask.DESCRIPTOR); |
| 1478 taskManager.addTaskDescriptor(BuildFunctionTypeAliasesTask.DESCRIPTOR); | 1515 taskManager.addTaskDescriptor(BuildFunctionTypeAliasesTask.DESCRIPTOR); |
| 1479 taskManager.addTaskDescriptor(ResolveUnitTypeNamesTask.DESCRIPTOR); | 1516 taskManager.addTaskDescriptor(ResolveUnitTypeNamesTask.DESCRIPTOR); |
| 1480 taskManager.addTaskDescriptor(ResolveLibraryTypeNamesTask.DESCRIPTOR); | 1517 taskManager.addTaskDescriptor(ResolveLibraryTypeNamesTask.DESCRIPTOR); |
| 1481 taskManager.addTaskDescriptor(ResolveReferencesTask.DESCRIPTOR); | 1518 taskManager.addTaskDescriptor(ResolveReferencesTask.DESCRIPTOR); |
| 1482 taskManager.addTaskDescriptor(ResolveVariableReferencesTask.DESCRIPTOR); | 1519 taskManager.addTaskDescriptor(ResolveVariableReferencesTask.DESCRIPTOR); |
| 1520 taskManager.addTaskDescriptor(VerifyUnitTask.DESCRIPTOR); |
| 1483 // prepare AnalysisDriver | 1521 // prepare AnalysisDriver |
| 1484 analysisDriver = new AnalysisDriver(taskManager, context); | 1522 analysisDriver = new AnalysisDriver(taskManager, context); |
| 1485 } | 1523 } |
| 1486 | 1524 |
| 1487 void _computeResult(AnalysisTarget target, ResultDescriptor result) { | 1525 void _computeResult(AnalysisTarget target, ResultDescriptor result) { |
| 1488 task = analysisDriver.computeResult(target, result); | 1526 task = analysisDriver.computeResult(target, result); |
| 1489 expect(task.caughtException, isNull); | 1527 expect(task.caughtException, isNull); |
| 1490 outputs = task.outputs; | 1528 outputs = task.outputs; |
| 1491 } | 1529 } |
| 1492 | 1530 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 return entryMap.putIfAbsent(target, () => new CacheEntry()); | 1570 return entryMap.putIfAbsent(target, () => new CacheEntry()); |
| 1533 } | 1571 } |
| 1534 | 1572 |
| 1535 TimestampedData<String> getContents(Source source) => source.contents; | 1573 TimestampedData<String> getContents(Source source) => source.contents; |
| 1536 | 1574 |
| 1537 noSuchMethod(Invocation invocation) { | 1575 noSuchMethod(Invocation invocation) { |
| 1538 print('noSuchMethod: ${invocation.memberName}'); | 1576 print('noSuchMethod: ${invocation.memberName}'); |
| 1539 return super.noSuchMethod(invocation); | 1577 return super.noSuchMethod(invocation); |
| 1540 } | 1578 } |
| 1541 } | 1579 } |
| OLD | NEW |