| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 // VMOptions=-DUSE_CPS_IR=true |
| 5 |
| 6 // Tests of interceptors. |
| 7 |
| 8 library constructor_test; |
| 9 |
| 10 import 'js_backend_cps_ir.dart'; |
| 11 |
| 12 const List<TestEntry> tests = const [ |
| 13 const TestEntry.forMethod('generative_constructor(Sub#)', """ |
| 14 class Base { |
| 15 var x; |
| 16 Base(this.x); |
| 17 } |
| 18 class Sub extends Base { |
| 19 var y; |
| 20 Sub(x, this.y) : super(x); |
| 21 } |
| 22 main() { |
| 23 print(new Sub(1, 2).x); |
| 24 }""", |
| 25 r""" |
| 26 function(x, y) { |
| 27 return new V.Sub(y, x); |
| 28 }"""), |
| 29 |
| 30 const TestEntry.forMethod('generative_constructor_body(Sub#)', """ |
| 31 class Base { |
| 32 var x; |
| 33 Base(this.x); |
| 34 } |
| 35 class Sub extends Base { |
| 36 var y; |
| 37 Sub(x, this.y) : super(x) { |
| 38 print(x); |
| 39 } |
| 40 } |
| 41 main() { |
| 42 print(new Sub(1, 2).x); |
| 43 }""", |
| 44 r""" |
| 45 function(x, y) { |
| 46 P.print(x); |
| 47 return null; |
| 48 }"""), |
| 49 |
| 50 const TestEntry.forMethod('generative_constructor(Sub#)', """ |
| 51 class Base0 { |
| 52 Base0() { |
| 53 print('Base0'); |
| 54 } |
| 55 } |
| 56 class Base extends Base0 { |
| 57 var x; |
| 58 Base(this.x); |
| 59 } |
| 60 class Sub extends Base { |
| 61 var y; |
| 62 Sub(x, this.y) : super(x) { |
| 63 print(x); |
| 64 } |
| 65 } |
| 66 main() { |
| 67 print(new Sub(1, 2).x); |
| 68 }""", |
| 69 r""" |
| 70 function(x, y) { |
| 71 var v0; |
| 72 v0 = new V.Sub(y, x); |
| 73 v0.Base0$0(); |
| 74 v0.Sub$2(x, y); |
| 75 return v0; |
| 76 }"""), |
| 77 |
| 78 const TestEntry.forMethod('generative_constructor(Sub#)', """ |
| 79 class Base0 { |
| 80 Base0() { |
| 81 print('Base0'); |
| 82 } |
| 83 } |
| 84 class Base extends Base0 { |
| 85 var x; |
| 86 Base(x1) : x = (() => ++x1) { |
| 87 print(x1); // use boxed x1 |
| 88 } |
| 89 } |
| 90 class Sub extends Base { |
| 91 var y; |
| 92 Sub(x, this.y) : super(x) { |
| 93 print(x); |
| 94 } |
| 95 } |
| 96 main() { |
| 97 print(new Sub(1, 2).x); |
| 98 }""", |
| 99 r""" |
| 100 function(x, y) { |
| 101 var box_0, v0; |
| 102 box_0 = {}; |
| 103 box_0.x1_0 = x; |
| 104 v0 = new V.Sub(y, new V.Base_closure(box_0)); |
| 105 v0.Base0$0(); |
| 106 v0.Base$1(box_0); |
| 107 v0.Sub$2(x, y); |
| 108 return v0; |
| 109 }"""), |
| 110 ]; |
| 111 |
| 112 void main() { |
| 113 runTests(tests); |
| 114 } |
| OLD | NEW |