| 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 | |
| 5 // Tests of interceptors. | |
| 6 | |
| 7 library supercall_test; | |
| 8 | |
| 9 import 'js_backend_cps_ir.dart'; | |
| 10 | |
| 11 const List<TestEntry> tests = const [ | |
| 12 const TestEntry(""" | |
| 13 class Base { | |
| 14 m(x) { | |
| 15 print(x+1); | |
| 16 } | |
| 17 } | |
| 18 class Sub extends Base { | |
| 19 m(x) => super.m(x+10); | |
| 20 } | |
| 21 main() { | |
| 22 new Sub().m(100); | |
| 23 }""", | |
| 24 r""" | |
| 25 function() { | |
| 26 var v0; | |
| 27 V.Sub$(); | |
| 28 v0 = H.S(100 + 10 + 1); | |
| 29 if (typeof dartPrint == "function") | |
| 30 dartPrint(v0); | |
| 31 else if (typeof console == "object" && typeof console.log != "undefined") | |
| 32 console.log(v0); | |
| 33 else if (!(typeof window == "object")) { | |
| 34 if (!(typeof print == "function")) | |
| 35 throw "Unable to print message: " + String(v0); | |
| 36 print(v0); | |
| 37 } | |
| 38 }"""), | |
| 39 | |
| 40 // Reenable when we support compiling functions that | |
| 41 // need interceptor calling convention. | |
| 42 // const TestEntry.forMethod('function(Sub#+)', """ | |
| 43 // class Base { | |
| 44 // m(x) { | |
| 45 // print(x+1000); | |
| 46 // } | |
| 47 // operator+(x) => m(x+10); | |
| 48 // } | |
| 49 // class Sub extends Base { | |
| 50 // m(x) => super.m(x+100); | |
| 51 // operator+(x) => super + (x+1); | |
| 52 // } | |
| 53 // main() { | |
| 54 // new Sub() + 10000; | |
| 55 // }""", | |
| 56 // r""" | |
| 57 // function(x) { | |
| 58 // var v0, v1, v2; | |
| 59 // v0 = 1; | |
| 60 // v1 = J.getInterceptor$ns(x).$add(x, v0); | |
| 61 // v2 = this; | |
| 62 // return V.Base.prototype.$add.call(null, v2, v1); | |
| 63 // }"""), | |
| 64 | |
| 65 const TestEntry(""" | |
| 66 class Base { | |
| 67 var field = 123; | |
| 68 } | |
| 69 class Sub extends Base { | |
| 70 m(x) => x + super.field; | |
| 71 } | |
| 72 main() { | |
| 73 print(new Sub().m(10)); | |
| 74 }""", | |
| 75 r""" | |
| 76 function() { | |
| 77 var v0 = H.S(10 + V.Sub$().field); | |
| 78 if (typeof dartPrint == "function") | |
| 79 dartPrint(v0); | |
| 80 else if (typeof console == "object" && typeof console.log != "undefined") | |
| 81 console.log(v0); | |
| 82 else if (!(typeof window == "object")) { | |
| 83 if (!(typeof print == "function")) | |
| 84 throw "Unable to print message: " + String(v0); | |
| 85 print(v0); | |
| 86 } | |
| 87 }"""), | |
| 88 | |
| 89 | |
| 90 ]; | |
| 91 | |
| 92 void main() { | |
| 93 runTests(tests); | |
| 94 } | |
| OLD | NEW |