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

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: Removed obsolete TODO 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..047f7461ac5818ece2d44e5e7459f11e43d96fe5
--- /dev/null
+++ b/tests/compiler/dart2js/js_backend_cps_ir_constructor_test.dart
@@ -0,0 +1,114 @@
+// 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;
+}"""),
+];
+
+void main() {
+ runTests(tests);
+}

Powered by Google App Engine
This is Rietveld 408576698