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" |
11 #include "vm/thread_barrier.h" | 11 #include "vm/thread_barrier.h" |
12 #include "vm/thread_pool.h" | 12 #include "vm/thread_pool.h" |
13 #include "vm/unit_test.h" | 13 #include "vm/unit_test.h" |
14 | 14 |
15 namespace dart { | 15 namespace dart { |
16 | 16 |
17 #ifndef PRODUCT | 17 #ifndef PRODUCT |
18 | 18 |
| 19 DECLARE_FLAG(bool, support_deprecated_tearoff_syntax); |
| 20 |
19 // TODO(johnmccutchan): | 21 // TODO(johnmccutchan): |
20 // - Tests involving generics. | 22 // - Tests involving generics. |
21 | 23 |
22 int64_t SimpleInvoke(Dart_Handle lib, const char* method) { | 24 int64_t SimpleInvoke(Dart_Handle lib, const char* method) { |
23 Dart_Handle result = Dart_Invoke(lib, NewString(method), 0, NULL); | 25 Dart_Handle result = Dart_Invoke(lib, NewString(method), 0, NULL); |
24 EXPECT_VALID(result); | 26 EXPECT_VALID(result); |
25 EXPECT(Dart_IsInteger(result)); | 27 EXPECT(Dart_IsInteger(result)); |
26 int64_t integer_result = 0; | 28 int64_t integer_result = 0; |
27 result = Dart_IntegerToInt64(result, &integer_result); | 29 result = Dart_IntegerToInt64(result, &integer_result); |
28 EXPECT_VALID(result); | 30 EXPECT_VALID(result); |
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 const char* kScript = | 1429 const char* kScript = |
1428 "import 'test:isolate_reload_helper';\n" | 1430 "import 'test:isolate_reload_helper';\n" |
1429 "class C {\n" | 1431 "class C {\n" |
1430 " foo() => 'old';\n" | 1432 " foo() => 'old';\n" |
1431 "}\n" | 1433 "}\n" |
1432 "List list = new List(2);\n" | 1434 "List list = new List(2);\n" |
1433 "Set set = new Set();\n" | 1435 "Set set = new Set();\n" |
1434 "main() {\n" | 1436 "main() {\n" |
1435 " var c = new C();\n" | 1437 " var c = new C();\n" |
1436 " list[0] = c.foo;\n" | 1438 " list[0] = c.foo;\n" |
1437 " list[1] = c#foo;\n" | 1439 " list[1] = c.foo;\n" |
1438 " set.add(c.foo);\n" | 1440 " set.add(c.foo);\n" |
1439 " set.add(c#foo);\n" | 1441 " set.add(c.foo);\n" |
1440 " int countBefore = set.length;\n" | 1442 " int countBefore = set.length;\n" |
1441 " reloadTest();\n" | 1443 " reloadTest();\n" |
1442 " list[1] = c.foo;\n" | 1444 " list[1] = c.foo;\n" |
1443 " set.add(c.foo);\n" | 1445 " set.add(c.foo);\n" |
1444 " set.add(c#foo);\n" | 1446 " set.add(c.foo);\n" |
1445 " int countAfter = set.length;\n" | 1447 " int countAfter = set.length;\n" |
1446 " return '${list[0]()} ${list[1]()} ${list[0] == list[1]} '\n" | 1448 " return '${list[0]()} ${list[1]()} ${list[0] == list[1]} '\n" |
1447 " '${countBefore == 1} ${countAfter == 1} ${(set.first)()} '\n" | 1449 " '${countBefore == 1} ${countAfter == 1} ${(set.first)()} '\n" |
1448 " '${set.first == c.foo} ${set.first == c#foo} '\n" | 1450 " '${set.first == c.foo} ${set.first == c.foo} '\n" |
1449 " '${set.remove(c#foo)}';\n" | 1451 " '${set.remove(c.foo)}';\n" |
1450 "}\n"; | 1452 "}\n"; |
1451 | 1453 |
1452 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1454 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1453 EXPECT_VALID(lib); | 1455 EXPECT_VALID(lib); |
1454 | 1456 |
1455 const char* kReloadScript = | 1457 const char* kReloadScript = |
1456 "import 'test:isolate_reload_helper';\n" | 1458 "import 'test:isolate_reload_helper';\n" |
1457 "class C {\n" | 1459 "class C {\n" |
1458 " foo() => 'new';\n" | 1460 " foo() => 'new';\n" |
1459 "}\n" | 1461 "}\n" |
1460 "List list = new List(2);\n" | 1462 "List list = new List(2);\n" |
1461 "Set set = new Set();\n" | 1463 "Set set = new Set();\n" |
1462 "main() {\n" | 1464 "main() {\n" |
1463 " var c = new C();\n" | 1465 " var c = new C();\n" |
1464 " list[0] = c.foo;\n" | 1466 " list[0] = c.foo;\n" |
1465 " list[1] = c#foo;\n" | 1467 " list[1] = c.foo;\n" |
1466 " set.add(c.foo);\n" | 1468 " set.add(c.foo);\n" |
1467 " set.add(c#foo);\n" | 1469 " set.add(c.foo);\n" |
1468 " int countBefore = set.length;\n" | 1470 " int countBefore = set.length;\n" |
1469 " reloadTest();\n" | 1471 " reloadTest();\n" |
1470 " list[1] = c.foo;\n" | 1472 " list[1] = c.foo;\n" |
1471 " set.add(c.foo);\n" | 1473 " set.add(c.foo);\n" |
1472 " set.add(c#foo);\n" | 1474 " set.add(c.foo);\n" |
1473 " int countAfter = set.length;\n" | 1475 " int countAfter = set.length;\n" |
1474 " return '${list[0]()} ${list[1]()} ${list[0] == list[1]} '\n" | 1476 " return '${list[0]()} ${list[1]()} ${list[0] == list[1]} '\n" |
1475 " '${countBefore == 1} ${countAfter == 1} ${(set.first)()} '\n" | 1477 " '${countBefore == 1} ${countAfter == 1} ${(set.first)()} '\n" |
1476 " '${set.first == c.foo} ${set.first == c#foo} '\n" | 1478 " '${set.first == c.foo} ${set.first == c.foo} '\n" |
1477 " '${set.remove(c#foo)}';\n" | 1479 " '${set.remove(c.foo)}';\n" |
1478 "}\n"; | 1480 "}\n"; |
1479 | 1481 |
1480 TestCase::SetReloadTestScript(kReloadScript); | 1482 TestCase::SetReloadTestScript(kReloadScript); |
1481 | 1483 |
1482 EXPECT_STREQ("new new true true true new true true true", | 1484 EXPECT_STREQ("new new true true true new true true true", |
1483 SimpleInvokeStr(lib, "main")); | 1485 SimpleInvokeStr(lib, "main")); |
1484 | 1486 |
1485 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1487 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1486 EXPECT_VALID(lib); | 1488 EXPECT_VALID(lib); |
1487 } | 1489 } |
1488 | 1490 |
1489 | 1491 |
1490 TEST_CASE(IsolateReload_DanglingGetter_Instance) { | 1492 TEST_CASE(IsolateReload_DanglingGetter_Instance) { |
1491 const char* kScript = | 1493 const char* kScript = |
1492 "import 'test:isolate_reload_helper';\n" | 1494 "import 'test:isolate_reload_helper';\n" |
1493 "class C {\n" | 1495 "class C {\n" |
1494 " var x = 3;\n" | 1496 " var x = 3;\n" |
1495 " var y = 4;\n" | 1497 " var y = 4;\n" |
1496 "}\n" | 1498 "}\n" |
1497 "invoke(f) {\n" | 1499 "invoke(f) {\n" |
1498 " try {\n" | 1500 " try {\n" |
1499 " return f();\n" | 1501 " return f();\n" |
1500 " } catch (e) {\n" | 1502 " } catch (e) {\n" |
1501 " return e.toString().split('\\n').first;\n" | 1503 " return e.toString().split('\\n').first;\n" |
1502 " }\n" | 1504 " }\n" |
1503 "}\n" | 1505 "}\n" |
1504 "main() {\n" | 1506 "main() {\n" |
1505 " var c = new C();\n" | 1507 " var c = new C();\n" |
1506 " var f = c#y;\n" | 1508 " var f = c.y;\n" |
1507 " var r1 = invoke(f);\n" | 1509 " var r1 = invoke(f);\n" |
1508 " reloadTest();\n" | 1510 " reloadTest();\n" |
1509 " var r2 = invoke(f);\n" | 1511 " var r2 = invoke(f);\n" |
1510 " return '$r1 $r2';\n" | 1512 " return '$r1 $r2';\n" |
1511 "}\n"; | 1513 "}\n"; |
1512 | 1514 |
1513 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1515 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1514 EXPECT_VALID(lib); | 1516 EXPECT_VALID(lib); |
1515 | 1517 |
1516 const char* kReloadScript = | 1518 const char* kReloadScript = |
1517 "import 'test:isolate_reload_helper';\n" | 1519 "import 'test:isolate_reload_helper';\n" |
1518 "class C {\n" | 1520 "class C {\n" |
1519 " var x = 3;\n" | 1521 " var x = 3;\n" |
1520 "}\n" | 1522 "}\n" |
1521 "invoke(f) {\n" | 1523 "invoke(f) {\n" |
1522 " try {\n" | 1524 " try {\n" |
1523 " return f();\n" | 1525 " return f();\n" |
1524 " } catch (e) {\n" | 1526 " } catch (e) {\n" |
1525 " return e.toString().split('\\n').first;\n" | 1527 " return e.toString().split('\\n').first;\n" |
1526 " }\n" | 1528 " }\n" |
1527 "}\n" | 1529 "}\n" |
1528 "main() {\n" | 1530 "main() {\n" |
1529 " var c = new C();\n" | 1531 " var c = new C();\n" |
1530 " var f = c#y;\n" | 1532 " var f = c.y;\n" |
1531 " var r1 = invoke(f);\n" | 1533 " var r1 = invoke(f);\n" |
1532 " reloadTest();\n" | 1534 " reloadTest();\n" |
1533 " var r2 = invoke(f);\n" | 1535 " var r2 = invoke(f);\n" |
1534 " return '$r1 $r2';\n" | 1536 " return '$r1 $r2';\n" |
1535 "}\n"; | 1537 "}\n"; |
1536 | 1538 |
1537 TestCase::SetReloadTestScript(kReloadScript); | 1539 TestCase::SetReloadTestScript(kReloadScript); |
1538 | 1540 |
1539 EXPECT_STREQ("4 NoSuchMethodError: Class 'C' has no instance getter 'y'.", | 1541 EXPECT_STREQ( |
1540 SimpleInvokeStr(lib, "main")); | 1542 "NoSuchMethodError: Class 'int' has no instance method 'call'. " |
| 1543 "NoSuchMethodError: Class 'int' has no instance method 'call'.", |
| 1544 SimpleInvokeStr(lib, "main")); |
1541 | 1545 |
1542 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1546 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1543 EXPECT_VALID(lib); | 1547 EXPECT_VALID(lib); |
1544 } | 1548 } |
1545 | 1549 |
1546 | 1550 |
1547 TEST_CASE(IsolateReload_DanglingGetter_Class) { | 1551 TEST_CASE(IsolateReload_DanglingGetter_Class) { |
1548 const char* kScript = | 1552 const char* kScript = |
1549 "import 'test:isolate_reload_helper';\n" | 1553 "import 'test:isolate_reload_helper';\n" |
1550 "class C {\n" | 1554 "class C {\n" |
1551 " static var x;\n" | 1555 " static var x;\n" |
1552 " static var y;\n" | 1556 " static var y;\n" |
1553 "}\n" | 1557 "}\n" |
1554 "invoke(f) {\n" | 1558 "invoke(f) {\n" |
1555 " try {\n" | 1559 " try {\n" |
1556 " return f();\n" | 1560 " return f();\n" |
1557 " } catch (e) {\n" | 1561 " } catch (e) {\n" |
1558 " return e.toString().split('\\n').first;\n" | 1562 " return e.toString().split('\\n').first;\n" |
1559 " }\n" | 1563 " }\n" |
1560 "}\n" | 1564 "}\n" |
1561 "main() {\n" | 1565 "main() {\n" |
1562 " C.x = 3;\n" | 1566 " C.x = 3;\n" |
1563 " C.y = 4;\n" | 1567 " C.y = 4;\n" |
1564 " var f = C#y;\n" | 1568 " var f = C.y;\n" |
1565 " var r1 = invoke(f);\n" | 1569 " var r1 = invoke(f);\n" |
1566 " reloadTest();\n" | 1570 " reloadTest();\n" |
1567 " var r2 = invoke(f);\n" | 1571 " var r2 = invoke(f);\n" |
1568 " return '$r1 $r2';\n" | 1572 " return '$r1 $r2';\n" |
1569 "}\n"; | 1573 "}\n"; |
1570 | 1574 |
1571 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1575 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1572 EXPECT_VALID(lib); | 1576 EXPECT_VALID(lib); |
1573 | 1577 |
1574 const char* kReloadScript = | 1578 const char* kReloadScript = |
1575 "import 'test:isolate_reload_helper';\n" | 1579 "import 'test:isolate_reload_helper';\n" |
1576 "class C {\n" | 1580 "class C {\n" |
1577 " static var x;\n" | 1581 " static var x;\n" |
1578 "}\n" | 1582 "}\n" |
1579 "invoke(f) {\n" | 1583 "invoke(f) {\n" |
1580 " try {\n" | 1584 " try {\n" |
1581 " return f();\n" | 1585 " return f();\n" |
1582 " } catch (e) {\n" | 1586 " } catch (e) {\n" |
1583 " return e.toString().split('\\n').first;\n" | 1587 " return e.toString().split('\\n').first;\n" |
1584 " }\n" | 1588 " }\n" |
1585 "}\n" | 1589 "}\n" |
1586 "main() {\n" | 1590 "main() {\n" |
1587 " C.x = 3;\n" | 1591 " C.x = 3;\n" |
1588 " C.y = 4;\n" | 1592 " C.y = 4;\n" |
1589 " var f = C#y;\n" | 1593 " var f = C.y;\n" |
1590 " var r1 = invoke(f);\n" | 1594 " var r1 = invoke(f);\n" |
1591 " reloadTest();\n" | 1595 " reloadTest();\n" |
1592 " var r2 = invoke(f);\n" | 1596 " var r2 = invoke(f);\n" |
1593 " return '$r1 $r2';\n" | 1597 " return '$r1 $r2';\n" |
1594 "}\n"; | 1598 "}\n"; |
1595 | 1599 |
1596 TestCase::SetReloadTestScript(kReloadScript); | 1600 TestCase::SetReloadTestScript(kReloadScript); |
1597 | 1601 |
1598 EXPECT_STREQ( | 1602 EXPECT_STREQ( |
1599 "4 NoSuchMethodError: No static getter 'y' declared " | 1603 "NoSuchMethodError: Class 'int' has no instance method 'call'. " |
1600 "in class 'C'.", | 1604 "NoSuchMethodError: Class 'int' has no instance method 'call'.", |
1601 SimpleInvokeStr(lib, "main")); | 1605 SimpleInvokeStr(lib, "main")); |
1602 | 1606 |
1603 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1607 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1604 EXPECT_VALID(lib); | 1608 EXPECT_VALID(lib); |
1605 } | 1609 } |
1606 | 1610 |
1607 | 1611 |
1608 static void IsolateReload_DanlingGetter_LibraryReload( | 1612 static void IsolateReload_DanlingGetter_LibraryReload( |
1609 Dart_NativeArguments native_args) { | 1613 Dart_NativeArguments native_args) { |
1610 const char* kImportScript2 = "var x;\n"; | 1614 const char* kImportScript2 = "var x;\n"; |
(...skipping 30 matching lines...) Expand all Loading... |
1641 "main() {\n" | 1645 "main() {\n" |
1642 " prefix.x = 3;\n" | 1646 " prefix.x = 3;\n" |
1643 " prefix.y = 4;\n" | 1647 " prefix.y = 4;\n" |
1644 " var f = prefix#y;\n" | 1648 " var f = prefix#y;\n" |
1645 " var r1 = invoke(f);\n" | 1649 " var r1 = invoke(f);\n" |
1646 " reloadTest();\n" | 1650 " reloadTest();\n" |
1647 " var r2 = invoke(f);\n" | 1651 " var r2 = invoke(f);\n" |
1648 " return '$r1 $r2';\n" | 1652 " return '$r1 $r2';\n" |
1649 "}\n"; | 1653 "}\n"; |
1650 | 1654 |
| 1655 FLAG_support_deprecated_tearoff_syntax = true; |
1651 Dart_Handle lib = TestCase::LoadTestScript( | 1656 Dart_Handle lib = TestCase::LoadTestScript( |
1652 kScript, IsolateReload_DanlingGetter_LibraryNativeResolver); | 1657 kScript, IsolateReload_DanlingGetter_LibraryNativeResolver); |
1653 EXPECT_VALID(lib); | 1658 EXPECT_VALID(lib); |
1654 | 1659 |
1655 TestCase::SetReloadTestScript(kScript); // Root library does not change. | 1660 TestCase::SetReloadTestScript(kScript); // Root library does not change. |
1656 | 1661 |
1657 EXPECT_STREQ("4 NoSuchMethodError: No top-level getter 'y' declared.", | 1662 EXPECT_STREQ("4 NoSuchMethodError: No top-level getter 'y' declared.", |
1658 SimpleInvokeStr(lib, "main")); | 1663 SimpleInvokeStr(lib, "main")); |
1659 | 1664 |
1660 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1665 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1661 EXPECT_VALID(lib); | 1666 EXPECT_VALID(lib); |
| 1667 FLAG_support_deprecated_tearoff_syntax = false; |
1662 } | 1668 } |
1663 | 1669 |
1664 | 1670 |
1665 TEST_CASE(IsolateReload_DanglingSetter_Instance) { | 1671 TEST_CASE(IsolateReload_DanglingSetter_Instance) { |
1666 const char* kScript = | 1672 const char* kScript = |
1667 "import 'test:isolate_reload_helper';\n" | 1673 "import 'test:isolate_reload_helper';\n" |
1668 "class C {\n" | 1674 "class C {\n" |
1669 " var x = 3;\n" | 1675 " var x = 3;\n" |
1670 " var y = 4;\n" | 1676 " var y = 4;\n" |
1671 "}\n" | 1677 "}\n" |
1672 "invoke(f, a) {\n" | 1678 "invoke(f, a) {\n" |
1673 " try {\n" | 1679 " try {\n" |
1674 " return f(a);\n" | 1680 " return f(a);\n" |
1675 " } catch (e) {\n" | 1681 " } catch (e) {\n" |
1676 " return e.toString().split('\\n').first;\n" | 1682 " return e.toString().split('\\n').first;\n" |
1677 " }\n" | 1683 " }\n" |
1678 "}\n" | 1684 "}\n" |
1679 "main() {\n" | 1685 "main() {\n" |
1680 " var c = new C();\n" | 1686 " var c = new C();\n" |
1681 " var f = c#y=;\n" | 1687 " var f = c#y=;\n" |
1682 " var r1 = invoke(f, 5);\n" | 1688 " var r1 = invoke(f, 5);\n" |
1683 " reloadTest();\n" | 1689 " reloadTest();\n" |
1684 " var r2 = invoke(f, 6);\n" | 1690 " var r2 = invoke(f, 6);\n" |
1685 " return '$r1 $r2';\n" | 1691 " return '$r1 $r2';\n" |
1686 "}\n"; | 1692 "}\n"; |
1687 | 1693 |
| 1694 FLAG_support_deprecated_tearoff_syntax = true; |
1688 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1695 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1689 EXPECT_VALID(lib); | 1696 EXPECT_VALID(lib); |
1690 | 1697 |
1691 const char* kReloadScript = | 1698 const char* kReloadScript = |
1692 "import 'test:isolate_reload_helper';\n" | 1699 "import 'test:isolate_reload_helper';\n" |
1693 "class C {\n" | 1700 "class C {\n" |
1694 " var x = 3;\n" | 1701 " var x = 3;\n" |
1695 "}\n" | 1702 "}\n" |
1696 "invoke(f, a) {\n" | 1703 "invoke(f, a) {\n" |
1697 " try {\n" | 1704 " try {\n" |
(...skipping 11 matching lines...) Expand all Loading... |
1709 " return '$r1 $r2';\n" | 1716 " return '$r1 $r2';\n" |
1710 "}\n"; | 1717 "}\n"; |
1711 | 1718 |
1712 TestCase::SetReloadTestScript(kReloadScript); | 1719 TestCase::SetReloadTestScript(kReloadScript); |
1713 | 1720 |
1714 EXPECT_STREQ("null NoSuchMethodError: Class 'C' has no instance setter 'y='.", | 1721 EXPECT_STREQ("null NoSuchMethodError: Class 'C' has no instance setter 'y='.", |
1715 SimpleInvokeStr(lib, "main")); | 1722 SimpleInvokeStr(lib, "main")); |
1716 | 1723 |
1717 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1724 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1718 EXPECT_VALID(lib); | 1725 EXPECT_VALID(lib); |
| 1726 FLAG_support_deprecated_tearoff_syntax = false; |
1719 } | 1727 } |
1720 | 1728 |
1721 | 1729 |
1722 TEST_CASE(IsolateReload_DanglingSetter_Class) { | 1730 TEST_CASE(IsolateReload_DanglingSetter_Class) { |
1723 const char* kScript = | 1731 const char* kScript = |
1724 "import 'test:isolate_reload_helper';\n" | 1732 "import 'test:isolate_reload_helper';\n" |
1725 "class C {\n" | 1733 "class C {\n" |
1726 " static var x;\n" | 1734 " static var x;\n" |
1727 " static var y;\n" | 1735 " static var y;\n" |
1728 "}\n" | 1736 "}\n" |
1729 "invoke(f, a) {\n" | 1737 "invoke(f, a) {\n" |
1730 " try {\n" | 1738 " try {\n" |
1731 " return f(a);\n" | 1739 " return f(a);\n" |
1732 " } catch (e) {\n" | 1740 " } catch (e) {\n" |
1733 " return e.toString().split('\\n').first;\n" | 1741 " return e.toString().split('\\n').first;\n" |
1734 " }\n" | 1742 " }\n" |
1735 "}\n" | 1743 "}\n" |
1736 "main() {\n" | 1744 "main() {\n" |
1737 " C.x = 3;\n" | 1745 " C.x = 3;\n" |
1738 " C.y = 4;\n" | 1746 " C.y = 4;\n" |
1739 " var f = C#y=;\n" | 1747 " var f = C#y=;\n" |
1740 " var r1 = invoke(f, 5);\n" | 1748 " var r1 = invoke(f, 5);\n" |
1741 " reloadTest();\n" | 1749 " reloadTest();\n" |
1742 " var r2 = invoke(f, 6);\n" | 1750 " var r2 = invoke(f, 6);\n" |
1743 " return '$r1 $r2';\n" | 1751 " return '$r1 $r2';\n" |
1744 "}\n"; | 1752 "}\n"; |
1745 | 1753 |
| 1754 FLAG_support_deprecated_tearoff_syntax = true; |
1746 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1755 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1747 EXPECT_VALID(lib); | 1756 EXPECT_VALID(lib); |
1748 | 1757 |
1749 const char* kReloadScript = | 1758 const char* kReloadScript = |
1750 "import 'test:isolate_reload_helper';\n" | 1759 "import 'test:isolate_reload_helper';\n" |
1751 "class C {\n" | 1760 "class C {\n" |
1752 " static var x;\n" | 1761 " static var x;\n" |
1753 "}\n" | 1762 "}\n" |
1754 "invoke(f, a) {\n" | 1763 "invoke(f, a) {\n" |
1755 " try {\n" | 1764 " try {\n" |
(...skipping 14 matching lines...) Expand all Loading... |
1770 | 1779 |
1771 TestCase::SetReloadTestScript(kReloadScript); | 1780 TestCase::SetReloadTestScript(kReloadScript); |
1772 | 1781 |
1773 EXPECT_STREQ( | 1782 EXPECT_STREQ( |
1774 "5 NoSuchMethodError: No static setter 'y=' declared in " | 1783 "5 NoSuchMethodError: No static setter 'y=' declared in " |
1775 "class 'C'.", | 1784 "class 'C'.", |
1776 SimpleInvokeStr(lib, "main")); | 1785 SimpleInvokeStr(lib, "main")); |
1777 | 1786 |
1778 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1787 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1779 EXPECT_VALID(lib); | 1788 EXPECT_VALID(lib); |
| 1789 FLAG_support_deprecated_tearoff_syntax = false; |
1780 } | 1790 } |
1781 | 1791 |
1782 | 1792 |
1783 static void IsolateReload_DanlingSetter_LibraryReload( | 1793 static void IsolateReload_DanlingSetter_LibraryReload( |
1784 Dart_NativeArguments native_args) { | 1794 Dart_NativeArguments native_args) { |
1785 const char* kImportScript2 = "var x;\n"; | 1795 const char* kImportScript2 = "var x;\n"; |
1786 TestCase::AddTestLib("test:other", kImportScript2); | 1796 TestCase::AddTestLib("test:other", kImportScript2); |
1787 | 1797 |
1788 DART_CHECK_VALID(TestCase::TriggerReload()); | 1798 DART_CHECK_VALID(TestCase::TriggerReload()); |
1789 } | 1799 } |
(...skipping 26 matching lines...) Expand all Loading... |
1816 "main() {\n" | 1826 "main() {\n" |
1817 " prefix.x = 3;\n" | 1827 " prefix.x = 3;\n" |
1818 " prefix.y = 4;\n" | 1828 " prefix.y = 4;\n" |
1819 " var f = prefix#y=;\n" | 1829 " var f = prefix#y=;\n" |
1820 " var r1 = invoke(f, 5);\n" | 1830 " var r1 = invoke(f, 5);\n" |
1821 " reloadTest();\n" | 1831 " reloadTest();\n" |
1822 " var r2 = invoke(f, 6);\n" | 1832 " var r2 = invoke(f, 6);\n" |
1823 " return '$r1 $r2';\n" | 1833 " return '$r1 $r2';\n" |
1824 "}\n"; | 1834 "}\n"; |
1825 | 1835 |
| 1836 FLAG_support_deprecated_tearoff_syntax = true; |
1826 Dart_Handle lib = TestCase::LoadTestScript( | 1837 Dart_Handle lib = TestCase::LoadTestScript( |
1827 kScript, IsolateReload_DanlingSetter_LibraryNativeResolver); | 1838 kScript, IsolateReload_DanlingSetter_LibraryNativeResolver); |
1828 EXPECT_VALID(lib); | 1839 EXPECT_VALID(lib); |
1829 | 1840 |
1830 TestCase::SetReloadTestScript(kScript); // Root library does not change. | 1841 TestCase::SetReloadTestScript(kScript); // Root library does not change. |
1831 | 1842 |
1832 EXPECT_STREQ("5 NoSuchMethodError: No top-level setter 'y=' declared.", | 1843 EXPECT_STREQ("5 NoSuchMethodError: No top-level setter 'y=' declared.", |
1833 SimpleInvokeStr(lib, "main")); | 1844 SimpleInvokeStr(lib, "main")); |
1834 | 1845 |
1835 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1846 lib = TestCase::GetReloadErrorOrRootLibrary(); |
1836 EXPECT_VALID(lib); | 1847 EXPECT_VALID(lib); |
| 1848 FLAG_support_deprecated_tearoff_syntax = false; |
1837 } | 1849 } |
1838 | 1850 |
1839 | 1851 |
1840 TEST_CASE(IsolateReload_TearOff_AddArguments) { | 1852 TEST_CASE(IsolateReload_TearOff_AddArguments) { |
1841 const char* kScript = | 1853 const char* kScript = |
1842 "import 'test:isolate_reload_helper';\n" | 1854 "import 'test:isolate_reload_helper';\n" |
1843 "class C {\n" | 1855 "class C {\n" |
1844 " foo(x) => x;\n" | 1856 " foo(x) => x;\n" |
1845 "}\n" | 1857 "}\n" |
1846 "invoke(f, a) {\n" | 1858 "invoke(f, a) {\n" |
1847 " try {\n" | 1859 " try {\n" |
1848 " return f(a);\n" | 1860 " return f(a);\n" |
1849 " } catch (e) {\n" | 1861 " } catch (e) {\n" |
1850 " return e.toString().split('\\n').first;\n" | 1862 " return e.toString().split('\\n').first;\n" |
1851 " }\n" | 1863 " }\n" |
1852 "}\n" | 1864 "}\n" |
1853 "main() {\n" | 1865 "main() {\n" |
1854 " var c = new C();\n" | 1866 " var c = new C();\n" |
1855 " var f = c#foo;\n" | 1867 " var f = c.foo;\n" |
1856 " var r1 = invoke(f, 1);\n" | 1868 " var r1 = invoke(f, 1);\n" |
1857 " reloadTest();\n" | 1869 " reloadTest();\n" |
1858 " var r2 = invoke(f, 1);\n" | 1870 " var r2 = invoke(f, 1);\n" |
1859 " return '$r1 $r2';\n" | 1871 " return '$r1 $r2';\n" |
1860 "}\n"; | 1872 "}\n"; |
1861 | 1873 |
1862 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1874 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1863 EXPECT_VALID(lib); | 1875 EXPECT_VALID(lib); |
1864 | 1876 |
1865 const char* kReloadScript = | 1877 const char* kReloadScript = |
1866 "import 'test:isolate_reload_helper';\n" | 1878 "import 'test:isolate_reload_helper';\n" |
1867 "class C {\n" | 1879 "class C {\n" |
1868 " foo(x, y, z) => x + y + z;\n" | 1880 " foo(x, y, z) => x + y + z;\n" |
1869 "}\n" | 1881 "}\n" |
1870 "invoke(f, a) {\n" | 1882 "invoke(f, a) {\n" |
1871 " try {\n" | 1883 " try {\n" |
1872 " return f(a);\n" | 1884 " return f(a);\n" |
1873 " } catch (e) {\n" | 1885 " } catch (e) {\n" |
1874 " return e.toString().split('\\n').first;\n" | 1886 " return e.toString().split('\\n').first;\n" |
1875 " }\n" | 1887 " }\n" |
1876 "}\n" | 1888 "}\n" |
1877 "main() {\n" | 1889 "main() {\n" |
1878 " var c = new C();\n" | 1890 " var c = new C();\n" |
1879 " var f = c#foo;\n" | 1891 " var f = c.foo;\n" |
1880 " var r1 = invoke(f, 1);\n" | 1892 " var r1 = invoke(f, 1);\n" |
1881 " reloadTest();\n" | 1893 " reloadTest();\n" |
1882 " var r2 = invoke(f, 1);\n" | 1894 " var r2 = invoke(f, 1);\n" |
1883 " return '$r1 $r2';\n" | 1895 " return '$r1 $r2';\n" |
1884 "}\n"; | 1896 "}\n"; |
1885 | 1897 |
1886 TestCase::SetReloadTestScript(kReloadScript); | 1898 TestCase::SetReloadTestScript(kReloadScript); |
1887 | 1899 |
1888 EXPECT_STREQ( | 1900 EXPECT_STREQ( |
1889 "1 NoSuchMethodError: Class 'C' has no instance method " | 1901 "1 NoSuchMethodError: Class 'C' has no instance method " |
(...skipping 12 matching lines...) Expand all Loading... |
1902 " static foo(x) => x;\n" | 1914 " static foo(x) => x;\n" |
1903 "}\n" | 1915 "}\n" |
1904 "invoke(f, a) {\n" | 1916 "invoke(f, a) {\n" |
1905 " try {\n" | 1917 " try {\n" |
1906 " return f(a);\n" | 1918 " return f(a);\n" |
1907 " } catch (e) {\n" | 1919 " } catch (e) {\n" |
1908 " return e.toString().split('\\n').first;\n" | 1920 " return e.toString().split('\\n').first;\n" |
1909 " }\n" | 1921 " }\n" |
1910 "}\n" | 1922 "}\n" |
1911 "main() {\n" | 1923 "main() {\n" |
1912 " var f = C#foo;\n" | 1924 " var f = C.foo;\n" |
1913 " var r1 = invoke(f, 1);\n" | 1925 " var r1 = invoke(f, 1);\n" |
1914 " reloadTest();\n" | 1926 " reloadTest();\n" |
1915 " var r2 = invoke(f, 1);\n" | 1927 " var r2 = invoke(f, 1);\n" |
1916 " return '$r1 $r2';\n" | 1928 " return '$r1 $r2';\n" |
1917 "}\n"; | 1929 "}\n"; |
1918 | 1930 |
1919 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1931 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
1920 EXPECT_VALID(lib); | 1932 EXPECT_VALID(lib); |
1921 | 1933 |
1922 const char* kReloadScript = | 1934 const char* kReloadScript = |
1923 "import 'test:isolate_reload_helper';\n" | 1935 "import 'test:isolate_reload_helper';\n" |
1924 "class C {\n" | 1936 "class C {\n" |
1925 " static foo(x, y, z) => x + y + z;\n" | 1937 " static foo(x, y, z) => x + y + z;\n" |
1926 "}\n" | 1938 "}\n" |
1927 "invoke(f, a) {\n" | 1939 "invoke(f, a) {\n" |
1928 " try {\n" | 1940 " try {\n" |
1929 " return f(a);\n" | 1941 " return f(a);\n" |
1930 " } catch (e) {\n" | 1942 " } catch (e) {\n" |
1931 " return e.toString().split('\\n').first;\n" | 1943 " return e.toString().split('\\n').first;\n" |
1932 " }\n" | 1944 " }\n" |
1933 "}\n" | 1945 "}\n" |
1934 "main() {\n" | 1946 "main() {\n" |
1935 " var f = C#foo;\n" | 1947 " var f = C.foo;\n" |
1936 " var r1 = invoke(f, 1);\n" | 1948 " var r1 = invoke(f, 1);\n" |
1937 " reloadTest();\n" | 1949 " reloadTest();\n" |
1938 " var r2 = invoke(f, 1);\n" | 1950 " var r2 = invoke(f, 1);\n" |
1939 " return '$r1 $r2';\n" | 1951 " return '$r1 $r2';\n" |
1940 "}\n"; | 1952 "}\n"; |
1941 | 1953 |
1942 TestCase::SetReloadTestScript(kReloadScript); | 1954 TestCase::SetReloadTestScript(kReloadScript); |
1943 | 1955 |
1944 EXPECT_STREQ( | 1956 EXPECT_STREQ( |
1945 "1 NoSuchMethodError: Closure call with mismatched arguments: " | 1957 "1 NoSuchMethodError: Closure call with mismatched arguments: " |
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3411 lib = TestCase::ReloadTestScript(kReloadScript); | 3423 lib = TestCase::ReloadTestScript(kReloadScript); |
3412 EXPECT_VALID(lib); | 3424 EXPECT_VALID(lib); |
3413 // Verify that we ran field initializers on existing instances in the | 3425 // Verify that we ran field initializers on existing instances in the |
3414 // correct scope. | 3426 // correct scope. |
3415 EXPECT_STREQ("right", SimpleInvokeStr(lib, "main")); | 3427 EXPECT_STREQ("right", SimpleInvokeStr(lib, "main")); |
3416 } | 3428 } |
3417 | 3429 |
3418 #endif // !PRODUCT | 3430 #endif // !PRODUCT |
3419 | 3431 |
3420 } // namespace dart | 3432 } // namespace dart |
OLD | NEW |