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

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

Issue 726543002: Add support for local variables(including parameters) to cps->js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: added test. 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
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';
11 import 'package:compiler/src/apiimpl.dart' 11 import 'package:compiler/src/apiimpl.dart'
12 show Compiler; 12 show Compiler;
13 import 'memory_compiler.dart'; 13 import 'memory_compiler.dart';
14 14
15 const String TEST_MAIN_FILE = 'test.dart'; 15 const String TEST_MAIN_FILE = 'test.dart';
16 16
17 /// The list of tests to run. 17 /// The list of tests to run.
18 const List<String> RAW_TESTS = const [ 18 const List<String> RAW_TESTS = const [
19 """ 19 """
20 foo() { return 42; } 20 foo(a) {
21 main() { return foo(); } 21 return a;
22 }
23 main() {
24 var a = 10;
25 var b = 1;
26 var t;
27 t = a;
28 a = b;
29 b = t;
30 print(a);
31 print(b);
32 print(b);
33 print(foo(a));
34 }
35 """,
36 """
37 foo() { return 42; }
38 main() { return foo(); }
22 """, 39 """,
23 "main() {}", 40 "main() {}",
24 "main() { return 42; }", 41 "main() { return 42; }",
25 ]; 42 ];
26 43
27 String formatTest(Map test) { 44 String formatTest(Map test) {
28 return test[TEST_MAIN_FILE]; 45 return test[TEST_MAIN_FILE];
29 } 46 }
30 47
31 main() { 48 main() {
32 Expect.isTrue(const bool.fromEnvironment("USE_CPS_IR")); 49 Expect.isTrue(const bool.fromEnvironment("USE_CPS_IR"));
33 50
34 Iterable<Map> tests = 51 Iterable<Map> tests =
35 RAW_TESTS.map((String text) => {TEST_MAIN_FILE: text}); 52 RAW_TESTS.map((String text) => {TEST_MAIN_FILE: text});
36 53
37 for (Map test in tests) { 54 for (Map test in tests) {
38 asyncTest(() { 55 asyncTest(() {
39 Compiler compiler = compilerFor(test); 56 Compiler compiler = compilerFor(test);
40 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE'); 57 Uri uri = Uri.parse('memory:$TEST_MAIN_FILE');
41 return compiler.run(uri).then((_) { 58 return compiler.run(uri).then((_) {
42 Expect.isNotNull(compiler.assembledCode); 59 Expect.isNotNull(compiler.assembledCode);
43 }).catchError((e) { 60 }).catchError((e) {
44 Expect.fail('The following test failed to compile:\n' 61 Expect.fail('The following test failed to compile:\n'
45 '${formatTest(test)}'); 62 '${formatTest(test)}');
46 }); 63 });
47 }); 64 });
48 } 65 }
49 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698