| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 for dartNativeDispatchHooksTransformer, getTag hook. | 7 // Test for dartNativeDispatchHooksTransformer, getTag hook. |
| 8 | 8 |
| 9 @Native("T1A") | 9 @Native("T1A") |
| 10 class T1A {} | 10 class T1A {} |
| 11 | 11 |
| 12 @Native("T1B") | 12 @Native("T1B") |
| 13 class T1B {} | 13 class T1B {} |
| 14 | 14 |
| 15 @Native("T1C") | 15 @Native("T1C") |
| 16 class T1C {} | 16 class T1C {} |
| 17 | 17 |
| 18 makeT1A() native ; | 18 makeT1A() native ; |
| 19 makeT1B() native ; | 19 makeT1B() native ; |
| 20 makeT1C() native ; | 20 makeT1C() native ; |
| 21 | 21 |
| 22 int getTagCallCount() native ; | 22 int getTagCallCount() native ; |
| 23 | 23 |
| 24 void setup() native r''' | 24 void setup() native r''' |
| 25 function T1A() { } // Normal native class. | 25 function T1A() { } // Normal native class. |
| 26 function T1CrazyB() { } // Native class with different constructor name. | 26 function T1CrazyB() { } // Native class with different constructor name. |
| 27 | 27 |
| 28 var T1fakeA = (function(){ | 28 var T1fakeA = (function(){ |
| 29 function T1A() {} // Native class with adversarial constructor name. | 29 function T1A() {} // Native class with adversarial constructor name. |
| 30 return T1A; | 30 return T1A; |
| 31 })(); | 31 })(); |
| 32 | 32 |
| 33 // Make constructors visible on 'window' for prepatching. | 33 // Make constructors visible on 'window' for prepatching. |
| 34 if (typeof window == "undefined") window = {} | 34 if (typeof window == "undefined") window = {} |
| 35 window.T1A = T1A; | 35 window.T1A = T1A; |
| 36 window.T1CrazyB = T1CrazyB; | 36 window.T1CrazyB = T1CrazyB; |
| 37 | 37 |
| 38 makeT1A = function(){return new T1A;}; | 38 makeT1A = function(){return new T1A;}; |
| 39 makeT1B = function(){return new T1CrazyB;}; | 39 makeT1B = function(){return new T1CrazyB;}; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 Expect.equals(true, t1c is T1C, '$t1c is T1C'); | 83 Expect.equals(true, t1c is T1C, '$t1c is T1C'); |
| 84 | 84 |
| 85 Expect.equals(2, getTagCallCount()); | 85 Expect.equals(2, getTagCallCount()); |
| 86 | 86 |
| 87 Expect.equals(true, confuse(t1a) is T1A, '$t1a is T1A'); | 87 Expect.equals(true, confuse(t1a) is T1A, '$t1a is T1A'); |
| 88 Expect.equals(true, confuse(t1b) is T1B, '$t1b is T1B'); | 88 Expect.equals(true, confuse(t1b) is T1B, '$t1b is T1B'); |
| 89 Expect.equals(true, confuse(t1c) is T1C, '$t1c is T1C'); | 89 Expect.equals(true, confuse(t1c) is T1C, '$t1c is T1C'); |
| 90 | 90 |
| 91 Expect.equals(2, getTagCallCount()); | 91 Expect.equals(2, getTagCallCount()); |
| 92 } | 92 } |
| OLD | NEW |