| OLD | NEW |
| (Empty) | |
| 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 |
| 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 supercall_test; |
| 9 |
| 10 import 'js_backend_cps_ir.dart'; |
| 11 |
| 12 const List<TestEntry> tests = const [ |
| 13 const TestEntry.forMethod('function(Sub#m)', """ |
| 14 class Base { |
| 15 m(x) { |
| 16 print(x+1); |
| 17 } |
| 18 } |
| 19 class Sub extends Base { |
| 20 m(x) => super.m(x+10); |
| 21 } |
| 22 main() { |
| 23 new Sub().m(100); |
| 24 }""", |
| 25 r""" |
| 26 function(x) { |
| 27 var v0, v1; |
| 28 v0 = 10; |
| 29 v1 = J.getInterceptor(x).$add(x, v0); |
| 30 return V.Base.prototype.m$1.call(this, v1); |
| 31 }"""), |
| 32 |
| 33 const TestEntry.forMethod('function(Sub#+)', """ |
| 34 class Base { |
| 35 m(x) { |
| 36 print(x+1000); |
| 37 } |
| 38 operator+(x) => m(x+10); |
| 39 } |
| 40 class Sub extends Base { |
| 41 m(x) => super.m(x+100); |
| 42 operator+(x) => super + (x+1); |
| 43 } |
| 44 main() { |
| 45 new Sub() + 10000; |
| 46 }""", |
| 47 r""" |
| 48 function(x) { |
| 49 var v0, v1, v2; |
| 50 v0 = 1; |
| 51 v1 = J.getInterceptor(x).$add(x, v0); |
| 52 v2 = this; |
| 53 return V.Base.prototype.$add.call(null, v2, v1); |
| 54 }"""), |
| 55 |
| 56 const TestEntry.forMethod('function(Sub#m)', """ |
| 57 class Base { |
| 58 var field; |
| 59 } |
| 60 class Sub extends Base { |
| 61 m(x) => x + super.field; |
| 62 } |
| 63 main() { |
| 64 print(new Sub().m(10)); |
| 65 }""", |
| 66 r""" |
| 67 function(x) { |
| 68 var v0; |
| 69 v0 = this.field; |
| 70 return J.getInterceptor(x).$add(x, v0); |
| 71 }"""), |
| 72 |
| 73 |
| 74 ]; |
| 75 |
| 76 void main() { |
| 77 runTests(tests); |
| 78 } |
| OLD | NEW |