| 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 import 'dart:_js_helper' show setNativeSubclassDispatchRecord; | 6 import 'dart:_js_helper' show setNativeSubclassDispatchRecord; |
| 7 import 'dart:_interceptors' | 7 import 'dart:_interceptors' |
| 8 show findInterceptorForType, findConstructorForNativeSubclassType; | 8 show findInterceptorForType, findConstructorForNativeSubclassType; |
| 9 | 9 |
| 10 // 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 Bfoo() => foo; | 29 Bfoo() => foo; |
| 30 | 30 |
| 31 toString() => '[N.foo = ${Nfoo()}, A.foo = ${Afoo()}, B.foo = ${Bfoo()}]'; | 31 toString() => '[N.foo = ${Nfoo()}, A.foo = ${Afoo()}, B.foo = ${Bfoo()}]'; |
| 32 } | 32 } |
| 33 | 33 |
| 34 B makeB() native; | 34 B makeB() native; |
| 35 | 35 |
| 36 @Creates('=Object') | 36 @Creates('=Object') |
| 37 getBPrototype() native; | 37 getBPrototype() native; |
| 38 | 38 |
| 39 void setup() native r""" | 39 void setup() { |
| 40 function B() { this.foo = 111; } // N.foo | 40 JS('', r""" |
| 41 makeB = function(){return new B;}; | 41 (function(){ |
| 42 function B() { this.foo = 111; } // N.foo |
| 43 makeB = function(){return new B()}; |
| 42 | 44 |
| 43 getBPrototype = function(){return B.prototype;}; | 45 getBPrototype = function(){return B.prototype;}; |
| 44 """; | 46 })()"""); |
| 47 } |
| 45 | 48 |
| 46 main() { | 49 main() { |
| 47 nativeTesting(); | 50 nativeTesting(); |
| 48 setup(); | 51 setup(); |
| 49 | 52 |
| 50 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); | 53 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); |
| 51 | 54 |
| 52 B b = makeB(); | 55 B b = makeB(); |
| 53 | 56 |
| 54 var constructor = findConstructorForNativeSubclassType(B, 'init'); | 57 var constructor = findConstructorForNativeSubclassType(B, 'init'); |
| 55 Expect.isNotNull(constructor); | 58 Expect.isNotNull(constructor); |
| 56 JS('', '#(#)', constructor, b); | 59 JS('', '#(#)', constructor, b); |
| 57 | 60 |
| 58 print(b); | 61 print(b); |
| 59 | 62 |
| 60 Expect.equals(333, confuse(b).Bfoo()); | 63 Expect.equals(333, confuse(b).Bfoo()); |
| 61 Expect.equals(222, confuse(b).Afoo()); | 64 Expect.equals(222, confuse(b).Afoo()); |
| 62 Expect.equals(111, confuse(b).Nfoo()); | 65 Expect.equals(111, confuse(b).Nfoo()); |
| 63 | 66 |
| 64 Expect.equals(333, b.Bfoo()); | 67 Expect.equals(333, b.Bfoo()); |
| 65 Expect.equals(222, b.Afoo()); | 68 Expect.equals(222, b.Afoo()); |
| 66 Expect.equals(111, b.Nfoo()); | 69 Expect.equals(111, b.Nfoo()); |
| 67 } | 70 } |
| OLD | NEW |