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 "dart:_js_helper"; | 5 import "native_testing.dart"; |
6 import "package:expect/expect.dart"; | |
7 | 6 |
8 // Test for dartExperimentalFixupGetTag. | 7 // Test for dartExperimentalFixupGetTag. |
9 | 8 |
10 @Native("A") | 9 @Native("A") |
11 class Foo { | 10 class Foo { |
12 // There is one native class with dispatch tag 'A'. | 11 // There is one native class with dispatch tag 'A'. |
13 token() native ; | 12 token() native ; |
14 } | 13 } |
15 | 14 |
16 void setup() native r""" | 15 void setup() native r""" |
(...skipping 10 matching lines...) Expand all Loading... |
27 }; | 26 }; |
28 | 27 |
29 function A(){ } | 28 function A(){ } |
30 A.prototype.token = function () { return 'isA'; } | 29 A.prototype.token = function () { return 'isA'; } |
31 | 30 |
32 function B(){ } | 31 function B(){ } |
33 B.prototype.token = function () { return 'isB'; } | 32 B.prototype.token = function () { return 'isB'; } |
34 | 33 |
35 makeA = function() { return new A; }; | 34 makeA = function() { return new A; }; |
36 makeB = function() { return new B; }; | 35 makeB = function() { return new B; }; |
| 36 |
| 37 self.nativeConstructor(A); |
37 """; | 38 """; |
38 | 39 |
39 makeA() native ; | 40 makeA() native ; |
40 makeB() native ; | 41 makeB() native ; |
41 | 42 |
42 main() { | 43 main() { |
| 44 nativeTesting(); |
43 setup(); | 45 setup(); |
44 | 46 |
45 var a = makeA(); | 47 var a = makeA(); |
46 var b = makeB(); | 48 var b = makeB(); |
47 | 49 |
48 Expect.equals('isA', a.token()); | 50 Expect.equals('isA', a.token()); |
49 | 51 |
50 // This call succeeds because the fixed-up 'getTag' method returns Foo's | 52 // This call succeeds because the fixed-up 'getTag' method returns Foo's |
51 // dispatch tag, and B is a faithful polyfil for Foo/A. | 53 // dispatch tag, and B is a faithful polyfil for Foo/A. |
52 Expect.equals('isB', b.token()); | 54 Expect.equals('isB', b.token()); |
53 | 55 |
54 Expect.isTrue(a is Foo); | 56 Expect.isTrue(a is Foo); |
55 Expect.isTrue(b is Foo); | 57 Expect.isTrue(b is Foo); |
56 } | 58 } |
OLD | NEW |