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

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

Issue 2990083002: dart2js_native tests: Migrate 'native STRING' to JS-calls - part 2/2 (Closed)
Patch Set: remove defunct comments Created 3 years, 4 months 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 "native_testing.dart"; 5 import "native_testing.dart";
6 import 'dart:_foreign_helper' show JS_INTERCEPTOR_CONSTANT; 6 import 'dart:_foreign_helper' show JS_INTERCEPTOR_CONSTANT;
7 import 'dart:_interceptors' 7 import 'dart:_interceptors'
8 show 8 show
9 Interceptor, 9 Interceptor,
10 JavaScriptObject, 10 JavaScriptObject,
(...skipping 15 matching lines...) Expand all
26 26
27 makeA() native; 27 makeA() native;
28 makeB() native; 28 makeB() native;
29 makeC() native; 29 makeC() native;
30 makeD() native; 30 makeD() native;
31 makeE() native; 31 makeE() native;
32 makeP() native; 32 makeP() native;
33 makeQ() native; 33 makeQ() native;
34 makeR() native; 34 makeR() native;
35 35
36 void setup() native r""" 36 void setup() {
37 makeA = function(){return {hello: 123};}; 37 JS('', r"""
38 (function(){
39 makeA = function(){return {hello: 123};};
38 40
39 function BB(){} 41 function BB(){}
40 makeB = function(){return new BB();}; 42 makeB = function(){return new BB();};
41 43
42 function CC(){} 44 function CC(){}
43 makeC = function(){ 45 makeC = function(){
44 var x = new CC(); 46 var x = new CC();
45 x.constructor = null; // Foils constructor lookup. 47 x.constructor = null; // Foils constructor lookup.
46 return x; 48 return x;
47 }; 49 };
48 50
49 function DD(){} 51 function DD(){}
50 makeD = function(){ 52 makeD = function(){
51 var x = new DD(); 53 var x = new DD();
52 x.constructor = {name: 'DDxxx'}; // Foils constructor lookup. 54 x.constructor = {name: 'DDxxx'}; // Foils constructor lookup.
53 return x; 55 return x;
54 }; 56 };
55 57
56 function EE(){} 58 function EE(){}
57 makeE = function(){ 59 makeE = function(){
58 var x = new EE(); 60 var x = new EE();
59 x.constructor = function Liar(){}; // Looks like a legitimate constructor. 61 x.constructor = function Liar(){}; // Looks like a legitimate constructor.
60 return x; 62 return x;
61 }; 63 };
62 64
63 function PPPP(){} 65 function PPPP(){}
64 makeP = function(){return new PPPP();}; 66 makeP = function(){return new PPPP();};
65 67
66 function QQQQ(){} 68 function QQQQ(){}
67 makeQ = function(){return new QQQQ();}; 69 makeQ = function(){return new QQQQ();};
68 70
69 function RRRR(){} 71 function RRRR(){}
70 makeR = function(){return new RRRR();}; 72 makeR = function(){return new RRRR();};
71 73
72 self.nativeConstructor(PPPP); 74 self.nativeConstructor(PPPP);
73 self.nativeConstructor(QQQQ); 75 self.nativeConstructor(QQQQ);
74 self.nativeConstructor(RRRR); 76 self.nativeConstructor(RRRR);
75 """; 77 })()""");
78 }
76 79
77 expectTypeName(expectedName, s) { 80 expectTypeName(expectedName, s) {
78 var m = new RegExp(r"Instance of '(.*)'").firstMatch(s); 81 var m = new RegExp(r"Instance of '(.*)'").firstMatch(s);
79 Expect.isNotNull(m); 82 Expect.isNotNull(m);
80 var name = m.group(1); 83 var name = m.group(1);
81 Expect.isTrue(expectedName == name || name.length <= 3, 84 Expect.isTrue(expectedName == name || name.length <= 3,
82 "Is '$expectedName' or minified: '$name'"); 85 "Is '$expectedName' or minified: '$name'");
83 } 86 }
84 87
85 final plainJsString = 88 final plainJsString =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 163 }
161 164
162 main() { 165 main() {
163 nativeTesting(); 166 nativeTesting();
164 setup(); 167 setup();
165 168
166 testDistinctInterceptors(); 169 testDistinctInterceptors();
167 testExternal(); 170 testExternal();
168 testNative(); 171 testNative();
169 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698