| 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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 EXPECT_STREQ("(a is A(true)/ B(false)/ C(false)/ X(true)," | 641 EXPECT_STREQ("(a is A(true)/ B(false)/ C(false)/ X(true)," |
| 642 " b is A(false)/ B(true)/ C(false)/ X(true)," | 642 " b is A(false)/ B(true)/ C(false)/ X(true)," |
| 643 " c is A(true)/ B(false)/ C(true)/ X(true)," | 643 " c is A(true)/ B(false)/ C(true)/ X(true)," |
| 644 " x is A(false)/ B(false)/ C(false)/ X(true))", | 644 " x is A(false)/ B(false)/ C(false)/ X(true))", |
| 645 SimpleInvokeStr(lib, "main")); | 645 SimpleInvokeStr(lib, "main")); |
| 646 } | 646 } |
| 647 | 647 |
| 648 | 648 |
| 649 TEST_CASE(IsolateReload_LiveStack) { | 649 TEST_CASE(IsolateReload_LiveStack) { |
| 650 const char* kScript = | 650 const char* kScript = |
| 651 "import 'isolate_reload_test_helper';\n" | 651 "import 'test:isolate_reload_helper';\n" |
| 652 "helper() => 7;\n" | 652 "helper() => 7;\n" |
| 653 "alpha() { var x = helper(); reloadTest(); return x + helper(); }\n" | 653 "alpha() { var x = helper(); reloadTest(); return x + helper(); }\n" |
| 654 "foo() => alpha();\n" | 654 "foo() => alpha();\n" |
| 655 "bar() => foo();\n" | 655 "bar() => foo();\n" |
| 656 "main() {\n" | 656 "main() {\n" |
| 657 " return bar();\n" | 657 " return bar();\n" |
| 658 "}\n"; | 658 "}\n"; |
| 659 | 659 |
| 660 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 660 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 661 EXPECT_VALID(lib); | 661 EXPECT_VALID(lib); |
| 662 | 662 |
| 663 const char* kReloadScript = | 663 const char* kReloadScript = |
| 664 "import 'isolate_reload_test_helper';\n" | 664 "import 'test:isolate_reload_helper';\n" |
| 665 "helper() => 100;\n" | 665 "helper() => 100;\n" |
| 666 "alpha() => 5 + helper();\n" | 666 "alpha() => 5 + helper();\n" |
| 667 "foo() => alpha();\n" | 667 "foo() => alpha();\n" |
| 668 "bar() => foo();\n" | 668 "bar() => foo();\n" |
| 669 "main() {\n" | 669 "main() {\n" |
| 670 " return bar();\n" | 670 " return bar();\n" |
| 671 "}\n"; | 671 "}\n"; |
| 672 | 672 |
| 673 TestCase::SetReloadTestScript(kReloadScript); | 673 TestCase::SetReloadTestScript(kReloadScript); |
| 674 | 674 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 687 " return importedFunc();\n" | 687 " return importedFunc();\n" |
| 688 "}\n"; | 688 "}\n"; |
| 689 | 689 |
| 690 Dart_Handle result; | 690 Dart_Handle result; |
| 691 | 691 |
| 692 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 692 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 693 EXPECT_VALID(lib); | 693 EXPECT_VALID(lib); |
| 694 | 694 |
| 695 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); | 695 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); |
| 696 | 696 |
| 697 // Fail to find 'importable_test_lib' in the isolate. | 697 // Fail to find 'test:importable_lib' in the isolate. |
| 698 result = Dart_LookupLibrary(NewString("importable_test_lib")); | 698 result = Dart_LookupLibrary(NewString("test:importable_lib")); |
| 699 EXPECT(Dart_IsError(result)); | 699 EXPECT(Dart_IsError(result)); |
| 700 | 700 |
| 701 const char* kReloadScript = | 701 const char* kReloadScript = |
| 702 "import 'importable_test_lib';\n" | 702 "import 'test:importable_lib';\n" |
| 703 "main() {\n" | 703 "main() {\n" |
| 704 " return importedFunc();\n" | 704 " return importedFunc();\n" |
| 705 "}\n"; | 705 "}\n"; |
| 706 | 706 |
| 707 // Reload and add 'importable_test_lib' to isolate. | 707 // Reload and add 'test:importable_lib' to isolate. |
| 708 lib = TestCase::ReloadTestScript(kReloadScript); | 708 lib = TestCase::ReloadTestScript(kReloadScript); |
| 709 EXPECT_VALID(lib); | 709 EXPECT_VALID(lib); |
| 710 | 710 |
| 711 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); | 711 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); |
| 712 | 712 |
| 713 // Find 'importable_test_lib' in the isolate. | 713 // Find 'test:importable_lib' in the isolate. |
| 714 result = Dart_LookupLibrary(NewString("importable_test_lib")); | 714 result = Dart_LookupLibrary(NewString("test:importable_lib")); |
| 715 EXPECT(Dart_IsLibrary(result)); | 715 EXPECT(Dart_IsLibrary(result)); |
| 716 | 716 |
| 717 // Reload and remove 'dart:math' from isolate. | 717 // Reload and remove 'dart:math' from isolate. |
| 718 lib = TestCase::ReloadTestScript(kScript); | 718 lib = TestCase::ReloadTestScript(kScript); |
| 719 EXPECT_VALID(lib); | 719 EXPECT_VALID(lib); |
| 720 | 720 |
| 721 // Fail to find 'importable_test_lib' in the isolate. | 721 // Fail to find 'test:importable_lib' in the isolate. |
| 722 result = Dart_LookupLibrary(NewString("importable_test_lib")); | 722 result = Dart_LookupLibrary(NewString("test:importable_lib")); |
| 723 EXPECT(Dart_IsError(result)); | 723 EXPECT(Dart_IsError(result)); |
| 724 } | 724 } |
| 725 | 725 |
| 726 | 726 |
| 727 TEST_CASE(IsolateReload_LibraryHide) { | 727 TEST_CASE(IsolateReload_LibraryHide) { |
| 728 // Import 'importable_test_lib' with importedFunc hidden. Will result in an | 728 // Import 'test:importable_lib' with importedFunc hidden. Will result in an |
| 729 // error. | 729 // error. |
| 730 const char* kScript = | 730 const char* kScript = |
| 731 "import 'importable_test_lib' hide importedFunc;\n" | 731 "import 'test:importable_lib' hide importedFunc;\n" |
| 732 "main() {\n" | 732 "main() {\n" |
| 733 " return importedFunc();\n" | 733 " return importedFunc();\n" |
| 734 "}\n"; | 734 "}\n"; |
| 735 | 735 |
| 736 // Dart_Handle result; | 736 // Dart_Handle result; |
| 737 | 737 |
| 738 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 738 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 739 EXPECT_VALID(lib); | 739 EXPECT_VALID(lib); |
| 740 | 740 |
| 741 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); | 741 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); |
| 742 | 742 |
| 743 // Import 'importable_test_lib'. | 743 // Import 'test:importable_lib'. |
| 744 const char* kReloadScript = | 744 const char* kReloadScript = |
| 745 "import 'importable_test_lib';\n" | 745 "import 'test:importable_lib';\n" |
| 746 "main() {\n" | 746 "main() {\n" |
| 747 " return importedFunc();\n" | 747 " return importedFunc();\n" |
| 748 "}\n"; | 748 "}\n"; |
| 749 | 749 |
| 750 lib = TestCase::ReloadTestScript(kReloadScript); | 750 lib = TestCase::ReloadTestScript(kReloadScript); |
| 751 EXPECT_VALID(lib); | 751 EXPECT_VALID(lib); |
| 752 | 752 |
| 753 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); | 753 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); |
| 754 } | 754 } |
| 755 | 755 |
| 756 | 756 |
| 757 TEST_CASE(IsolateReload_LibraryShow) { | 757 TEST_CASE(IsolateReload_LibraryShow) { |
| 758 // Import 'importable_test_lib' with importedIntFunc visible. Will result in | 758 // Import 'test:importable_lib' with importedIntFunc visible. Will result in |
| 759 // an error when 'main' is invoked. | 759 // an error when 'main' is invoked. |
| 760 const char* kScript = | 760 const char* kScript = |
| 761 "import 'importable_test_lib' show importedIntFunc;\n" | 761 "import 'test:importable_lib' show importedIntFunc;\n" |
| 762 "main() {\n" | 762 "main() {\n" |
| 763 " return importedFunc();\n" | 763 " return importedFunc();\n" |
| 764 "}\n" | 764 "}\n" |
| 765 "mainInt() {\n" | 765 "mainInt() {\n" |
| 766 " return importedIntFunc();\n" | 766 " return importedIntFunc();\n" |
| 767 "}\n"; | 767 "}\n"; |
| 768 | 768 |
| 769 | 769 |
| 770 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 770 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 771 EXPECT_VALID(lib); | 771 EXPECT_VALID(lib); |
| 772 | 772 |
| 773 // Works. | 773 // Works. |
| 774 EXPECT_EQ(4, SimpleInvoke(lib, "mainInt")); | 774 EXPECT_EQ(4, SimpleInvoke(lib, "mainInt")); |
| 775 // Results in an error. | 775 // Results in an error. |
| 776 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); | 776 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); |
| 777 | 777 |
| 778 // Import 'importable_test_lib' with importedFunc visible. Will result in | 778 // Import 'test:importable_lib' with importedFunc visible. Will result in |
| 779 // an error when 'mainInt' is invoked. | 779 // an error when 'mainInt' is invoked. |
| 780 const char* kReloadScript = | 780 const char* kReloadScript = |
| 781 "import 'importable_test_lib' show importedFunc;\n" | 781 "import 'test:importable_lib' show importedFunc;\n" |
| 782 "main() {\n" | 782 "main() {\n" |
| 783 " return importedFunc();\n" | 783 " return importedFunc();\n" |
| 784 "}\n" | 784 "}\n" |
| 785 "mainInt() {\n" | 785 "mainInt() {\n" |
| 786 " return importedIntFunc();\n" | 786 " return importedIntFunc();\n" |
| 787 "}\n"; | 787 "}\n"; |
| 788 | 788 |
| 789 lib = TestCase::ReloadTestScript(kReloadScript); | 789 lib = TestCase::ReloadTestScript(kReloadScript); |
| 790 EXPECT_VALID(lib); | 790 EXPECT_VALID(lib); |
| 791 | 791 |
| 792 // Works. | 792 // Works. |
| 793 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); | 793 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); |
| 794 // Results in an error. | 794 // Results in an error. |
| 795 EXPECT_ERROR(SimpleInvokeError(lib, "mainInt"), "importedIntFunc"); | 795 EXPECT_ERROR(SimpleInvokeError(lib, "mainInt"), "importedIntFunc"); |
| 796 } | 796 } |
| 797 | 797 |
| 798 | 798 |
| 799 // Verifies that we clear the ICs for the functions live on the stack in a way | 799 // Verifies that we clear the ICs for the functions live on the stack in a way |
| 800 // that is compatible with the fast path smi stubs. | 800 // that is compatible with the fast path smi stubs. |
| 801 TEST_CASE(IsolateReload_SmiFastPathStubs) { | 801 TEST_CASE(IsolateReload_SmiFastPathStubs) { |
| 802 const char* kScript = | 802 const char* kScript = |
| 803 "import 'isolate_reload_test_helper';\n" | 803 "import 'test:isolate_reload_helper';\n" |
| 804 "import 'importable_test_lib' show importedIntFunc;\n" | 804 "import 'test:importable_lib' show importedIntFunc;\n" |
| 805 "main() {\n" | 805 "main() {\n" |
| 806 " var x = importedIntFunc();\n" | 806 " var x = importedIntFunc();\n" |
| 807 " var y = importedIntFunc();\n" | 807 " var y = importedIntFunc();\n" |
| 808 " reloadTest();\n" | 808 " reloadTest();\n" |
| 809 " return x + y;\n" | 809 " return x + y;\n" |
| 810 "}\n"; | 810 "}\n"; |
| 811 | 811 |
| 812 | 812 |
| 813 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 813 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 814 EXPECT_VALID(lib); | 814 EXPECT_VALID(lib); |
| 815 | 815 |
| 816 // Identity reload. | 816 // Identity reload. |
| 817 TestCase::SetReloadTestScript(kScript); | 817 TestCase::SetReloadTestScript(kScript); |
| 818 | 818 |
| 819 EXPECT_EQ(8, SimpleInvoke(lib, "main")); | 819 EXPECT_EQ(8, SimpleInvoke(lib, "main")); |
| 820 } | 820 } |
| 821 | 821 |
| 822 | 822 |
| 823 // Verifies that we assign the correct patch classes for imported | 823 // Verifies that we assign the correct patch classes for imported |
| 824 // mixins when we reload. | 824 // mixins when we reload. |
| 825 TEST_CASE(IsolateReload_ImportedMixinFunction) { | 825 TEST_CASE(IsolateReload_ImportedMixinFunction) { |
| 826 const char* kScript = | 826 const char* kScript = |
| 827 "import 'importable_test_lib' show ImportedMixin;\n" | 827 "import 'test:importable_lib' show ImportedMixin;\n" |
| 828 "class A extends Object with ImportedMixin {\n" | 828 "class A extends Object with ImportedMixin {\n" |
| 829 "}" | 829 "}" |
| 830 "var func = new A().mixinFunc;\n" | 830 "var func = new A().mixinFunc;\n" |
| 831 "main() {\n" | 831 "main() {\n" |
| 832 " return func();\n" | 832 " return func();\n" |
| 833 "}\n"; | 833 "}\n"; |
| 834 | 834 |
| 835 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 835 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 836 EXPECT_VALID(lib); | 836 EXPECT_VALID(lib); |
| 837 | 837 |
| 838 EXPECT_STREQ("mixin", SimpleInvokeStr(lib, "main")); | 838 EXPECT_STREQ("mixin", SimpleInvokeStr(lib, "main")); |
| 839 | 839 |
| 840 const char* kReloadScript = | 840 const char* kReloadScript = |
| 841 "import 'importable_test_lib' show ImportedMixin;\n" | 841 "import 'test:importable_lib' show ImportedMixin;\n" |
| 842 "class A extends Object with ImportedMixin {\n" | 842 "class A extends Object with ImportedMixin {\n" |
| 843 "}" | 843 "}" |
| 844 "var func;\n" | 844 "var func;\n" |
| 845 "main() {\n" | 845 "main() {\n" |
| 846 " return func();\n" | 846 " return func();\n" |
| 847 "}\n"; | 847 "}\n"; |
| 848 | 848 |
| 849 lib = TestCase::ReloadTestScript(kReloadScript); | 849 lib = TestCase::ReloadTestScript(kReloadScript); |
| 850 EXPECT_VALID(lib); | 850 EXPECT_VALID(lib); |
| 851 | 851 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 870 " return 4;\n" | 870 " return 4;\n" |
| 871 "}\n"; | 871 "}\n"; |
| 872 | 872 |
| 873 lib = TestCase::ReloadTestScript(kReloadScript); | 873 lib = TestCase::ReloadTestScript(kReloadScript); |
| 874 EXPECT_ERROR(lib, "unexpected token"); | 874 EXPECT_ERROR(lib, "unexpected token"); |
| 875 } | 875 } |
| 876 | 876 |
| 877 | 877 |
| 878 TEST_CASE(IsolateReload_PendingUnqualifiedCall_StaticToInstance) { | 878 TEST_CASE(IsolateReload_PendingUnqualifiedCall_StaticToInstance) { |
| 879 const char* kScript = | 879 const char* kScript = |
| 880 "import 'isolate_reload_test_helper';\n" | 880 "import 'test:isolate_reload_helper';\n" |
| 881 "class C {\n" | 881 "class C {\n" |
| 882 " static foo() => 'static';\n" | 882 " static foo() => 'static';\n" |
| 883 " test() {\n" | 883 " test() {\n" |
| 884 " reloadTest();\n" | 884 " reloadTest();\n" |
| 885 " return foo();\n" | 885 " return foo();\n" |
| 886 " }\n" | 886 " }\n" |
| 887 "}\n" | 887 "}\n" |
| 888 "main() {\n" | 888 "main() {\n" |
| 889 " return new C().test();\n" | 889 " return new C().test();\n" |
| 890 "}\n"; | 890 "}\n"; |
| 891 | 891 |
| 892 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 892 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 893 EXPECT_VALID(lib); | 893 EXPECT_VALID(lib); |
| 894 | 894 |
| 895 const char* kReloadScript = | 895 const char* kReloadScript = |
| 896 "import 'isolate_reload_test_helper';\n" | 896 "import 'test:isolate_reload_helper';\n" |
| 897 "class C {\n" | 897 "class C {\n" |
| 898 " foo() => 'instance';\n" | 898 " foo() => 'instance';\n" |
| 899 " test() {\n" | 899 " test() {\n" |
| 900 " reloadTest();\n" | 900 " reloadTest();\n" |
| 901 " return foo();\n" | 901 " return foo();\n" |
| 902 " }\n" | 902 " }\n" |
| 903 "}\n" | 903 "}\n" |
| 904 "main() {\n" | 904 "main() {\n" |
| 905 " return new C().test();\n" | 905 " return new C().test();\n" |
| 906 "}\n"; | 906 "}\n"; |
| 907 | 907 |
| 908 TestCase::SetReloadTestScript(kReloadScript); | 908 TestCase::SetReloadTestScript(kReloadScript); |
| 909 | 909 |
| 910 EXPECT_EQ("instance", SimpleInvokeStr(lib, "main")); | 910 EXPECT_EQ("instance", SimpleInvokeStr(lib, "main")); |
| 911 | 911 |
| 912 lib = TestCase::GetReloadErrorOrRootLibrary(); | 912 lib = TestCase::GetReloadErrorOrRootLibrary(); |
| 913 EXPECT_VALID(lib); | 913 EXPECT_VALID(lib); |
| 914 | 914 |
| 915 EXPECT_EQ("instance", SimpleInvokeStr(lib, "main")); | 915 EXPECT_EQ("instance", SimpleInvokeStr(lib, "main")); |
| 916 } | 916 } |
| 917 | 917 |
| 918 | 918 |
| 919 TEST_CASE(IsolateReload_PendingUnqualifiedCall_InstanceToStatic) { | 919 TEST_CASE(IsolateReload_PendingUnqualifiedCall_InstanceToStatic) { |
| 920 const char* kScript = | 920 const char* kScript = |
| 921 "import 'isolate_reload_test_helper';\n" | 921 "import 'test:isolate_reload_helper';\n" |
| 922 "class C {\n" | 922 "class C {\n" |
| 923 " foo() => 'instance';\n" | 923 " foo() => 'instance';\n" |
| 924 " test() {\n" | 924 " test() {\n" |
| 925 " reloadTest();\n" | 925 " reloadTest();\n" |
| 926 " return foo();\n" | 926 " return foo();\n" |
| 927 " }\n" | 927 " }\n" |
| 928 "}\n" | 928 "}\n" |
| 929 "main() {\n" | 929 "main() {\n" |
| 930 " return new C().test();\n" | 930 " return new C().test();\n" |
| 931 "}\n"; | 931 "}\n"; |
| 932 | 932 |
| 933 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 933 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 934 EXPECT_VALID(lib); | 934 EXPECT_VALID(lib); |
| 935 | 935 |
| 936 const char* kReloadScript = | 936 const char* kReloadScript = |
| 937 "import 'isolate_reload_test_helper';\n" | 937 "import 'test:isolate_reload_helper';\n" |
| 938 "class C {\n" | 938 "class C {\n" |
| 939 " static foo() => 'static';\n" | 939 " static foo() => 'static';\n" |
| 940 " test() {\n" | 940 " test() {\n" |
| 941 " reloadTest();\n" | 941 " reloadTest();\n" |
| 942 " return foo();\n" | 942 " return foo();\n" |
| 943 " }\n" | 943 " }\n" |
| 944 "}\n" | 944 "}\n" |
| 945 "main() {\n" | 945 "main() {\n" |
| 946 " return new C().test();\n" | 946 " return new C().test();\n" |
| 947 "}\n"; | 947 "}\n"; |
| 948 | 948 |
| 949 TestCase::SetReloadTestScript(kReloadScript); | 949 TestCase::SetReloadTestScript(kReloadScript); |
| 950 | 950 |
| 951 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); | 951 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); |
| 952 | 952 |
| 953 lib = TestCase::GetReloadErrorOrRootLibrary(); | 953 lib = TestCase::GetReloadErrorOrRootLibrary(); |
| 954 EXPECT_VALID(lib); | 954 EXPECT_VALID(lib); |
| 955 | 955 |
| 956 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); | 956 EXPECT_EQ("static", SimpleInvokeStr(lib, "main")); |
| 957 } | 957 } |
| 958 | 958 |
| 959 | 959 |
| 960 TEST_CASE(IsolateReload_PendingConstructorCall_AbstractToConcrete) { | 960 TEST_CASE(IsolateReload_PendingConstructorCall_AbstractToConcrete) { |
| 961 const char* kScript = | 961 const char* kScript = |
| 962 "import 'isolate_reload_test_helper';\n" | 962 "import 'test:isolate_reload_helper';\n" |
| 963 "abstract class Foo {}\n" | 963 "abstract class Foo {}\n" |
| 964 "class C {\n" | 964 "class C {\n" |
| 965 " test() {\n" | 965 " test() {\n" |
| 966 " reloadTest();\n" | 966 " reloadTest();\n" |
| 967 " return new Foo();\n" | 967 " return new Foo();\n" |
| 968 " }\n" | 968 " }\n" |
| 969 "}\n" | 969 "}\n" |
| 970 "main() {\n" | 970 "main() {\n" |
| 971 " try {\n" | 971 " try {\n" |
| 972 " new C().test();\n" | 972 " new C().test();\n" |
| 973 " return 'okay';\n" | 973 " return 'okay';\n" |
| 974 " } catch (e) {\n" | 974 " } catch (e) {\n" |
| 975 " return 'exception';\n" | 975 " return 'exception';\n" |
| 976 " }\n" | 976 " }\n" |
| 977 "}\n"; | 977 "}\n"; |
| 978 | 978 |
| 979 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 979 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 980 EXPECT_VALID(lib); | 980 EXPECT_VALID(lib); |
| 981 | 981 |
| 982 const char* kReloadScript = | 982 const char* kReloadScript = |
| 983 "import 'isolate_reload_test_helper';\n" | 983 "import 'test:isolate_reload_helper';\n" |
| 984 "class Foo {}\n" | 984 "class Foo {}\n" |
| 985 "class C {\n" | 985 "class C {\n" |
| 986 " test() {\n" | 986 " test() {\n" |
| 987 " reloadTest();\n" | 987 " reloadTest();\n" |
| 988 " return new Foo();\n" | 988 " return new Foo();\n" |
| 989 " }\n" | 989 " }\n" |
| 990 "}\n" | 990 "}\n" |
| 991 "main() {\n" | 991 "main() {\n" |
| 992 " try {\n" | 992 " try {\n" |
| 993 " new C().test();\n" | 993 " new C().test();\n" |
| 994 " return 'okay';\n" | 994 " return 'okay';\n" |
| 995 " } catch (e) {\n" | 995 " } catch (e) {\n" |
| 996 " return 'exception';\n" | 996 " return 'exception';\n" |
| 997 " }\n" | 997 " }\n" |
| 998 "}\n"; | 998 "}\n"; |
| 999 | 999 |
| 1000 TestCase::SetReloadTestScript(kReloadScript); | 1000 TestCase::SetReloadTestScript(kReloadScript); |
| 1001 | 1001 |
| 1002 EXPECT_EQ("okay", SimpleInvokeStr(lib, "main")); | 1002 EXPECT_EQ("okay", SimpleInvokeStr(lib, "main")); |
| 1003 | 1003 |
| 1004 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1004 lib = TestCase::GetReloadErrorOrRootLibrary(); |
| 1005 EXPECT_VALID(lib); | 1005 EXPECT_VALID(lib); |
| 1006 | 1006 |
| 1007 EXPECT_EQ("okay", SimpleInvokeStr(lib, "main")); | 1007 EXPECT_EQ("okay", SimpleInvokeStr(lib, "main")); |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 | 1010 |
| 1011 TEST_CASE(IsolateReload_PendingConstructorCall_ConcreteToAbstract) { | 1011 TEST_CASE(IsolateReload_PendingConstructorCall_ConcreteToAbstract) { |
| 1012 const char* kScript = | 1012 const char* kScript = |
| 1013 "import 'isolate_reload_test_helper';\n" | 1013 "import 'test:isolate_reload_helper';\n" |
| 1014 "class Foo {}\n" | 1014 "class Foo {}\n" |
| 1015 "class C {\n" | 1015 "class C {\n" |
| 1016 " test() {\n" | 1016 " test() {\n" |
| 1017 " reloadTest();\n" | 1017 " reloadTest();\n" |
| 1018 " return new Foo();\n" | 1018 " return new Foo();\n" |
| 1019 " }\n" | 1019 " }\n" |
| 1020 "}\n" | 1020 "}\n" |
| 1021 "main() {\n" | 1021 "main() {\n" |
| 1022 " try {\n" | 1022 " try {\n" |
| 1023 " new C().test();\n" | 1023 " new C().test();\n" |
| 1024 " return 'okay';\n" | 1024 " return 'okay';\n" |
| 1025 " } catch (e) {\n" | 1025 " } catch (e) {\n" |
| 1026 " return 'exception';\n" | 1026 " return 'exception';\n" |
| 1027 " }\n" | 1027 " }\n" |
| 1028 "}\n"; | 1028 "}\n"; |
| 1029 | 1029 |
| 1030 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1030 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 1031 EXPECT_VALID(lib); | 1031 EXPECT_VALID(lib); |
| 1032 | 1032 |
| 1033 const char* kReloadScript = | 1033 const char* kReloadScript = |
| 1034 "import 'isolate_reload_test_helper';\n" | 1034 "import 'test:isolate_reload_helper';\n" |
| 1035 "abstract class Foo {}\n" | 1035 "abstract class Foo {}\n" |
| 1036 "class C {\n" | 1036 "class C {\n" |
| 1037 " test() {\n" | 1037 " test() {\n" |
| 1038 " reloadTest();\n" | 1038 " reloadTest();\n" |
| 1039 " return new Foo();\n" | 1039 " return new Foo();\n" |
| 1040 " }\n" | 1040 " }\n" |
| 1041 "}\n" | 1041 "}\n" |
| 1042 "main() {\n" | 1042 "main() {\n" |
| 1043 " try {\n" | 1043 " try {\n" |
| 1044 " new C().test();\n" | 1044 " new C().test();\n" |
| 1045 " return 'okay';\n" | 1045 " return 'okay';\n" |
| 1046 " } catch (e) {\n" | 1046 " } catch (e) {\n" |
| 1047 " return 'exception';\n" | 1047 " return 'exception';\n" |
| 1048 " }\n" | 1048 " }\n" |
| 1049 "}\n"; | 1049 "}\n"; |
| 1050 | 1050 |
| 1051 TestCase::SetReloadTestScript(kReloadScript); | 1051 TestCase::SetReloadTestScript(kReloadScript); |
| 1052 | 1052 |
| 1053 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); | 1053 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); |
| 1054 | 1054 |
| 1055 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1055 lib = TestCase::GetReloadErrorOrRootLibrary(); |
| 1056 EXPECT_VALID(lib); | 1056 EXPECT_VALID(lib); |
| 1057 | 1057 |
| 1058 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); | 1058 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 | 1061 |
| 1062 TEST_CASE(IsolateReload_PendingStaticCall_DefinedToNSM) { | 1062 TEST_CASE(IsolateReload_PendingStaticCall_DefinedToNSM) { |
| 1063 const char* kScript = | 1063 const char* kScript = |
| 1064 "import 'isolate_reload_test_helper';\n" | 1064 "import 'test:isolate_reload_helper';\n" |
| 1065 "class C {\n" | 1065 "class C {\n" |
| 1066 " static foo() => 'static'\n" | 1066 " static foo() => 'static'\n" |
| 1067 " test() {\n" | 1067 " test() {\n" |
| 1068 " reloadTest();\n" | 1068 " reloadTest();\n" |
| 1069 " return C.foo();\n" | 1069 " return C.foo();\n" |
| 1070 " }\n" | 1070 " }\n" |
| 1071 "}\n" | 1071 "}\n" |
| 1072 "main() {\n" | 1072 "main() {\n" |
| 1073 " try {\n" | 1073 " try {\n" |
| 1074 " return new C().test();\n" | 1074 " return new C().test();\n" |
| 1075 " } catch (e) {\n" | 1075 " } catch (e) {\n" |
| 1076 " return 'exception';\n" | 1076 " return 'exception';\n" |
| 1077 " }\n" | 1077 " }\n" |
| 1078 "}\n"; | 1078 "}\n"; |
| 1079 | 1079 |
| 1080 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1080 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 1081 EXPECT_VALID(lib); | 1081 EXPECT_VALID(lib); |
| 1082 | 1082 |
| 1083 const char* kReloadScript = | 1083 const char* kReloadScript = |
| 1084 "import 'isolate_reload_test_helper';\n" | 1084 "import 'test:isolate_reload_helper';\n" |
| 1085 "class C {\n" | 1085 "class C {\n" |
| 1086 " test() {\n" | 1086 " test() {\n" |
| 1087 " reloadTest();\n" | 1087 " reloadTest();\n" |
| 1088 " return C.foo();\n" | 1088 " return C.foo();\n" |
| 1089 " }\n" | 1089 " }\n" |
| 1090 "}\n" | 1090 "}\n" |
| 1091 "main() {\n" | 1091 "main() {\n" |
| 1092 " try {\n" | 1092 " try {\n" |
| 1093 " return new C().test();\n" | 1093 " return new C().test();\n" |
| 1094 " } catch (e) {\n" | 1094 " } catch (e) {\n" |
| 1095 " return 'exception';\n" | 1095 " return 'exception';\n" |
| 1096 " }\n" | 1096 " }\n" |
| 1097 "}\n"; | 1097 "}\n"; |
| 1098 | 1098 |
| 1099 TestCase::SetReloadTestScript(kReloadScript); | 1099 TestCase::SetReloadTestScript(kReloadScript); |
| 1100 | 1100 |
| 1101 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); | 1101 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); |
| 1102 | 1102 |
| 1103 lib = TestCase::GetReloadErrorOrRootLibrary(); | 1103 lib = TestCase::GetReloadErrorOrRootLibrary(); |
| 1104 EXPECT_VALID(lib); | 1104 EXPECT_VALID(lib); |
| 1105 | 1105 |
| 1106 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); | 1106 EXPECT_EQ("exception", SimpleInvokeStr(lib, "main")); |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 | 1109 |
| 1110 TEST_CASE(IsolateReload_PendingStaticCall_NSMToDefined) { | 1110 TEST_CASE(IsolateReload_PendingStaticCall_NSMToDefined) { |
| 1111 const char* kScript = | 1111 const char* kScript = |
| 1112 "import 'isolate_reload_test_helper';\n" | 1112 "import 'test:isolate_reload_helper';\n" |
| 1113 "class C {\n" | 1113 "class C {\n" |
| 1114 " test() {\n" | 1114 " test() {\n" |
| 1115 " reloadTest();\n" | 1115 " reloadTest();\n" |
| 1116 " return C.foo();\n" | 1116 " return C.foo();\n" |
| 1117 " }\n" | 1117 " }\n" |
| 1118 "}\n" | 1118 "}\n" |
| 1119 "main() {\n" | 1119 "main() {\n" |
| 1120 " try {\n" | 1120 " try {\n" |
| 1121 " return new C().test();\n" | 1121 " return new C().test();\n" |
| 1122 " } catch (e) {\n" | 1122 " } catch (e) {\n" |
| 1123 " return 'exception';\n" | 1123 " return 'exception';\n" |
| 1124 " }\n" | 1124 " }\n" |
| 1125 "}\n"; | 1125 "}\n"; |
| 1126 | 1126 |
| 1127 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); | 1127 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); |
| 1128 EXPECT_VALID(lib); | 1128 EXPECT_VALID(lib); |
| 1129 | 1129 |
| 1130 const char* kReloadScript = | 1130 const char* kReloadScript = |
| 1131 "import 'isolate_reload_test_helper';\n" | 1131 "import 'test:isolate_reload_helper';\n" |
| 1132 "class C {\n" | 1132 "class C {\n" |
| 1133 " static foo() => 'static'\n" | 1133 " static foo() => 'static'\n" |
| 1134 " test() {\n" | 1134 " test() {\n" |
| 1135 " reloadTest();\n" | 1135 " reloadTest();\n" |
| 1136 " return C.foo();\n" | 1136 " return C.foo();\n" |
| 1137 " }\n" | 1137 " }\n" |
| 1138 "}\n" | 1138 "}\n" |
| 1139 "main() {\n" | 1139 "main() {\n" |
| 1140 " try {\n" | 1140 " try {\n" |
| 1141 " return new C().test();\n" | 1141 " return new C().test();\n" |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 | 1823 |
| 1824 // ...and the non-core subclass is still named AIterator. | 1824 // ...and the non-core subclass is still named AIterator. |
| 1825 new_subclass = subclasses.At(subclasses.Length() - 1); | 1825 new_subclass = subclasses.At(subclasses.Length() - 1); |
| 1826 name = Class::Cast(new_subclass).Name(); | 1826 name = Class::Cast(new_subclass).Name(); |
| 1827 EXPECT_STREQ("AIterator", name.ToCString()); | 1827 EXPECT_STREQ("AIterator", name.ToCString()); |
| 1828 } | 1828 } |
| 1829 | 1829 |
| 1830 #endif // !PRODUCT | 1830 #endif // !PRODUCT |
| 1831 | 1831 |
| 1832 } // namespace dart | 1832 } // namespace dart |
| OLD | NEW |