| 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 "dart:_js_helper"; | 5 import "dart:_js_helper"; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 // 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. |
| 9 | 9 |
| 10 @Native("BB") | 10 @Native("BB") |
| 11 class AA { | 11 class AA { |
| 12 get name => 'AA'; | 12 get name => 'AA'; |
| 13 static AA create() => makeA(); | 13 static AA create() => makeA(); |
| 14 } | 14 } |
| 15 | 15 |
| 16 @Native("CC") | 16 @Native("CC") |
| 17 class BB { | 17 class BB { |
| 18 get name => 'BB'; | 18 get name => 'BB'; |
| 19 static BB create() => makeB(); | 19 static BB create() => makeB(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 class CC { // Ordinary class with name clashing with native class. | 22 class CC { |
| 23 // Ordinary class with name clashing with native class. |
| 23 get name => 'CC'; | 24 get name => 'CC'; |
| 24 static CC create() => new CC(); | 25 static CC create() => new CC(); |
| 25 } | 26 } |
| 26 | 27 |
| 27 makeA() native; | 28 makeA() native ; |
| 28 makeB() native; | 29 makeB() native ; |
| 29 | 30 |
| 30 void setup1() native """ | 31 void setup1() native """ |
| 31 // Poison hidden native names 'BB' and 'CC' to prove the compiler didn't place | 32 // Poison hidden native names 'BB' and 'CC' to prove the compiler didn't place |
| 32 // anthing on the hidden native class. | 33 // anthing on the hidden native class. |
| 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. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 | 51 |
| 51 var things = [AA.create(), BB.create(), CC.create()]; | 52 var things = [AA.create(), BB.create(), CC.create()]; |
| 52 var a = things[inscrutable(0)]; | 53 var a = things[inscrutable(0)]; |
| 53 var b = things[inscrutable(1)]; | 54 var b = things[inscrutable(1)]; |
| 54 var c = things[inscrutable(2)]; | 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 |