| Index: pkg/analyzer2dart/test/sexpr_test.dart
|
| diff --git a/pkg/analyzer2dart/test/sexpr_test.dart b/pkg/analyzer2dart/test/sexpr_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c8a6fbf7a1b0a8624024e46250c913d1b038dcb8
|
| --- /dev/null
|
| +++ b/pkg/analyzer2dart/test/sexpr_test.dart
|
| @@ -0,0 +1,46 @@
|
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +/// Unittest test of the CPS ir generated by the analyzer2dart compiler.
|
| +
|
| +import 'mock_sdk.dart';
|
| +import 'package:analyzer/file_system/memory_file_system.dart';
|
| +import 'package:analyzer/src/generated/element.dart';
|
| +import 'package:analyzer/src/generated/sdk.dart';
|
| +import 'package:analyzer/src/generated/source.dart';
|
| +import 'package:compiler/implementation/cps_ir/cps_ir_nodes_sexpr.dart';
|
| +import 'package:unittest/unittest.dart';
|
| +
|
| +import '../lib/src/closed_world.dart';
|
| +import '../lib/src/driver.dart';
|
| +import '../lib/src/converted_world.dart';
|
| +import 'output_helper.dart';
|
| +import 'test_helper.dart';
|
| +import 'sexpr_data.dart';
|
| +
|
| +main() {
|
| + performTests(TEST_DATA, unittester, checkResult);
|
| +}
|
| +
|
| +checkResult(TestSpec result) {
|
| + String input = result.input.trim();
|
| + String expectedOutput = result.output.trim();
|
| + CollectingOutputProvider outputProvider = new CollectingOutputProvider();
|
| + MemoryResourceProvider provider = new MemoryResourceProvider();
|
| + DartSdk sdk = new MockSdk();
|
| + Driver driver = new Driver(provider, sdk, outputProvider);
|
| + String rootFile = '/root.dart';
|
| + provider.newFile(rootFile, input);
|
| + Source rootSource = driver.setRoot(rootFile);
|
| + FunctionElement entryPoint = driver.resolveEntryPoint(rootSource);
|
| + ClosedWorld world = driver.computeWorld(entryPoint);
|
| + ConvertedWorld convertedWorld = convertWorld(world);
|
| + String output = convertedWorld.getIr(convertedWorld.mainFunction)
|
| + .accept(new SExpressionStringifier());
|
| + expect(output, equals(expectedOutput),
|
| + reason: 'Input:\n$input\n'
|
| + 'Expected:\n$expectedOutput\n'
|
| + 'Actual:\n$output');
|
| +}
|
| +
|
|
|