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 "package:expect/expect.dart"; | 5 import "native_testing.dart"; |
6 import 'dart:_foreign_helper' show JS; | 6 import 'dart:_js_helper' show setNativeSubclassDispatchRecord; |
7 import 'dart:_js_helper' show Native, Creates, setNativeSubclassDispatchRecord; | |
8 import 'dart:_interceptors' | 7 import 'dart:_interceptors' |
9 show findInterceptorForType, findConstructorForNativeSubclassType; | 8 show findInterceptorForType, findConstructorForNativeSubclassType; |
10 | 9 |
11 // Test for fields with same name as native fields. We expect N.foo to have the | 10 // Test for fields with same name as native fields. We expect N.foo to have the |
12 // property name 'foo' and A.foo and B.foo to have non-conflicting names. | 11 // property name 'foo' and A.foo and B.foo to have non-conflicting names. |
13 | 12 |
14 @Native("N") | 13 @Native("N") |
15 class N { | 14 class N { |
16 var foo; | 15 var foo; |
17 N.init(); | 16 N.init(); |
(...skipping 19 matching lines...) Expand all Loading... |
37 @Creates('=Object') | 36 @Creates('=Object') |
38 getBPrototype() native ; | 37 getBPrototype() native ; |
39 | 38 |
40 void setup() native r""" | 39 void setup() native r""" |
41 function B() { this.foo = 111; } // N.foo | 40 function B() { this.foo = 111; } // N.foo |
42 makeB = function(){return new B;}; | 41 makeB = function(){return new B;}; |
43 | 42 |
44 getBPrototype = function(){return B.prototype;}; | 43 getBPrototype = function(){return B.prototype;}; |
45 """; | 44 """; |
46 | 45 |
47 var inscrutable; | |
48 | |
49 main() { | 46 main() { |
| 47 nativeTesting(); |
50 setup(); | 48 setup(); |
51 inscrutable = (x) => x; | |
52 | 49 |
53 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); | 50 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); |
54 | 51 |
55 B b = makeB(); | 52 B b = makeB(); |
56 | 53 |
57 var constructor = findConstructorForNativeSubclassType(B, 'init'); | 54 var constructor = findConstructorForNativeSubclassType(B, 'init'); |
58 Expect.isNotNull(constructor); | 55 Expect.isNotNull(constructor); |
59 JS('', '#(#)', constructor, b); | 56 JS('', '#(#)', constructor, b); |
60 | 57 |
61 print(b); | 58 print(b); |
62 | 59 |
63 Expect.equals(333, inscrutable(b).Bfoo()); | 60 Expect.equals(333, confuse(b).Bfoo()); |
64 Expect.equals(222, inscrutable(b).Afoo()); | 61 Expect.equals(222, confuse(b).Afoo()); |
65 Expect.equals(111, inscrutable(b).Nfoo()); | 62 Expect.equals(111, confuse(b).Nfoo()); |
66 | 63 |
67 Expect.equals(333, b.Bfoo()); | 64 Expect.equals(333, b.Bfoo()); |
68 Expect.equals(222, b.Afoo()); | 65 Expect.equals(222, b.Afoo()); |
69 Expect.equals(111, b.Nfoo()); | 66 Expect.equals(111, b.Nfoo()); |
70 } | 67 } |
OLD | NEW |