OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 i += input_offset; | 858 i += input_offset; |
859 character_length -= output_adjust; | 859 character_length -= output_adjust; |
860 } | 860 } |
861 } | 861 } |
862 } | 862 } |
863 return character_length; | 863 return character_length; |
864 } | 864 } |
865 | 865 |
866 | 866 |
867 TEST(ScopePositions) { | 867 TEST(ScopePositions) { |
| 868 v8::internal::FLAG_harmony_scoping = true; |
| 869 |
868 // Test the parser for correctly setting the start and end positions | 870 // Test the parser for correctly setting the start and end positions |
869 // of a scope. We check the scope positions of exactly one scope | 871 // of a scope. We check the scope positions of exactly one scope |
870 // nested in the global scope of a program. 'inner source' is the | 872 // nested in the global scope of a program. 'inner source' is the |
871 // source code that determines the part of the source belonging | 873 // source code that determines the part of the source belonging |
872 // to the nested scope. 'outer_prefix' and 'outer_suffix' are | 874 // to the nested scope. 'outer_prefix' and 'outer_suffix' are |
873 // parts of the source that belong to the global scope. | 875 // parts of the source that belong to the global scope. |
874 struct SourceData { | 876 struct SourceData { |
875 const char* outer_prefix; | 877 const char* outer_prefix; |
876 const char* inner_source; | 878 const char* inner_source; |
877 const char* outer_suffix; | 879 const char* outer_suffix; |
878 i::ScopeType scope_type; | 880 i::ScopeType scope_type; |
879 i::LanguageMode language_mode; | 881 i::StrictMode strict_mode; |
880 }; | 882 }; |
881 | 883 |
882 const SourceData source_data[] = { | 884 const SourceData source_data[] = { |
883 { " with ({}) ", "{ block; }", " more;", i::WITH_SCOPE, i::SLOPPY_MODE }, | 885 { " with ({}) ", "{ block; }", " more;", i::WITH_SCOPE, i::SLOPPY }, |
884 { " with ({}) ", "{ block; }", "; more;", i::WITH_SCOPE, i::SLOPPY_MODE }, | 886 { " with ({}) ", "{ block; }", "; more;", i::WITH_SCOPE, i::SLOPPY }, |
885 { " with ({}) ", "{\n" | 887 { " with ({}) ", "{\n" |
886 " block;\n" | 888 " block;\n" |
887 " }", "\n" | 889 " }", "\n" |
888 " more;", i::WITH_SCOPE, i::SLOPPY_MODE }, | 890 " more;", i::WITH_SCOPE, i::SLOPPY }, |
889 { " with ({}) ", "statement;", " more;", i::WITH_SCOPE, i::SLOPPY_MODE }, | 891 { " with ({}) ", "statement;", " more;", i::WITH_SCOPE, i::SLOPPY }, |
890 { " with ({}) ", "statement", "\n" | 892 { " with ({}) ", "statement", "\n" |
891 " more;", i::WITH_SCOPE, i::SLOPPY_MODE }, | 893 " more;", i::WITH_SCOPE, i::SLOPPY }, |
892 { " with ({})\n" | 894 { " with ({})\n" |
893 " ", "statement;", "\n" | 895 " ", "statement;", "\n" |
894 " more;", i::WITH_SCOPE, i::SLOPPY_MODE }, | 896 " more;", i::WITH_SCOPE, i::SLOPPY }, |
895 { " try {} catch ", "(e) { block; }", " more;", | 897 { " try {} catch ", "(e) { block; }", " more;", |
896 i::CATCH_SCOPE, i::SLOPPY_MODE }, | 898 i::CATCH_SCOPE, i::SLOPPY }, |
897 { " try {} catch ", "(e) { block; }", "; more;", | 899 { " try {} catch ", "(e) { block; }", "; more;", |
898 i::CATCH_SCOPE, i::SLOPPY_MODE }, | 900 i::CATCH_SCOPE, i::SLOPPY }, |
899 { " try {} catch ", "(e) {\n" | 901 { " try {} catch ", "(e) {\n" |
900 " block;\n" | 902 " block;\n" |
901 " }", "\n" | 903 " }", "\n" |
902 " more;", i::CATCH_SCOPE, i::SLOPPY_MODE }, | 904 " more;", i::CATCH_SCOPE, i::SLOPPY }, |
903 { " try {} catch ", "(e) { block; }", " finally { block; } more;", | 905 { " try {} catch ", "(e) { block; }", " finally { block; } more;", |
904 i::CATCH_SCOPE, i::SLOPPY_MODE }, | 906 i::CATCH_SCOPE, i::SLOPPY }, |
905 { " start;\n" | 907 { " start;\n" |
906 " ", "{ let block; }", " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 908 " ", "{ let block; }", " more;", i::BLOCK_SCOPE, i::STRICT }, |
907 { " start;\n" | 909 { " start;\n" |
908 " ", "{ let block; }", "; more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 910 " ", "{ let block; }", "; more;", i::BLOCK_SCOPE, i::STRICT }, |
909 { " start;\n" | 911 { " start;\n" |
910 " ", "{\n" | 912 " ", "{\n" |
911 " let block;\n" | 913 " let block;\n" |
912 " }", "\n" | 914 " }", "\n" |
913 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 915 " more;", i::BLOCK_SCOPE, i::STRICT }, |
914 { " start;\n" | 916 { " start;\n" |
915 " function fun", "(a,b) { infunction; }", " more;", | 917 " function fun", "(a,b) { infunction; }", " more;", |
916 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 918 i::FUNCTION_SCOPE, i::SLOPPY }, |
917 { " start;\n" | 919 { " start;\n" |
918 " function fun", "(a,b) {\n" | 920 " function fun", "(a,b) {\n" |
919 " infunction;\n" | 921 " infunction;\n" |
920 " }", "\n" | 922 " }", "\n" |
921 " more;", i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 923 " more;", i::FUNCTION_SCOPE, i::SLOPPY }, |
922 { " (function fun", "(a,b) { infunction; }", ")();", | 924 { " (function fun", "(a,b) { infunction; }", ")();", |
923 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 925 i::FUNCTION_SCOPE, i::SLOPPY }, |
924 { " for ", "(let x = 1 ; x < 10; ++ x) { block; }", " more;", | 926 { " for ", "(let x = 1 ; x < 10; ++ x) { block; }", " more;", |
925 i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 927 i::BLOCK_SCOPE, i::STRICT }, |
926 { " for ", "(let x = 1 ; x < 10; ++ x) { block; }", "; more;", | 928 { " for ", "(let x = 1 ; x < 10; ++ x) { block; }", "; more;", |
927 i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 929 i::BLOCK_SCOPE, i::STRICT }, |
928 { " for ", "(let x = 1 ; x < 10; ++ x) {\n" | 930 { " for ", "(let x = 1 ; x < 10; ++ x) {\n" |
929 " block;\n" | 931 " block;\n" |
930 " }", "\n" | 932 " }", "\n" |
931 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 933 " more;", i::BLOCK_SCOPE, i::STRICT }, |
932 { " for ", "(let x = 1 ; x < 10; ++ x) statement;", " more;", | 934 { " for ", "(let x = 1 ; x < 10; ++ x) statement;", " more;", |
933 i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 935 i::BLOCK_SCOPE, i::STRICT }, |
934 { " for ", "(let x = 1 ; x < 10; ++ x) statement", "\n" | 936 { " for ", "(let x = 1 ; x < 10; ++ x) statement", "\n" |
935 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 937 " more;", i::BLOCK_SCOPE, i::STRICT }, |
936 { " for ", "(let x = 1 ; x < 10; ++ x)\n" | 938 { " for ", "(let x = 1 ; x < 10; ++ x)\n" |
937 " statement;", "\n" | 939 " statement;", "\n" |
938 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 940 " more;", i::BLOCK_SCOPE, i::STRICT }, |
939 { " for ", "(let x in {}) { block; }", " more;", | 941 { " for ", "(let x in {}) { block; }", " more;", |
940 i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 942 i::BLOCK_SCOPE, i::STRICT }, |
941 { " for ", "(let x in {}) { block; }", "; more;", | 943 { " for ", "(let x in {}) { block; }", "; more;", |
942 i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 944 i::BLOCK_SCOPE, i::STRICT }, |
943 { " for ", "(let x in {}) {\n" | 945 { " for ", "(let x in {}) {\n" |
944 " block;\n" | 946 " block;\n" |
945 " }", "\n" | 947 " }", "\n" |
946 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 948 " more;", i::BLOCK_SCOPE, i::STRICT }, |
947 { " for ", "(let x in {}) statement;", " more;", | 949 { " for ", "(let x in {}) statement;", " more;", |
948 i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 950 i::BLOCK_SCOPE, i::STRICT }, |
949 { " for ", "(let x in {}) statement", "\n" | 951 { " for ", "(let x in {}) statement", "\n" |
950 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 952 " more;", i::BLOCK_SCOPE, i::STRICT }, |
951 { " for ", "(let x in {})\n" | 953 { " for ", "(let x in {})\n" |
952 " statement;", "\n" | 954 " statement;", "\n" |
953 " more;", i::BLOCK_SCOPE, i::EXTENDED_MODE }, | 955 " more;", i::BLOCK_SCOPE, i::STRICT }, |
954 // Check that 6-byte and 4-byte encodings of UTF-8 strings do not throw | 956 // Check that 6-byte and 4-byte encodings of UTF-8 strings do not throw |
955 // the preparser off in terms of byte offsets. | 957 // the preparser off in terms of byte offsets. |
956 // 6 byte encoding. | 958 // 6 byte encoding. |
957 { " 'foo\355\240\201\355\260\211';\n" | 959 { " 'foo\355\240\201\355\260\211';\n" |
958 " (function fun", "(a,b) { infunction; }", ")();", | 960 " (function fun", "(a,b) { infunction; }", ")();", |
959 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 961 i::FUNCTION_SCOPE, i::SLOPPY }, |
960 // 4 byte encoding. | 962 // 4 byte encoding. |
961 { " 'foo\360\220\220\212';\n" | 963 { " 'foo\360\220\220\212';\n" |
962 " (function fun", "(a,b) { infunction; }", ")();", | 964 " (function fun", "(a,b) { infunction; }", ")();", |
963 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 965 i::FUNCTION_SCOPE, i::SLOPPY }, |
964 // 3 byte encoding of \u0fff. | 966 // 3 byte encoding of \u0fff. |
965 { " 'foo\340\277\277';\n" | 967 { " 'foo\340\277\277';\n" |
966 " (function fun", "(a,b) { infunction; }", ")();", | 968 " (function fun", "(a,b) { infunction; }", ")();", |
967 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 969 i::FUNCTION_SCOPE, i::SLOPPY }, |
968 // Broken 6 byte encoding with missing last byte. | 970 // Broken 6 byte encoding with missing last byte. |
969 { " 'foo\355\240\201\355\211';\n" | 971 { " 'foo\355\240\201\355\211';\n" |
970 " (function fun", "(a,b) { infunction; }", ")();", | 972 " (function fun", "(a,b) { infunction; }", ")();", |
971 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 973 i::FUNCTION_SCOPE, i::SLOPPY }, |
972 // Broken 3 byte encoding of \u0fff with missing last byte. | 974 // Broken 3 byte encoding of \u0fff with missing last byte. |
973 { " 'foo\340\277';\n" | 975 { " 'foo\340\277';\n" |
974 " (function fun", "(a,b) { infunction; }", ")();", | 976 " (function fun", "(a,b) { infunction; }", ")();", |
975 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 977 i::FUNCTION_SCOPE, i::SLOPPY }, |
976 // Broken 3 byte encoding of \u0fff with missing 2 last bytes. | 978 // Broken 3 byte encoding of \u0fff with missing 2 last bytes. |
977 { " 'foo\340';\n" | 979 { " 'foo\340';\n" |
978 " (function fun", "(a,b) { infunction; }", ")();", | 980 " (function fun", "(a,b) { infunction; }", ")();", |
979 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 981 i::FUNCTION_SCOPE, i::SLOPPY }, |
980 // Broken 3 byte encoding of \u00ff should be a 2 byte encoding. | 982 // Broken 3 byte encoding of \u00ff should be a 2 byte encoding. |
981 { " 'foo\340\203\277';\n" | 983 { " 'foo\340\203\277';\n" |
982 " (function fun", "(a,b) { infunction; }", ")();", | 984 " (function fun", "(a,b) { infunction; }", ")();", |
983 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 985 i::FUNCTION_SCOPE, i::SLOPPY }, |
984 // Broken 3 byte encoding of \u007f should be a 2 byte encoding. | 986 // Broken 3 byte encoding of \u007f should be a 2 byte encoding. |
985 { " 'foo\340\201\277';\n" | 987 { " 'foo\340\201\277';\n" |
986 " (function fun", "(a,b) { infunction; }", ")();", | 988 " (function fun", "(a,b) { infunction; }", ")();", |
987 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 989 i::FUNCTION_SCOPE, i::SLOPPY }, |
988 // Unpaired lead surrogate. | 990 // Unpaired lead surrogate. |
989 { " 'foo\355\240\201';\n" | 991 { " 'foo\355\240\201';\n" |
990 " (function fun", "(a,b) { infunction; }", ")();", | 992 " (function fun", "(a,b) { infunction; }", ")();", |
991 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 993 i::FUNCTION_SCOPE, i::SLOPPY }, |
992 // Unpaired lead surrogate where following code point is a 3 byte sequence. | 994 // Unpaired lead surrogate where following code point is a 3 byte sequence. |
993 { " 'foo\355\240\201\340\277\277';\n" | 995 { " 'foo\355\240\201\340\277\277';\n" |
994 " (function fun", "(a,b) { infunction; }", ")();", | 996 " (function fun", "(a,b) { infunction; }", ")();", |
995 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 997 i::FUNCTION_SCOPE, i::SLOPPY }, |
996 // Unpaired lead surrogate where following code point is a 4 byte encoding | 998 // Unpaired lead surrogate where following code point is a 4 byte encoding |
997 // of a trail surrogate. | 999 // of a trail surrogate. |
998 { " 'foo\355\240\201\360\215\260\211';\n" | 1000 { " 'foo\355\240\201\360\215\260\211';\n" |
999 " (function fun", "(a,b) { infunction; }", ")();", | 1001 " (function fun", "(a,b) { infunction; }", ")();", |
1000 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1002 i::FUNCTION_SCOPE, i::SLOPPY }, |
1001 // Unpaired trail surrogate. | 1003 // Unpaired trail surrogate. |
1002 { " 'foo\355\260\211';\n" | 1004 { " 'foo\355\260\211';\n" |
1003 " (function fun", "(a,b) { infunction; }", ")();", | 1005 " (function fun", "(a,b) { infunction; }", ")();", |
1004 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1006 i::FUNCTION_SCOPE, i::SLOPPY }, |
1005 // 2 byte encoding of \u00ff. | 1007 // 2 byte encoding of \u00ff. |
1006 { " 'foo\303\277';\n" | 1008 { " 'foo\303\277';\n" |
1007 " (function fun", "(a,b) { infunction; }", ")();", | 1009 " (function fun", "(a,b) { infunction; }", ")();", |
1008 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1010 i::FUNCTION_SCOPE, i::SLOPPY }, |
1009 // Broken 2 byte encoding of \u00ff with missing last byte. | 1011 // Broken 2 byte encoding of \u00ff with missing last byte. |
1010 { " 'foo\303';\n" | 1012 { " 'foo\303';\n" |
1011 " (function fun", "(a,b) { infunction; }", ")();", | 1013 " (function fun", "(a,b) { infunction; }", ")();", |
1012 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1014 i::FUNCTION_SCOPE, i::SLOPPY }, |
1013 // Broken 2 byte encoding of \u007f should be a 1 byte encoding. | 1015 // Broken 2 byte encoding of \u007f should be a 1 byte encoding. |
1014 { " 'foo\301\277';\n" | 1016 { " 'foo\301\277';\n" |
1015 " (function fun", "(a,b) { infunction; }", ")();", | 1017 " (function fun", "(a,b) { infunction; }", ")();", |
1016 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1018 i::FUNCTION_SCOPE, i::SLOPPY }, |
1017 // Illegal 5 byte encoding. | 1019 // Illegal 5 byte encoding. |
1018 { " 'foo\370\277\277\277\277';\n" | 1020 { " 'foo\370\277\277\277\277';\n" |
1019 " (function fun", "(a,b) { infunction; }", ")();", | 1021 " (function fun", "(a,b) { infunction; }", ")();", |
1020 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1022 i::FUNCTION_SCOPE, i::SLOPPY }, |
1021 // Illegal 6 byte encoding. | 1023 // Illegal 6 byte encoding. |
1022 { " 'foo\374\277\277\277\277\277';\n" | 1024 { " 'foo\374\277\277\277\277\277';\n" |
1023 " (function fun", "(a,b) { infunction; }", ")();", | 1025 " (function fun", "(a,b) { infunction; }", ")();", |
1024 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1026 i::FUNCTION_SCOPE, i::SLOPPY }, |
1025 // Illegal 0xfe byte | 1027 // Illegal 0xfe byte |
1026 { " 'foo\376\277\277\277\277\277\277';\n" | 1028 { " 'foo\376\277\277\277\277\277\277';\n" |
1027 " (function fun", "(a,b) { infunction; }", ")();", | 1029 " (function fun", "(a,b) { infunction; }", ")();", |
1028 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1030 i::FUNCTION_SCOPE, i::SLOPPY }, |
1029 // Illegal 0xff byte | 1031 // Illegal 0xff byte |
1030 { " 'foo\377\277\277\277\277\277\277\277';\n" | 1032 { " 'foo\377\277\277\277\277\277\277\277';\n" |
1031 " (function fun", "(a,b) { infunction; }", ")();", | 1033 " (function fun", "(a,b) { infunction; }", ")();", |
1032 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1034 i::FUNCTION_SCOPE, i::SLOPPY }, |
1033 { " 'foo';\n" | 1035 { " 'foo';\n" |
1034 " (function fun", "(a,b) { 'bar\355\240\201\355\260\213'; }", ")();", | 1036 " (function fun", "(a,b) { 'bar\355\240\201\355\260\213'; }", ")();", |
1035 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1037 i::FUNCTION_SCOPE, i::SLOPPY }, |
1036 { " 'foo';\n" | 1038 { " 'foo';\n" |
1037 " (function fun", "(a,b) { 'bar\360\220\220\214'; }", ")();", | 1039 " (function fun", "(a,b) { 'bar\360\220\220\214'; }", ")();", |
1038 i::FUNCTION_SCOPE, i::SLOPPY_MODE }, | 1040 i::FUNCTION_SCOPE, i::SLOPPY }, |
1039 { NULL, NULL, NULL, i::EVAL_SCOPE, i::SLOPPY_MODE } | 1041 { NULL, NULL, NULL, i::EVAL_SCOPE, i::SLOPPY } |
1040 }; | 1042 }; |
1041 | 1043 |
1042 i::Isolate* isolate = CcTest::i_isolate(); | 1044 i::Isolate* isolate = CcTest::i_isolate(); |
1043 i::Factory* factory = isolate->factory(); | 1045 i::Factory* factory = isolate->factory(); |
1044 | 1046 |
1045 v8::HandleScope handles(CcTest::isolate()); | 1047 v8::HandleScope handles(CcTest::isolate()); |
1046 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); | 1048 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); |
1047 v8::Context::Scope context_scope(context); | 1049 v8::Context::Scope context_scope(context); |
1048 | 1050 |
1049 int marker; | 1051 int marker; |
(...skipping 18 matching lines...) Expand all Loading... |
1068 // Parse program source. | 1070 // Parse program source. |
1069 i::Handle<i::String> source( | 1071 i::Handle<i::String> source( |
1070 factory->NewStringFromUtf8(i::CStrVector(program.start()))); | 1072 factory->NewStringFromUtf8(i::CStrVector(program.start()))); |
1071 CHECK_EQ(source->length(), kProgramSize); | 1073 CHECK_EQ(source->length(), kProgramSize); |
1072 i::Handle<i::Script> script = factory->NewScript(source); | 1074 i::Handle<i::Script> script = factory->NewScript(source); |
1073 i::CompilationInfoWithZone info(script); | 1075 i::CompilationInfoWithZone info(script); |
1074 i::Parser parser(&info); | 1076 i::Parser parser(&info); |
1075 parser.set_allow_lazy(true); | 1077 parser.set_allow_lazy(true); |
1076 parser.set_allow_harmony_scoping(true); | 1078 parser.set_allow_harmony_scoping(true); |
1077 info.MarkAsGlobal(); | 1079 info.MarkAsGlobal(); |
1078 info.SetLanguageMode(source_data[i].language_mode); | 1080 info.SetStrictMode(source_data[i].strict_mode); |
1079 parser.Parse(); | 1081 parser.Parse(); |
1080 CHECK(info.function() != NULL); | 1082 CHECK(info.function() != NULL); |
1081 | 1083 |
1082 // Check scope types and positions. | 1084 // Check scope types and positions. |
1083 i::Scope* scope = info.function()->scope(); | 1085 i::Scope* scope = info.function()->scope(); |
1084 CHECK(scope->is_global_scope()); | 1086 CHECK(scope->is_global_scope()); |
1085 CHECK_EQ(scope->start_position(), 0); | 1087 CHECK_EQ(scope->start_position(), 0); |
1086 CHECK_EQ(scope->end_position(), kProgramSize); | 1088 CHECK_EQ(scope->end_position(), kProgramSize); |
1087 CHECK_EQ(scope->inner_scopes()->length(), 1); | 1089 CHECK_EQ(scope->inner_scopes()->length(), 1); |
1088 | 1090 |
(...skipping 12 matching lines...) Expand all Loading... |
1101 i::Factory* factory = isolate->factory(); | 1103 i::Factory* factory = isolate->factory(); |
1102 const char* message = data->BuildMessage(); | 1104 const char* message = data->BuildMessage(); |
1103 i::Handle<i::String> format = v8::Utils::OpenHandle( | 1105 i::Handle<i::String> format = v8::Utils::OpenHandle( |
1104 *v8::String::NewFromUtf8(CcTest::isolate(), message)); | 1106 *v8::String::NewFromUtf8(CcTest::isolate(), message)); |
1105 i::Vector<const char*> args = data->BuildArgs(); | 1107 i::Vector<const char*> args = data->BuildArgs(); |
1106 i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length()); | 1108 i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length()); |
1107 for (int i = 0; i < args.length(); i++) { | 1109 for (int i = 0; i < args.length(); i++) { |
1108 i::JSArray::SetElement( | 1110 i::JSArray::SetElement( |
1109 args_array, i, v8::Utils::OpenHandle(*v8::String::NewFromUtf8( | 1111 args_array, i, v8::Utils::OpenHandle(*v8::String::NewFromUtf8( |
1110 CcTest::isolate(), args[i])), | 1112 CcTest::isolate(), args[i])), |
1111 NONE, i::kSloppyMode); | 1113 NONE, i::SLOPPY); |
1112 } | 1114 } |
1113 i::Handle<i::JSObject> builtins(isolate->js_builtins_object()); | 1115 i::Handle<i::JSObject> builtins(isolate->js_builtins_object()); |
1114 i::Handle<i::Object> format_fun = | 1116 i::Handle<i::Object> format_fun = |
1115 i::GetProperty(builtins, "FormatMessage"); | 1117 i::GetProperty(builtins, "FormatMessage"); |
1116 i::Handle<i::Object> arg_handles[] = { format, args_array }; | 1118 i::Handle<i::Object> arg_handles[] = { format, args_array }; |
1117 bool has_exception = false; | 1119 bool has_exception = false; |
1118 i::Handle<i::Object> result = i::Execution::Call( | 1120 i::Handle<i::Object> result = i::Execution::Call( |
1119 isolate, format_fun, builtins, 2, arg_handles, &has_exception); | 1121 isolate, format_fun, builtins, 2, arg_handles, &has_exception); |
1120 CHECK(!has_exception); | 1122 CHECK(!has_exception); |
1121 CHECK(result->IsString()); | 1123 CHECK(result->IsString()); |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 | 2153 |
2152 const char* statement_data[] = { | 2154 const char* statement_data[] = { |
2153 "new foo bar", | 2155 "new foo bar", |
2154 "new ) foo", | 2156 "new ) foo", |
2155 "new ++foo", | 2157 "new ++foo", |
2156 NULL | 2158 NULL |
2157 }; | 2159 }; |
2158 | 2160 |
2159 RunParserSyncTest(context_data, statement_data, kError); | 2161 RunParserSyncTest(context_data, statement_data, kError); |
2160 } | 2162 } |
OLD | NEW |