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

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

Issue 739883003: Fix codegeneration for 'return'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « pkg/compiler/lib/src/js_backend/codegen/codegen.dart ('k') | no next file » | 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 4 // VMOptions=-DUSE_CPS_IR=true
5 5
6 // Test that the CPS IR code generator is able to compile the provided 6 // Test that the CPS IR code generator is able to compile the provided
7 // example programs. 7 // example programs.
8 8
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const TestEntry( 57 const TestEntry(
58 """ 58 """
59 foo() { return 42; } 59 foo() { return 42; }
60 main() { return foo(); } 60 main() { return foo(); }
61 """, 61 """,
62 """function() { 62 """function() {
63 return V.foo(); 63 return V.foo();
64 }"""), 64 }"""),
65 const TestEntry("main() {}"), 65 const TestEntry("main() {}"),
66 const TestEntry("main() { return 42; }"), 66 const TestEntry("main() { return 42; }"),
67 const TestEntry("main() { return; }", """
68 function() {
69 return null;
70 }"""),
67 ]; 71 ];
68 72
69 String formatTest(Map test) { 73 String formatTest(Map test) {
70 return test[TEST_MAIN_FILE]; 74 return test[TEST_MAIN_FILE];
71 } 75 }
72 76
73 String getCodeForMain(Compiler compiler) { 77 String getCodeForMain(Compiler compiler) {
74 Element mainFunction = compiler.mainFunction; 78 Element mainFunction = compiler.mainFunction;
75 js.Node ast = compiler.enqueuer.codegen.generatedCode[mainFunction]; 79 js.Node ast = compiler.enqueuer.codegen.generatedCode[mainFunction];
76 return js.prettyPrint(ast, compiler).getText(); 80 return js.prettyPrint(ast, compiler).getText();
(...skipping 14 matching lines...) Expand all
91 Expect.equals(test.expectation, getCodeForMain(compiler)); 95 Expect.equals(test.expectation, getCodeForMain(compiler));
92 } 96 }
93 }).catchError((e) { 97 }).catchError((e) {
94 print(e); 98 print(e);
95 Expect.fail('The following test failed to compile:\n' 99 Expect.fail('The following test failed to compile:\n'
96 '${formatTest(files)}'); 100 '${formatTest(files)}');
97 }); 101 });
98 }); 102 });
99 } 103 }
100 } 104 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/codegen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698