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

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

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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/isolate_test.cc » ('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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 "}\n" 627 "}\n"
628 "class B extends Object with Mixin1 {\n" 628 "class B extends Object with Mixin1 {\n"
629 "}\n" 629 "}\n"
630 "var saved = new B();\n" 630 "var saved = new B();\n"
631 "main() {\n" 631 "main() {\n"
632 " return 'saved:field=${saved.field},func=${saved.func()}';\n" 632 " return 'saved:field=${saved.field},func=${saved.func()}';\n"
633 "}\n"; 633 "}\n";
634 634
635 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 635 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
636 EXPECT_VALID(lib); 636 EXPECT_VALID(lib);
637 EXPECT_STREQ("saved:field=mixin1,func=mixin1", 637 EXPECT_STREQ("saved:field=mixin1,func=mixin1", SimpleInvokeStr(lib, "main"));
638 SimpleInvokeStr(lib, "main"));
639 638
640 const char* kReloadScript = 639 const char* kReloadScript =
641 "class Mixin2 {\n" 640 "class Mixin2 {\n"
642 " var field = 'mixin2';\n" 641 " var field = 'mixin2';\n"
643 " func() => 'mixin2';\n" 642 " func() => 'mixin2';\n"
644 "}\n" 643 "}\n"
645 "class B extends Object with Mixin2 {\n" 644 "class B extends Object with Mixin2 {\n"
646 "}\n" 645 "}\n"
647 "var saved = new B();\n" 646 "var saved = new B();\n"
648 "main() {\n" 647 "main() {\n"
649 " var newer = new B();\n" 648 " var newer = new B();\n"
650 " return 'saved:field=${saved.field},func=${saved.func()} '\n" 649 " return 'saved:field=${saved.field},func=${saved.func()} '\n"
651 " 'newer:field=${newer.field},func=${newer.func()}';\n" 650 " 'newer:field=${newer.field},func=${newer.func()}';\n"
652 "}\n"; 651 "}\n";
653 652
654 lib = TestCase::ReloadTestScript(kReloadScript); 653 lib = TestCase::ReloadTestScript(kReloadScript);
655 EXPECT_VALID(lib); 654 EXPECT_VALID(lib);
656 655
657 // The saved instance of B retains its old field value from mixin1, 656 // The saved instance of B retains its old field value from mixin1,
658 // but it gets the new implementation of func from mixin2. 657 // but it gets the new implementation of func from mixin2.
659 EXPECT_STREQ("saved:field=mixin1,func=mixin2 " 658 EXPECT_STREQ(
660 "newer:field=mixin2,func=mixin2", 659 "saved:field=mixin1,func=mixin2 "
661 SimpleInvokeStr(lib, "main")); 660 "newer:field=mixin2,func=mixin2",
661 SimpleInvokeStr(lib, "main"));
662 } 662 }
663 663
664 664
665 TEST_CASE(IsolateReload_ComplexInheritanceChange) { 665 TEST_CASE(IsolateReload_ComplexInheritanceChange) {
666 const char* kScript = 666 const char* kScript =
667 "class A {\n" 667 "class A {\n"
668 " String name;\n" 668 " String name;\n"
669 " A(this.name);\n" 669 " A(this.name);\n"
670 "}\n" 670 "}\n"
671 "class B extends A {\n" 671 "class B extends A {\n"
672 " B(name) : super(name);\n" 672 " B(name) : super(name);\n"
673 "}\n" 673 "}\n"
674 "class C extends B {\n" 674 "class C extends B {\n"
675 " C(name) : super(name);\n" 675 " C(name) : super(name);\n"
676 "}\n" 676 "}\n"
677 "var list = [ new A('a'), new B('b'), new C('c') ];\n" 677 "var list = [ new A('a'), new B('b'), new C('c') ];\n"
678 "main() {\n" 678 "main() {\n"
679 " return (list.map((x) {\n" 679 " return (list.map((x) {\n"
680 " return '${x.name} is A(${x is A})/ B(${x is B})/ C(${x is C})';\n" 680 " return '${x.name} is A(${x is A})/ B(${x is B})/ C(${x is C})';\n"
681 " })).toString();\n" 681 " })).toString();\n"
682 "}\n"; 682 "}\n";
683 683
684 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 684 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
685 EXPECT_VALID(lib); 685 EXPECT_VALID(lib);
686 EXPECT_STREQ("(a is A(true)/ B(false)/ C(false)," 686 EXPECT_STREQ(
687 " b is A(true)/ B(true)/ C(false)," 687 "(a is A(true)/ B(false)/ C(false),"
688 " c is A(true)/ B(true)/ C(true))", 688 " b is A(true)/ B(true)/ C(false),"
689 SimpleInvokeStr(lib, "main")); 689 " c is A(true)/ B(true)/ C(true))",
690 SimpleInvokeStr(lib, "main"));
690 691
691 const char* kReloadScript = 692 const char* kReloadScript =
692 "class C {\n" 693 "class C {\n"
693 " String name;\n" 694 " String name;\n"
694 " C(this.name);\n" 695 " C(this.name);\n"
695 "}\n" 696 "}\n"
696 "class X extends C {\n" 697 "class X extends C {\n"
697 " X(name) : super(name);\n" 698 " X(name) : super(name);\n"
698 "}\n" 699 "}\n"
699 "class A extends X {\n" 700 "class A extends X {\n"
700 " A(name) : super(name);\n" 701 " A(name) : super(name);\n"
701 "}\n" 702 "}\n"
702 "var list;\n" 703 "var list;\n"
703 "main() {\n" 704 "main() {\n"
704 " list.add(new X('x'));\n" 705 " list.add(new X('x'));\n"
705 " return (list.map((x) {\n" 706 " return (list.map((x) {\n"
706 " return '${x.name} is A(${x is A})/ C(${x is C})/ X(${x is X})';\n" 707 " return '${x.name} is A(${x is A})/ C(${x is C})/ X(${x is X})';\n"
707 " })).toString();\n" 708 " })).toString();\n"
708 "}\n"; 709 "}\n";
709 710
710 lib = TestCase::ReloadTestScript(kReloadScript); 711 lib = TestCase::ReloadTestScript(kReloadScript);
711 EXPECT_VALID(lib); 712 EXPECT_VALID(lib);
712 EXPECT_STREQ("(a is A(true)/ C(true)/ X(true)," 713 EXPECT_STREQ(
713 " b is A(true)/ C(true)/ X(true)," // still extends A... 714 "(a is A(true)/ C(true)/ X(true),"
714 " c is A(false)/ C(true)/ X(false)," 715 " b is A(true)/ C(true)/ X(true)," // still extends A...
715 " x is A(false)/ C(true)/ X(true))", 716 " c is A(false)/ C(true)/ X(false),"
716 SimpleInvokeStr(lib, "main")); 717 " x is A(false)/ C(true)/ X(true))",
718 SimpleInvokeStr(lib, "main"));
717 719
718 // Revive the class B and make sure all allocated instances take 720 // Revive the class B and make sure all allocated instances take
719 // their place in the inheritance hierarchy. 721 // their place in the inheritance hierarchy.
720 const char* kReloadScript2 = 722 const char* kReloadScript2 =
721 "class X {\n" 723 "class X {\n"
722 " String name;\n" 724 " String name;\n"
723 " X(this.name);\n" 725 " X(this.name);\n"
724 "}\n" 726 "}\n"
725 "class A extends X{\n" 727 "class A extends X{\n"
726 " A(name) : super(name);\n" 728 " A(name) : super(name);\n"
727 "}\n" 729 "}\n"
728 "class B extends X {\n" 730 "class B extends X {\n"
729 " B(name) : super(name);\n" 731 " B(name) : super(name);\n"
730 "}\n" 732 "}\n"
731 "class C extends A {\n" 733 "class C extends A {\n"
732 " C(name) : super(name);\n" 734 " C(name) : super(name);\n"
733 "}\n" 735 "}\n"
734 "var list;\n" 736 "var list;\n"
735 "main() {\n" 737 "main() {\n"
736 " return (list.map((x) {\n" 738 " return (list.map((x) {\n"
737 " return '${x.name} is '\n" 739 " return '${x.name} is '\n"
738 " 'A(${x is A})/ B(${x is B})/ C(${x is C})/ X(${x is X})';\n" 740 " 'A(${x is A})/ B(${x is B})/ C(${x is C})/ X(${x is X})';\n"
739 " })).toString();\n" 741 " })).toString();\n"
740 "}\n"; 742 "}\n";
741 743
742 lib = TestCase::ReloadTestScript(kReloadScript2); 744 lib = TestCase::ReloadTestScript(kReloadScript2);
743 EXPECT_VALID(lib); 745 EXPECT_VALID(lib);
744 EXPECT_STREQ("(a is A(true)/ B(false)/ C(false)/ X(true)," 746 EXPECT_STREQ(
745 " b is A(false)/ B(true)/ C(false)/ X(true)," 747 "(a is A(true)/ B(false)/ C(false)/ X(true),"
746 " c is A(true)/ B(false)/ C(true)/ X(true)," 748 " b is A(false)/ B(true)/ C(false)/ X(true),"
747 " x is A(false)/ B(false)/ C(false)/ X(true))", 749 " c is A(true)/ B(false)/ C(true)/ X(true),"
748 SimpleInvokeStr(lib, "main")); 750 " x is A(false)/ B(false)/ C(false)/ X(true))",
751 SimpleInvokeStr(lib, "main"));
749 } 752 }
750 753
751 754
752 TEST_CASE(IsolateReload_LiveStack) { 755 TEST_CASE(IsolateReload_LiveStack) {
753 const char* kScript = 756 const char* kScript =
754 "import 'test:isolate_reload_helper';\n" 757 "import 'test:isolate_reload_helper';\n"
755 "helper() => 7;\n" 758 "helper() => 7;\n"
756 "alpha() { var x = helper(); reloadTest(); return x + helper(); }\n" 759 "alpha() { var x = helper(); reloadTest(); return x + helper(); }\n"
757 "foo() => alpha();\n" 760 "foo() => alpha();\n"
758 "bar() => foo();\n" 761 "bar() => foo();\n"
(...skipping 18 matching lines...) Expand all
777 780
778 EXPECT_EQ(107, SimpleInvoke(lib, "main")); 781 EXPECT_EQ(107, SimpleInvoke(lib, "main"));
779 782
780 lib = TestCase::GetReloadErrorOrRootLibrary(); 783 lib = TestCase::GetReloadErrorOrRootLibrary();
781 EXPECT_VALID(lib); 784 EXPECT_VALID(lib);
782 EXPECT_EQ(105, SimpleInvoke(lib, "main")); 785 EXPECT_EQ(105, SimpleInvoke(lib, "main"));
783 } 786 }
784 787
785 788
786 TEST_CASE(IsolateReload_LibraryLookup) { 789 TEST_CASE(IsolateReload_LibraryLookup) {
787 const char* kImportScript = 790 const char* kImportScript = "importedFunc() => 'a';\n";
788 "importedFunc() => 'a';\n";
789 TestCase::AddTestLib("test:lib1", kImportScript); 791 TestCase::AddTestLib("test:lib1", kImportScript);
790 792
791 const char* kScript = 793 const char* kScript =
792 "main() {\n" 794 "main() {\n"
793 " return importedFunc();\n" 795 " return importedFunc();\n"
794 "}\n"; 796 "}\n";
795 Dart_Handle result; 797 Dart_Handle result;
796 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 798 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
797 EXPECT_VALID(lib); 799 EXPECT_VALID(lib);
798 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc"); 800 EXPECT_ERROR(SimpleInvokeError(lib, "main"), "importedFunc");
(...skipping 21 matching lines...) Expand all
820 lib = TestCase::ReloadTestScript(kScript); 822 lib = TestCase::ReloadTestScript(kScript);
821 EXPECT_VALID(lib); 823 EXPECT_VALID(lib);
822 824
823 // Fail to find 'test:lib1' in the isolate. 825 // Fail to find 'test:lib1' in the isolate.
824 result = Dart_LookupLibrary(NewString("test:lib1")); 826 result = Dart_LookupLibrary(NewString("test:lib1"));
825 EXPECT(Dart_IsError(result)); 827 EXPECT(Dart_IsError(result));
826 } 828 }
827 829
828 830
829 TEST_CASE(IsolateReload_LibraryHide) { 831 TEST_CASE(IsolateReload_LibraryHide) {
830 const char* kImportScript = 832 const char* kImportScript = "importedFunc() => 'a';\n";
831 "importedFunc() => 'a';\n";
832 TestCase::AddTestLib("test:lib1", kImportScript); 833 TestCase::AddTestLib("test:lib1", kImportScript);
833 834
834 // Import 'test:lib1' with importedFunc hidden. Will result in an 835 // Import 'test:lib1' with importedFunc hidden. Will result in an
835 // error. 836 // error.
836 const char* kScript = 837 const char* kScript =
837 "import 'test:lib1' hide importedFunc;\n" 838 "import 'test:lib1' hide importedFunc;\n"
838 "main() {\n" 839 "main() {\n"
839 " return importedFunc();\n" 840 " return importedFunc();\n"
840 "}\n"; 841 "}\n";
841 842
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 // Works. 902 // Works.
902 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main")); 903 EXPECT_STREQ("a", SimpleInvokeStr(lib, "main"));
903 // Results in an error. 904 // Results in an error.
904 EXPECT_ERROR(SimpleInvokeError(lib, "mainInt"), "importedIntFunc"); 905 EXPECT_ERROR(SimpleInvokeError(lib, "mainInt"), "importedIntFunc");
905 } 906 }
906 907
907 908
908 // Verifies that we clear the ICs for the functions live on the stack in a way 909 // Verifies that we clear the ICs for the functions live on the stack in a way
909 // that is compatible with the fast path smi stubs. 910 // that is compatible with the fast path smi stubs.
910 TEST_CASE(IsolateReload_SmiFastPathStubs) { 911 TEST_CASE(IsolateReload_SmiFastPathStubs) {
911 const char* kImportScript = 912 const char* kImportScript = "importedIntFunc() => 4;\n";
912 "importedIntFunc() => 4;\n";
913 TestCase::AddTestLib("test:lib1", kImportScript); 913 TestCase::AddTestLib("test:lib1", kImportScript);
914 914
915 const char* kScript = 915 const char* kScript =
916 "import 'test:isolate_reload_helper';\n" 916 "import 'test:isolate_reload_helper';\n"
917 "import 'test:lib1' show importedIntFunc;\n" 917 "import 'test:lib1' show importedIntFunc;\n"
918 "main() {\n" 918 "main() {\n"
919 " var x = importedIntFunc();\n" 919 " var x = importedIntFunc();\n"
920 " var y = importedIntFunc();\n" 920 " var y = importedIntFunc();\n"
921 " reloadTest();\n" 921 " reloadTest();\n"
922 " return x + y;\n" 922 " return x + y;\n"
(...skipping 665 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 NoSuchMethodError: No static getter 'y' declared " 1598 EXPECT_STREQ(
1599 "in class 'C'.", SimpleInvokeStr(lib, "main")); 1599 "4 NoSuchMethodError: No static getter 'y' declared "
1600 "in class 'C'.",
1601 SimpleInvokeStr(lib, "main"));
1600 1602
1601 lib = TestCase::GetReloadErrorOrRootLibrary(); 1603 lib = TestCase::GetReloadErrorOrRootLibrary();
1602 EXPECT_VALID(lib); 1604 EXPECT_VALID(lib);
1603 } 1605 }
1604 1606
1605 1607
1606 static void IsolateReload_DanlingGetter_LibraryReload( 1608 static void IsolateReload_DanlingGetter_LibraryReload(
1607 Dart_NativeArguments native_args) { 1609 Dart_NativeArguments native_args) {
1608 const char* kImportScript2 = 1610 const char* kImportScript2 = "var x;\n";
1609 "var x;\n";
1610 TestCase::AddTestLib("test:other", kImportScript2); 1611 TestCase::AddTestLib("test:other", kImportScript2);
1611 1612
1612 DART_CHECK_VALID(TestCase::TriggerReload()); 1613 DART_CHECK_VALID(TestCase::TriggerReload());
1613 } 1614 }
1614 1615
1615 1616
1616 static Dart_NativeFunction IsolateReload_DanlingGetter_LibraryNativeResolver( 1617 static Dart_NativeFunction IsolateReload_DanlingGetter_LibraryNativeResolver(
1617 Dart_Handle name, 1618 Dart_Handle name,
1618 int num_of_arguments, 1619 int num_of_arguments,
1619 bool* auto_setup_scope) { 1620 bool* auto_setup_scope) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 " C.y = 4;\n" 1763 " C.y = 4;\n"
1763 " var f = C#y=;\n" 1764 " var f = C#y=;\n"
1764 " var r1 = invoke(f, 5);\n" 1765 " var r1 = invoke(f, 5);\n"
1765 " reloadTest();\n" 1766 " reloadTest();\n"
1766 " var r2 = invoke(f, 6);\n" 1767 " var r2 = invoke(f, 6);\n"
1767 " return '$r1 $r2';\n" 1768 " return '$r1 $r2';\n"
1768 "}\n"; 1769 "}\n";
1769 1770
1770 TestCase::SetReloadTestScript(kReloadScript); 1771 TestCase::SetReloadTestScript(kReloadScript);
1771 1772
1772 EXPECT_STREQ("5 NoSuchMethodError: No static setter 'y=' declared in " 1773 EXPECT_STREQ(
1773 "class 'C'.", SimpleInvokeStr(lib, "main")); 1774 "5 NoSuchMethodError: No static setter 'y=' declared in "
1775 "class 'C'.",
1776 SimpleInvokeStr(lib, "main"));
1774 1777
1775 lib = TestCase::GetReloadErrorOrRootLibrary(); 1778 lib = TestCase::GetReloadErrorOrRootLibrary();
1776 EXPECT_VALID(lib); 1779 EXPECT_VALID(lib);
1777 } 1780 }
1778 1781
1779 1782
1780 static void IsolateReload_DanlingSetter_LibraryReload( 1783 static void IsolateReload_DanlingSetter_LibraryReload(
1781 Dart_NativeArguments native_args) { 1784 Dart_NativeArguments native_args) {
1782 const char* kImportScript2 = 1785 const char* kImportScript2 = "var x;\n";
1783 "var x;\n";
1784 TestCase::AddTestLib("test:other", kImportScript2); 1786 TestCase::AddTestLib("test:other", kImportScript2);
1785 1787
1786 DART_CHECK_VALID(TestCase::TriggerReload()); 1788 DART_CHECK_VALID(TestCase::TriggerReload());
1787 } 1789 }
1788 1790
1789 1791
1790 static Dart_NativeFunction IsolateReload_DanlingSetter_LibraryNativeResolver( 1792 static Dart_NativeFunction IsolateReload_DanlingSetter_LibraryNativeResolver(
1791 Dart_Handle name, 1793 Dart_Handle name,
1792 int num_of_arguments, 1794 int num_of_arguments,
1793 bool* auto_setup_scope) { 1795 bool* auto_setup_scope) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 " var c = new C();\n" 1878 " var c = new C();\n"
1877 " var f = c#foo;\n" 1879 " var f = c#foo;\n"
1878 " var r1 = invoke(f, 1);\n" 1880 " var r1 = invoke(f, 1);\n"
1879 " reloadTest();\n" 1881 " reloadTest();\n"
1880 " var r2 = invoke(f, 1);\n" 1882 " var r2 = invoke(f, 1);\n"
1881 " return '$r1 $r2';\n" 1883 " return '$r1 $r2';\n"
1882 "}\n"; 1884 "}\n";
1883 1885
1884 TestCase::SetReloadTestScript(kReloadScript); 1886 TestCase::SetReloadTestScript(kReloadScript);
1885 1887
1886 EXPECT_STREQ("1 NoSuchMethodError: Class 'C' has no instance method " 1888 EXPECT_STREQ(
1887 "'foo' with matching arguments.", SimpleInvokeStr(lib, "main")); 1889 "1 NoSuchMethodError: Class 'C' has no instance method "
1890 "'foo' with matching arguments.",
1891 SimpleInvokeStr(lib, "main"));
1888 1892
1889 lib = TestCase::GetReloadErrorOrRootLibrary(); 1893 lib = TestCase::GetReloadErrorOrRootLibrary();
1890 EXPECT_VALID(lib); 1894 EXPECT_VALID(lib);
1891 } 1895 }
1892 1896
1893 1897
1894 TEST_CASE(IsolateReload_TearOff_AddArguments2) { 1898 TEST_CASE(IsolateReload_TearOff_AddArguments2) {
1895 const char* kScript = 1899 const char* kScript =
1896 "import 'test:isolate_reload_helper';\n" 1900 "import 'test:isolate_reload_helper';\n"
1897 "class C {\n" 1901 "class C {\n"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 "main() {\n" 1934 "main() {\n"
1931 " var f = C#foo;\n" 1935 " var f = C#foo;\n"
1932 " var r1 = invoke(f, 1);\n" 1936 " var r1 = invoke(f, 1);\n"
1933 " reloadTest();\n" 1937 " reloadTest();\n"
1934 " var r2 = invoke(f, 1);\n" 1938 " var r2 = invoke(f, 1);\n"
1935 " return '$r1 $r2';\n" 1939 " return '$r1 $r2';\n"
1936 "}\n"; 1940 "}\n";
1937 1941
1938 TestCase::SetReloadTestScript(kReloadScript); 1942 TestCase::SetReloadTestScript(kReloadScript);
1939 1943
1940 EXPECT_STREQ("1 NoSuchMethodError: Closure call with mismatched arguments: " 1944 EXPECT_STREQ(
1941 "function 'C.foo'", SimpleInvokeStr(lib, "main")); 1945 "1 NoSuchMethodError: Closure call with mismatched arguments: "
1946 "function 'C.foo'",
1947 SimpleInvokeStr(lib, "main"));
1942 1948
1943 lib = TestCase::GetReloadErrorOrRootLibrary(); 1949 lib = TestCase::GetReloadErrorOrRootLibrary();
1944 EXPECT_VALID(lib); 1950 EXPECT_VALID(lib);
1945 } 1951 }
1946 1952
1947 1953
1948 TEST_CASE(IsolateReload_EnumEquality) { 1954 TEST_CASE(IsolateReload_EnumEquality) {
1949 const char* kScript = 1955 const char* kScript =
1950 "enum Fruit {\n" 1956 "enum Fruit {\n"
1951 " Apple,\n" 1957 " Apple,\n"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 " Banana,\n" 2173 " Banana,\n"
2168 "}\n" 2174 "}\n"
2169 "var x;\n" 2175 "var x;\n"
2170 "main() {\n" 2176 "main() {\n"
2171 " String r = '$x ${x.hashCode is int} ${x.index}';\n" 2177 " String r = '$x ${x.hashCode is int} ${x.index}';\n"
2172 " return r;\n" 2178 " return r;\n"
2173 "}\n"; 2179 "}\n";
2174 2180
2175 lib = TestCase::ReloadTestScript(kReloadScript); 2181 lib = TestCase::ReloadTestScript(kReloadScript);
2176 EXPECT_VALID(lib); 2182 EXPECT_VALID(lib);
2177 EXPECT_STREQ("Fruit.Cantalope true 2", 2183 EXPECT_STREQ("Fruit.Cantalope true 2", SimpleInvokeStr(lib, "main"));
2178 SimpleInvokeStr(lib, "main"));
2179 } 2184 }
2180 2185
2181 2186
2182 TEST_CASE(IsolateReload_EnumIdentityReload) { 2187 TEST_CASE(IsolateReload_EnumIdentityReload) {
2183 const char* kScript = 2188 const char* kScript =
2184 "enum Fruit {\n" 2189 "enum Fruit {\n"
2185 " Apple,\n" 2190 " Apple,\n"
2186 " Banana,\n" 2191 " Banana,\n"
2187 " Cantalope,\n" 2192 " Cantalope,\n"
2188 "}\n" 2193 "}\n"
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
2874 EXPECT_STREQ("true", SimpleInvokeStr(lib, "main")); 2879 EXPECT_STREQ("true", SimpleInvokeStr(lib, "main"));
2875 } 2880 }
2876 2881
2877 2882
2878 static bool NothingModifiedCallback(const char* url, int64_t since) { 2883 static bool NothingModifiedCallback(const char* url, int64_t since) {
2879 return false; 2884 return false;
2880 } 2885 }
2881 2886
2882 2887
2883 TEST_CASE(IsolateReload_NoLibsModified) { 2888 TEST_CASE(IsolateReload_NoLibsModified) {
2884 const char* kImportScript = 2889 const char* kImportScript = "importedFunc() => 'fancy';";
2885 "importedFunc() => 'fancy';";
2886 TestCase::AddTestLib("test:lib1", kImportScript); 2890 TestCase::AddTestLib("test:lib1", kImportScript);
2887 2891
2888 const char* kScript = 2892 const char* kScript =
2889 "import 'test:lib1';\n" 2893 "import 'test:lib1';\n"
2890 "main() {\n" 2894 "main() {\n"
2891 " return importedFunc() + ' feast';\n" 2895 " return importedFunc() + ' feast';\n"
2892 "}\n"; 2896 "}\n";
2893 2897
2894 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 2898 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
2895 EXPECT_VALID(lib); 2899 EXPECT_VALID(lib);
2896 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); 2900 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main"));
2897 2901
2898 const char* kReloadImportScript = 2902 const char* kReloadImportScript = "importedFunc() => 'bossy';";
2899 "importedFunc() => 'bossy';";
2900 TestCase::AddTestLib("test:lib1", kReloadImportScript); 2903 TestCase::AddTestLib("test:lib1", kReloadImportScript);
2901 2904
2902 const char* kReloadScript = 2905 const char* kReloadScript =
2903 "import 'test:lib1';\n" 2906 "import 'test:lib1';\n"
2904 "main() {\n" 2907 "main() {\n"
2905 " return importedFunc() + ' pants';\n" 2908 " return importedFunc() + ' pants';\n"
2906 "}\n"; 2909 "}\n";
2907 2910
2908 Dart_SetFileModifiedCallback(&NothingModifiedCallback); 2911 Dart_SetFileModifiedCallback(&NothingModifiedCallback);
2909 lib = TestCase::ReloadTestScript(kReloadScript); 2912 lib = TestCase::ReloadTestScript(kReloadScript);
2910 EXPECT_VALID(lib); 2913 EXPECT_VALID(lib);
2911 Dart_SetFileModifiedCallback(NULL); 2914 Dart_SetFileModifiedCallback(NULL);
2912 2915
2913 // No reload occurred because no files were "modified". 2916 // No reload occurred because no files were "modified".
2914 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); 2917 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main"));
2915 } 2918 }
2916 2919
2917 2920
2918 static bool MainModifiedCallback(const char* url, int64_t since) { 2921 static bool MainModifiedCallback(const char* url, int64_t since) {
2919 if (strcmp(url, "test-lib") == 0) { 2922 if (strcmp(url, "test-lib") == 0) {
2920 return true; 2923 return true;
2921 } 2924 }
2922 return false; 2925 return false;
2923 } 2926 }
2924 2927
2925 2928
2926 TEST_CASE(IsolateReload_MainLibModified) { 2929 TEST_CASE(IsolateReload_MainLibModified) {
2927 const char* kImportScript = 2930 const char* kImportScript = "importedFunc() => 'fancy';";
2928 "importedFunc() => 'fancy';";
2929 TestCase::AddTestLib("test:lib1", kImportScript); 2931 TestCase::AddTestLib("test:lib1", kImportScript);
2930 2932
2931 const char* kScript = 2933 const char* kScript =
2932 "import 'test:lib1';\n" 2934 "import 'test:lib1';\n"
2933 "main() {\n" 2935 "main() {\n"
2934 " return importedFunc() + ' feast';\n" 2936 " return importedFunc() + ' feast';\n"
2935 "}\n"; 2937 "}\n";
2936 2938
2937 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 2939 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
2938 EXPECT_VALID(lib); 2940 EXPECT_VALID(lib);
2939 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); 2941 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main"));
2940 2942
2941 const char* kReloadImportScript = 2943 const char* kReloadImportScript = "importedFunc() => 'bossy';";
2942 "importedFunc() => 'bossy';";
2943 TestCase::AddTestLib("test:lib1", kReloadImportScript); 2944 TestCase::AddTestLib("test:lib1", kReloadImportScript);
2944 2945
2945 const char* kReloadScript = 2946 const char* kReloadScript =
2946 "import 'test:lib1';\n" 2947 "import 'test:lib1';\n"
2947 "main() {\n" 2948 "main() {\n"
2948 " return importedFunc() + ' pants';\n" 2949 " return importedFunc() + ' pants';\n"
2949 "}\n"; 2950 "}\n";
2950 2951
2951 Dart_SetFileModifiedCallback(&MainModifiedCallback); 2952 Dart_SetFileModifiedCallback(&MainModifiedCallback);
2952 lib = TestCase::ReloadTestScript(kReloadScript); 2953 lib = TestCase::ReloadTestScript(kReloadScript);
2953 EXPECT_VALID(lib); 2954 EXPECT_VALID(lib);
2954 Dart_SetFileModifiedCallback(NULL); 2955 Dart_SetFileModifiedCallback(NULL);
2955 2956
2956 // Imported library is not reloaded. 2957 // Imported library is not reloaded.
2957 EXPECT_STREQ("fancy pants", SimpleInvokeStr(lib, "main")); 2958 EXPECT_STREQ("fancy pants", SimpleInvokeStr(lib, "main"));
2958 } 2959 }
2959 2960
2960 2961
2961 static bool ImportModifiedCallback(const char* url, int64_t since) { 2962 static bool ImportModifiedCallback(const char* url, int64_t since) {
2962 if (strcmp(url, "test:lib1") == 0) { 2963 if (strcmp(url, "test:lib1") == 0) {
2963 return true; 2964 return true;
2964 } 2965 }
2965 return false; 2966 return false;
2966 } 2967 }
2967 2968
2968 2969
2969 TEST_CASE(IsolateReload_ImportedLibModified) { 2970 TEST_CASE(IsolateReload_ImportedLibModified) {
2970 const char* kImportScript = 2971 const char* kImportScript = "importedFunc() => 'fancy';";
2971 "importedFunc() => 'fancy';";
2972 TestCase::AddTestLib("test:lib1", kImportScript); 2972 TestCase::AddTestLib("test:lib1", kImportScript);
2973 2973
2974 const char* kScript = 2974 const char* kScript =
2975 "import 'test:lib1';\n" 2975 "import 'test:lib1';\n"
2976 "main() {\n" 2976 "main() {\n"
2977 " return importedFunc() + ' feast';\n" 2977 " return importedFunc() + ' feast';\n"
2978 "}\n"; 2978 "}\n";
2979 2979
2980 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 2980 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
2981 EXPECT_VALID(lib); 2981 EXPECT_VALID(lib);
2982 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); 2982 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main"));
2983 2983
2984 const char* kReloadImportScript = 2984 const char* kReloadImportScript = "importedFunc() => 'bossy';";
2985 "importedFunc() => 'bossy';";
2986 TestCase::AddTestLib("test:lib1", kReloadImportScript); 2985 TestCase::AddTestLib("test:lib1", kReloadImportScript);
2987 2986
2988 const char* kReloadScript = 2987 const char* kReloadScript =
2989 "import 'test:lib1';\n" 2988 "import 'test:lib1';\n"
2990 "main() {\n" 2989 "main() {\n"
2991 " return importedFunc() + ' pants';\n" 2990 " return importedFunc() + ' pants';\n"
2992 "}\n"; 2991 "}\n";
2993 2992
2994 Dart_SetFileModifiedCallback(&ImportModifiedCallback); 2993 Dart_SetFileModifiedCallback(&ImportModifiedCallback);
2995 lib = TestCase::ReloadTestScript(kReloadScript); 2994 lib = TestCase::ReloadTestScript(kReloadScript);
2996 EXPECT_VALID(lib); 2995 EXPECT_VALID(lib);
2997 Dart_SetFileModifiedCallback(NULL); 2996 Dart_SetFileModifiedCallback(NULL);
2998 2997
2999 // Modification of an imported library propagates to the importing library. 2998 // Modification of an imported library propagates to the importing library.
3000 EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main")); 2999 EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main"));
3001 } 3000 }
3002 3001
3003 3002
3004 TEST_CASE(IsolateReload_PrefixImportedLibModified) { 3003 TEST_CASE(IsolateReload_PrefixImportedLibModified) {
3005 const char* kImportScript = 3004 const char* kImportScript = "importedFunc() => 'fancy';";
3006 "importedFunc() => 'fancy';";
3007 TestCase::AddTestLib("test:lib1", kImportScript); 3005 TestCase::AddTestLib("test:lib1", kImportScript);
3008 3006
3009 const char* kScript = 3007 const char* kScript =
3010 "import 'test:lib1' as cobra;\n" 3008 "import 'test:lib1' as cobra;\n"
3011 "main() {\n" 3009 "main() {\n"
3012 " return cobra.importedFunc() + ' feast';\n" 3010 " return cobra.importedFunc() + ' feast';\n"
3013 "}\n"; 3011 "}\n";
3014 3012
3015 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 3013 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
3016 EXPECT_VALID(lib); 3014 EXPECT_VALID(lib);
3017 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); 3015 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main"));
3018 3016
3019 const char* kReloadImportScript = 3017 const char* kReloadImportScript = "importedFunc() => 'bossy';";
3020 "importedFunc() => 'bossy';";
3021 TestCase::AddTestLib("test:lib1", kReloadImportScript); 3018 TestCase::AddTestLib("test:lib1", kReloadImportScript);
3022 3019
3023 const char* kReloadScript = 3020 const char* kReloadScript =
3024 "import 'test:lib1' as cobra;\n" 3021 "import 'test:lib1' as cobra;\n"
3025 "main() {\n" 3022 "main() {\n"
3026 " return cobra.importedFunc() + ' pants';\n" 3023 " return cobra.importedFunc() + ' pants';\n"
3027 "}\n"; 3024 "}\n";
3028 3025
3029 Dart_SetFileModifiedCallback(&ImportModifiedCallback); 3026 Dart_SetFileModifiedCallback(&ImportModifiedCallback);
3030 lib = TestCase::ReloadTestScript(kReloadScript); 3027 lib = TestCase::ReloadTestScript(kReloadScript);
3031 EXPECT_VALID(lib); 3028 EXPECT_VALID(lib);
3032 Dart_SetFileModifiedCallback(NULL); 3029 Dart_SetFileModifiedCallback(NULL);
3033 3030
3034 // Modification of an prefix-imported library propagates to the 3031 // Modification of an prefix-imported library propagates to the
3035 // importing library. 3032 // importing library.
3036 EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main")); 3033 EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main"));
3037 } 3034 }
3038 3035
3039 3036
3040 static bool ExportModifiedCallback(const char* url, int64_t since) { 3037 static bool ExportModifiedCallback(const char* url, int64_t since) {
3041 if (strcmp(url, "test:exportlib") == 0) { 3038 if (strcmp(url, "test:exportlib") == 0) {
3042 return true; 3039 return true;
3043 } 3040 }
3044 return false; 3041 return false;
3045 } 3042 }
3046 3043
3047 3044
3048 TEST_CASE(IsolateReload_ExportedLibModified) { 3045 TEST_CASE(IsolateReload_ExportedLibModified) {
3049 const char* kImportScript = 3046 const char* kImportScript = "export 'test:exportlib';";
3050 "export 'test:exportlib';";
3051 TestCase::AddTestLib("test:importlib", kImportScript); 3047 TestCase::AddTestLib("test:importlib", kImportScript);
3052 3048
3053 const char* kExportScript = 3049 const char* kExportScript = "exportedFunc() => 'fancy';";
3054 "exportedFunc() => 'fancy';";
3055 TestCase::AddTestLib("test:exportlib", kExportScript); 3050 TestCase::AddTestLib("test:exportlib", kExportScript);
3056 3051
3057 const char* kScript = 3052 const char* kScript =
3058 "import 'test:importlib';\n" 3053 "import 'test:importlib';\n"
3059 "main() {\n" 3054 "main() {\n"
3060 " return exportedFunc() + ' feast';\n" 3055 " return exportedFunc() + ' feast';\n"
3061 "}\n"; 3056 "}\n";
3062 3057
3063 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 3058 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
3064 EXPECT_VALID(lib); 3059 EXPECT_VALID(lib);
3065 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main")); 3060 EXPECT_STREQ("fancy feast", SimpleInvokeStr(lib, "main"));
3066 3061
3067 const char* kReloadExportScript = 3062 const char* kReloadExportScript = "exportedFunc() => 'bossy';";
3068 "exportedFunc() => 'bossy';";
3069 TestCase::AddTestLib("test:exportlib", kReloadExportScript); 3063 TestCase::AddTestLib("test:exportlib", kReloadExportScript);
3070 3064
3071 const char* kReloadScript = 3065 const char* kReloadScript =
3072 "import 'test:importlib';\n" 3066 "import 'test:importlib';\n"
3073 "main() {\n" 3067 "main() {\n"
3074 " return exportedFunc() + ' pants';\n" 3068 " return exportedFunc() + ' pants';\n"
3075 "}\n"; 3069 "}\n";
3076 3070
3077 Dart_SetFileModifiedCallback(&ExportModifiedCallback); 3071 Dart_SetFileModifiedCallback(&ExportModifiedCallback);
3078 lib = TestCase::ReloadTestScript(kReloadScript); 3072 lib = TestCase::ReloadTestScript(kReloadScript);
3079 EXPECT_VALID(lib); 3073 EXPECT_VALID(lib);
3080 Dart_SetFileModifiedCallback(NULL); 3074 Dart_SetFileModifiedCallback(NULL);
3081 3075
3082 // Modification of an exported library propagates. 3076 // Modification of an exported library propagates.
3083 EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main")); 3077 EXPECT_STREQ("bossy pants", SimpleInvokeStr(lib, "main"));
3084 } 3078 }
3085 3079
3086 3080
3087 TEST_CASE(IsolateReload_SimpleConstFieldUpdate) { 3081 TEST_CASE(IsolateReload_SimpleConstFieldUpdate) {
3088 const char* kScript = 3082 const char* kScript =
3089 "const value = 'a';\n" 3083 "const value = 'a';\n"
3090 "main() {\n" 3084 "main() {\n"
3091 " return 'value=${value}';\n" 3085 " return 'value=${value}';\n"
3092 "}\n"; 3086 "}\n";
3093 3087
3094 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 3088 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
3095 EXPECT_VALID(lib); 3089 EXPECT_VALID(lib);
3096 EXPECT_STREQ("value=a", SimpleInvokeStr(lib, "main")); 3090 EXPECT_STREQ("value=a", SimpleInvokeStr(lib, "main"));
3097 3091
3098 const char* kReloadScript = 3092 const char* kReloadScript =
3099 "const value = 'b';\n" 3093 "const value = 'b';\n"
3100 "main() {\n" 3094 "main() {\n"
3101 " return 'value=${value}';\n" 3095 " return 'value=${value}';\n"
3102 "}\n"; 3096 "}\n";
3103 3097
3104 lib = TestCase::ReloadTestScript(kReloadScript); 3098 lib = TestCase::ReloadTestScript(kReloadScript);
3105 EXPECT_VALID(lib); 3099 EXPECT_VALID(lib);
3106 EXPECT_STREQ("value=b", SimpleInvokeStr(lib, "main")); 3100 EXPECT_STREQ("value=b", SimpleInvokeStr(lib, "main"));
3107 } 3101 }
3108 3102
3109 3103
3110 TEST_CASE(IsolateReload_ConstFieldUpdate) { 3104 TEST_CASE(IsolateReload_ConstFieldUpdate) {
3111 const char* kScript = 3105 const char* kScript =
3112 "const value = const Duration(seconds: 1);\n" 3106 "const value = const Duration(seconds: 1);\n"
3113 "main() {\n" 3107 "main() {\n"
3114 " return 'value=${value}';\n" 3108 " return 'value=${value}';\n"
3115 "}\n"; 3109 "}\n";
3116 3110
3117 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL); 3111 Dart_Handle lib = TestCase::LoadTestScript(kScript, NULL);
3118 EXPECT_VALID(lib); 3112 EXPECT_VALID(lib);
3119 EXPECT_STREQ("value=0:00:01.000000", SimpleInvokeStr(lib, "main")); 3113 EXPECT_STREQ("value=0:00:01.000000", SimpleInvokeStr(lib, "main"));
3120 3114
3121 const char* kReloadScript = 3115 const char* kReloadScript =
3122 "const value = const Duration(seconds: 2);\n" 3116 "const value = const Duration(seconds: 2);\n"
3123 "main() {\n" 3117 "main() {\n"
3124 " return 'value=${value}';\n" 3118 " return 'value=${value}';\n"
3125 "}\n"; 3119 "}\n";
3126 3120
3127 lib = TestCase::ReloadTestScript(kReloadScript); 3121 lib = TestCase::ReloadTestScript(kReloadScript);
3128 EXPECT_VALID(lib); 3122 EXPECT_VALID(lib);
3129 EXPECT_STREQ("value=0:00:02.000000", SimpleInvokeStr(lib, "main")); 3123 EXPECT_STREQ("value=0:00:02.000000", SimpleInvokeStr(lib, "main"));
3130 } 3124 }
3131 3125
3132 #endif // !PRODUCT 3126 #endif // !PRODUCT
3133 3127
3134 } // namespace dart 3128 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate_reload.cc ('k') | runtime/vm/isolate_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698