Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: tests/compiler/dart2js_native/error_safeToString_test.dart

Issue 2379173002: Add native_testing library to mock @Native classes (Closed)
Patch Set: xxx Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "package:expect/expect.dart"; 5 import "native_testing.dart";
6 import 'dart:_foreign_helper' show JS_INTERCEPTOR_CONSTANT, JS; 6 import 'dart:_foreign_helper' show JS_INTERCEPTOR_CONSTANT;
7 import 'dart:_js_helper' show Native, Creates;
8 import 'dart:_interceptors' 7 import 'dart:_interceptors'
9 show 8 show
10 Interceptor, 9 Interceptor,
11 JavaScriptObject, 10 JavaScriptObject,
12 PlainJavaScriptObject, 11 PlainJavaScriptObject,
13 UnknownJavaScriptObject; 12 UnknownJavaScriptObject;
14 13
15 // Test for safe formatting of JavaScript objects by Error.safeToString. 14 // Test for safe formatting of JavaScript objects by Error.safeToString.
16 15
17 @Native('PPPP') 16 @Native('PPPP')
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 62
64 function PPPP(){} 63 function PPPP(){}
65 makeP = function(){return new PPPP();}; 64 makeP = function(){return new PPPP();};
66 65
67 function QQQQ(){} 66 function QQQQ(){}
68 makeQ = function(){return new QQQQ();}; 67 makeQ = function(){return new QQQQ();};
69 68
70 function RRRR(){} 69 function RRRR(){}
71 makeR = function(){return new RRRR();}; 70 makeR = function(){return new RRRR();};
72 71
72 self.nativeConstructor(PPPP);
73 self.nativeConstructor(QQQQ);
74 self.nativeConstructor(RRRR);
73 """; 75 """;
74 76
75 expectTypeName(expectedName, s) { 77 expectTypeName(expectedName, s) {
76 var m = new RegExp(r"Instance of '(.*)'").firstMatch(s); 78 var m = new RegExp(r"Instance of '(.*)'").firstMatch(s);
77 Expect.isNotNull(m); 79 Expect.isNotNull(m);
78 var name = m.group(1); 80 var name = m.group(1);
79 Expect.isTrue(expectedName == name || name.length <= 3, 81 Expect.isTrue(expectedName == name || name.length <= 3,
80 "Is '$expectedName' or minified: '$name'"); 82 "Is '$expectedName' or minified: '$name'");
81 } 83 }
82 84
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 x.toString(); 153 x.toString();
152 Expect.notEquals(plainJsString, Error.safeToString(x)); 154 Expect.notEquals(plainJsString, Error.safeToString(x));
153 Expect.notEquals(unknownJsString, Error.safeToString(x)); 155 Expect.notEquals(unknownJsString, Error.safeToString(x));
154 Expect.notEquals(interceptorString, Error.safeToString(x)); 156 Expect.notEquals(interceptorString, Error.safeToString(x));
155 // And not the native class constructor. 157 // And not the native class constructor.
156 Expect.notEquals("Instance of 'RRRR'", Error.safeToString(x)); 158 Expect.notEquals("Instance of 'RRRR'", Error.safeToString(x));
157 expectTypeName('Rascal', Error.safeToString(x)); 159 expectTypeName('Rascal', Error.safeToString(x));
158 } 160 }
159 161
160 main() { 162 main() {
163 nativeTesting();
161 setup(); 164 setup();
162 165
163 testDistinctInterceptors(); 166 testDistinctInterceptors();
164 testExternal(); 167 testExternal();
165 testNative(); 168 testNative();
166 } 169 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/downcast_test.dart ('k') | tests/compiler/dart2js_native/event_loop_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698