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

Unified Diff: tests/compiler/dart2js/js_backend_cps_ir_test.dart

Issue 743973002: Add list literals in js cps codegen. (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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/js_backend_cps_ir_test.dart
diff --git a/tests/compiler/dart2js/js_backend_cps_ir_test.dart b/tests/compiler/dart2js/js_backend_cps_ir_test.dart
index df21e239e9825f043c0d19478d6a0a47c1e64cb8..97996efdea0665726a0b9e9ce0182cb4ad57bda0 100644
--- a/tests/compiler/dart2js/js_backend_cps_ir_test.dart
+++ b/tests/compiler/dart2js/js_backend_cps_ir_test.dart
@@ -3,8 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
// VMOptions=-DUSE_CPS_IR=true
-// Test that the CPS IR code generator is able to compile the provided
-// example programs.
+// Test that the CPS IR code generator compiles programs as expected
karlklose 2014/11/20 12:31:18 'expected' -> 'and produces the expected output'?
sigurdm 2014/11/20 13:32:45 Done.
import 'package:async_helper/async_helper.dart';
import 'package:expect/expect.dart';
@@ -14,6 +13,8 @@ import 'memory_compiler.dart';
import 'package:compiler/src/js/js.dart' as js;
import 'package:compiler/src/common.dart' show Element;
+import 'js_backend_cps_ir_basic.dart' as basic;
+import 'js_backend_cps_ir_literals.dart' as literals;
const String TEST_MAIN_FILE = 'test.dart';
@@ -23,53 +24,6 @@ class TestEntry {
const TestEntry(this.source, [this.expectation]);
}
-/// The list of tests to run.
-const List<TestEntry> tests = const [
- const TestEntry(
- """
-foo(a) {
- return a;
-}
-main() {
- var a = 10;
- var b = 1;
- var t;
- t = a;
- a = b;
- b = t;
- print(a);
- print(b);
- print(b);
- print(foo(a));
-}
- """,
- """
-function() {
- var a, b;
- a = 10;
- b = 1;
- P.print(b);
- P.print(a);
- P.print(a);
- P.print(V.foo(b));
- return null;
-}"""),
- const TestEntry(
- """
-foo() { return 42; }
-main() { return foo(); }
- """,
- """function() {
- return V.foo();
-}"""),
- const TestEntry("main() {}"),
- const TestEntry("main() { return 42; }"),
- const TestEntry("main() { return; }", """
-function() {
- return null;
-}"""),
-];
-
String formatTest(Map test) {
return test[TEST_MAIN_FILE];
}
@@ -83,22 +37,24 @@ String getCodeForMain(Compiler compiler) {
main() {
Expect.isTrue(const bool.fromEnvironment("USE_CPS_IR"));
- for (TestEntry test in tests) {
- Map files = {TEST_MAIN_FILE: test.source};
- asyncTest(() {
- Compiler compiler = compilerFor(files);
- Uri uri = Uri.parse('memory:$TEST_MAIN_FILE');
- return compiler.run(uri).then((_) {
- Expect.isNotNull(compiler.assembledCode);
- String expectation = test.expectation;
- if (expectation != null) {
- Expect.equals(test.expectation, getCodeForMain(compiler));
- }
- }).catchError((e) {
- print(e);
- Expect.fail('The following test failed to compile:\n'
- '${formatTest(files)}');
+ for (List<TestEntry> tests in [basic.tests, literals.tests]) {
karlklose 2014/11/20 12:31:18 Could you instead leaves tests where it is as L
sigurdm 2014/11/20 13:32:45 Done.
+ for (TestEntry test in tests) {
+ Map files = {TEST_MAIN_FILE: test.source};
+ asyncTest(() {
+ Compiler compiler = compilerFor(files);
+ Uri uri = Uri.parse('memory:$TEST_MAIN_FILE');
+ return compiler.run(uri).then((_) {
+ Expect.isNotNull(compiler.assembledCode);
+ String expectation = test.expectation;
+ if (expectation != null) {
+ Expect.equals(test.expectation, getCodeForMain(compiler));
+ }
+ }).catchError((e) {
+ print(e);
+ Expect.fail('The following test failed to compile:\n'
+ '${formatTest(files)}');
+ });
});
- });
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698