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

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

Issue 862703002: Implement constructor bodies and initializers in CPS->JS backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test case 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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/js_backend_cps_ir_constructor_test.dart
diff --git a/tests/compiler/dart2js/js_backend_cps_ir_constructor_test.dart b/tests/compiler/dart2js/js_backend_cps_ir_constructor_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b807c29af41218c3047679df806bf16ac4edcbdb
--- /dev/null
+++ b/tests/compiler/dart2js/js_backend_cps_ir_constructor_test.dart
@@ -0,0 +1,145 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// VMOptions=-DUSE_CPS_IR=true
+
+// Tests of interceptors.
+
+library constructor_test;
+
+import 'js_backend_cps_ir.dart';
+
+const List<TestEntry> tests = const [
+ const TestEntry.forMethod('generative_constructor(Sub#)', """
+class Base {
+ var x;
+ Base(this.x);
+}
+class Sub extends Base {
+ var y;
+ Sub(x, this.y) : super(x);
+}
+main() {
+ print(new Sub(1, 2).x);
+}""",
+r"""
+function(x, y) {
+ return new V.Sub(y, x);
+}"""),
+
+ const TestEntry.forMethod('generative_constructor_body(Sub#)', """
+class Base {
+ var x;
+ Base(this.x);
+}
+class Sub extends Base {
+ var y;
+ Sub(x, this.y) : super(x) {
+ print(x);
+ }
+}
+main() {
+ print(new Sub(1, 2).x);
+}""",
+r"""
+function(x, y) {
+ P.print(x);
+ return null;
+}"""),
+
+ const TestEntry.forMethod('generative_constructor(Sub#)', """
+class Base0 {
+ Base0() {
+ print('Base0');
+ }
+}
+class Base extends Base0 {
+ var x;
+ Base(this.x);
+}
+class Sub extends Base {
+ var y;
+ Sub(x, this.y) : super(x) {
+ print(x);
+ }
+}
+main() {
+ print(new Sub(1, 2).x);
+}""",
+r"""
+function(x, y) {
+ var v0;
+ v0 = new V.Sub(y, x);
+ v0.Base0$0();
+ v0.Sub$2(x, y);
+ return v0;
+}"""),
+
+ const TestEntry.forMethod('generative_constructor(Sub#)', """
+class Base0 {
+ Base0() {
+ print('Base0');
+ }
+}
+class Base extends Base0 {
+ var x;
+ Base(x1) : x = (() => ++x1) {
+ print(x1); // use boxed x1
+ }
+}
+class Sub extends Base {
+ var y;
+ Sub(x, this.y) : super(x) {
+ print(x);
+ }
+}
+main() {
+ print(new Sub(1, 2).x);
+}""",
+r"""
+function(x, y) {
+ var box_0, v0;
+ box_0 = {};
+ box_0.x1_0 = x;
+ v0 = new V.Sub(y, new V.Base_closure(box_0));
+ v0.Base0$0();
+ v0.Base$1(box_0);
+ v0.Sub$2(x, y);
+ return v0;
+}"""),
+
+ const TestEntry.forMethod('generative_constructor(Sub#)', """
+foo(x) {
+ print(x);
+}
+class Base {
+ var x1 = foo('x1');
+ var x2;
+ var x3 = foo('x3');
+ Base() : x2 = foo('x2');
+}
+class Sub extends Base {
+ var y1 = foo('y1');
+ var y2;
+ var y3;
+ Sub() : y2 = foo('y2'), super(), y3 = foo('y3');
+}
+main() {
+ new Sub();
+}
+""",
+r"""
+function() {
+ var v0, v1, v2, v3, v4;
+ v0 = V.foo("y1");
+ v1 = V.foo("y2");
+ v2 = V.foo("x1");
+ v3 = V.foo("x3");
+ v4 = V.foo("x2");
+ return new V.Sub(v0, v1, V.foo("y3"), v2, v4, v3);
+}"""),
+];
+
+void main() {
+ runTests(tests);
+}

Powered by Google App Engine
This is Rietveld 408576698