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 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 | 1321 |
1322 TestCase::SetReloadTestScript(kReloadScript); | 1322 TestCase::SetReloadTestScript(kReloadScript); |
1323 | 1323 |
1324 EXPECT_STREQ("new new true false", SimpleInvokeStr(lib, "main")); | 1324 EXPECT_STREQ("new new true false", SimpleInvokeStr(lib, "main")); |
1325 | 1325 |
1326 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1326 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1327 EXPECT_VALID(lib); | 1327 EXPECT_VALID(lib); |
1328 } | 1328 } |
1329 | 1329 |
1330 | 1330 |
| 1331 TEST_CASE(IsolateReload_TearOff_List_Set) { |
| 1332 const char* kScript = |
| 1333 "import 'test:isolate_reload_helper';\n" |
| 1334 "class C {\n" |
| 1335 " foo() => 'old';\n" |
| 1336 "}\n" |
| 1337 "List list = new List(2);\n" |
| 1338 "Set set = new Set();\n" |
| 1339 "main() {\n" |
| 1340 " var c = new C();\n" |
| 1341 " list[0] = c.foo;\n" |
| 1342 " list[1] = c#foo;\n" |
| 1343 " set.add(c.foo);\n" |
| 1344 " set.add(c#foo);\n" |
| 1345 " int countBefore = set.length;\n" |
| 1346 " reloadTest();\n" |
| 1347 " list[1] = c.foo;\n" |
| 1348 " set.add(c.foo);\n" |
| 1349 " set.add(c#foo);\n" |
| 1350 " int countAfter = set.length;\n" |
| 1351 " return '${list[0]()} ${list[1]()} ${list[0] == list[1]} '\n" |
| 1352 " '${countBefore == 1} ${countAfter == 1} ${(set.first)()} '\n" |
| 1353 " '${set.first == c.foo} ${set.first == c#foo} '\n" |
| 1354 " '${set.remove(c#foo)}';\n" |
| 1355 "}\n"; |
| 1356 |
| 1357 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 1358 EXPECT_VALID(lib); |
| 1359 |
| 1360 const char* kReloadScript = |
| 1361 "import 'test:isolate_reload_helper';\n" |
| 1362 "class C {\n" |
| 1363 " foo() => 'new';\n" |
| 1364 "}\n" |
| 1365 "List list = new List(2);\n" |
| 1366 "Set set = new Set();\n" |
| 1367 "main() {\n" |
| 1368 " var c = new C();\n" |
| 1369 " list[0] = c.foo;\n" |
| 1370 " list[1] = c#foo;\n" |
| 1371 " set.add(c.foo);\n" |
| 1372 " set.add(c#foo);\n" |
| 1373 " int countBefore = set.length;\n" |
| 1374 " reloadTest();\n" |
| 1375 " list[1] = c.foo;\n" |
| 1376 " set.add(c.foo);\n" |
| 1377 " set.add(c#foo);\n" |
| 1378 " int countAfter = set.length;\n" |
| 1379 " return '${list[0]()} ${list[1]()} ${list[0] == list[1]} '\n" |
| 1380 " '${countBefore == 1} ${countAfter == 1} ${(set.first)()} '\n" |
| 1381 " '${set.first == c.foo} ${set.first == c#foo} '\n" |
| 1382 " '${set.remove(c#foo)}';\n" |
| 1383 "}\n"; |
| 1384 |
| 1385 TestCase::SetReloadTestScript(kReloadScript); |
| 1386 |
| 1387 EXPECT_STREQ("new new true true true new true true true", |
| 1388 SimpleInvokeStr(lib, "main")); |
| 1389 |
| 1390 lib = TestCase::GetReloadErrorOrRootLibrary(); |
| 1391 EXPECT_VALID(lib); |
| 1392 } |
| 1393 |
1331 | 1394 |
1332 TEST_CASE(IsolateReload_EnumEquality) { | 1395 TEST_CASE(IsolateReload_EnumEquality) { |
1333 const char* kScript = | 1396 const char* kScript = |
1334 "enum Fruit {\n" | 1397 "enum Fruit {\n" |
1335 " Apple,\n" | 1398 " Apple,\n" |
1336 " Banana,\n" | 1399 " Banana,\n" |
1337 "}\n" | 1400 "}\n" |
1338 "var x;\n" | 1401 "var x;\n" |
1339 "main() {\n" | 1402 "main() {\n" |
1340 " x = Fruit.Banana;\n" | 1403 " x = Fruit.Banana;\n" |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 "class Foo<A> {\n" | 2219 "class Foo<A> {\n" |
2157 " var a;\n" | 2220 " var a;\n" |
2158 "}\n"; | 2221 "}\n"; |
2159 lib = TestCase::ReloadTestScript(kReloadScript); | 2222 lib = TestCase::ReloadTestScript(kReloadScript); |
2160 EXPECT_VALID(lib); | 2223 EXPECT_VALID(lib); |
2161 } | 2224 } |
2162 | 2225 |
2163 #endif // !PRODUCT | 2226 #endif // !PRODUCT |
2164 | 2227 |
2165 } // namespace dart | 2228 } // namespace dart |
OLD | NEW |