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

Side by Side Diff: tests/compiler/dart2js/js_backend_cps_ir.dart

Issue 1089793002: Add a command line option to use the new CPS based backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Test that the CPS IR code generator compiles programs and produces the 5 // Test that the CPS IR code generator compiles programs and produces the
6 // the expected output. 6 // the expected output.
7 7
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import 'package:compiler/src/apiimpl.dart' 10 import 'package:compiler/src/apiimpl.dart'
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 if (foundElement == null) { 52 if (foundElement == null) {
53 Expect.fail('There is no compiled element called $name'); 53 Expect.fail('There is no compiled element called $name');
54 } 54 }
55 55
56 js.Node ast = compiler.enqueuer.codegen.generatedCode[foundElement]; 56 js.Node ast = compiler.enqueuer.codegen.generatedCode[foundElement];
57 return js.prettyPrint(ast, compiler).getText(); 57 return js.prettyPrint(ast, compiler).getText();
58 } 58 }
59 59
60 runTests(List<TestEntry> tests) { 60 runTests(List<TestEntry> tests) {
61 Expect.isTrue(const bool.fromEnvironment("USE_CPS_IR"),
62 'Run with USE_CPS_IR=true');
63
64 for (TestEntry test in tests) { 61 for (TestEntry test in tests) {
65 Map files = {TEST_MAIN_FILE: test.source}; 62 Map files = {TEST_MAIN_FILE: test.source};
66 asyncTest(() { 63 asyncTest(() {
67 Compiler compiler = compilerFor(files); 64 Compiler compiler = compilerFor(files, options: <String>['--use-cps-ir']);
68 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); 65 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE');
69 return compiler.run(uri).then((bool success) { 66 return compiler.run(uri).then((bool success) {
70 Expect.isTrue(success); 67 Expect.isTrue(success);
71 String expectation = test.expectation; 68 String expectation = test.expectation;
72 if (expectation != null) { 69 if (expectation != null) {
73 String expected = test.expectation; 70 String expected = test.expectation;
74 String found = test.elementName == null 71 String found = test.elementName == null
75 ? getCodeForMain(compiler) 72 ? getCodeForMain(compiler)
76 : getCodeForMethod(compiler, test.elementName); 73 : getCodeForMethod(compiler, test.elementName);
77 if (expected != found) { 74 if (expected != found) {
78 Expect.fail('Expected:\n$expected\nbut found\n$found'); 75 Expect.fail('Expected:\n$expected\nbut found\n$found');
79 } 76 }
80 } 77 }
81 }).catchError((e) { 78 }).catchError((e) {
82 print(e); 79 print(e);
83 Expect.fail('The following test failed to compile:\n' 80 Expect.fail('The following test failed to compile:\n'
84 '${formatTest(files)}'); 81 '${formatTest(files)}');
85 }); 82 });
86 }); 83 });
87 } 84 }
88 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698