| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "native_testing.dart"; | 5 import "dart:_js_helper"; |
| 6 import "package:expect/expect.dart"; |
| 6 | 7 |
| 7 // Test that hidden native class names are not used by generated code. | 8 // Test that hidden native class names are not used by generated code. |
| 8 | 9 |
| 9 @Native("BB") | 10 @Native("BB") |
| 10 class AA { | 11 class AA { |
| 11 get name => 'AA'; | 12 get name => 'AA'; |
| 12 static AA create() => makeA(); | 13 static AA create() => makeA(); |
| 13 } | 14 } |
| 14 | 15 |
| 15 @Native("CC") | 16 @Native("CC") |
| (...skipping 17 matching lines...) Expand all Loading... |
| 33 BB = null; | 34 BB = null; |
| 34 CC = null; | 35 CC = null; |
| 35 """; | 36 """; |
| 36 | 37 |
| 37 void setup2() native """ | 38 void setup2() native """ |
| 38 // This code is all inside 'setup' and so not accesible from the global scope. | 39 // This code is all inside 'setup' and so not accesible from the global scope. |
| 39 function BB(){} | 40 function BB(){} |
| 40 function CC(){} | 41 function CC(){} |
| 41 makeA = function(){return new BB}; // AA is native "BB" | 42 makeA = function(){return new BB}; // AA is native "BB" |
| 42 makeB = function(){return new CC}; // BB is native "CC" | 43 makeB = function(){return new CC}; // BB is native "CC" |
| 43 self.nativeConstructor(BB); | |
| 44 self.nativeConstructor(CC); | |
| 45 """; | 44 """; |
| 46 | 45 |
| 46 int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1)); |
| 47 |
| 47 main() { | 48 main() { |
| 48 nativeTesting(); | |
| 49 setup1(); | 49 setup1(); |
| 50 setup2(); | 50 setup2(); |
| 51 | 51 |
| 52 var a = confuse(AA.create()); | 52 var things = [AA.create(), BB.create(), CC.create()]; |
| 53 var b = confuse(BB.create()); | 53 var a = things[inscrutable(0)]; |
| 54 var c = confuse(CC.create()); | 54 var b = things[inscrutable(1)]; |
| 55 var c = things[inscrutable(2)]; |
| 55 | 56 |
| 56 Expect.equals('AA', a.name); | 57 Expect.equals('AA', a.name); |
| 57 Expect.equals('BB', b.name); | 58 Expect.equals('BB', b.name); |
| 58 Expect.equals('CC', c.name); | 59 Expect.equals('CC', c.name); |
| 59 } | 60 } |
| OLD | NEW |