| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// End-to-end test of the analyzer2dart compiler. | 5 /// End-to-end test of the analyzer2dart compiler. |
| 6 library test.end2end; | 6 library test.end2end; |
| 7 | 7 |
| 8 import 'mock_sdk.dart'; | 8 import 'mock_sdk.dart'; |
| 9 import 'package:analyzer/file_system/memory_file_system.dart'; | 9 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| 11 import 'package:analyzer/src/generated/sdk.dart'; | 11 import 'package:analyzer/src/generated/sdk.dart'; |
| 12 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
| 13 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
| 14 | 14 |
| 15 import '../lib/src/closed_world.dart'; | 15 import '../lib/src/closed_world.dart'; |
| 16 import '../lib/src/driver.dart'; | 16 import '../lib/src/driver.dart'; |
| 17 import '../lib/src/converted_world.dart'; | 17 import '../lib/src/converted_world.dart'; |
| 18 import '../lib/src/dart_backend.dart'; | 18 import '../lib/src/dart_backend.dart'; |
| 19 | 19 |
| 20 import 'test_helper.dart' hide TestSpec; | 20 import 'test_helper.dart' hide TestSpec; |
| 21 import 'output_helper.dart'; | 21 import 'output_helper.dart'; |
| 22 import 'end2end_data.dart'; | 22 import 'end2end_data.dart'; |
| 23 | 23 |
| 24 main() { | 24 main(List<String> args) { |
| 25 performTests(TEST_DATA, unittester, checkResult); | 25 performTests(TEST_DATA, unittester, checkResult, args); |
| 26 } | 26 } |
| 27 | 27 |
| 28 checkResult(TestSpec result) { | 28 checkResult(TestSpec result) { |
| 29 String input = result.input; | 29 String input = result.input; |
| 30 String expectedOutput = result.output.trim(); | 30 String expectedOutput = result.output.trim(); |
| 31 | 31 |
| 32 CollectingOutputProvider outputProvider = new CollectingOutputProvider(); | 32 CollectingOutputProvider outputProvider = new CollectingOutputProvider(); |
| 33 MemoryResourceProvider provider = new MemoryResourceProvider(); | 33 MemoryResourceProvider provider = new MemoryResourceProvider(); |
| 34 DartSdk sdk = new MockSdk(); | 34 DartSdk sdk = new MockSdk(); |
| 35 Driver driver = new Driver(provider, sdk, outputProvider); | 35 Driver driver = new Driver(provider, sdk, outputProvider); |
| 36 String rootFile = '/root.dart'; | 36 String rootFile = '/root.dart'; |
| 37 provider.newFile(rootFile, input); | 37 provider.newFile(rootFile, input); |
| 38 Source rootSource = driver.setRoot(rootFile); | 38 Source rootSource = driver.setRoot(rootFile); |
| 39 FunctionElement entryPoint = driver.resolveEntryPoint(rootSource); | 39 FunctionElement entryPoint = driver.resolveEntryPoint(rootSource); |
| 40 ClosedWorld world = driver.computeWorld(entryPoint); | 40 ClosedWorld world = driver.computeWorld(entryPoint); |
| 41 ConvertedWorld convertedWorld = convertWorld(world); | 41 ConvertedWorld convertedWorld = convertWorld(world); |
| 42 compileToDart(driver, convertedWorld); | 42 compileToDart(driver, convertedWorld); |
| 43 String output = outputProvider.output.text.trim(); | 43 String output = outputProvider.output.text.trim(); |
| 44 expect(output, equals(expectedOutput)); | 44 expect(output, equals(expectedOutput)); |
| 45 } | 45 } |
| OLD | NEW |