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

Side by Side Diff: runtime/vm/isolate_reload_test.cc

Issue 2194333002: RELOAD: Maintain identity of static tear-offs. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: . Created 4 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
« no previous file with comments | « runtime/vm/isolate_reload.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 "main() {\n" 1282 "main() {\n"
1283 " return new C().test();\n" 1283 " return new C().test();\n"
1284 "}\n"; 1284 "}\n";
1285 1285
1286 TestCase::SetReloadTestScript(kReloadScript); 1286 TestCase::SetReloadTestScript(kReloadScript);
1287 1287
1288 EXPECT_EQ(11, SimpleInvoke(lib, "main")); 1288 EXPECT_EQ(11, SimpleInvoke(lib, "main"));
1289 } 1289 }
1290 1290
1291 1291
1292 TEST_CASE(IsolateReload_TearOff_Equality) { 1292 TEST_CASE(IsolateReload_TearOff_Instance_Equality) {
1293 const char* kScript = 1293 const char* kScript =
1294 "import 'test:isolate_reload_helper';\n" 1294 "import 'test:isolate_reload_helper';\n"
1295 "class C {\n" 1295 "class C {\n"
1296 " foo() => 'old';\n" 1296 " foo() => 'old';\n"
1297 "}\n" 1297 "}\n"
1298 "main() {\n" 1298 "main() {\n"
1299 " var c = new C();\n" 1299 " var c = new C();\n"
1300 " var f1 = c.foo;\n" 1300 " var f1 = c.foo;\n"
1301 " reloadTest();\n" 1301 " reloadTest();\n"
1302 " var f2 = c.foo;\n" 1302 " var f2 = c.foo;\n"
(...skipping 18 matching lines...) Expand all
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_Class_Identity) {
1332 const char* kScript =
1333 "import 'test:isolate_reload_helper';\n"
1334 "class C {\n"
1335 " static foo() => 'old';\n"
1336 "}\n"
1337 "getFoo() => C.foo;\n"
1338 "main() {\n"
1339 " var f1 = getFoo();\n"
1340 " reloadTest();\n"
1341 " var f2 = getFoo();\n"
1342 " return '${f1()} ${f2()} ${f1 == f2} ${identical(f1, f2)}';\n"
1343 "}\n";
1344
1345 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
1346 EXPECT_VALID(lib);
1347
1348 const char* kReloadScript =
1349 "import 'test:isolate_reload_helper';\n"
1350 "class C {\n"
1351 " static foo() => 'new';\n"
1352 "}\n"
1353 "getFoo() => C.foo;\n"
1354 "main() {\n"
1355 " var f1 = getFoo();\n"
1356 " reloadTest();\n"
1357 " var f2 = getFoo();\n"
1358 " return '${f1()} ${f2()} ${f1 == f2} ${identical(f1, f2)}';\n"
1359 "}\n";
1360
1361 TestCase::SetReloadTestScript(kReloadScript);
1362
1363 EXPECT_STREQ("new new true true", SimpleInvokeStr(lib, "main"));
1364
1365 lib = TestCase::GetReloadErrorOrRootLibrary();
1366 EXPECT_VALID(lib);
1367 }
1368
1369
1370 TEST_CASE(IsolateReload_TearOff_Library_Identity) {
1371 const char* kScript =
1372 "import 'test:isolate_reload_helper';\n"
1373 "foo() => 'old';\n"
1374 "getFoo() => foo;\n"
1375 "main() {\n"
1376 " var f1 = getFoo();\n"
1377 " reloadTest();\n"
1378 " var f2 = getFoo();\n"
1379 " return '${f1()} ${f2()} ${f1 == f2} ${identical(f1, f2)}';\n"
1380 "}\n";
1381
1382 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
1383 EXPECT_VALID(lib);
1384
1385 const char* kReloadScript =
1386 "import 'test:isolate_reload_helper';\n"
1387 "foo() => 'new';\n"
1388 "getFoo() => foo;\n"
1389 "main() {\n"
1390 " var f1 = getFoo();\n"
1391 " reloadTest();\n"
1392 " var f2 = getFoo();\n"
1393 " return '${f1()} ${f2()} ${f1 == f2} ${identical(f1, f2)}';\n"
1394 "}\n";
1395
1396 TestCase::SetReloadTestScript(kReloadScript);
1397
1398 EXPECT_STREQ("new new true true", SimpleInvokeStr(lib, "main"));
1399
1400 lib = TestCase::GetReloadErrorOrRootLibrary();
1401 EXPECT_VALID(lib);
1402 }
1403
1404
1331 TEST_CASE(IsolateReload_TearOff_List_Set) { 1405 TEST_CASE(IsolateReload_TearOff_List_Set) {
1332 const char* kScript = 1406 const char* kScript =
1333 "import 'test:isolate_reload_helper';\n" 1407 "import 'test:isolate_reload_helper';\n"
1334 "class C {\n" 1408 "class C {\n"
1335 " foo() => 'old';\n" 1409 " foo() => 'old';\n"
1336 "}\n" 1410 "}\n"
1337 "List list = new List(2);\n" 1411 "List list = new List(2);\n"
1338 "Set set = new Set();\n" 1412 "Set set = new Set();\n"
1339 "main() {\n" 1413 "main() {\n"
1340 " var c = new C();\n" 1414 " var c = new C();\n"
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 2455
2382 // Modification of an prefix-imported library propagates to the 2456 // Modification of an prefix-imported library propagates to the
2383 // importing library. 2457 // importing library.
2384 EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main")); 2458 EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main"));
2385 } 2459 }
2386 2460
2387 2461
2388 #endif // !PRODUCT 2462 #endif // !PRODUCT
2389 2463
2390 } // namespace dart 2464 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate_reload.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698