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 "native_testing.dart"; |
6 | 6 |
7 // Test that hidden native class names are not used by generated code. | 7 // Test that hidden native class names are not used by generated code. |
8 | 8 |
9 @Native("BB") | 9 @Native("BB") |
10 class AA { | 10 class AA { |
11 get name => 'AA'; | 11 get name => 'AA'; |
12 static AA create() => makeA(); | 12 static AA create() => makeA(); |
13 } | 13 } |
14 | 14 |
15 @Native("CC") | 15 @Native("CC") |
16 class BB { | 16 class BB { |
17 get name => 'BB'; | 17 get name => 'BB'; |
18 static BB create() => makeB(); | 18 static BB create() => makeB(); |
19 } | 19 } |
20 | 20 |
21 class CC { | 21 class CC { |
22 // Ordinary class with name clashing with native class. | 22 // Ordinary class with name clashing with native class. |
23 get name => 'CC'; | 23 get name => 'CC'; |
24 static CC create() => new CC(); | 24 static CC create() => new CC(); |
25 } | 25 } |
26 | 26 |
27 makeA() native ; | 27 makeA() native; |
28 makeB() native ; | 28 makeB() native; |
29 | 29 |
30 void setup1() native """ | 30 void setup1() native """ |
31 // Poison hidden native names 'BB' and 'CC' to prove the compiler didn't place | 31 // Poison hidden native names 'BB' and 'CC' to prove the compiler didn't place |
32 // anthing on the hidden native class. | 32 // anthing on the hidden native class. |
33 BB = null; | 33 BB = null; |
34 CC = null; | 34 CC = null; |
35 """; | 35 """; |
36 | 36 |
37 void setup2() native """ | 37 void setup2() native """ |
38 // This code is all inside 'setup' and so not accesible from the global scope. | 38 // This code is all inside 'setup' and so not accesible from the global scope. |
(...skipping 11 matching lines...) Expand all Loading... |
50 setup2(); | 50 setup2(); |
51 | 51 |
52 var a = confuse(AA.create()); | 52 var a = confuse(AA.create()); |
53 var b = confuse(BB.create()); | 53 var b = confuse(BB.create()); |
54 var c = confuse(CC.create()); | 54 var c = confuse(CC.create()); |
55 | 55 |
56 Expect.equals('AA', a.name); | 56 Expect.equals('AA', a.name); |
57 Expect.equals('BB', b.name); | 57 Expect.equals('BB', b.name); |
58 Expect.equals('CC', c.name); | 58 Expect.equals('CC', c.name); |
59 } | 59 } |
OLD | NEW |