Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: tests/compiler/dart2js/backend_dart/test_helper.dart

Issue 669673006: Add SExpression test and share tests between dart2dart and analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/backend_dart/sexpr_test.dart ('k') | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/backend_dart/test_helper.dart
diff --git a/tests/compiler/dart2js/backend_dart/dart_new_backend_test.dart b/tests/compiler/dart2js/backend_dart/test_helper.dart
similarity index 53%
copy from tests/compiler/dart2js/backend_dart/dart_new_backend_test.dart
copy to tests/compiler/dart2js/backend_dart/test_helper.dart
index 62c6ca8e2d463fc514a507442eee4f7e28f94e84..a5d5b209cd2c8f03c3418476a9691c1f87b5cd47 100644
--- a/tests/compiler/dart2js/backend_dart/dart_new_backend_test.dart
+++ b/tests/compiler/dart2js/backend_dart/test_helper.dart
@@ -1,61 +1,43 @@
-// 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.
-
-import '../compiler_helper.dart';
-import 'dart:async';
-import 'package:async_helper/async_helper.dart';
-import 'package:compiler/implementation/dart2jslib.dart';
-import 'package:compiler/implementation/dart_backend/dart_backend.dart';
-import 'package:compiler/implementation/dart_backend/backend_ast_to_frontend_ast.dart'
- show INSERT_NEW_BACKEND_COMMENT;
-
-const String TestStaticField = """
-class Foo {
- static int x = 1;
-}
-main() {
- print(Foo.x);
-}
-""";
-
-Future<String> compile(String code) {
- MockCompiler compiler = new MockCompiler.internal(
- emitJavaScript: false,
- enableMinification: false);
- return compiler.init().then((_) {
- compiler.parseScript(code);
- Element element = compiler.mainApp.find('main');
- if (element == null) return null;
- compiler.mainFunction = element;
- compiler.phase = Compiler.PHASE_RESOLVING;
- compiler.backend.enqueueHelpers(compiler.enqueuer.resolution,
- compiler.globalDependencies);
- compiler.processQueue(compiler.enqueuer.resolution, element);
- compiler.world.populate();
- compiler.backend.onResolutionComplete();
- compiler.irBuilder.buildNodes(useNewBackend: true);
- compiler.phase = Compiler.PHASE_COMPILING;
- DartBackend backend = compiler.backend;
- backend.assembleProgram();
- String generated = compiler.assembledCode;
- return generated;
- });
-}
-
-Future test(String code, String feature) {
- return compile(code).then((output) {
- if (output == null || !output.contains('main() /* new backend */')) {
- throw 'New backend appears to be deactivated for $feature.\n'
- 'Output was: $output';
- }
- });
-}
-
-main() {
- INSERT_NEW_BACKEND_COMMENT = true;
-
- asyncTest(() => Future.forEach([
- () => test(TestStaticField, 'static fields'),
- ], (f) => f()));
-}
+// 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.
+
+library dart_backend.test_helper;
+
+import 'dart:async';
+import 'package:async_helper/async_helper.dart';
+import 'package:compiler/implementation/dart2jslib.dart';
+import '../../../../pkg/analyzer2dart/test/test_helper.dart';
+import '../compiler_helper.dart';
+
+/// Compiles the given dart code (which must include a 'main' function) and
+/// returns the compiler.
+Future<Compiler> compilerFor(String code) {
+ MockCompiler compiler = new MockCompiler.internal(
+ emitJavaScript: false,
+ enableMinification: false);
+ compiler.diagnosticHandler = createHandler(compiler, code);
+ return compiler.init().then((_) {
+ compiler.parseScript(code);
+
+ Element element = compiler.mainApp.find('main');
+ if (element == null) return null;
+
+ compiler.mainFunction = element;
+ compiler.phase = Compiler.PHASE_RESOLVING;
+ compiler.backend.enqueueHelpers(compiler.enqueuer.resolution,
+ compiler.globalDependencies);
+ compiler.processQueue(compiler.enqueuer.resolution, element);
+ compiler.world.populate();
+ compiler.backend.onResolutionComplete();
+
+ compiler.irBuilder.buildNodes(useNewBackend: true);
+
+ return compiler;
+ });
+}
+
+/// Test group using async_helper.
+asyncTester(Group group, RunTest runTest) {
+ asyncTest(() => Future.forEach(group.results, runTest));
+}
« no previous file with comments | « tests/compiler/dart2js/backend_dart/sexpr_test.dart ('k') | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698