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

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

Issue 2405353002: Improvements to NoSuchMethodError.toString (Closed)
Patch Set: Fix for Ryan's comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 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 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 " var c = new C();\n" 1529 " var c = new C();\n"
1530 " var f = c#y;\n" 1530 " var f = c#y;\n"
1531 " var r1 = invoke(f);\n" 1531 " var r1 = invoke(f);\n"
1532 " reloadTest();\n" 1532 " reloadTest();\n"
1533 " var r2 = invoke(f);\n" 1533 " var r2 = invoke(f);\n"
1534 " return '$r1 $r2';\n" 1534 " return '$r1 $r2';\n"
1535 "}\n"; 1535 "}\n";
1536 1536
1537 TestCase::SetReloadTestScript(kReloadScript); 1537 TestCase::SetReloadTestScript(kReloadScript);
1538 1538
1539 EXPECT_STREQ("4 Class 'C' has no instance getter 'y'.", 1539 EXPECT_STREQ("4 NoSuchMethodError: Class 'C' has no instance getter 'y'.",
1540 SimpleInvokeStr(lib, "main")); 1540 SimpleInvokeStr(lib, "main"));
1541 1541
1542 lib = TestCase::GetReloadErrorOrRootLibrary(); 1542 lib = TestCase::GetReloadErrorOrRootLibrary();
1543 EXPECT_VALID(lib); 1543 EXPECT_VALID(lib);
1544 } 1544 }
1545 1545
1546 1546
1547 TEST_CASE(IsolateReload_DanglingGetter_Class) { 1547 TEST_CASE(IsolateReload_DanglingGetter_Class) {
1548 const char* kScript = 1548 const char* kScript =
1549 "import 'test:isolate_reload_helper';\n" 1549 "import 'test:isolate_reload_helper';\n"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 " C.y = 4;\n" 1588 " C.y = 4;\n"
1589 " var f = C#y;\n" 1589 " var f = C#y;\n"
1590 " var r1 = invoke(f);\n" 1590 " var r1 = invoke(f);\n"
1591 " reloadTest();\n" 1591 " reloadTest();\n"
1592 " var r2 = invoke(f);\n" 1592 " var r2 = invoke(f);\n"
1593 " return '$r1 $r2';\n" 1593 " return '$r1 $r2';\n"
1594 "}\n"; 1594 "}\n";
1595 1595
1596 TestCase::SetReloadTestScript(kReloadScript); 1596 TestCase::SetReloadTestScript(kReloadScript);
1597 1597
1598 EXPECT_STREQ("4 No static getter 'y' declared in class 'C'.", 1598 EXPECT_STREQ("4 NoSuchMethodError: No static getter 'y' declared "
1599 SimpleInvokeStr(lib, "main")); 1599 "in class 'C'.", SimpleInvokeStr(lib, "main"));
1600 1600
1601 lib = TestCase::GetReloadErrorOrRootLibrary(); 1601 lib = TestCase::GetReloadErrorOrRootLibrary();
1602 EXPECT_VALID(lib); 1602 EXPECT_VALID(lib);
1603 } 1603 }
1604 1604
1605 1605
1606 static void IsolateReload_DanlingGetter_LibraryReload( 1606 static void IsolateReload_DanlingGetter_LibraryReload(
1607 Dart_NativeArguments native_args) { 1607 Dart_NativeArguments native_args) {
1608 const char* kImportScript2 = 1608 const char* kImportScript2 =
1609 "var x;\n"; 1609 "var x;\n";
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 " var r2 = invoke(f);\n" 1646 " var r2 = invoke(f);\n"
1647 " return '$r1 $r2';\n" 1647 " return '$r1 $r2';\n"
1648 "}\n"; 1648 "}\n";
1649 1649
1650 Dart_Handle lib = TestCase::LoadTestScript( 1650 Dart_Handle lib = TestCase::LoadTestScript(
1651 kScript, IsolateReload_DanlingGetter_LibraryNativeResolver); 1651 kScript, IsolateReload_DanlingGetter_LibraryNativeResolver);
1652 EXPECT_VALID(lib); 1652 EXPECT_VALID(lib);
1653 1653
1654 TestCase::SetReloadTestScript(kScript); // Root library does not change. 1654 TestCase::SetReloadTestScript(kScript); // Root library does not change.
1655 1655
1656 EXPECT_STREQ("4 No top-level getter 'y' declared.", 1656 EXPECT_STREQ("4 NoSuchMethodError: No top-level getter 'y' declared.",
1657 SimpleInvokeStr(lib, "main")); 1657 SimpleInvokeStr(lib, "main"));
1658 1658
1659 lib = TestCase::GetReloadErrorOrRootLibrary(); 1659 lib = TestCase::GetReloadErrorOrRootLibrary();
1660 EXPECT_VALID(lib); 1660 EXPECT_VALID(lib);
1661 } 1661 }
1662 1662
1663 1663
1664 TEST_CASE(IsolateReload_DanglingSetter_Instance) { 1664 TEST_CASE(IsolateReload_DanglingSetter_Instance) {
1665 const char* kScript = 1665 const char* kScript =
1666 "import 'test:isolate_reload_helper';\n" 1666 "import 'test:isolate_reload_helper';\n"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 " var c = new C();\n" 1703 " var c = new C();\n"
1704 " var f = c#y=;\n" 1704 " var f = c#y=;\n"
1705 " var r1 = invoke(f, 5);\n" 1705 " var r1 = invoke(f, 5);\n"
1706 " reloadTest();\n" 1706 " reloadTest();\n"
1707 " var r2 = invoke(f, 6);\n" 1707 " var r2 = invoke(f, 6);\n"
1708 " return '$r1 $r2';\n" 1708 " return '$r1 $r2';\n"
1709 "}\n"; 1709 "}\n";
1710 1710
1711 TestCase::SetReloadTestScript(kReloadScript); 1711 TestCase::SetReloadTestScript(kReloadScript);
1712 1712
1713 EXPECT_STREQ("null Class 'C' has no instance setter 'y='.", 1713 EXPECT_STREQ("null NoSuchMethodError: Class 'C' has no instance setter 'y='.",
1714 SimpleInvokeStr(lib, "main")); 1714 SimpleInvokeStr(lib, "main"));
1715 1715
1716 lib = TestCase::GetReloadErrorOrRootLibrary(); 1716 lib = TestCase::GetReloadErrorOrRootLibrary();
1717 EXPECT_VALID(lib); 1717 EXPECT_VALID(lib);
1718 } 1718 }
1719 1719
1720 1720
1721 TEST_CASE(IsolateReload_DanglingSetter_Class) { 1721 TEST_CASE(IsolateReload_DanglingSetter_Class) {
1722 const char* kScript = 1722 const char* kScript =
1723 "import 'test:isolate_reload_helper';\n" 1723 "import 'test:isolate_reload_helper';\n"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 " C.y = 4;\n" 1762 " C.y = 4;\n"
1763 " var f = C#y=;\n" 1763 " var f = C#y=;\n"
1764 " var r1 = invoke(f, 5);\n" 1764 " var r1 = invoke(f, 5);\n"
1765 " reloadTest();\n" 1765 " reloadTest();\n"
1766 " var r2 = invoke(f, 6);\n" 1766 " var r2 = invoke(f, 6);\n"
1767 " return '$r1 $r2';\n" 1767 " return '$r1 $r2';\n"
1768 "}\n"; 1768 "}\n";
1769 1769
1770 TestCase::SetReloadTestScript(kReloadScript); 1770 TestCase::SetReloadTestScript(kReloadScript);
1771 1771
1772 EXPECT_STREQ("5 No static setter 'y=' declared in class 'C'.", 1772 EXPECT_STREQ("5 NoSuchMethodError: No static setter 'y=' declared in "
1773 SimpleInvokeStr(lib, "main")); 1773 "class 'C'.", SimpleInvokeStr(lib, "main"));
1774 1774
1775 lib = TestCase::GetReloadErrorOrRootLibrary(); 1775 lib = TestCase::GetReloadErrorOrRootLibrary();
1776 EXPECT_VALID(lib); 1776 EXPECT_VALID(lib);
1777 } 1777 }
1778 1778
1779 1779
1780 static void IsolateReload_DanlingSetter_LibraryReload( 1780 static void IsolateReload_DanlingSetter_LibraryReload(
1781 Dart_NativeArguments native_args) { 1781 Dart_NativeArguments native_args) {
1782 const char* kImportScript2 = 1782 const char* kImportScript2 =
1783 "var x;\n"; 1783 "var x;\n";
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 " var r2 = invoke(f, 6);\n" 1820 " var r2 = invoke(f, 6);\n"
1821 " return '$r1 $r2';\n" 1821 " return '$r1 $r2';\n"
1822 "}\n"; 1822 "}\n";
1823 1823
1824 Dart_Handle lib = TestCase::LoadTestScript( 1824 Dart_Handle lib = TestCase::LoadTestScript(
1825 kScript, IsolateReload_DanlingSetter_LibraryNativeResolver); 1825 kScript, IsolateReload_DanlingSetter_LibraryNativeResolver);
1826 EXPECT_VALID(lib); 1826 EXPECT_VALID(lib);
1827 1827
1828 TestCase::SetReloadTestScript(kScript); // Root library does not change. 1828 TestCase::SetReloadTestScript(kScript); // Root library does not change.
1829 1829
1830 EXPECT_STREQ("5 No top-level setter 'y=' declared.", 1830 EXPECT_STREQ("5 NoSuchMethodError: No top-level setter 'y=' declared.",
1831 SimpleInvokeStr(lib, "main")); 1831 SimpleInvokeStr(lib, "main"));
1832 1832
1833 lib = TestCase::GetReloadErrorOrRootLibrary(); 1833 lib = TestCase::GetReloadErrorOrRootLibrary();
1834 EXPECT_VALID(lib); 1834 EXPECT_VALID(lib);
1835 } 1835 }
1836 1836
1837 1837
1838 TEST_CASE(IsolateReload_TearOff_AddArguments) { 1838 TEST_CASE(IsolateReload_TearOff_AddArguments) {
1839 const char* kScript = 1839 const char* kScript =
1840 "import 'test:isolate_reload_helper';\n" 1840 "import 'test:isolate_reload_helper';\n"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 " var c = new C();\n" 1876 " var c = new C();\n"
1877 " var f = c#foo;\n" 1877 " var f = c#foo;\n"
1878 " var r1 = invoke(f, 1);\n" 1878 " var r1 = invoke(f, 1);\n"
1879 " reloadTest();\n" 1879 " reloadTest();\n"
1880 " var r2 = invoke(f, 1);\n" 1880 " var r2 = invoke(f, 1);\n"
1881 " return '$r1 $r2';\n" 1881 " return '$r1 $r2';\n"
1882 "}\n"; 1882 "}\n";
1883 1883
1884 TestCase::SetReloadTestScript(kReloadScript); 1884 TestCase::SetReloadTestScript(kReloadScript);
1885 1885
1886 EXPECT_STREQ("1 Class 'C' has no instance method 'foo' with matching" 1886 EXPECT_STREQ("1 NoSuchMethodError: Class 'C' has no instance method "
1887 " arguments.", SimpleInvokeStr(lib, "main")); 1887 "'foo' with matching arguments.", SimpleInvokeStr(lib, "main"));
1888 1888
1889 lib = TestCase::GetReloadErrorOrRootLibrary(); 1889 lib = TestCase::GetReloadErrorOrRootLibrary();
1890 EXPECT_VALID(lib); 1890 EXPECT_VALID(lib);
1891 } 1891 }
1892 1892
1893 1893
1894 TEST_CASE(IsolateReload_TearOff_AddArguments2) { 1894 TEST_CASE(IsolateReload_TearOff_AddArguments2) {
1895 const char* kScript = 1895 const char* kScript =
1896 "import 'test:isolate_reload_helper';\n" 1896 "import 'test:isolate_reload_helper';\n"
1897 "class C {\n" 1897 "class C {\n"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 "main() {\n" 1930 "main() {\n"
1931 " var f = C#foo;\n" 1931 " var f = C#foo;\n"
1932 " var r1 = invoke(f, 1);\n" 1932 " var r1 = invoke(f, 1);\n"
1933 " reloadTest();\n" 1933 " reloadTest();\n"
1934 " var r2 = invoke(f, 1);\n" 1934 " var r2 = invoke(f, 1);\n"
1935 " return '$r1 $r2';\n" 1935 " return '$r1 $r2';\n"
1936 "}\n"; 1936 "}\n";
1937 1937
1938 TestCase::SetReloadTestScript(kReloadScript); 1938 TestCase::SetReloadTestScript(kReloadScript);
1939 1939
1940 EXPECT_STREQ("1 Closure call with mismatched arguments: function 'C.foo'", 1940 EXPECT_STREQ("1 NoSuchMethodError: Closure call with mismatched arguments: "
1941 SimpleInvokeStr(lib, "main")); 1941 "function 'C.foo'", SimpleInvokeStr(lib, "main"));
1942 1942
1943 lib = TestCase::GetReloadErrorOrRootLibrary(); 1943 lib = TestCase::GetReloadErrorOrRootLibrary();
1944 EXPECT_VALID(lib); 1944 EXPECT_VALID(lib);
1945 } 1945 }
1946 1946
1947 1947
1948 TEST_CASE(IsolateReload_EnumEquality) { 1948 TEST_CASE(IsolateReload_EnumEquality) {
1949 const char* kScript = 1949 const char* kScript =
1950 "enum Fruit {\n" 1950 "enum Fruit {\n"
1951 " Apple,\n" 1951 " Apple,\n"
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after
3079 EXPECT_VALID(lib); 3079 EXPECT_VALID(lib);
3080 Dart_SetFileModifiedCallback(NULL); 3080 Dart_SetFileModifiedCallback(NULL);
3081 3081
3082 // Modification of an exported library propagates. 3082 // Modification of an exported library propagates.
3083 EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main")); 3083 EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main"));
3084 } 3084 }
3085 3085
3086 #endif // !PRODUCT 3086 #endif // !PRODUCT
3087 3087
3088 } // namespace dart 3088 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/errors_patch.dart ('k') | tests/language/vm/no_such_method_error_message_vm_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698