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

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

Issue 810183003: Split js_backend_cps_ir tests into multiple test units. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | tests/compiler/dart2js/js_backend_cps_ir_basic.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // VMOptions=-DUSE_CPS_IR=true
5 4
6 // 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
7 // the expected output. 6 // the expected output.
8 7
9 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
10 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
11 import 'package:compiler/src/apiimpl.dart' 10 import 'package:compiler/src/apiimpl.dart'
12 show Compiler; 11 show Compiler;
13 import 'memory_compiler.dart'; 12 import 'memory_compiler.dart';
14 import 'package:compiler/src/js/js.dart' as js; 13 import 'package:compiler/src/js/js.dart' as js;
15 import 'package:compiler/src/common.dart' show Element; 14 import 'package:compiler/src/common.dart' show Element;
16 15
17 import 'js_backend_cps_ir_basic.dart' as basic;
18 import 'js_backend_cps_ir_literals.dart' as literals;
19 import 'js_backend_cps_ir_operators.dart' as operators;
20 import 'js_backend_cps_ir_control_flow.dart' as control_flow;
21 import 'js_backend_cps_ir_interceptors.dart' as interceptors;
22 import 'js_backend_cps_ir_closures.dart' as closures;
23
24 const String TEST_MAIN_FILE = 'test.dart'; 16 const String TEST_MAIN_FILE = 'test.dart';
25 17
26 List<TestEntry> tests = <TestEntry>[]
27 ..addAll(basic.tests)
28 ..addAll(literals.tests)
29 ..addAll(control_flow.tests)
30 ..addAll(operators.tests)
31 ..addAll(interceptors.tests)
32 ..addAll(closures.tests);
33
34 class TestEntry { 18 class TestEntry {
35 final String source; 19 final String source;
36 final String expectation; 20 final String expectation;
37 const TestEntry(this.source, [this.expectation]); 21 const TestEntry(this.source, [this.expectation]);
38 } 22 }
39 23
40 String formatTest(Map test) { 24 String formatTest(Map test) {
41 return test[TEST_MAIN_FILE]; 25 return test[TEST_MAIN_FILE];
42 } 26 }
43 27
44 String getCodeForMain(Compiler compiler) { 28 String getCodeForMain(Compiler compiler) {
45 Element mainFunction = compiler.mainFunction; 29 Element mainFunction = compiler.mainFunction;
46 js.Node ast = compiler.enqueuer.codegen.generatedCode[mainFunction]; 30 js.Node ast = compiler.enqueuer.codegen.generatedCode[mainFunction];
47 return js.prettyPrint(ast, compiler).getText(); 31 return js.prettyPrint(ast, compiler).getText();
48 } 32 }
49 33
50 main() { 34
35 runTests(List<TestEntry> tests) {
51 Expect.isTrue(const bool.fromEnvironment("USE_CPS_IR")); 36 Expect.isTrue(const bool.fromEnvironment("USE_CPS_IR"));
52 37
53 for (TestEntry test in tests) { 38 for (TestEntry test in tests) {
54 Map files = {TEST_MAIN_FILE: test.source}; 39 Map files = {TEST_MAIN_FILE: test.source};
55 asyncTest(() { 40 asyncTest(() {
56 Compiler compiler = compilerFor(files); 41 Compiler compiler = compilerFor(files);
57 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); 42 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE');
58 return compiler.run(uri).then((bool success) { 43 return compiler.run(uri).then((bool success) {
59 Expect.isTrue(success); 44 Expect.isTrue(success);
60 String expectation = test.expectation; 45 String expectation = test.expectation;
61 if (expectation != null) { 46 if (expectation != null) {
62 String expected = test.expectation; 47 String expected = test.expectation;
63 String found = getCodeForMain(compiler); 48 String found = getCodeForMain(compiler);
64 if (expected != found) { 49 if (expected != found) {
65 Expect.fail('Expected:\n$expected\nbut found\n$found'); 50 Expect.fail('Expected:\n$expected\nbut found\n$found');
66 } 51 }
67 } 52 }
68 }).catchError((e) { 53 }).catchError((e) {
69 print(e); 54 print(e);
70 Expect.fail('The following test failed to compile:\n' 55 Expect.fail('The following test failed to compile:\n'
71 '${formatTest(files)}'); 56 '${formatTest(files)}');
72 }); 57 });
73 }); 58 });
74 } 59 }
75 } 60 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/js_backend_cps_ir_basic.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698