| 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 that subclasses of native classes can be initialized by calling the | 10 // Test that subclasses of native classes can be initialized by calling the |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 B.three([x]) : super.three(205, x); | 53 B.three([x]) : super.three(205, x); |
| 54 | 54 |
| 55 get increment => 20; | 55 get increment => 20; |
| 56 } | 56 } |
| 57 | 57 |
| 58 makeB() native; | 58 makeB() native; |
| 59 | 59 |
| 60 @Creates('=Object') | 60 @Creates('=Object') |
| 61 getBPrototype() native; | 61 getBPrototype() native; |
| 62 | 62 |
| 63 void setup() native r""" | 63 void setup() { |
| 64 function B() { this.a2 = 102; } | 64 JS('', r""" |
| 65 (function(){ |
| 66 function B() { this.a2 = 102; } |
| 65 | 67 |
| 66 makeB = function(){return new B;}; | 68 makeB = function(){return new B()}; |
| 67 | 69 |
| 68 getBPrototype = function(){return B.prototype;}; | 70 getBPrototype = function(){return B.prototype;}; |
| 69 """; | 71 })()"""); |
| 72 } |
| 70 | 73 |
| 71 test_one() { | 74 test_one() { |
| 72 trace = []; | 75 trace = []; |
| 73 var constructor = findConstructorForNativeSubclassType(B, 'one'); | 76 var constructor = findConstructorForNativeSubclassType(B, 'one'); |
| 74 Expect.isNotNull(constructor); | 77 Expect.isNotNull(constructor); |
| 75 Expect.isNull(findConstructorForNativeSubclassType(B, 'Missing')); | 78 Expect.isNull(findConstructorForNativeSubclassType(B, 'Missing')); |
| 76 | 79 |
| 77 var b = makeB(); | 80 var b = makeB(); |
| 78 Expect.isTrue(b is B); | 81 Expect.isTrue(b is B); |
| 79 // Call constructor to initialize native object. | 82 // Call constructor to initialize native object. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 return message; | 168 return message; |
| 166 }; | 169 }; |
| 167 | 170 |
| 168 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); | 171 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); |
| 169 | 172 |
| 170 test_one(); | 173 test_one(); |
| 171 test_two(); | 174 test_two(); |
| 172 test_three(); | 175 test_three(); |
| 173 test_new(); | 176 test_new(); |
| 174 } | 177 } |
| OLD | NEW |