| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 "package:expect/expect.dart"; |
| 6 import 'dart:_foreign_helper' show JS_INTERCEPTOR_CONSTANT; | 6 import 'dart:_foreign_helper' show JS_INTERCEPTOR_CONSTANT, JS; |
| 7 import 'dart:_js_helper' show Native, Creates; |
| 7 import 'dart:_interceptors' | 8 import 'dart:_interceptors' |
| 8 show | 9 show |
| 9 Interceptor, | 10 Interceptor, |
| 10 JavaScriptObject, | 11 JavaScriptObject, |
| 11 PlainJavaScriptObject, | 12 PlainJavaScriptObject, |
| 12 UnknownJavaScriptObject; | 13 UnknownJavaScriptObject; |
| 13 | 14 |
| 14 // Test for safe formatting of JavaScript objects by Error.safeToString. | 15 // Test for safe formatting of JavaScript objects by Error.safeToString. |
| 15 | 16 |
| 16 @Native('PPPP') | 17 @Native('PPPP') |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 63 |
| 63 function PPPP(){} | 64 function PPPP(){} |
| 64 makeP = function(){return new PPPP();}; | 65 makeP = function(){return new PPPP();}; |
| 65 | 66 |
| 66 function QQQQ(){} | 67 function QQQQ(){} |
| 67 makeQ = function(){return new QQQQ();}; | 68 makeQ = function(){return new QQQQ();}; |
| 68 | 69 |
| 69 function RRRR(){} | 70 function RRRR(){} |
| 70 makeR = function(){return new RRRR();}; | 71 makeR = function(){return new RRRR();}; |
| 71 | 72 |
| 72 self.nativeConstructor(PPPP); | |
| 73 self.nativeConstructor(QQQQ); | |
| 74 self.nativeConstructor(RRRR); | |
| 75 """; | 73 """; |
| 76 | 74 |
| 77 expectTypeName(expectedName, s) { | 75 expectTypeName(expectedName, s) { |
| 78 var m = new RegExp(r"Instance of '(.*)'").firstMatch(s); | 76 var m = new RegExp(r"Instance of '(.*)'").firstMatch(s); |
| 79 Expect.isNotNull(m); | 77 Expect.isNotNull(m); |
| 80 var name = m.group(1); | 78 var name = m.group(1); |
| 81 Expect.isTrue(expectedName == name || name.length <= 3, | 79 Expect.isTrue(expectedName == name || name.length <= 3, |
| 82 "Is '$expectedName' or minified: '$name'"); | 80 "Is '$expectedName' or minified: '$name'"); |
| 83 } | 81 } |
| 84 | 82 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 x.toString(); | 151 x.toString(); |
| 154 Expect.notEquals(plainJsString, Error.safeToString(x)); | 152 Expect.notEquals(plainJsString, Error.safeToString(x)); |
| 155 Expect.notEquals(unknownJsString, Error.safeToString(x)); | 153 Expect.notEquals(unknownJsString, Error.safeToString(x)); |
| 156 Expect.notEquals(interceptorString, Error.safeToString(x)); | 154 Expect.notEquals(interceptorString, Error.safeToString(x)); |
| 157 // And not the native class constructor. | 155 // And not the native class constructor. |
| 158 Expect.notEquals("Instance of 'RRRR'", Error.safeToString(x)); | 156 Expect.notEquals("Instance of 'RRRR'", Error.safeToString(x)); |
| 159 expectTypeName('Rascal', Error.safeToString(x)); | 157 expectTypeName('Rascal', Error.safeToString(x)); |
| 160 } | 158 } |
| 161 | 159 |
| 162 main() { | 160 main() { |
| 163 nativeTesting(); | |
| 164 setup(); | 161 setup(); |
| 165 | 162 |
| 166 testDistinctInterceptors(); | 163 testDistinctInterceptors(); |
| 167 testExternal(); | 164 testExternal(); |
| 168 testNative(); | 165 testNative(); |
| 169 } | 166 } |
| OLD | NEW |