| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011, 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 // Verify that methods are not renamed to clash with native field names |
| 6 // that are known from the DOM (like x, y, z). |
| 7 class A native "*A" { |
| 8 int x; |
| 9 int y; |
| 10 int z; |
| 11 int gettersCalled; |
| 12 } |
| 13 |
| 14 |
| 15 void setup() native r""" |
| 16 function getter() { |
| 17 this.gettersCalled++; |
| 18 return 42; |
| 19 } |
| 20 |
| 21 function A(){ |
| 22 var a = Object.create( |
| 23 { constructor: { name: 'A'}}, |
| 24 { x: { get: getter, configurable: false, writeable: false }, |
| 25 y: { get: getter, configurable: false, writeable: false }, |
| 26 z: { get: getter, configurable: false, writeable: false } |
| 27 }); |
| 28 a.gettersCalled = 0; |
| 29 return a; |
| 30 } |
| 31 |
| 32 makeA = function() { return new A; }; |
| 33 """; |
| 34 |
| 35 A makeA() native; |
| 36 |
| 37 class B { |
| 38 void a() { } |
| 39 void a0() { } |
| 40 void a1() { } |
| 41 void a2() { } |
| 42 void a3() { } |
| 43 void a4() { } |
| 44 void a5() { } |
| 45 void a6() { } |
| 46 void a7() { } |
| 47 void a8() { } |
| 48 void a9() { } |
| 49 void a10() { } |
| 50 void a11() { } |
| 51 void a12() { } |
| 52 void a13() { } |
| 53 void a14() { } |
| 54 void a15() { } |
| 55 void a16() { } |
| 56 void a17() { } |
| 57 void a18() { } |
| 58 void a19() { } |
| 59 void a20() { } |
| 60 void a21() { } |
| 61 void a22() { } |
| 62 void a23() { } |
| 63 void a24() { } |
| 64 void a25() { } |
| 65 void a26() { } |
| 66 int z = 0; |
| 67 } |
| 68 |
| 69 int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1)); |
| 70 |
| 71 main() { |
| 72 setup(); |
| 73 var both = [makeA(), new B()]; |
| 74 var x = both[inscrutable(0)]; |
| 75 // Each of these will throw, because an instance of A doesn't have any of |
| 76 // these functions. The important thing is that none of them have been |
| 77 // renamed to be called 'z' by the minifier, because then the getter will be |
| 78 // hit. |
| 79 try { x.a(); } catch(e) { } |
| 80 try { x.a0(); } catch(e) { } |
| 81 try { x.a1(); } catch(e) { } |
| 82 try { x.a2(); } catch(e) { } |
| 83 try { x.a3(); } catch(e) { } |
| 84 try { x.a4(); } catch(e) { } |
| 85 try { x.a5(); } catch(e) { } |
| 86 try { x.a6(); } catch(e) { } |
| 87 try { x.a7(); } catch(e) { } |
| 88 try { x.a8(); } catch(e) { } |
| 89 try { x.a9(); } catch(e) { } |
| 90 try { x.a10(); } catch(e) { } |
| 91 try { x.a11(); } catch(e) { } |
| 92 try { x.a12(); } catch(e) { } |
| 93 try { x.a13(); } catch(e) { } |
| 94 try { x.a14(); } catch(e) { } |
| 95 try { x.a15(); } catch(e) { } |
| 96 try { x.a16(); } catch(e) { } |
| 97 try { x.a17(); } catch(e) { } |
| 98 try { x.a18(); } catch(e) { } |
| 99 try { x.a19(); } catch(e) { } |
| 100 try { x.a20(); } catch(e) { } |
| 101 try { x.a21(); } catch(e) { } |
| 102 try { x.a12(); } catch(e) { } |
| 103 try { x.a23(); } catch(e) { } |
| 104 try { x.a24(); } catch(e) { } |
| 105 try { x.a25(); } catch(e) { } |
| 106 try { x.a26(); } catch(e) { } |
| 107 Expect.equals(0, x.gettersCalled); |
| 108 Expect.equals(42, x.z); |
| 109 Expect.equals(1, x.gettersCalled); |
| 110 } |
| 111 |
| OLD | NEW |