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