OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "include/dart_tools_api.h" | 6 #include "include/dart_tools_api.h" |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 EXPECT_EQ(4, SimpleInvoke(lib, "main")); | 58 EXPECT_EQ(4, SimpleInvoke(lib, "main")); |
59 | 59 |
60 const char* kReloadScript = | 60 const char* kReloadScript = |
61 "var _unused;" | 61 "var _unused;" |
62 "main() {\n" | 62 "main() {\n" |
63 " return 10;\n" | 63 " return 10;\n" |
64 "}\n"; | 64 "}\n"; |
65 | 65 |
66 lib = TestCase::ReloadTestScript(kReloadScript); | 66 lib = TestCase::ReloadTestScript(kReloadScript); |
67 EXPECT_VALID(lib); | 67 EXPECT_VALID(lib); |
68 | |
69 EXPECT_EQ(10, SimpleInvoke(lib, "main")); | 68 EXPECT_EQ(10, SimpleInvoke(lib, "main")); |
70 } | 69 } |
71 | 70 |
72 | 71 |
73 TEST_CASE(IsolateReload_BadClass) { | 72 TEST_CASE(IsolateReload_BadClass) { |
74 const char* kScript = | 73 const char* kScript = |
75 "class Foo {\n" | 74 "class Foo {\n" |
76 " final a;\n" | 75 " final a;\n" |
77 " Foo(this.a);\n" | 76 " Foo(this.a);\n" |
78 "}\n" | 77 "}\n" |
79 "main() {\n" | 78 "main() {\n" |
80 " new Foo(5);\n" | 79 " new Foo(5);\n" |
81 " return 4;\n" | 80 " return 4;\n" |
82 "}\n"; | 81 "}\n"; |
83 | 82 |
84 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 83 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
85 EXPECT_VALID(lib); | 84 EXPECT_VALID(lib); |
86 | |
87 EXPECT_EQ(4, SimpleInvoke(lib, "main")); | 85 EXPECT_EQ(4, SimpleInvoke(lib, "main")); |
88 | 86 |
89 const char* kReloadScript = | 87 const char* kReloadScript = |
90 "var _unused;" | 88 "var _unused;" |
91 "class Foo {\n" | 89 "class Foo {\n" |
92 " final a kjsdf ksjdf ;\n" | 90 " final a kjsdf ksjdf ;\n" |
93 " Foo(this.a);\n" | 91 " Foo(this.a);\n" |
94 "}\n" | 92 "}\n" |
95 "main() {\n" | 93 "main() {\n" |
96 " new Foo(5);\n" | 94 " new Foo(5);\n" |
97 " return 10;\n" | 95 " return 10;\n" |
98 "}\n"; | 96 "}\n"; |
99 | 97 |
100 Dart_Handle result = TestCase::ReloadTestScript(kReloadScript); | 98 Dart_Handle result = TestCase::ReloadTestScript(kReloadScript); |
101 EXPECT_ERROR(result, "unexpected token"); | 99 EXPECT_ERROR(result, "unexpected token"); |
102 | |
103 EXPECT_EQ(4, SimpleInvoke(lib, "main")); | 100 EXPECT_EQ(4, SimpleInvoke(lib, "main")); |
104 } | 101 } |
105 | 102 |
106 | 103 |
107 TEST_CASE(IsolateReload_StaticValuePreserved) { | 104 TEST_CASE(IsolateReload_StaticValuePreserved) { |
108 const char* kScript = | 105 const char* kScript = |
109 "init() => 'old value';\n" | 106 "init() => 'old value';\n" |
110 "var value = init();\n" | 107 "var value = init();\n" |
111 "main() {\n" | 108 "main() {\n" |
112 " return 'init()=${init()},value=${value}';\n" | 109 " return 'init()=${init()},value=${value}';\n" |
113 "}\n"; | 110 "}\n"; |
114 | 111 |
115 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 112 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
116 EXPECT_VALID(lib); | 113 EXPECT_VALID(lib); |
117 | |
118 EXPECT_STREQ("init()=old value,value=old value", | 114 EXPECT_STREQ("init()=old value,value=old value", |
119 SimpleInvokeStr(lib, "main")); | 115 SimpleInvokeStr(lib, "main")); |
120 | 116 |
121 const char* kReloadScript = | 117 const char* kReloadScript = |
122 "var _unused;" | 118 "var _unused;" |
123 "init() => 'new value';\n" | 119 "init() => 'new value';\n" |
124 "var value = init();\n" | 120 "var value = init();\n" |
125 "main() {\n" | 121 "main() {\n" |
126 " return 'init()=${init()},value=${value}';\n" | 122 " return 'init()=${init()},value=${value}';\n" |
127 "}\n"; | 123 "}\n"; |
128 | 124 |
129 lib = TestCase::ReloadTestScript(kReloadScript); | 125 lib = TestCase::ReloadTestScript(kReloadScript); |
130 EXPECT_VALID(lib); | 126 EXPECT_VALID(lib); |
131 | |
132 EXPECT_STREQ("init()=new value,value=old value", | 127 EXPECT_STREQ("init()=new value,value=old value", |
133 SimpleInvokeStr(lib, "main")); | 128 SimpleInvokeStr(lib, "main")); |
134 } | 129 } |
135 | 130 |
136 | 131 |
137 TEST_CASE(IsolateReload_SavedClosure) { | 132 TEST_CASE(IsolateReload_SavedClosure) { |
138 // Create a closure in main which only exists in the original source. | 133 // Create a closure in main which only exists in the original source. |
139 const char* kScript = | 134 const char* kScript = |
140 "magic() {\n" | 135 "magic() {\n" |
141 " var x = 'ante';\n" | 136 " var x = 'ante';\n" |
142 " return x + 'diluvian';\n" | 137 " return x + 'diluvian';\n" |
143 "}\n" | 138 "}\n" |
144 "var closure;\n" | 139 "var closure;\n" |
145 "main() {\n" | 140 "main() {\n" |
146 " closure = () { return magic().toString() + '!'; };\n" | 141 " closure = () { return magic().toString() + '!'; };\n" |
147 " return closure();\n" | 142 " return closure();\n" |
148 "}\n"; | 143 "}\n"; |
149 | 144 |
150 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 145 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
151 EXPECT_VALID(lib); | 146 EXPECT_VALID(lib); |
152 | |
153 EXPECT_STREQ("antediluvian!", SimpleInvokeStr(lib, "main")); | 147 EXPECT_STREQ("antediluvian!", SimpleInvokeStr(lib, "main")); |
154 | 148 |
155 // Remove the original closure from the source code. The closure is | 149 // Remove the original closure from the source code. The closure is |
156 // able to be recompiled because its source is preserved in a | 150 // able to be recompiled because its source is preserved in a |
157 // special patch class. | 151 // special patch class. |
158 const char* kReloadScript = | 152 const char* kReloadScript = |
159 "magic() {\n" | 153 "magic() {\n" |
160 " return 'postapocalyptic';\n" | 154 " return 'postapocalyptic';\n" |
161 "}\n" | 155 "}\n" |
162 "var closure;\n" | 156 "var closure;\n" |
163 "main() {\n" | 157 "main() {\n" |
164 " return closure();\n" | 158 " return closure();\n" |
165 "}\n"; | 159 "}\n"; |
166 | 160 |
167 lib = TestCase::ReloadTestScript(kReloadScript); | 161 lib = TestCase::ReloadTestScript(kReloadScript); |
168 EXPECT_VALID(lib); | 162 EXPECT_VALID(lib); |
169 | |
170 EXPECT_STREQ("postapocalyptic!", SimpleInvokeStr(lib, "main")); | 163 EXPECT_STREQ("postapocalyptic!", SimpleInvokeStr(lib, "main")); |
171 } | 164 } |
172 | 165 |
173 | 166 |
174 TEST_CASE(IsolateReload_TopLevelFieldAdded) { | 167 TEST_CASE(IsolateReload_TopLevelFieldAdded) { |
175 const char* kScript = | 168 const char* kScript = |
176 "var value1 = 10;\n" | 169 "var value1 = 10;\n" |
177 "main() {\n" | 170 "main() {\n" |
178 " return 'value1=${value1}';\n" | 171 " return 'value1=${value1}';\n" |
179 "}\n"; | 172 "}\n"; |
180 | 173 |
181 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 174 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
182 EXPECT_VALID(lib); | 175 EXPECT_VALID(lib); |
183 | |
184 EXPECT_STREQ("value1=10", SimpleInvokeStr(lib, "main")); | 176 EXPECT_STREQ("value1=10", SimpleInvokeStr(lib, "main")); |
185 | 177 |
186 const char* kReloadScript = | 178 const char* kReloadScript = |
187 "var value1 = 10;\n" | 179 "var value1 = 10;\n" |
188 "var value2 = 20;\n" | 180 "var value2 = 20;\n" |
189 "main() {\n" | 181 "main() {\n" |
190 " return 'value1=${value1},value2=${value2}';\n" | 182 " return 'value1=${value1},value2=${value2}';\n" |
191 "}\n"; | 183 "}\n"; |
192 | 184 |
193 lib = TestCase::ReloadTestScript(kReloadScript); | 185 lib = TestCase::ReloadTestScript(kReloadScript); |
194 EXPECT_VALID(lib); | 186 EXPECT_VALID(lib); |
195 | 187 EXPECT_STREQ("value1=10,value2=20", SimpleInvokeStr(lib, "main")); |
196 EXPECT_STREQ("value1=10,value2=20", | |
197 SimpleInvokeStr(lib, "main")); | |
198 } | 188 } |
199 | 189 |
200 | 190 |
201 TEST_CASE(IsolateReload_ClassFieldAdded) { | 191 TEST_CASE(IsolateReload_ClassFieldAdded) { |
202 const char* kScript = | 192 const char* kScript = |
203 "class Foo {\n" | 193 "class Foo {\n" |
204 " var x;\n" | 194 " var x;\n" |
205 "}\n" | 195 "}\n" |
206 "main() {\n" | 196 "main() {\n" |
207 " new Foo();\n" | 197 " new Foo();\n" |
208 " return 44;\n" | 198 " return 44;\n" |
209 "}\n"; | 199 "}\n"; |
210 | 200 |
211 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 201 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
212 EXPECT_VALID(lib); | 202 EXPECT_VALID(lib); |
213 | |
214 EXPECT_EQ(44, SimpleInvoke(lib, "main")); | 203 EXPECT_EQ(44, SimpleInvoke(lib, "main")); |
215 | 204 |
216 const char* kReloadScript = | 205 const char* kReloadScript = |
217 "class Foo {\n" | 206 "class Foo {\n" |
218 " var x;\n" | 207 " var x;\n" |
219 " var y;\n" | 208 " var y;\n" |
220 "}\n" | 209 "}\n" |
221 "main() {\n" | 210 "main() {\n" |
222 " new Foo();\n" | 211 " new Foo();\n" |
223 " return 44;\n" | 212 " return 44;\n" |
224 "}\n"; | 213 "}\n"; |
225 | 214 |
226 lib = TestCase::ReloadTestScript(kReloadScript); | 215 lib = TestCase::ReloadTestScript(kReloadScript); |
227 EXPECT_ERROR(lib, "Number of instance fields changed"); | 216 EXPECT_VALID(lib); |
| 217 EXPECT_EQ(44, SimpleInvoke(lib, "main")); |
228 } | 218 } |
229 | 219 |
230 | 220 |
231 TEST_CASE(IsolateReload_ClassFieldAdded2) { | 221 TEST_CASE(IsolateReload_ClassFieldAdded2) { |
232 const char* kScript = | 222 const char* kScript = |
233 "class Foo {\n" | 223 "class Foo {\n" |
234 " var x;\n" | 224 " var x;\n" |
235 " var y;\n" | 225 " var y;\n" |
236 "}\n" | 226 "}\n" |
237 "main() {\n" | 227 "main() {\n" |
238 " new Foo();\n" | 228 " new Foo();\n" |
239 " return 44;\n" | 229 " return 44;\n" |
240 "}\n"; | 230 "}\n"; |
241 | 231 |
242 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 232 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
243 EXPECT_VALID(lib); | 233 EXPECT_VALID(lib); |
244 | |
245 EXPECT_EQ(44, SimpleInvoke(lib, "main")); | 234 EXPECT_EQ(44, SimpleInvoke(lib, "main")); |
246 | 235 |
247 const char* kReloadScript = | 236 const char* kReloadScript = |
248 "class Foo {\n" | 237 "class Foo {\n" |
249 " var x;\n" | 238 " var x;\n" |
250 " var y;\n" | 239 " var y;\n" |
251 " var z;\n" | 240 " var z;\n" |
252 "}\n" | 241 "}\n" |
253 "main() {\n" | 242 "main() {\n" |
254 " new Foo();\n" | 243 " new Foo();\n" |
255 " return 44;\n" | 244 " return 44;\n" |
256 "}\n"; | 245 "}\n"; |
257 | 246 |
258 lib = TestCase::ReloadTestScript(kReloadScript); | 247 lib = TestCase::ReloadTestScript(kReloadScript); |
259 EXPECT_ERROR(lib, "Number of instance fields changed"); | 248 EXPECT_VALID(lib); |
| 249 EXPECT_EQ(44, SimpleInvoke(lib, "main")); |
260 } | 250 } |
261 | 251 |
262 | 252 |
263 TEST_CASE(IsolateReload_ClassFieldRemoved) { | 253 TEST_CASE(IsolateReload_ClassFieldRemoved) { |
264 const char* kScript = | 254 const char* kScript = |
265 "class Foo {\n" | 255 "class Foo {\n" |
266 " var x;\n" | 256 " var x;\n" |
267 " var y;\n" | 257 " var y;\n" |
268 "}\n" | 258 "}\n" |
269 "main() {\n" | 259 "main() {\n" |
270 " new Foo();\n" | 260 " new Foo();\n" |
271 " return 44;\n" | 261 " return 44;\n" |
272 "}\n"; | 262 "}\n"; |
273 | 263 |
274 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 264 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
275 EXPECT_VALID(lib); | 265 EXPECT_VALID(lib); |
276 | |
277 EXPECT_EQ(44, SimpleInvoke(lib, "main")); | 266 EXPECT_EQ(44, SimpleInvoke(lib, "main")); |
278 | 267 |
279 const char* kReloadScript = | 268 const char* kReloadScript = |
280 "class Foo {\n" | 269 "class Foo {\n" |
281 " var x;\n" | 270 " var x;\n" |
282 "}\n" | 271 "}\n" |
283 "main() {\n" | 272 "main() {\n" |
284 " new Foo();\n" | 273 " new Foo();\n" |
285 " return 44;\n" | 274 " return 44;\n" |
286 "}\n"; | 275 "}\n"; |
287 | 276 |
288 lib = TestCase::ReloadTestScript(kReloadScript); | 277 lib = TestCase::ReloadTestScript(kReloadScript); |
289 EXPECT_ERROR(lib, "Number of instance fields changed"); | 278 EXPECT_VALID(lib); |
| 279 EXPECT_EQ(44, SimpleInvoke(lib, "main")); |
290 } | 280 } |
291 | 281 |
292 | 282 |
293 TEST_CASE(IsolateReload_ClassAdded) { | 283 TEST_CASE(IsolateReload_ClassAdded) { |
294 const char* kScript = | 284 const char* kScript = |
295 "main() {\n" | 285 "main() {\n" |
296 " return 'hello';\n" | 286 " return 'hello';\n" |
297 "}\n"; | 287 "}\n"; |
298 | 288 |
299 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 289 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
300 EXPECT_VALID(lib); | 290 EXPECT_VALID(lib); |
301 | |
302 EXPECT_STREQ("hello", SimpleInvokeStr(lib, "main")); | 291 EXPECT_STREQ("hello", SimpleInvokeStr(lib, "main")); |
303 | 292 |
304 const char* kReloadScript = | 293 const char* kReloadScript = |
305 "var _unused;" | 294 "var _unused;" |
306 "class A {\n" | 295 "class A {\n" |
307 " toString() => 'hello from A';\n" | 296 " toString() => 'hello from A';\n" |
308 "}\n" | 297 "}\n" |
309 "main() {\n" | 298 "main() {\n" |
310 " return new A().toString();\n" | 299 " return new A().toString();\n" |
311 "}\n"; | 300 "}\n"; |
312 | 301 |
313 lib = TestCase::ReloadTestScript(kReloadScript); | 302 lib = TestCase::ReloadTestScript(kReloadScript); |
314 EXPECT_VALID(lib); | 303 EXPECT_VALID(lib); |
315 | |
316 EXPECT_STREQ("hello from A", SimpleInvokeStr(lib, "main")); | 304 EXPECT_STREQ("hello from A", SimpleInvokeStr(lib, "main")); |
317 } | 305 } |
318 | 306 |
319 | 307 |
320 TEST_CASE(IsolateReload_LibraryImportAdded) { | 308 TEST_CASE(IsolateReload_LibraryImportAdded) { |
321 const char* kScript = | 309 const char* kScript = |
322 "main() {\n" | 310 "main() {\n" |
323 " return max(3, 4);\n" | 311 " return max(3, 4);\n" |
324 "}\n"; | 312 "}\n"; |
325 | 313 |
326 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 314 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
327 EXPECT_VALID(lib); | 315 EXPECT_VALID(lib); |
328 | |
329 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "max");; | 316 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "max");; |
330 | 317 |
331 const char* kReloadScript = | 318 const char* kReloadScript = |
332 "import 'dart:math';\n" | 319 "import 'dart:math';\n" |
333 "main() {\n" | 320 "main() {\n" |
334 " return max(3, 4);\n" | 321 " return max(3, 4);\n" |
335 "}\n"; | 322 "}\n"; |
336 | 323 |
337 lib = TestCase::ReloadTestScript(kReloadScript); | 324 lib = TestCase::ReloadTestScript(kReloadScript); |
338 EXPECT_VALID(lib); | 325 EXPECT_VALID(lib); |
339 | |
340 EXPECT_EQ(4, SimpleInvoke(lib, "main")); | 326 EXPECT_EQ(4, SimpleInvoke(lib, "main")); |
341 } | 327 } |
342 | 328 |
343 | 329 |
344 TEST_CASE(IsolateReload_LibraryImportRemoved) { | 330 TEST_CASE(IsolateReload_LibraryImportRemoved) { |
345 const char* kScript = | 331 const char* kScript = |
346 "import 'dart:math';\n" | 332 "import 'dart:math';\n" |
347 "main() {\n" | 333 "main() {\n" |
348 " return max(3, 4);\n" | 334 " return max(3, 4);\n" |
349 "}\n"; | 335 "}\n"; |
350 | 336 |
351 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 337 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
352 EXPECT_VALID(lib); | 338 EXPECT_VALID(lib); |
353 | |
354 EXPECT_EQ(4, SimpleInvoke(lib, "main")); | 339 EXPECT_EQ(4, SimpleInvoke(lib, "main")); |
355 | 340 |
356 const char* kReloadScript = | 341 const char* kReloadScript = |
357 "main() {\n" | 342 "main() {\n" |
358 " return max(3, 4);\n" | 343 " return max(3, 4);\n" |
359 "}\n"; | 344 "}\n"; |
360 | 345 |
361 lib = TestCase::ReloadTestScript(kReloadScript); | 346 lib = TestCase::ReloadTestScript(kReloadScript); |
362 EXPECT_VALID(lib); | 347 EXPECT_VALID(lib); |
363 | 348 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 " int field = 20;\n" | 398 " int field = 20;\n" |
414 "}\n" | 399 "}\n" |
415 "var savedA = new A();\n" | 400 "var savedA = new A();\n" |
416 "main() {\n" | 401 "main() {\n" |
417 " var newA = new A();\n" | 402 " var newA = new A();\n" |
418 " return 'saved:${savedA.field} new:${newA.field}';\n" | 403 " return 'saved:${savedA.field} new:${newA.field}';\n" |
419 "}\n"; | 404 "}\n"; |
420 | 405 |
421 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 406 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
422 EXPECT_VALID(lib); | 407 EXPECT_VALID(lib); |
423 | |
424 EXPECT_STREQ("saved:20 new:20", SimpleInvokeStr(lib, "main")); | 408 EXPECT_STREQ("saved:20 new:20", SimpleInvokeStr(lib, "main")); |
425 | 409 |
426 const char* kReloadScript = | 410 const char* kReloadScript = |
427 "class A {\n" | 411 "class A {\n" |
428 " int field = 10;\n" | 412 " int field = 10;\n" |
429 "}\n" | 413 "}\n" |
430 "var savedA = new A();\n" | 414 "var savedA = new A();\n" |
431 "main() {\n" | 415 "main() {\n" |
432 " var newA = new A();\n" | 416 " var newA = new A();\n" |
433 " return 'saved:${savedA.field} new:${newA.field}';\n" | 417 " return 'saved:${savedA.field} new:${newA.field}';\n" |
434 "}\n"; | 418 "}\n"; |
435 | 419 |
436 lib = TestCase::ReloadTestScript(kReloadScript); | 420 lib = TestCase::ReloadTestScript(kReloadScript); |
437 EXPECT_VALID(lib); | 421 EXPECT_VALID(lib); |
438 | |
439 EXPECT_STREQ("saved:20 new:10", SimpleInvokeStr(lib, "main")); | 422 EXPECT_STREQ("saved:20 new:10", SimpleInvokeStr(lib, "main")); |
440 } | 423 } |
441 | 424 |
442 | 425 |
443 TEST_CASE(IsolateReload_ConstructorChanged) { | 426 TEST_CASE(IsolateReload_ConstructorChanged) { |
444 const char* kScript = | 427 const char* kScript = |
445 "class A {\n" | 428 "class A {\n" |
446 " int field;\n" | 429 " int field;\n" |
447 " A() { field = 20; }\n" | 430 " A() { field = 20; }\n" |
448 "}\n" | 431 "}\n" |
449 "var savedA = new A();\n" | 432 "var savedA = new A();\n" |
450 "main() {\n" | 433 "main() {\n" |
451 " var newA = new A();\n" | 434 " var newA = new A();\n" |
452 " return 'saved:${savedA.field} new:${newA.field}';\n" | 435 " return 'saved:${savedA.field} new:${newA.field}';\n" |
453 "}\n"; | 436 "}\n"; |
454 | 437 |
455 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 438 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
456 EXPECT_VALID(lib); | 439 EXPECT_VALID(lib); |
457 | |
458 EXPECT_STREQ("saved:20 new:20", SimpleInvokeStr(lib, "main")); | 440 EXPECT_STREQ("saved:20 new:20", SimpleInvokeStr(lib, "main")); |
459 | 441 |
460 const char* kReloadScript = | 442 const char* kReloadScript = |
461 "var _unused;" | 443 "var _unused;" |
462 "class A {\n" | 444 "class A {\n" |
463 " int field;\n" | 445 " int field;\n" |
464 " A() { field = 10; }\n" | 446 " A() { field = 10; }\n" |
465 "}\n" | 447 "}\n" |
466 "var savedA = new A();\n" | 448 "var savedA = new A();\n" |
467 "main() {\n" | 449 "main() {\n" |
468 " var newA = new A();\n" | 450 " var newA = new A();\n" |
469 " return 'saved:${savedA.field} new:${newA.field}';\n" | 451 " return 'saved:${savedA.field} new:${newA.field}';\n" |
470 "}\n"; | 452 "}\n"; |
471 | 453 |
472 lib = TestCase::ReloadTestScript(kReloadScript); | 454 lib = TestCase::ReloadTestScript(kReloadScript); |
473 EXPECT_VALID(lib); | 455 EXPECT_VALID(lib); |
474 | |
475 EXPECT_STREQ("saved:20 new:10", SimpleInvokeStr(lib, "main")); | 456 EXPECT_STREQ("saved:20 new:10", SimpleInvokeStr(lib, "main")); |
476 } | 457 } |
477 | 458 |
478 | 459 |
479 TEST_CASE(IsolateReload_SuperClassChanged) { | 460 TEST_CASE(IsolateReload_SuperClassChanged) { |
480 const char* kScript = | 461 const char* kScript = |
481 "class A {\n" | 462 "class A {\n" |
482 "}\n" | 463 "}\n" |
483 "class B extends A {\n" | 464 "class B extends A {\n" |
484 "}\n" | 465 "}\n" |
485 "var list = [ new A(), new B() ];\n" | 466 "var list = [ new A(), new B() ];\n" |
486 "main() {\n" | 467 "main() {\n" |
487 " return (list.map((x) => '${x is A}/${x is B}')).toString();\n" | 468 " return (list.map((x) => '${x is A}/${x is B}')).toString();\n" |
488 "}\n"; | 469 "}\n"; |
489 | 470 |
490 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 471 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
491 EXPECT_VALID(lib); | 472 EXPECT_VALID(lib); |
492 | |
493 EXPECT_STREQ("(true/false, true/true)", SimpleInvokeStr(lib, "main")); | 473 EXPECT_STREQ("(true/false, true/true)", SimpleInvokeStr(lib, "main")); |
494 | 474 |
495 const char* kReloadScript = | 475 const char* kReloadScript = |
496 "var _unused;" | 476 "var _unused;" |
497 "class B{\n" | 477 "class B{\n" |
498 "}\n" | 478 "}\n" |
499 "class A extends B {\n" | 479 "class A extends B {\n" |
500 "}\n" | 480 "}\n" |
501 "var list = [ new A(), new B() ];\n" | 481 "var list = [ new A(), new B() ];\n" |
502 "main() {\n" | 482 "main() {\n" |
503 " return (list.map((x) => '${x is A}/${x is B}')).toString();\n" | 483 " return (list.map((x) => '${x is A}/${x is B}')).toString();\n" |
504 "}\n"; | 484 "}\n"; |
505 | 485 |
506 lib = TestCase::ReloadTestScript(kReloadScript); | 486 lib = TestCase::ReloadTestScript(kReloadScript); |
507 EXPECT_VALID(lib); | 487 EXPECT_VALID(lib); |
508 | |
509 EXPECT_STREQ("(true/true, false/true)", SimpleInvokeStr(lib, "main")); | 488 EXPECT_STREQ("(true/true, false/true)", SimpleInvokeStr(lib, "main")); |
510 } | 489 } |
511 | 490 |
512 | 491 |
513 TEST_CASE(IsolateReload_Generics) { | 492 TEST_CASE(IsolateReload_Generics) { |
514 // Reload a program with generics without changing the source. We | 493 // Reload a program with generics without changing the source. We |
515 // do this to produce duplication TypeArguments and make sure that | 494 // do this to produce duplication TypeArguments and make sure that |
516 // the system doesn't die. | 495 // the system doesn't die. |
517 const char* kScript = | 496 const char* kScript = |
518 "class A {\n" | 497 "class A {\n" |
519 "}\n" | 498 "}\n" |
520 "class B<T extends A> {\n" | 499 "class B<T extends A> {\n" |
521 "}\n" | 500 "}\n" |
522 "main() {\n" | 501 "main() {\n" |
523 " return new B<A>().toString();\n" | 502 " return new B<A>().toString();\n" |
524 "}\n"; | 503 "}\n"; |
525 | 504 |
526 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 505 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
527 EXPECT_VALID(lib); | 506 EXPECT_VALID(lib); |
528 | |
529 EXPECT_STREQ("Instance of 'B<A>'", SimpleInvokeStr(lib, "main")); | 507 EXPECT_STREQ("Instance of 'B<A>'", SimpleInvokeStr(lib, "main")); |
530 | 508 |
531 const char* kReloadScript = | 509 const char* kReloadScript = |
532 "class A {\n" | 510 "class A {\n" |
533 "}\n" | 511 "}\n" |
534 "class B<T extends A> {\n" | 512 "class B<T extends A> {\n" |
535 "}\n" | 513 "}\n" |
536 "main() {\n" | 514 "main() {\n" |
537 " return new B<A>().toString();\n" | 515 " return new B<A>().toString();\n" |
538 "}\n"; | 516 "}\n"; |
539 | 517 |
540 lib = TestCase::ReloadTestScript(kReloadScript); | 518 lib = TestCase::ReloadTestScript(kReloadScript); |
541 EXPECT_VALID(lib); | 519 EXPECT_VALID(lib); |
542 | |
543 EXPECT_STREQ("Instance of 'B<A>'", SimpleInvokeStr(lib, "main")); | 520 EXPECT_STREQ("Instance of 'B<A>'", SimpleInvokeStr(lib, "main")); |
544 } | 521 } |
545 | 522 |
546 | 523 |
547 TEST_CASE(IsolateReload_TypeIdentity) { | 524 TEST_CASE(IsolateReload_TypeIdentity) { |
548 const char* kScript = | 525 const char* kScript = |
549 "import 'test:isolate_reload_helper';\n" | 526 "import 'test:isolate_reload_helper';\n" |
550 "class T { }\n" | 527 "class T { }\n" |
551 "getType() => T;\n" | 528 "getType() => T;\n" |
552 "main() {\n" | 529 "main() {\n" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 "}\n" | 627 "}\n" |
651 "class B extends Object with Mixin1 {\n" | 628 "class B extends Object with Mixin1 {\n" |
652 "}\n" | 629 "}\n" |
653 "var saved = new B();\n" | 630 "var saved = new B();\n" |
654 "main() {\n" | 631 "main() {\n" |
655 " return 'saved:field=${saved.field},func=${saved.func()}';\n" | 632 " return 'saved:field=${saved.field},func=${saved.func()}';\n" |
656 "}\n"; | 633 "}\n"; |
657 | 634 |
658 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 635 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
659 EXPECT_VALID(lib); | 636 EXPECT_VALID(lib); |
660 | |
661 EXPECT_STREQ("saved:field=mixin1,func=mixin1", | 637 EXPECT_STREQ("saved:field=mixin1,func=mixin1", |
662 SimpleInvokeStr(lib, "main")); | 638 SimpleInvokeStr(lib, "main")); |
663 | 639 |
664 const char* kReloadScript = | 640 const char* kReloadScript = |
665 "class Mixin2 {\n" | 641 "class Mixin2 {\n" |
666 " var field = 'mixin2';\n" | 642 " var field = 'mixin2';\n" |
667 " func() => 'mixin2';\n" | 643 " func() => 'mixin2';\n" |
668 "}\n" | 644 "}\n" |
669 "class B extends Object with Mixin2 {\n" | 645 "class B extends Object with Mixin2 {\n" |
670 "}\n" | 646 "}\n" |
(...skipping 29 matching lines...) Expand all Loading... |
700 "}\n" | 676 "}\n" |
701 "var list = [ new A('a'), new B('b'), new C('c') ];\n" | 677 "var list = [ new A('a'), new B('b'), new C('c') ];\n" |
702 "main() {\n" | 678 "main() {\n" |
703 " return (list.map((x) {\n" | 679 " return (list.map((x) {\n" |
704 " return '${x.name} is A(${x is A})/ B(${x is B})/ C(${x is C})';\n" | 680 " return '${x.name} is A(${x is A})/ B(${x is B})/ C(${x is C})';\n" |
705 " })).toString();\n" | 681 " })).toString();\n" |
706 "}\n"; | 682 "}\n"; |
707 | 683 |
708 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 684 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
709 EXPECT_VALID(lib); | 685 EXPECT_VALID(lib); |
710 | |
711 EXPECT_STREQ("(a is A(true)/ B(false)/ C(false)," | 686 EXPECT_STREQ("(a is A(true)/ B(false)/ C(false)," |
712 " b is A(true)/ B(true)/ C(false)," | 687 " b is A(true)/ B(true)/ C(false)," |
713 " c is A(true)/ B(true)/ C(true))", | 688 " c is A(true)/ B(true)/ C(true))", |
714 SimpleInvokeStr(lib, "main")); | 689 SimpleInvokeStr(lib, "main")); |
715 | 690 |
716 const char* kReloadScript = | 691 const char* kReloadScript = |
717 "class C {\n" | 692 "class C {\n" |
718 " String name;\n" | 693 " String name;\n" |
719 " C(this.name);\n" | 694 " C(this.name);\n" |
720 "}\n" | 695 "}\n" |
721 "class X extends C {\n" | 696 "class X extends C {\n" |
722 " X(name) : super(name);\n" | 697 " X(name) : super(name);\n" |
723 "}\n" | 698 "}\n" |
724 "class A extends X {\n" | 699 "class A extends X {\n" |
725 " A(name) : super(name);\n" | 700 " A(name) : super(name);\n" |
726 "}\n" | 701 "}\n" |
727 "var list;\n" | 702 "var list;\n" |
728 "main() {\n" | 703 "main() {\n" |
729 " list.add(new X('x'));\n" | 704 " list.add(new X('x'));\n" |
730 " return (list.map((x) {\n" | 705 " return (list.map((x) {\n" |
731 " return '${x.name} is A(${x is A})/ C(${x is C})/ X(${x is X})';\n" | 706 " return '${x.name} is A(${x is A})/ C(${x is C})/ X(${x is X})';\n" |
732 " })).toString();\n" | 707 " })).toString();\n" |
733 "}\n"; | 708 "}\n"; |
734 | 709 |
735 lib = TestCase::ReloadTestScript(kReloadScript); | 710 lib = TestCase::ReloadTestScript(kReloadScript); |
736 EXPECT_VALID(lib); | 711 EXPECT_VALID(lib); |
737 | |
738 EXPECT_STREQ("(a is A(true)/ C(true)/ X(true)," | 712 EXPECT_STREQ("(a is A(true)/ C(true)/ X(true)," |
739 " b is A(true)/ C(true)/ X(true)," // still extends A... | 713 " b is A(true)/ C(true)/ X(true)," // still extends A... |
740 " c is A(false)/ C(true)/ X(false)," | 714 " c is A(false)/ C(true)/ X(false)," |
741 " x is A(false)/ C(true)/ X(true))", | 715 " x is A(false)/ C(true)/ X(true))", |
742 SimpleInvokeStr(lib, "main")); | 716 SimpleInvokeStr(lib, "main")); |
743 | 717 |
744 // Revive the class B and make sure all allocated instances take | 718 // Revive the class B and make sure all allocated instances take |
745 // their place in the inheritance hierarchy. | 719 // their place in the inheritance hierarchy. |
746 const char* kReloadScript2 = | 720 const char* kReloadScript2 = |
747 "class X {\n" | 721 "class X {\n" |
(...skipping 12 matching lines...) Expand all Loading... |
760 "var list;\n" | 734 "var list;\n" |
761 "main() {\n" | 735 "main() {\n" |
762 " return (list.map((x) {\n" | 736 " return (list.map((x) {\n" |
763 " return '${x.name} is '\n" | 737 " return '${x.name} is '\n" |
764 " 'A(${x is A})/ B(${x is B})/ C(${x is C})/ X(${x is X})';\n" | 738 " 'A(${x is A})/ B(${x is B})/ C(${x is C})/ X(${x is X})';\n" |
765 " })).toString();\n" | 739 " })).toString();\n" |
766 "}\n"; | 740 "}\n"; |
767 | 741 |
768 lib = TestCase::ReloadTestScript(kReloadScript2); | 742 lib = TestCase::ReloadTestScript(kReloadScript2); |
769 EXPECT_VALID(lib); | 743 EXPECT_VALID(lib); |
770 | |
771 EXPECT_STREQ("(a is A(true)/ B(false)/ C(false)/ X(true)," | 744 EXPECT_STREQ("(a is A(true)/ B(false)/ C(false)/ X(true)," |
772 " b is A(false)/ B(true)/ C(false)/ X(true)," | 745 " b is A(false)/ B(true)/ C(false)/ X(true)," |
773 " c is A(true)/ B(false)/ C(true)/ X(true)," | 746 " c is A(true)/ B(false)/ C(true)/ X(true)," |
774 " x is A(false)/ B(false)/ C(false)/ X(true))", | 747 " x is A(false)/ B(false)/ C(false)/ X(true))", |
775 SimpleInvokeStr(lib, "main")); | 748 SimpleInvokeStr(lib, "main")); |
776 } | 749 } |
777 | 750 |
778 | 751 |
779 TEST_CASE(IsolateReload_LiveStack) { | 752 TEST_CASE(IsolateReload_LiveStack) { |
780 const char* kScript = | 753 const char* kScript = |
(...skipping 18 matching lines...) Expand all Loading... |
799 "main() {\n" | 772 "main() {\n" |
800 " return bar();\n" | 773 " return bar();\n" |
801 "}\n"; | 774 "}\n"; |
802 | 775 |
803 TestCase::SetReloadTestScript(kReloadScript); | 776 TestCase::SetReloadTestScript(kReloadScript); |
804 | 777 |
805 EXPECT_EQ(107, SimpleInvoke(lib, "main")); | 778 EXPECT_EQ(107, SimpleInvoke(lib, "main")); |
806 | 779 |
807 lib = TestCase::GetReloadErrorOrRootLibrary(); | 780 lib = TestCase::GetReloadErrorOrRootLibrary(); |
808 EXPECT_VALID(lib); | 781 EXPECT_VALID(lib); |
809 | |
810 EXPECT_EQ(105, SimpleInvoke(lib, "main")); | 782 EXPECT_EQ(105, SimpleInvoke(lib, "main")); |
811 } | 783 } |
812 | 784 |
813 | 785 |
814 TEST_CASE(IsolateReload_LibraryLookup) { | 786 TEST_CASE(IsolateReload_LibraryLookup) { |
815 const char* kScript = | 787 const char* kScript = |
816 "main() {\n" | 788 "main() {\n" |
817 " return importedFunc();\n" | 789 " return importedFunc();\n" |
818 "}\n"; | 790 "}\n"; |
819 | 791 |
820 Dart_Handle result; | 792 Dart_Handle result; |
821 | 793 |
822 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 794 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
823 EXPECT_VALID(lib); | 795 EXPECT_VALID(lib); |
824 | |
825 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); | 796 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); |
826 | 797 |
827 // Fail to find 'test:importable_lib' in the isolate. | 798 // Fail to find 'test:importable_lib' in the isolate. |
828 result = Dart_LookupLibrary(NewString("test:importable_lib")); | 799 result = Dart_LookupLibrary(NewString("test:importable_lib")); |
829 EXPECT(Dart_IsError(result)); | 800 EXPECT(Dart_IsError(result)); |
830 | 801 |
831 const char* kReloadScript = | 802 const char* kReloadScript = |
832 "import 'test:importable_lib';\n" | 803 "import 'test:importable_lib';\n" |
833 "main() {\n" | 804 "main() {\n" |
834 " return importedFunc();\n" | 805 " return importedFunc();\n" |
835 "}\n"; | 806 "}\n"; |
836 | 807 |
837 // Reload and add 'test:importable_lib' to isolate. | 808 // Reload and add 'test:importable_lib' to isolate. |
838 lib = TestCase::ReloadTestScript(kReloadScript); | 809 lib = TestCase::ReloadTestScript(kReloadScript); |
839 EXPECT_VALID(lib); | 810 EXPECT_VALID(lib); |
840 | |
841 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); | 811 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); |
842 | 812 |
843 // Find 'test:importable_lib' in the isolate. | 813 // Find 'test:importable_lib' in the isolate. |
844 result = Dart_LookupLibrary(NewString("test:importable_lib")); | 814 result = Dart_LookupLibrary(NewString("test:importable_lib")); |
845 EXPECT(Dart_IsLibrary(result)); | 815 EXPECT(Dart_IsLibrary(result)); |
846 | 816 |
847 // Reload and remove 'dart:math' from isolate. | 817 // Reload and remove 'dart:math' from isolate. |
848 lib = TestCase::ReloadTestScript(kScript); | 818 lib = TestCase::ReloadTestScript(kScript); |
849 EXPECT_VALID(lib); | 819 EXPECT_VALID(lib); |
850 | 820 |
851 // Fail to find 'test:importable_lib' in the isolate. | 821 // Fail to find 'test:importable_lib' in the isolate. |
852 result = Dart_LookupLibrary(NewString("test:importable_lib")); | 822 result = Dart_LookupLibrary(NewString("test:importable_lib")); |
853 EXPECT(Dart_IsError(result)); | 823 EXPECT(Dart_IsError(result)); |
854 } | 824 } |
855 | 825 |
856 | 826 |
857 TEST_CASE(IsolateReload_LibraryHide) { | 827 TEST_CASE(IsolateReload_LibraryHide) { |
858 // Import 'test:importable_lib' with importedFunc hidden. Will result in an | 828 // Import 'test:importable_lib' with importedFunc hidden. Will result in an |
859 // error. | 829 // error. |
860 const char* kScript = | 830 const char* kScript = |
861 "import 'test:importable_lib' hide importedFunc;\n" | 831 "import 'test:importable_lib' hide importedFunc;\n" |
862 "main() {\n" | 832 "main() {\n" |
863 " return importedFunc();\n" | 833 " return importedFunc();\n" |
864 "}\n"; | 834 "}\n"; |
865 | 835 |
866 // Dart_Handle result; | 836 // Dart_Handle result; |
867 | 837 |
868 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 838 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
869 EXPECT_VALID(lib); | 839 EXPECT_VALID(lib); |
870 | |
871 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); | 840 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); |
872 | 841 |
873 // Import 'test:importable_lib'. | 842 // Import 'test:importable_lib'. |
874 const char* kReloadScript = | 843 const char* kReloadScript = |
875 "import 'test:importable_lib';\n" | 844 "import 'test:importable_lib';\n" |
876 "main() {\n" | 845 "main() {\n" |
877 " return importedFunc();\n" | 846 " return importedFunc();\n" |
878 "}\n"; | 847 "}\n"; |
879 | 848 |
880 lib = TestCase::ReloadTestScript(kReloadScript); | 849 lib = TestCase::ReloadTestScript(kReloadScript); |
881 EXPECT_VALID(lib); | 850 EXPECT_VALID(lib); |
882 | |
883 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); | 851 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); |
884 } | 852 } |
885 | 853 |
886 | 854 |
887 TEST_CASE(IsolateReload_LibraryShow) { | 855 TEST_CASE(IsolateReload_LibraryShow) { |
888 // Import 'test:importable_lib' with importedIntFunc visible. Will result in | 856 // Import 'test:importable_lib' with importedIntFunc visible. Will result in |
889 // an error when 'main' is invoked. | 857 // an error when 'main' is invoked. |
890 const char* kScript = | 858 const char* kScript = |
891 "import 'test:importable_lib' show importedIntFunc;\n" | 859 "import 'test:importable_lib' show importedIntFunc;\n" |
892 "main() {\n" | 860 "main() {\n" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 "import 'test:importable_lib' show ImportedMixin;\n" | 939 "import 'test:importable_lib' show ImportedMixin;\n" |
972 "class A extends Object with ImportedMixin {\n" | 940 "class A extends Object with ImportedMixin {\n" |
973 "}" | 941 "}" |
974 "var func;\n" | 942 "var func;\n" |
975 "main() {\n" | 943 "main() {\n" |
976 " return func();\n" | 944 " return func();\n" |
977 "}\n"; | 945 "}\n"; |
978 | 946 |
979 lib = TestCase::ReloadTestScript(kReloadScript); | 947 lib = TestCase::ReloadTestScript(kReloadScript); |
980 EXPECT_VALID(lib); | 948 EXPECT_VALID(lib); |
981 | |
982 EXPECT_STREQ("mixin", SimpleInvokeStr(lib, "main")); | 949 EXPECT_STREQ("mixin", SimpleInvokeStr(lib, "main")); |
983 } | 950 } |
984 | 951 |
985 | 952 |
986 TEST_CASE(IsolateReload_TopLevelParseError) { | 953 TEST_CASE(IsolateReload_TopLevelParseError) { |
987 const char* kScript = | 954 const char* kScript = |
988 "main() {\n" | 955 "main() {\n" |
989 " return 4;\n" | 956 " return 4;\n" |
990 "}\n"; | 957 "}\n"; |
991 | 958 |
992 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 959 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
993 EXPECT_VALID(lib); | 960 EXPECT_VALID(lib); |
994 | |
995 EXPECT_EQ(4, SimpleInvoke(lib, "main")); | 961 EXPECT_EQ(4, SimpleInvoke(lib, "main")); |
996 | 962 |
997 const char* kReloadScript = | 963 const char* kReloadScript = |
998 "kjsadkfjaksldfjklsadf;\n" | 964 "kjsadkfjaksldfjklsadf;\n" |
999 "main() {\n" | 965 "main() {\n" |
1000 " return 4;\n" | 966 " return 4;\n" |
1001 "}\n"; | 967 "}\n"; |
1002 | 968 |
1003 lib = TestCase::ReloadTestScript(kReloadScript); | 969 lib = TestCase::ReloadTestScript(kReloadScript); |
1004 EXPECT_ERROR(lib, "unexpected token"); | 970 EXPECT_ERROR(lib, "unexpected token"); |
(...skipping 29 matching lines...) Expand all Loading... |
1034 "main() {\n" | 1000 "main() {\n" |
1035 " return new C().test();\n" | 1001 " return new C().test();\n" |
1036 "}\n"; | 1002 "}\n"; |
1037 | 1003 |
1038 TestCase::SetReloadTestScript(kReloadScript); | 1004 TestCase::SetReloadTestScript(kReloadScript); |
1039 | 1005 |
1040 EXPECT_EQ("instance", SimpleInvokeStr(lib, "main")); | 1006 EXPECT_EQ("instance", SimpleInvokeStr(lib, "main")); |
1041 | 1007 |
1042 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1008 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1043 EXPECT_VALID(lib); | 1009 EXPECT_VALID(lib); |
1044 | |
1045 EXPECT_EQ("instance", SimpleInvokeStr(lib, "main")); | 1010 EXPECT_EQ("instance", SimpleInvokeStr(lib, "main")); |
1046 } | 1011 } |
1047 | 1012 |
1048 | 1013 |
1049 TEST_CASE(IsolateReload_PendingUnqualifiedCall_InstanceToStatic) { | 1014 TEST_CASE(IsolateReload_PendingUnqualifiedCall_InstanceToStatic) { |
1050 const char* kScript = | 1015 const char* kScript = |
1051 "import 'test:isolate_reload_helper';\n" | 1016 "import 'test:isolate_reload_helper';\n" |
1052 "class C {\n" | 1017 "class C {\n" |
1053 " foo() => 'instance';\n" | 1018 " foo() => 'instance';\n" |
1054 " test() {\n" | 1019 " test() {\n" |
(...skipping 20 matching lines...) Expand all Loading... |
1075 "main() {\n" | 1040 "main() {\n" |
1076 " return new C().test();\n" | 1041 " return new C().test();\n" |
1077 "}\n"; | 1042 "}\n"; |
1078 | 1043 |
1079 TestCase::SetReloadTestScript(kReloadScript); | 1044 TestCase::SetReloadTestScript(kReloadScript); |
1080 | 1045 |
1081 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); | 1046 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); |
1082 | 1047 |
1083 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1048 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1084 EXPECT_VALID(lib); | 1049 EXPECT_VALID(lib); |
1085 | |
1086 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); | 1050 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); |
1087 } | 1051 } |
1088 | 1052 |
1089 | 1053 |
1090 TEST_CASE(IsolateReload_PendingConstructorCall_AbstractToConcrete) { | 1054 TEST_CASE(IsolateReload_PendingConstructorCall_AbstractToConcrete) { |
1091 const char* kScript = | 1055 const char* kScript = |
1092 "import 'test:isolate_reload_helper';\n" | 1056 "import 'test:isolate_reload_helper';\n" |
1093 "abstract class Foo {}\n" | 1057 "abstract class Foo {}\n" |
1094 "class C {\n" | 1058 "class C {\n" |
1095 " test() {\n" | 1059 " test() {\n" |
(...skipping 30 matching lines...) Expand all Loading... |
1126 " return 'exception';\n" | 1090 " return 'exception';\n" |
1127 " }\n" | 1091 " }\n" |
1128 "}\n"; | 1092 "}\n"; |
1129 | 1093 |
1130 TestCase::SetReloadTestScript(kReloadScript); | 1094 TestCase::SetReloadTestScript(kReloadScript); |
1131 | 1095 |
1132 EXPECT_EQ("okay", SimpleInvokeStr(lib, "main")); | 1096 EXPECT_EQ("okay", SimpleInvokeStr(lib, "main")); |
1133 | 1097 |
1134 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1098 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1135 EXPECT_VALID(lib); | 1099 EXPECT_VALID(lib); |
1136 | |
1137 EXPECT_EQ("okay", SimpleInvokeStr(lib, "main")); | 1100 EXPECT_EQ("okay", SimpleInvokeStr(lib, "main")); |
1138 } | 1101 } |
1139 | 1102 |
1140 | 1103 |
1141 TEST_CASE(IsolateReload_PendingConstructorCall_ConcreteToAbstract) { | 1104 TEST_CASE(IsolateReload_PendingConstructorCall_ConcreteToAbstract) { |
1142 const char* kScript = | 1105 const char* kScript = |
1143 "import 'test:isolate_reload_helper';\n" | 1106 "import 'test:isolate_reload_helper';\n" |
1144 "class Foo {}\n" | 1107 "class Foo {}\n" |
1145 "class C {\n" | 1108 "class C {\n" |
1146 " test() {\n" | 1109 " test() {\n" |
(...skipping 30 matching lines...) Expand all Loading... |
1177 " return 'exception';\n" | 1140 " return 'exception';\n" |
1178 " }\n" | 1141 " }\n" |
1179 "}\n"; | 1142 "}\n"; |
1180 | 1143 |
1181 TestCase::SetReloadTestScript(kReloadScript); | 1144 TestCase::SetReloadTestScript(kReloadScript); |
1182 | 1145 |
1183 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); | 1146 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); |
1184 | 1147 |
1185 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1148 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1186 EXPECT_VALID(lib); | 1149 EXPECT_VALID(lib); |
1187 | |
1188 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); | 1150 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); |
1189 } | 1151 } |
1190 | 1152 |
1191 | 1153 |
1192 TEST_CASE(IsolateReload_PendingStaticCall_DefinedToNSM) { | 1154 TEST_CASE(IsolateReload_PendingStaticCall_DefinedToNSM) { |
1193 const char* kScript = | 1155 const char* kScript = |
1194 "import 'test:isolate_reload_helper';\n" | 1156 "import 'test:isolate_reload_helper';\n" |
1195 "class C {\n" | 1157 "class C {\n" |
1196 " static foo() => 'static'\n" | 1158 " static foo() => 'static'\n" |
1197 " test() {\n" | 1159 " test() {\n" |
(...skipping 27 matching lines...) Expand all Loading... |
1225 " return 'exception';\n" | 1187 " return 'exception';\n" |
1226 " }\n" | 1188 " }\n" |
1227 "}\n"; | 1189 "}\n"; |
1228 | 1190 |
1229 TestCase::SetReloadTestScript(kReloadScript); | 1191 TestCase::SetReloadTestScript(kReloadScript); |
1230 | 1192 |
1231 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); | 1193 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); |
1232 | 1194 |
1233 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1195 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1234 EXPECT_VALID(lib); | 1196 EXPECT_VALID(lib); |
1235 | |
1236 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); | 1197 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); |
1237 } | 1198 } |
1238 | 1199 |
1239 | 1200 |
1240 TEST_CASE(IsolateReload_PendingStaticCall_NSMToDefined) { | 1201 TEST_CASE(IsolateReload_PendingStaticCall_NSMToDefined) { |
1241 const char* kScript = | 1202 const char* kScript = |
1242 "import 'test:isolate_reload_helper';\n" | 1203 "import 'test:isolate_reload_helper';\n" |
1243 "class C {\n" | 1204 "class C {\n" |
1244 " test() {\n" | 1205 " test() {\n" |
1245 " reloadTest();\n" | 1206 " reloadTest();\n" |
(...skipping 27 matching lines...) Expand all Loading... |
1273 " return 'exception';\n" | 1234 " return 'exception';\n" |
1274 " }\n" | 1235 " }\n" |
1275 "}\n"; | 1236 "}\n"; |
1276 | 1237 |
1277 TestCase::SetReloadTestScript(kReloadScript); | 1238 TestCase::SetReloadTestScript(kReloadScript); |
1278 | 1239 |
1279 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); | 1240 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); |
1280 | 1241 |
1281 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1242 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1282 EXPECT_VALID(lib); | 1243 EXPECT_VALID(lib); |
1283 | |
1284 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); | 1244 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); |
1285 } | 1245 } |
1286 | 1246 |
1287 | 1247 |
1288 TEST_CASE(IsolateReload_PendingSuperCall) { | 1248 TEST_CASE(IsolateReload_PendingSuperCall) { |
1289 const char* kScript = | 1249 const char* kScript = |
1290 "import 'test:isolate_reload_helper';\n" | 1250 "import 'test:isolate_reload_helper';\n" |
1291 "class S {\n" | 1251 "class S {\n" |
1292 " foo() => 1;\n" | 1252 " foo() => 1;\n" |
1293 "}\n" | 1253 "}\n" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 "main() {\n" | 1315 "main() {\n" |
1356 " if (x == Fruit.Banana) {\n" | 1316 " if (x == Fruit.Banana) {\n" |
1357 " return 'yes';\n" | 1317 " return 'yes';\n" |
1358 " } else {\n" | 1318 " } else {\n" |
1359 " return 'no';\n" | 1319 " return 'no';\n" |
1360 " }\n" | 1320 " }\n" |
1361 "}\n"; | 1321 "}\n"; |
1362 | 1322 |
1363 lib = TestCase::ReloadTestScript(kReloadScript); | 1323 lib = TestCase::ReloadTestScript(kReloadScript); |
1364 EXPECT_VALID(lib); | 1324 EXPECT_VALID(lib); |
1365 | |
1366 EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main")); | 1325 EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main")); |
1367 } | 1326 } |
1368 | 1327 |
1369 | 1328 |
1370 TEST_CASE(IsolateReload_EnumIdentical) { | 1329 TEST_CASE(IsolateReload_EnumIdentical) { |
1371 const char* kScript = | 1330 const char* kScript = |
1372 "enum Fruit {\n" | 1331 "enum Fruit {\n" |
1373 " Apple,\n" | 1332 " Apple,\n" |
1374 " Banana,\n" | 1333 " Banana,\n" |
1375 "}\n" | 1334 "}\n" |
1376 "var x;\n" | 1335 "var x;\n" |
1377 "main() {\n" | 1336 "main() {\n" |
1378 " x = Fruit.Banana;\n" | 1337 " x = Fruit.Banana;\n" |
1379 " return Fruit.Apple.toString();\n" | 1338 " return Fruit.Apple.toString();\n" |
1380 "}\n"; | 1339 "}\n"; |
1381 | 1340 |
1382 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1341 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1383 EXPECT_VALID(lib); | 1342 EXPECT_VALID(lib); |
1384 | |
1385 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); | 1343 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); |
1386 | 1344 |
1387 const char* kReloadScript = | 1345 const char* kReloadScript = |
1388 "enum Fruit {\n" | 1346 "enum Fruit {\n" |
1389 " Apple,\n" | 1347 " Apple,\n" |
1390 " Banana,\n" | 1348 " Banana,\n" |
1391 "}\n" | 1349 "}\n" |
1392 "var x;\n" | 1350 "var x;\n" |
1393 "main() {\n" | 1351 "main() {\n" |
1394 " if (identical(x, Fruit.Banana)) {\n" | 1352 " if (identical(x, Fruit.Banana)) {\n" |
1395 " return 'yes';\n" | 1353 " return 'yes';\n" |
1396 " } else {\n" | 1354 " } else {\n" |
1397 " return 'no';\n" | 1355 " return 'no';\n" |
1398 " }\n" | 1356 " }\n" |
1399 "}\n"; | 1357 "}\n"; |
1400 | 1358 |
1401 lib = TestCase::ReloadTestScript(kReloadScript); | 1359 lib = TestCase::ReloadTestScript(kReloadScript); |
1402 EXPECT_VALID(lib); | 1360 EXPECT_VALID(lib); |
1403 | |
1404 EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main")); | 1361 EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main")); |
1405 } | 1362 } |
1406 | 1363 |
1407 | 1364 |
1408 TEST_CASE(IsolateReload_EnumReorderIdentical) { | 1365 TEST_CASE(IsolateReload_EnumReorderIdentical) { |
1409 const char* kScript = | 1366 const char* kScript = |
1410 "enum Fruit {\n" | 1367 "enum Fruit {\n" |
1411 " Apple,\n" | 1368 " Apple,\n" |
1412 " Banana,\n" | 1369 " Banana,\n" |
1413 "}\n" | 1370 "}\n" |
1414 "var x;\n" | 1371 "var x;\n" |
1415 "main() {\n" | 1372 "main() {\n" |
1416 " x = Fruit.Banana;\n" | 1373 " x = Fruit.Banana;\n" |
1417 " return Fruit.Apple.toString();\n" | 1374 " return Fruit.Apple.toString();\n" |
1418 "}\n"; | 1375 "}\n"; |
1419 | 1376 |
1420 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1377 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1421 EXPECT_VALID(lib); | 1378 EXPECT_VALID(lib); |
1422 | |
1423 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); | 1379 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); |
1424 | 1380 |
1425 const char* kReloadScript = | 1381 const char* kReloadScript = |
1426 "enum Fruit {\n" | 1382 "enum Fruit {\n" |
1427 " Banana,\n" | 1383 " Banana,\n" |
1428 " Apple,\n" | 1384 " Apple,\n" |
1429 "}\n" | 1385 "}\n" |
1430 "var x;\n" | 1386 "var x;\n" |
1431 "main() {\n" | 1387 "main() {\n" |
1432 " if (identical(x, Fruit.Banana)) {\n" | 1388 " if (identical(x, Fruit.Banana)) {\n" |
1433 " return 'yes';\n" | 1389 " return 'yes';\n" |
1434 " } else {\n" | 1390 " } else {\n" |
1435 " return 'no';\n" | 1391 " return 'no';\n" |
1436 " }\n" | 1392 " }\n" |
1437 "}\n"; | 1393 "}\n"; |
1438 | 1394 |
1439 lib = TestCase::ReloadTestScript(kReloadScript); | 1395 lib = TestCase::ReloadTestScript(kReloadScript); |
1440 EXPECT_VALID(lib); | 1396 EXPECT_VALID(lib); |
1441 | |
1442 EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main")); | 1397 EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main")); |
1443 } | 1398 } |
1444 | 1399 |
1445 | 1400 |
1446 TEST_CASE(IsolateReload_EnumAddition) { | 1401 TEST_CASE(IsolateReload_EnumAddition) { |
1447 const char* kScript = | 1402 const char* kScript = |
1448 "enum Fruit {\n" | 1403 "enum Fruit {\n" |
1449 " Apple,\n" | 1404 " Apple,\n" |
1450 " Banana,\n" | 1405 " Banana,\n" |
1451 "}\n" | 1406 "}\n" |
1452 "var x;\n" | 1407 "var x;\n" |
1453 "main() {\n" | 1408 "main() {\n" |
1454 " return Fruit.Apple.toString();\n" | 1409 " return Fruit.Apple.toString();\n" |
1455 "}\n"; | 1410 "}\n"; |
1456 | 1411 |
1457 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1412 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1458 EXPECT_VALID(lib); | 1413 EXPECT_VALID(lib); |
1459 | |
1460 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); | 1414 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); |
1461 | 1415 |
1462 const char* kReloadScript = | 1416 const char* kReloadScript = |
1463 "enum Fruit {\n" | 1417 "enum Fruit {\n" |
1464 " Apple,\n" | 1418 " Apple,\n" |
1465 " Cantalope,\n" | 1419 " Cantalope,\n" |
1466 " Banana,\n" | 1420 " Banana,\n" |
1467 "}\n" | 1421 "}\n" |
1468 "var x;\n" | 1422 "var x;\n" |
1469 "main() {\n" | 1423 "main() {\n" |
1470 " String r = '${Fruit.Apple.index}/${Fruit.Apple} ';\n" | 1424 " String r = '${Fruit.Apple.index}/${Fruit.Apple} ';\n" |
1471 " r += '${Fruit.Cantalope.index}/${Fruit.Cantalope} ';\n" | 1425 " r += '${Fruit.Cantalope.index}/${Fruit.Cantalope} ';\n" |
1472 " r += '${Fruit.Banana.index}/${Fruit.Banana}';\n" | 1426 " r += '${Fruit.Banana.index}/${Fruit.Banana}';\n" |
1473 " return r;\n" | 1427 " return r;\n" |
1474 "}\n"; | 1428 "}\n"; |
1475 | 1429 |
1476 lib = TestCase::ReloadTestScript(kReloadScript); | 1430 lib = TestCase::ReloadTestScript(kReloadScript); |
1477 EXPECT_VALID(lib); | 1431 EXPECT_VALID(lib); |
1478 | |
1479 EXPECT_STREQ("0/Fruit.Apple 1/Fruit.Cantalope 2/Fruit.Banana", | 1432 EXPECT_STREQ("0/Fruit.Apple 1/Fruit.Cantalope 2/Fruit.Banana", |
1480 SimpleInvokeStr(lib, "main")); | 1433 SimpleInvokeStr(lib, "main")); |
1481 } | 1434 } |
1482 | 1435 |
1483 | 1436 |
1484 TEST_CASE(IsolateReload_EnumToNotEnum) { | 1437 TEST_CASE(IsolateReload_EnumToNotEnum) { |
1485 const char* kScript = | 1438 const char* kScript = |
1486 "enum Fruit {\n" | 1439 "enum Fruit {\n" |
1487 " Apple\n" | 1440 " Apple\n" |
1488 "}\n" | 1441 "}\n" |
1489 "main() {\n" | 1442 "main() {\n" |
1490 " return Fruit.Apple.toString();\n" | 1443 " return Fruit.Apple.toString();\n" |
1491 "}\n"; | 1444 "}\n"; |
1492 | 1445 |
1493 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1446 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1494 EXPECT_VALID(lib); | 1447 EXPECT_VALID(lib); |
1495 | |
1496 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); | 1448 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); |
1497 | 1449 |
1498 const char* kReloadScript = | 1450 const char* kReloadScript = |
1499 "class Fruit {\n" | 1451 "class Fruit {\n" |
1500 " final int zero = 0;\n" | 1452 " final int zero = 0;\n" |
1501 "}\n" | 1453 "}\n" |
1502 "main() {\n" | 1454 "main() {\n" |
1503 "}\n"; | 1455 "}\n"; |
1504 | 1456 |
1505 Dart_Handle result = TestCase::ReloadTestScript(kReloadScript); | 1457 Dart_Handle result = TestCase::ReloadTestScript(kReloadScript); |
1506 EXPECT_ERROR(result, "Enum class cannot be redefined to be a non-enum class"); | 1458 EXPECT_ERROR(result, "Enum class cannot be redefined to be a non-enum class"); |
1507 } | 1459 } |
1508 | 1460 |
1509 | 1461 |
1510 TEST_CASE(IsolateReload_NotEnumToEnum) { | 1462 TEST_CASE(IsolateReload_NotEnumToEnum) { |
1511 const char* kScript = | 1463 const char* kScript = |
1512 "class Fruit {\n" | 1464 "class Fruit {\n" |
1513 " final int zero = 0;\n" | 1465 " final int zero = 0;\n" |
1514 "}\n" | 1466 "}\n" |
1515 "main() {\n" | 1467 "main() {\n" |
1516 " return 'yes';\n" | 1468 " return 'yes';\n" |
1517 "}\n"; | 1469 "}\n"; |
1518 | 1470 |
1519 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1471 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1520 EXPECT_VALID(lib); | 1472 EXPECT_VALID(lib); |
1521 | |
1522 EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main")); | 1473 EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main")); |
1523 | 1474 |
1524 const char* kReloadScript = | 1475 const char* kReloadScript = |
1525 "enum Fruit {\n" | 1476 "enum Fruit {\n" |
1526 " Apple\n" | 1477 " Apple\n" |
1527 "}\n" | 1478 "}\n" |
1528 "main() {\n" | 1479 "main() {\n" |
1529 " return Fruit.Apple.toString();\n" | 1480 " return Fruit.Apple.toString();\n" |
1530 "}\n"; | 1481 "}\n"; |
1531 | 1482 |
(...skipping 10 matching lines...) Expand all Loading... |
1542 " Cantalope,\n" | 1493 " Cantalope,\n" |
1543 "}\n" | 1494 "}\n" |
1544 "var x;\n" | 1495 "var x;\n" |
1545 "main() {\n" | 1496 "main() {\n" |
1546 " x = Fruit.Cantalope;\n" | 1497 " x = Fruit.Cantalope;\n" |
1547 " return Fruit.Apple.toString();\n" | 1498 " return Fruit.Apple.toString();\n" |
1548 "}\n"; | 1499 "}\n"; |
1549 | 1500 |
1550 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1501 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1551 EXPECT_VALID(lib); | 1502 EXPECT_VALID(lib); |
1552 | |
1553 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); | 1503 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); |
1554 | 1504 |
1555 // Delete 'Cantalope' but make sure that we can still invoke toString, | 1505 // Delete 'Cantalope' but make sure that we can still invoke toString, |
1556 // and access the hashCode and index properties. | 1506 // and access the hashCode and index properties. |
1557 | 1507 |
1558 const char* kReloadScript = | 1508 const char* kReloadScript = |
1559 "enum Fruit {\n" | 1509 "enum Fruit {\n" |
1560 " Apple,\n" | 1510 " Apple,\n" |
1561 " Banana,\n" | 1511 " Banana,\n" |
1562 "}\n" | 1512 "}\n" |
1563 "var x;\n" | 1513 "var x;\n" |
1564 "main() {\n" | 1514 "main() {\n" |
1565 " String r = '$x ${x.hashCode is int} ${x.index}';\n" | 1515 " String r = '$x ${x.hashCode is int} ${x.index}';\n" |
1566 " return r;\n" | 1516 " return r;\n" |
1567 "}\n"; | 1517 "}\n"; |
1568 | 1518 |
1569 lib = TestCase::ReloadTestScript(kReloadScript); | 1519 lib = TestCase::ReloadTestScript(kReloadScript); |
1570 EXPECT_VALID(lib); | 1520 EXPECT_VALID(lib); |
1571 | |
1572 EXPECT_STREQ("Fruit.Cantalope true 2", | 1521 EXPECT_STREQ("Fruit.Cantalope true 2", |
1573 SimpleInvokeStr(lib, "main")); | 1522 SimpleInvokeStr(lib, "main")); |
1574 } | 1523 } |
1575 | 1524 |
1576 | 1525 |
1577 TEST_CASE(IsolateReload_EnumIdentityReload) { | 1526 TEST_CASE(IsolateReload_EnumIdentityReload) { |
1578 const char* kScript = | 1527 const char* kScript = |
1579 "enum Fruit {\n" | 1528 "enum Fruit {\n" |
1580 " Apple,\n" | 1529 " Apple,\n" |
1581 " Banana,\n" | 1530 " Banana,\n" |
1582 " Cantalope,\n" | 1531 " Cantalope,\n" |
1583 "}\n" | 1532 "}\n" |
1584 "var x;\n" | 1533 "var x;\n" |
1585 "var y;\n" | 1534 "var y;\n" |
1586 "var z;\n" | 1535 "var z;\n" |
1587 "var w;\n" | 1536 "var w;\n" |
1588 "main() {\n" | 1537 "main() {\n" |
1589 " x = { Fruit.Apple: Fruit.Apple.index,\n" | 1538 " x = { Fruit.Apple: Fruit.Apple.index,\n" |
1590 " Fruit.Banana: Fruit.Banana.index,\n" | 1539 " Fruit.Banana: Fruit.Banana.index,\n" |
1591 " Fruit.Cantalope: Fruit.Cantalope.index};\n" | 1540 " Fruit.Cantalope: Fruit.Cantalope.index};\n" |
1592 " y = Fruit.Apple;\n" | 1541 " y = Fruit.Apple;\n" |
1593 " z = Fruit.Banana;\n" | 1542 " z = Fruit.Banana;\n" |
1594 " w = Fruit.Cantalope;\n" | 1543 " w = Fruit.Cantalope;\n" |
1595 " return Fruit.Apple.toString();\n" | 1544 " return Fruit.Apple.toString();\n" |
1596 "}\n"; | 1545 "}\n"; |
1597 | 1546 |
1598 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1547 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1599 EXPECT_VALID(lib); | 1548 EXPECT_VALID(lib); |
1600 | |
1601 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); | 1549 EXPECT_STREQ("Fruit.Apple", SimpleInvokeStr(lib, "main")); |
1602 | 1550 |
1603 const char* kReloadScript = | 1551 const char* kReloadScript = |
1604 "enum Fruit {\n" | 1552 "enum Fruit {\n" |
1605 " Apple,\n" | 1553 " Apple,\n" |
1606 " Banana,\n" | 1554 " Banana,\n" |
1607 " Cantalope,\n" | 1555 " Cantalope,\n" |
1608 "}\n" | 1556 "}\n" |
1609 "var x;\n" | 1557 "var x;\n" |
1610 "var y;\n" | 1558 "var y;\n" |
(...skipping 11 matching lines...) Expand all Loading... |
1622 " r += '${x[Fruit.Banana] == Fruit.Banana.index} ';\n" | 1570 " r += '${x[Fruit.Banana] == Fruit.Banana.index} ';\n" |
1623 " r += '${x[Fruit.Cantalope] == Fruit.Cantalope.index} ';\n" | 1571 " r += '${x[Fruit.Cantalope] == Fruit.Cantalope.index} ';\n" |
1624 " r += '${identical(y, Fruit.values[x[Fruit.Apple]])} ';\n" | 1572 " r += '${identical(y, Fruit.values[x[Fruit.Apple]])} ';\n" |
1625 " r += '${identical(z, Fruit.values[x[Fruit.Banana]])} ';\n" | 1573 " r += '${identical(z, Fruit.values[x[Fruit.Banana]])} ';\n" |
1626 " r += '${identical(w, Fruit.values[x[Fruit.Cantalope]])} ';\n" | 1574 " r += '${identical(w, Fruit.values[x[Fruit.Cantalope]])} ';\n" |
1627 " return r;\n" | 1575 " return r;\n" |
1628 "}\n"; | 1576 "}\n"; |
1629 | 1577 |
1630 lib = TestCase::ReloadTestScript(kReloadScript); | 1578 lib = TestCase::ReloadTestScript(kReloadScript); |
1631 EXPECT_VALID(lib); | 1579 EXPECT_VALID(lib); |
1632 | |
1633 EXPECT_STREQ("true true true true true true true true true ", | 1580 EXPECT_STREQ("true true true true true true true true true ", |
1634 SimpleInvokeStr(lib, "main")); | 1581 SimpleInvokeStr(lib, "main")); |
1635 } | 1582 } |
1636 | 1583 |
1637 | 1584 |
1638 TEST_CASE(IsolateReload_ConstantIdentical) { | 1585 TEST_CASE(IsolateReload_ConstantIdentical) { |
1639 const char* kScript = | 1586 const char* kScript = |
1640 "class Fruit {\n" | 1587 "class Fruit {\n" |
1641 " final String name;\n" | 1588 " final String name;\n" |
1642 " const Fruit(this.name);\n" | 1589 " const Fruit(this.name);\n" |
1643 " String toString() => name;\n" | 1590 " String toString() => name;\n" |
1644 "}\n" | 1591 "}\n" |
1645 "var x;\n" | 1592 "var x;\n" |
1646 "main() {\n" | 1593 "main() {\n" |
1647 " x = const Fruit('Pear');\n" | 1594 " x = const Fruit('Pear');\n" |
1648 " return x.toString();\n" | 1595 " return x.toString();\n" |
1649 "}\n"; | 1596 "}\n"; |
1650 | 1597 |
1651 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1598 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1652 EXPECT_VALID(lib); | 1599 EXPECT_VALID(lib); |
1653 | |
1654 EXPECT_STREQ("Pear", SimpleInvokeStr(lib, "main")); | 1600 EXPECT_STREQ("Pear", SimpleInvokeStr(lib, "main")); |
1655 | 1601 |
1656 const char* kReloadScript = | 1602 const char* kReloadScript = |
1657 "class Fruit {\n" | 1603 "class Fruit {\n" |
1658 " final String name;\n" | 1604 " final String name;\n" |
1659 " const Fruit(this.name);\n" | 1605 " const Fruit(this.name);\n" |
1660 " String toString() => name;\n" | 1606 " String toString() => name;\n" |
1661 "}\n" | 1607 "}\n" |
1662 "var x;\n" | 1608 "var x;\n" |
1663 "main() {\n" | 1609 "main() {\n" |
1664 " if (identical(x, const Fruit('Pear'))) {\n" | 1610 " if (identical(x, const Fruit('Pear'))) {\n" |
1665 " return 'yes';\n" | 1611 " return 'yes';\n" |
1666 " } else {\n" | 1612 " } else {\n" |
1667 " return 'no';\n" | 1613 " return 'no';\n" |
1668 " }\n" | 1614 " }\n" |
1669 "}\n"; | 1615 "}\n"; |
1670 | 1616 |
1671 lib = TestCase::ReloadTestScript(kReloadScript); | 1617 lib = TestCase::ReloadTestScript(kReloadScript); |
1672 EXPECT_VALID(lib); | 1618 EXPECT_VALID(lib); |
1673 | |
1674 EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main")); | 1619 EXPECT_STREQ("yes", SimpleInvokeStr(lib, "main")); |
1675 } | 1620 } |
1676 | 1621 |
1677 | 1622 |
1678 TEST_CASE(IsolateReload_EnumValuesToString) { | 1623 TEST_CASE(IsolateReload_EnumValuesToString) { |
1679 const char* kScript = | 1624 const char* kScript = |
1680 "enum Fruit {\n" | 1625 "enum Fruit {\n" |
1681 " Apple,\n" | 1626 " Apple,\n" |
1682 " Banana,\n" | 1627 " Banana,\n" |
1683 "}\n" | 1628 "}\n" |
1684 "var x;\n" | 1629 "var x;\n" |
1685 "main() {\n" | 1630 "main() {\n" |
1686 " String r = '';\n" | 1631 " String r = '';\n" |
1687 " r += Fruit.Apple.toString();\n" | 1632 " r += Fruit.Apple.toString();\n" |
1688 " r += ' ';\n" | 1633 " r += ' ';\n" |
1689 " r += Fruit.Banana.toString();\n" | 1634 " r += Fruit.Banana.toString();\n" |
1690 " return r;\n" | 1635 " return r;\n" |
1691 "}\n"; | 1636 "}\n"; |
1692 | 1637 |
1693 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1638 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1694 EXPECT_VALID(lib); | 1639 EXPECT_VALID(lib); |
1695 | |
1696 EXPECT_STREQ("Fruit.Apple Fruit.Banana", SimpleInvokeStr(lib, "main")); | 1640 EXPECT_STREQ("Fruit.Apple Fruit.Banana", SimpleInvokeStr(lib, "main")); |
1697 | 1641 |
1698 // Insert 'Cantalope'. | 1642 // Insert 'Cantalope'. |
1699 | 1643 |
1700 const char* kReloadScript = | 1644 const char* kReloadScript = |
1701 "enum Fruit {\n" | 1645 "enum Fruit {\n" |
1702 " Apple,\n" | 1646 " Apple,\n" |
1703 " Cantalope,\n" | 1647 " Cantalope,\n" |
1704 " Banana\n" | 1648 " Banana\n" |
1705 "}\n" | 1649 "}\n" |
1706 "var x;\n" | 1650 "var x;\n" |
1707 "main() {\n" | 1651 "main() {\n" |
1708 " String r = '';\n" | 1652 " String r = '';\n" |
1709 " r += Fruit.Apple.toString();\n" | 1653 " r += Fruit.Apple.toString();\n" |
1710 " r += ' ';\n" | 1654 " r += ' ';\n" |
1711 " r += Fruit.Cantalope.toString();\n" | 1655 " r += Fruit.Cantalope.toString();\n" |
1712 " r += ' ';\n" | 1656 " r += ' ';\n" |
1713 " r += Fruit.Banana.toString();\n" | 1657 " r += Fruit.Banana.toString();\n" |
1714 " return r;\n" | 1658 " return r;\n" |
1715 "}\n"; | 1659 "}\n"; |
1716 | 1660 |
1717 lib = TestCase::ReloadTestScript(kReloadScript); | 1661 lib = TestCase::ReloadTestScript(kReloadScript); |
1718 EXPECT_VALID(lib); | 1662 EXPECT_VALID(lib); |
1719 | |
1720 EXPECT_STREQ("Fruit.Apple Fruit.Cantalope Fruit.Banana", | 1663 EXPECT_STREQ("Fruit.Apple Fruit.Cantalope Fruit.Banana", |
1721 SimpleInvokeStr(lib, "main")); | 1664 SimpleInvokeStr(lib, "main")); |
1722 } | 1665 } |
1723 | 1666 |
1724 | 1667 |
1725 TEST_CASE(IsolateReload_DirectSubclasses_Success) { | 1668 TEST_CASE(IsolateReload_DirectSubclasses_Success) { |
1726 Object& new_subclass = Object::Handle(); | 1669 Object& new_subclass = Object::Handle(); |
1727 String& name = String::Handle(); | 1670 String& name = String::Handle(); |
1728 | 1671 |
1729 // Lookup the Iterator class by name from the dart core library. | 1672 // Lookup the Iterator class by name from the dart core library. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 // the list of subclasses, which would be bad. Make sure that | 1841 // the list of subclasses, which would be bad. Make sure that |
1899 // Iterator still has only one non-core subclass... | 1842 // Iterator still has only one non-core subclass... |
1900 EXPECT_EQ(saved_subclass_count + 1, subclasses.Length()); | 1843 EXPECT_EQ(saved_subclass_count + 1, subclasses.Length()); |
1901 | 1844 |
1902 // ...and the non-core subclass is still named AIterator. | 1845 // ...and the non-core subclass is still named AIterator. |
1903 new_subclass = subclasses.At(subclasses.Length() - 1); | 1846 new_subclass = subclasses.At(subclasses.Length() - 1); |
1904 name = Class::Cast(new_subclass).Name(); | 1847 name = Class::Cast(new_subclass).Name(); |
1905 EXPECT_STREQ("AIterator", name.ToCString()); | 1848 EXPECT_STREQ("AIterator", name.ToCString()); |
1906 } | 1849 } |
1907 | 1850 |
| 1851 |
| 1852 // Tests reload succeeds when instance format changes. |
| 1853 // Change: Foo {a, b, c:42} -> Foo {c:42} |
| 1854 // Validate: c keeps the value in the retained Foo object. |
| 1855 TEST_CASE(IsolateReload_ChangeInstanceFormat0) { |
| 1856 const char* kScript = |
| 1857 "class Foo {\n" |
| 1858 " var a;\n" |
| 1859 " var b;\n" |
| 1860 " var c;\n" |
| 1861 "}\n" |
| 1862 "var f;\n" |
| 1863 "main() {\n" |
| 1864 " f = new Foo();\n" |
| 1865 " f.c = 42;\n" |
| 1866 " return f.c;\n" |
| 1867 "}\n"; |
| 1868 |
| 1869 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 1870 EXPECT_VALID(lib); |
| 1871 EXPECT_EQ(42, SimpleInvoke(lib, "main")); |
| 1872 |
| 1873 const char* kReloadScript = |
| 1874 "class Foo {\n" |
| 1875 " var c;\n" |
| 1876 "}\n" |
| 1877 "var f;\n" |
| 1878 "main() {\n" |
| 1879 " return f.c;\n" |
| 1880 "}\n"; |
| 1881 |
| 1882 lib = TestCase::ReloadTestScript(kReloadScript); |
| 1883 EXPECT_VALID(lib); |
| 1884 EXPECT_EQ(42, SimpleInvoke(lib, "main")); |
| 1885 } |
| 1886 |
| 1887 |
| 1888 // Tests reload succeeds when instance format changes. |
| 1889 // Change: Foo {} -> Foo {c:null} |
| 1890 // Validate: c is initialized to null the retained Foo object. |
| 1891 TEST_CASE(IsolateReload_ChangeInstanceFormat1) { |
| 1892 const char* kScript = |
| 1893 "class Foo {\n" |
| 1894 "}\n" |
| 1895 "var f;\n" |
| 1896 "main() {\n" |
| 1897 " f = new Foo();\n" |
| 1898 " return 42;\n" |
| 1899 "}\n"; |
| 1900 |
| 1901 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 1902 EXPECT_VALID(lib); |
| 1903 EXPECT_EQ(42, SimpleInvoke(lib, "main")); |
| 1904 |
| 1905 const char* kReloadScript = |
| 1906 "class Foo {\n" |
| 1907 " var c;\n" |
| 1908 "}\n" |
| 1909 "var f;\n" |
| 1910 "main() {\n" |
| 1911 " return (f.c == null) ? 42: 21;\n" |
| 1912 "}\n"; |
| 1913 |
| 1914 lib = TestCase::ReloadTestScript(kReloadScript); |
| 1915 EXPECT_VALID(lib); |
| 1916 EXPECT_EQ(42, SimpleInvoke(lib, "main")); |
| 1917 } |
| 1918 |
| 1919 // Tests reload succeeds when instance format changes. |
| 1920 // Change: Foo {c:42} -> Foo {} |
| 1921 // Validate: running the after script fails. |
| 1922 TEST_CASE(IsolateReload_ChangeInstanceFormat2) { |
| 1923 const char* kScript = |
| 1924 "class Foo {\n" |
| 1925 " var c;\n" |
| 1926 "}\n" |
| 1927 "var f;\n" |
| 1928 "main() {\n" |
| 1929 " f = new Foo();\n" |
| 1930 " f.c = 42;\n" |
| 1931 " return f.c;\n" |
| 1932 "}\n"; |
| 1933 |
| 1934 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 1935 EXPECT_VALID(lib); |
| 1936 EXPECT_EQ(42, SimpleInvoke(lib, "main")); |
| 1937 |
| 1938 const char* kReloadScript = |
| 1939 "class Foo {\n" |
| 1940 "}\n" |
| 1941 "var f;\n" |
| 1942 "main() {\n" |
| 1943 " try {\n" |
| 1944 " return f.c;\n" |
| 1945 " } catch (e) {\n" |
| 1946 " return 24;\n" |
| 1947 " }\n" |
| 1948 "}\n"; |
| 1949 |
| 1950 lib = TestCase::ReloadTestScript(kReloadScript); |
| 1951 EXPECT_VALID(lib); |
| 1952 EXPECT_EQ(24, SimpleInvoke(lib, "main")); |
| 1953 } |
| 1954 |
| 1955 |
| 1956 // Tests reload succeeds when instance format changes. |
| 1957 // Change: Foo {a, b, c:42, d} -> Foo {c:42, g} |
| 1958 // Validate: c keeps the value in the retained Foo object. |
| 1959 TEST_CASE(IsolateReload_ChangeInstanceFormat3) { |
| 1960 const char* kScript = |
| 1961 "class Foo<A,B> {\n" |
| 1962 " var a;\n" |
| 1963 " var b;\n" |
| 1964 " var c;\n" |
| 1965 " var d;\n" |
| 1966 "}\n" |
| 1967 "var f;\n" |
| 1968 "main() {\n" |
| 1969 " f = new Foo();\n" |
| 1970 " f.a = 1;\n" |
| 1971 " f.b = 2;\n" |
| 1972 " f.c = 3;\n" |
| 1973 " f.d = 4;\n" |
| 1974 " return f.c;\n" |
| 1975 "}\n"; |
| 1976 |
| 1977 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 1978 EXPECT_VALID(lib); |
| 1979 EXPECT_EQ(3, SimpleInvoke(lib, "main")); |
| 1980 |
| 1981 const char* kReloadScript = |
| 1982 "class Foo<A,B> {\n" |
| 1983 " var c;\n" |
| 1984 " var g;\n" |
| 1985 "}\n" |
| 1986 "var f;\n" |
| 1987 "main() {\n" |
| 1988 " return f.c;\n" |
| 1989 "}\n"; |
| 1990 |
| 1991 lib = TestCase::ReloadTestScript(kReloadScript); |
| 1992 EXPECT_VALID(lib); |
| 1993 EXPECT_EQ(3, SimpleInvoke(lib, "main")); |
| 1994 } |
| 1995 |
| 1996 |
| 1997 // Tests reload succeeds when instance format changes. |
| 1998 // Change: Bar {c:42}, Foo : Bar {d, e} -> Foo {c:42} |
| 1999 // Validate: c keeps the value in the retained Foo object. |
| 2000 TEST_CASE(IsolateReload_ChangeInstanceFormat4) { |
| 2001 const char* kScript = |
| 2002 "class Bar{\n" |
| 2003 " var c;\n" |
| 2004 "}\n" |
| 2005 "class Foo extends Bar{\n" |
| 2006 " var d;\n" |
| 2007 " var e;\n" |
| 2008 "}\n" |
| 2009 "var f;\n" |
| 2010 "main() {\n" |
| 2011 " f = new Foo();\n" |
| 2012 " f.c = 44;\n" |
| 2013 " return f.c;\n" |
| 2014 "}\n"; |
| 2015 |
| 2016 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 2017 EXPECT_VALID(lib); |
| 2018 EXPECT_EQ(44, SimpleInvoke(lib, "main")); |
| 2019 |
| 2020 const char* kReloadScript = |
| 2021 "class Foo {\n" |
| 2022 " var c;\n" |
| 2023 "}\n" |
| 2024 "var f;\n" |
| 2025 "main() {\n" |
| 2026 " return f.c;\n" |
| 2027 "}\n"; |
| 2028 |
| 2029 lib = TestCase::ReloadTestScript(kReloadScript); |
| 2030 EXPECT_VALID(lib); |
| 2031 EXPECT_EQ(44, SimpleInvoke(lib, "main")); |
| 2032 } |
| 2033 |
| 2034 |
| 2035 // Tests reload succeeds when instance format changes. |
| 2036 // Change: Bar {a, b}, Foo : Bar {c:42} -> Bar {c:42}, Foo : Bar {} |
| 2037 // Validate: c keeps the value in the retained Foo object. |
| 2038 TEST_CASE(IsolateReload_ChangeInstanceFormat5) { |
| 2039 const char* kScript = |
| 2040 "class Bar{\n" |
| 2041 " var a;\n" |
| 2042 " var b;\n" |
| 2043 "}\n" |
| 2044 "class Foo extends Bar{\n" |
| 2045 " var c;\n" |
| 2046 "}\n" |
| 2047 "var f;\n" |
| 2048 "main() {\n" |
| 2049 " f = new Foo();\n" |
| 2050 " f.c = 44;\n" |
| 2051 " return f.c;\n" |
| 2052 "}\n"; |
| 2053 |
| 2054 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 2055 EXPECT_VALID(lib); |
| 2056 EXPECT_EQ(44, SimpleInvoke(lib, "main")); |
| 2057 |
| 2058 const char* kReloadScript = |
| 2059 "class Bar{\n" |
| 2060 " var c;\n" |
| 2061 "}\n" |
| 2062 "class Foo extends Bar {\n" |
| 2063 "}\n" |
| 2064 "var f;\n" |
| 2065 "main() {\n" |
| 2066 " return f.c;\n" |
| 2067 "}\n"; |
| 2068 |
| 2069 lib = TestCase::ReloadTestScript(kReloadScript); |
| 2070 EXPECT_VALID(lib); |
| 2071 EXPECT_EQ(44, SimpleInvoke(lib, "main")); |
| 2072 } |
| 2073 |
| 2074 |
| 2075 // Tests reload fails when type parameters change. |
| 2076 // Change: Foo<A,B> {a, b} -> Foo<A> {a} |
| 2077 // Validate: the right error message is returned. |
| 2078 TEST_CASE(IsolateReload_ChangeInstanceFormat6) { |
| 2079 const char* kScript = |
| 2080 "class Foo<A, B> {\n" |
| 2081 " var a;\n" |
| 2082 " var b;\n" |
| 2083 "}\n" |
| 2084 "main() {\n" |
| 2085 " new Foo();\n" |
| 2086 " return 43;\n" |
| 2087 "}\n"; |
| 2088 |
| 2089 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 2090 EXPECT_VALID(lib); |
| 2091 EXPECT_EQ(43, SimpleInvoke(lib, "main")); |
| 2092 |
| 2093 const char* kReloadScript = |
| 2094 "class Foo<A> {\n" |
| 2095 " var a;\n" |
| 2096 "}\n"; |
| 2097 lib = TestCase::ReloadTestScript(kReloadScript); |
| 2098 EXPECT_ERROR(lib, "type parameters have changed"); |
| 2099 } |
| 2100 |
| 2101 // Tests reload succeeds when type parameters are changed for allocated class. |
| 2102 // Change: Foo<A,B> {a, b} -> Foo<A> {a} |
| 2103 // Validate: return value from main is correct. |
| 2104 // Please note: This test works because no instances are created from Foo. |
| 2105 TEST_CASE(IsolateReload_ChangeInstanceFormat7) { |
| 2106 const char* kScript = |
| 2107 "class Foo<A, B> {\n" |
| 2108 " var a;\n" |
| 2109 " var b;\n" |
| 2110 "}\n"; |
| 2111 |
| 2112 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 2113 EXPECT_VALID(lib); |
| 2114 |
| 2115 const char* kReloadScript = |
| 2116 "class Foo<A> {\n" |
| 2117 " var a;\n" |
| 2118 "}\n"; |
| 2119 lib = TestCase::ReloadTestScript(kReloadScript); |
| 2120 EXPECT_VALID(lib); |
| 2121 } |
| 2122 |
1908 #endif // !PRODUCT | 2123 #endif // !PRODUCT |
1909 | 2124 |
1910 } // namespace dart | 2125 } // namespace dart |
OLD | NEW |