| 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' show findInterceptorForType; | 7 import 'dart:_interceptors' show findInterceptorForType; |
| 8 | 8 |
| 9 // Test that subclasses of native classes can be defined by setting the dispatch | 9 // Test that subclasses of native classes can be defined by setting the dispatch |
| 10 // record. | 10 // record. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 B makeB1() native; | 22 B makeB1() native; |
| 23 B makeB2() native; | 23 B makeB2() native; |
| 24 B makeC() native; | 24 B makeC() native; |
| 25 | 25 |
| 26 @Creates('=Object') | 26 @Creates('=Object') |
| 27 getBPrototype() native; | 27 getBPrototype() native; |
| 28 | 28 |
| 29 @Creates('=Object') | 29 @Creates('=Object') |
| 30 getCPrototype() native; | 30 getCPrototype() native; |
| 31 | 31 |
| 32 void setup() native r""" | 32 void setup() { |
| 33 function A() {} | 33 JS('', r""" |
| 34 function B() {} | 34 (function(){ |
| 35 function C() {} | 35 function A() {} |
| 36 makeA = function(){return new A;}; | 36 function B() {} |
| 37 makeB1 = function(){return new B;}; | 37 function C() {} |
| 38 makeB2 = function(){return new B;}; | 38 makeA = function(){return new A()}; |
| 39 makeC = function(){return new C;}; | 39 makeB1 = function(){return new B()}; |
| 40 makeB2 = function(){return new B()}; |
| 41 makeC = function(){return new C()}; |
| 40 | 42 |
| 41 getBPrototype = function(){return B.prototype;}; | 43 getBPrototype = function(){return B.prototype;}; |
| 42 getCPrototype = function(){return C.prototype;}; | 44 getCPrototype = function(){return C.prototype;}; |
| 43 """; | 45 })()"""); |
| 46 } |
| 44 | 47 |
| 45 main() { | 48 main() { |
| 46 nativeTesting(); | 49 nativeTesting(); |
| 47 setup(); | 50 setup(); |
| 48 | 51 |
| 49 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); | 52 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); |
| 50 setNativeSubclassDispatchRecord(getCPrototype(), findInterceptorForType(B)); | 53 setNativeSubclassDispatchRecord(getCPrototype(), findInterceptorForType(B)); |
| 51 | 54 |
| 52 B b1 = makeB1(); | 55 B b1 = makeB1(); |
| 53 Expect.equals('1,B', b1.foo(1)); | 56 Expect.equals('1,B', b1.foo(1)); |
| 54 | 57 |
| 55 B b2 = makeB2(); | 58 B b2 = makeB2(); |
| 56 Expect.equals('2,B', b2.foo(2)); | 59 Expect.equals('2,B', b2.foo(2)); |
| 57 | 60 |
| 58 B b3 = makeC(); | 61 B b3 = makeC(); |
| 59 Expect.equals('3,B', b3.foo(3)); | 62 Expect.equals('3,B', b3.foo(3)); |
| 60 } | 63 } |
| OLD | NEW |