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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 2526453002: Merged: Return kBadChar for longest subpart of incomplete utf-8 character. (Closed)
Patch Set: 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 | « src/unicode.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]"); 677 TestScanRegExp("/[\\u123]/flipperwald", "[\\u123]");
678 // Escaped ']'s wont end the character class. 678 // Escaped ']'s wont end the character class.
679 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]"); 679 TestScanRegExp("/[\\]/]/flipperwald", "[\\]/]");
680 // Escaped slashes are not terminating. 680 // Escaped slashes are not terminating.
681 TestScanRegExp("/\\//flipperwald", "\\/"); 681 TestScanRegExp("/\\//flipperwald", "\\/");
682 // Starting with '=' works too. 682 // Starting with '=' works too.
683 TestScanRegExp("/=/", "="); 683 TestScanRegExp("/=/", "=");
684 TestScanRegExp("/=?/", "=?"); 684 TestScanRegExp("/=?/", "=?");
685 } 685 }
686 686
687 static int Ucs2CharLength(unibrow::uchar c) {
688 if (c == unibrow::Utf8::kIncomplete || c == unibrow::Utf8::kBufferEmpty) {
689 return 0;
690 } else if (c < 0xffff) {
691 return 1;
692 } else {
693 return 2;
694 }
695 }
687 696
688 static int Utf8LengthHelper(const char* s) { 697 static int Utf8LengthHelper(const char* s) {
689 int len = i::StrLength(s); 698 unibrow::Utf8::Utf8IncrementalBuffer buffer(unibrow::Utf8::kBufferEmpty);
690 int character_length = len; 699 int length = 0;
691 for (int i = 0; i < len; i++) { 700 for (; *s != '\0'; s++) {
692 unsigned char c = s[i]; 701 unibrow::uchar tmp = unibrow::Utf8::ValueOfIncremental(*s, &buffer);
693 int input_offset = 0; 702 length += Ucs2CharLength(tmp);
694 int output_adjust = 0;
695 if (c > 0x7f) {
696 if (c < 0xc0) continue;
697 if (c >= 0xf0) {
698 if (c >= 0xf8) {
699 // 5 and 6 byte UTF-8 sequences turn into a kBadChar for each UTF-8
700 // byte.
701 continue; // Handle first UTF-8 byte.
702 }
703 if ((c & 7) == 0 && ((s[i + 1] & 0x30) == 0)) {
704 // This 4 byte sequence could have been coded as a 3 byte sequence.
705 // Record a single kBadChar for the first byte and continue.
706 continue;
707 }
708 input_offset = 3;
709 // 4 bytes of UTF-8 turn into 2 UTF-16 code units.
710 character_length -= 2;
711 } else if (c >= 0xe0) {
712 if ((c & 0xf) == 0 && ((s[i + 1] & 0x20) == 0)) {
713 // This 3 byte sequence could have been coded as a 2 byte sequence.
714 // Record a single kBadChar for the first byte and continue.
715 continue;
716 }
717 if (c == 0xed) {
718 unsigned char d = s[i + 1];
719 if ((d < 0x80) || (d > 0x9f)) {
720 // This 3 byte sequence is part of a surrogate pair which is not
721 // supported by UTF-8. Record a single kBadChar for the first byte
722 // and continue.
723 continue;
724 }
725 }
726 input_offset = 2;
727 // 3 bytes of UTF-8 turn into 1 UTF-16 code unit.
728 output_adjust = 2;
729 } else {
730 if ((c & 0x1e) == 0) {
731 // This 2 byte sequence could have been coded as a 1 byte sequence.
732 // Record a single kBadChar for the first byte and continue.
733 continue;
734 }
735 input_offset = 1;
736 // 2 bytes of UTF-8 turn into 1 UTF-16 code unit.
737 output_adjust = 1;
738 }
739 bool bad = false;
740 for (int j = 1; j <= input_offset; j++) {
741 if ((s[i + j] & 0xc0) != 0x80) {
742 // Bad UTF-8 sequence turns the first in the sequence into kBadChar,
743 // which is a single UTF-16 code unit.
744 bad = true;
745 break;
746 }
747 }
748 if (!bad) {
749 i += input_offset;
750 character_length -= output_adjust;
751 }
752 }
753 } 703 }
754 return character_length; 704 unibrow::uchar tmp = unibrow::Utf8::ValueOfIncrementalFinish(&buffer);
705 length += Ucs2CharLength(tmp);
706 return length;
755 } 707 }
756 708
757 709
758 TEST(ScopeUsesArgumentsSuperThis) { 710 TEST(ScopeUsesArgumentsSuperThis) {
759 static const struct { 711 static const struct {
760 const char* prefix; 712 const char* prefix;
761 const char* suffix; 713 const char* suffix;
762 } surroundings[] = { 714 } surroundings[] = {
763 { "function f() {", "}" }, 715 { "function f() {", "}" },
764 { "var f = () => {", "};" }, 716 { "var f = () => {", "};" },
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 // parts of the source that belong to the global scope. 926 // parts of the source that belong to the global scope.
975 struct SourceData { 927 struct SourceData {
976 const char* outer_prefix; 928 const char* outer_prefix;
977 const char* inner_source; 929 const char* inner_source;
978 const char* outer_suffix; 930 const char* outer_suffix;
979 i::ScopeType scope_type; 931 i::ScopeType scope_type;
980 i::LanguageMode language_mode; 932 i::LanguageMode language_mode;
981 }; 933 };
982 934
983 const SourceData source_data[] = { 935 const SourceData source_data[] = {
984 { " with ({}) ", "{ block; }", " more;", i::WITH_SCOPE, i::SLOPPY }, 936 {" with ({}) ", "{ block; }", " more;", i::WITH_SCOPE, i::SLOPPY},
985 { " with ({}) ", "{ block; }", "; more;", i::WITH_SCOPE, i::SLOPPY }, 937 {" with ({}) ", "{ block; }", "; more;", i::WITH_SCOPE, i::SLOPPY},
986 { " with ({}) ", "{\n" 938 {" with ({}) ",
987 " block;\n" 939 "{\n"
988 " }", "\n" 940 " block;\n"
989 " more;", i::WITH_SCOPE, i::SLOPPY }, 941 " }",
990 { " with ({}) ", "statement;", " more;", i::WITH_SCOPE, i::SLOPPY }, 942 "\n"
991 { " with ({}) ", "statement", "\n" 943 " more;",
992 " more;", i::WITH_SCOPE, i::SLOPPY }, 944 i::WITH_SCOPE, i::SLOPPY},
993 { " with ({})\n" 945 {" with ({}) ", "statement;", " more;", i::WITH_SCOPE, i::SLOPPY},
994 " ", "statement;", "\n" 946 {" with ({}) ", "statement",
995 " more;", i::WITH_SCOPE, i::SLOPPY }, 947 "\n"
996 { " try {} catch ", "(e) { block; }", " more;", 948 " more;",
997 i::CATCH_SCOPE, i::SLOPPY }, 949 i::WITH_SCOPE, i::SLOPPY},
998 { " try {} catch ", "(e) { block; }", "; more;", 950 {" with ({})\n"
999 i::CATCH_SCOPE, i::SLOPPY }, 951 " ",
1000 { " try {} catch ", "(e) {\n" 952 "statement;",
1001 " block;\n" 953 "\n"
1002 " }", "\n" 954 " more;",
1003 " more;", i::CATCH_SCOPE, i::SLOPPY }, 955 i::WITH_SCOPE, i::SLOPPY},
1004 { " try {} catch ", "(e) { block; }", " finally { block; } more;", 956 {" try {} catch ", "(e) { block; }", " more;", i::CATCH_SCOPE,
1005 i::CATCH_SCOPE, i::SLOPPY }, 957 i::SLOPPY},
1006 { " start;\n" 958 {" try {} catch ", "(e) { block; }", "; more;", i::CATCH_SCOPE,
1007 " ", "{ let block; }", " more;", i::BLOCK_SCOPE, i::STRICT }, 959 i::SLOPPY},
1008 { " start;\n" 960 {" try {} catch ",
1009 " ", "{ let block; }", "; more;", i::BLOCK_SCOPE, i::STRICT }, 961 "(e) {\n"
1010 { " start;\n" 962 " block;\n"
1011 " ", "{\n" 963 " }",
1012 " let block;\n" 964 "\n"
1013 " }", "\n" 965 " more;",
1014 " more;", i::BLOCK_SCOPE, i::STRICT }, 966 i::CATCH_SCOPE, i::SLOPPY},
1015 { " start;\n" 967 {" try {} catch ", "(e) { block; }", " finally { block; } more;",
1016 " function fun", "(a,b) { infunction; }", " more;", 968 i::CATCH_SCOPE, i::SLOPPY},
1017 i::FUNCTION_SCOPE, i::SLOPPY }, 969 {" start;\n"
1018 { " start;\n" 970 " ",
1019 " function fun", "(a,b) {\n" 971 "{ let block; }", " more;", i::BLOCK_SCOPE, i::STRICT},
1020 " infunction;\n" 972 {" start;\n"
1021 " }", "\n" 973 " ",
1022 " more;", i::FUNCTION_SCOPE, i::SLOPPY }, 974 "{ let block; }", "; more;", i::BLOCK_SCOPE, i::STRICT},
1023 { " start;\n", "(a,b) => a + b", "; more;", 975 {" start;\n"
1024 i::FUNCTION_SCOPE, i::SLOPPY }, 976 " ",
1025 { " start;\n", "(a,b) => { return a+b; }", "\nmore;", 977 "{\n"
1026 i::FUNCTION_SCOPE, i::SLOPPY }, 978 " let block;\n"
1027 { " start;\n" 979 " }",
1028 " (function fun", "(a,b) { infunction; }", ")();", 980 "\n"
1029 i::FUNCTION_SCOPE, i::SLOPPY }, 981 " more;",
1030 { " for ", "(let x = 1 ; x < 10; ++ x) { block; }", " more;", 982 i::BLOCK_SCOPE, i::STRICT},
1031 i::BLOCK_SCOPE, i::STRICT }, 983 {" start;\n"
1032 { " for ", "(let x = 1 ; x < 10; ++ x) { block; }", "; more;", 984 " function fun",
1033 i::BLOCK_SCOPE, i::STRICT }, 985 "(a,b) { infunction; }", " more;", i::FUNCTION_SCOPE, i::SLOPPY},
1034 { " for ", "(let x = 1 ; x < 10; ++ x) {\n" 986 {" start;\n"
1035 " block;\n" 987 " function fun",
1036 " }", "\n" 988 "(a,b) {\n"
1037 " more;", i::BLOCK_SCOPE, i::STRICT }, 989 " infunction;\n"
1038 { " for ", "(let x = 1 ; x < 10; ++ x) statement;", " more;", 990 " }",
1039 i::BLOCK_SCOPE, i::STRICT }, 991 "\n"
1040 { " for ", "(let x = 1 ; x < 10; ++ x) statement", "\n" 992 " more;",
1041 " more;", i::BLOCK_SCOPE, i::STRICT }, 993 i::FUNCTION_SCOPE, i::SLOPPY},
1042 { " for ", "(let x = 1 ; x < 10; ++ x)\n" 994 {" start;\n", "(a,b) => a + b", "; more;", i::FUNCTION_SCOPE, i::SLOPPY},
1043 " statement;", "\n" 995 {" start;\n", "(a,b) => { return a+b; }", "\nmore;", i::FUNCTION_SCOPE,
1044 " more;", i::BLOCK_SCOPE, i::STRICT }, 996 i::SLOPPY},
1045 { " for ", "(let x in {}) { block; }", " more;", 997 {" start;\n"
1046 i::BLOCK_SCOPE, i::STRICT }, 998 " (function fun",
1047 { " for ", "(let x in {}) { block; }", "; more;", 999 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1048 i::BLOCK_SCOPE, i::STRICT }, 1000 {" for ", "(let x = 1 ; x < 10; ++ x) { block; }", " more;",
1049 { " for ", "(let x in {}) {\n" 1001 i::BLOCK_SCOPE, i::STRICT},
1050 " block;\n" 1002 {" for ", "(let x = 1 ; x < 10; ++ x) { block; }", "; more;",
1051 " }", "\n" 1003 i::BLOCK_SCOPE, i::STRICT},
1052 " more;", i::BLOCK_SCOPE, i::STRICT }, 1004 {" for ",
1053 { " for ", "(let x in {}) statement;", " more;", 1005 "(let x = 1 ; x < 10; ++ x) {\n"
1054 i::BLOCK_SCOPE, i::STRICT }, 1006 " block;\n"
1055 { " for ", "(let x in {}) statement", "\n" 1007 " }",
1056 " more;", i::BLOCK_SCOPE, i::STRICT }, 1008 "\n"
1057 { " for ", "(let x in {})\n" 1009 " more;",
1058 " statement;", "\n" 1010 i::BLOCK_SCOPE, i::STRICT},
1059 " more;", i::BLOCK_SCOPE, i::STRICT }, 1011 {" for ", "(let x = 1 ; x < 10; ++ x) statement;", " more;",
1060 // Check that 6-byte and 4-byte encodings of UTF-8 strings do not throw 1012 i::BLOCK_SCOPE, i::STRICT},
1061 // the preparser off in terms of byte offsets. 1013 {" for ", "(let x = 1 ; x < 10; ++ x) statement",
1062 // 6 byte encoding. 1014 "\n"
1063 { " 'foo\355\240\201\355\260\211';\n" 1015 " more;",
1064 " (function fun", "(a,b) { infunction; }", ")();", 1016 i::BLOCK_SCOPE, i::STRICT},
1065 i::FUNCTION_SCOPE, i::SLOPPY }, 1017 {" for ",
1066 // 4 byte encoding. 1018 "(let x = 1 ; x < 10; ++ x)\n"
1067 { " 'foo\360\220\220\212';\n" 1019 " statement;",
1068 " (function fun", "(a,b) { infunction; }", ")();", 1020 "\n"
1069 i::FUNCTION_SCOPE, i::SLOPPY }, 1021 " more;",
1070 // 3 byte encoding of \u0fff. 1022 i::BLOCK_SCOPE, i::STRICT},
1071 { " 'foo\340\277\277';\n" 1023 {" for ", "(let x in {}) { block; }", " more;", i::BLOCK_SCOPE,
1072 " (function fun", "(a,b) { infunction; }", ")();", 1024 i::STRICT},
1073 i::FUNCTION_SCOPE, i::SLOPPY }, 1025 {" for ", "(let x in {}) { block; }", "; more;", i::BLOCK_SCOPE,
1074 // Broken 6 byte encoding with missing last byte. 1026 i::STRICT},
1075 { " 'foo\355\240\201\355\211';\n" 1027 {" for ",
1076 " (function fun", "(a,b) { infunction; }", ")();", 1028 "(let x in {}) {\n"
1077 i::FUNCTION_SCOPE, i::SLOPPY }, 1029 " block;\n"
1078 // Broken 3 byte encoding of \u0fff with missing last byte. 1030 " }",
1079 { " 'foo\340\277';\n" 1031 "\n"
1080 " (function fun", "(a,b) { infunction; }", ")();", 1032 " more;",
1081 i::FUNCTION_SCOPE, i::SLOPPY }, 1033 i::BLOCK_SCOPE, i::STRICT},
1082 // Broken 3 byte encoding of \u0fff with missing 2 last bytes. 1034 {" for ", "(let x in {}) statement;", " more;", i::BLOCK_SCOPE,
1083 { " 'foo\340';\n" 1035 i::STRICT},
1084 " (function fun", "(a,b) { infunction; }", ")();", 1036 {" for ", "(let x in {}) statement",
1085 i::FUNCTION_SCOPE, i::SLOPPY }, 1037 "\n"
1086 // Broken 3 byte encoding of \u00ff should be a 2 byte encoding. 1038 " more;",
1087 { " 'foo\340\203\277';\n" 1039 i::BLOCK_SCOPE, i::STRICT},
1088 " (function fun", "(a,b) { infunction; }", ")();", 1040 {" for ",
1089 i::FUNCTION_SCOPE, i::SLOPPY }, 1041 "(let x in {})\n"
1090 // Broken 3 byte encoding of \u007f should be a 2 byte encoding. 1042 " statement;",
1091 { " 'foo\340\201\277';\n" 1043 "\n"
1092 " (function fun", "(a,b) { infunction; }", ")();", 1044 " more;",
1093 i::FUNCTION_SCOPE, i::SLOPPY }, 1045 i::BLOCK_SCOPE, i::STRICT},
1094 // Unpaired lead surrogate. 1046 // Check that 6-byte and 4-byte encodings of UTF-8 strings do not throw
1095 { " 'foo\355\240\201';\n" 1047 // the preparser off in terms of byte offsets.
1096 " (function fun", "(a,b) { infunction; }", ")();", 1048 // 2 surrogates, encode a character that doesn't need a surrogate.
1097 i::FUNCTION_SCOPE, i::SLOPPY }, 1049 {" 'foo\355\240\201\355\260\211';\n"
1098 // Unpaired lead surrogate where following code point is a 3 byte sequence. 1050 " (function fun",
1099 { " 'foo\355\240\201\340\277\277';\n" 1051 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1100 " (function fun", "(a,b) { infunction; }", ")();", 1052 // 4 byte encoding.
1101 i::FUNCTION_SCOPE, i::SLOPPY }, 1053 {" 'foo\360\220\220\212';\n"
1102 // Unpaired lead surrogate where following code point is a 4 byte encoding 1054 " (function fun",
1103 // of a trail surrogate. 1055 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1104 { " 'foo\355\240\201\360\215\260\211';\n" 1056 // 3 byte encoding of \u0fff.
1105 " (function fun", "(a,b) { infunction; }", ")();", 1057 {" 'foo\340\277\277';\n"
1106 i::FUNCTION_SCOPE, i::SLOPPY }, 1058 " (function fun",
1107 // Unpaired trail surrogate. 1059 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1108 { " 'foo\355\260\211';\n" 1060 // 3 byte surrogate, followed by broken 2-byte surrogate w/ impossible 2nd
1109 " (function fun", "(a,b) { infunction; }", ")();", 1061 // byte and last byte missing.
1110 i::FUNCTION_SCOPE, i::SLOPPY }, 1062 {" 'foo\355\240\201\355\211';\n"
1111 // 2 byte encoding of \u00ff. 1063 " (function fun",
1112 { " 'foo\303\277';\n" 1064 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1113 " (function fun", "(a,b) { infunction; }", ")();", 1065 // Broken 3 byte encoding of \u0fff with missing last byte.
1114 i::FUNCTION_SCOPE, i::SLOPPY }, 1066 {" 'foo\340\277';\n"
1115 // Broken 2 byte encoding of \u00ff with missing last byte. 1067 " (function fun",
1116 { " 'foo\303';\n" 1068 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1117 " (function fun", "(a,b) { infunction; }", ")();", 1069 // Broken 3 byte encoding of \u0fff with missing 2 last bytes.
1118 i::FUNCTION_SCOPE, i::SLOPPY }, 1070 {" 'foo\340';\n"
1119 // Broken 2 byte encoding of \u007f should be a 1 byte encoding. 1071 " (function fun",
1120 { " 'foo\301\277';\n" 1072 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1121 " (function fun", "(a,b) { infunction; }", ")();", 1073 // Broken 3 byte encoding of \u00ff should be a 2 byte encoding.
1122 i::FUNCTION_SCOPE, i::SLOPPY }, 1074 {" 'foo\340\203\277';\n"
1123 // Illegal 5 byte encoding. 1075 " (function fun",
1124 { " 'foo\370\277\277\277\277';\n" 1076 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1125 " (function fun", "(a,b) { infunction; }", ")();", 1077 // Broken 3 byte encoding of \u007f should be a 2 byte encoding.
1126 i::FUNCTION_SCOPE, i::SLOPPY }, 1078 {" 'foo\340\201\277';\n"
1127 // Illegal 6 byte encoding. 1079 " (function fun",
1128 { " 'foo\374\277\277\277\277\277';\n" 1080 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1129 " (function fun", "(a,b) { infunction; }", ")();", 1081 // Unpaired lead surrogate.
1130 i::FUNCTION_SCOPE, i::SLOPPY }, 1082 {" 'foo\355\240\201';\n"
1131 // Illegal 0xfe byte 1083 " (function fun",
1132 { " 'foo\376\277\277\277\277\277\277';\n" 1084 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1133 " (function fun", "(a,b) { infunction; }", ")();", 1085 // Unpaired lead surrogate where following code point is a 3 byte
1134 i::FUNCTION_SCOPE, i::SLOPPY }, 1086 // sequence.
1135 // Illegal 0xff byte 1087 {" 'foo\355\240\201\340\277\277';\n"
1136 { " 'foo\377\277\277\277\277\277\277\277';\n" 1088 " (function fun",
1137 " (function fun", "(a,b) { infunction; }", ")();", 1089 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1138 i::FUNCTION_SCOPE, i::SLOPPY }, 1090 // Unpaired lead surrogate where following code point is a 4 byte encoding
1139 { " 'foo';\n" 1091 // of a trail surrogate.
1140 " (function fun", "(a,b) { 'bar\355\240\201\355\260\213'; }", ")();", 1092 {" 'foo\355\240\201\360\215\260\211';\n"
1141 i::FUNCTION_SCOPE, i::SLOPPY }, 1093 " (function fun",
1142 { " 'foo';\n" 1094 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1143 " (function fun", "(a,b) { 'bar\360\220\220\214'; }", ")();", 1095 // Unpaired trail surrogate.
1144 i::FUNCTION_SCOPE, i::SLOPPY }, 1096 {" 'foo\355\260\211';\n"
1145 { NULL, NULL, NULL, i::EVAL_SCOPE, i::SLOPPY } 1097 " (function fun",
1146 }; 1098 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1099 // 2 byte encoding of \u00ff.
1100 {" 'foo\303\277';\n"
1101 " (function fun",
1102 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1103 // Broken 2 byte encoding of \u00ff with missing last byte.
1104 {" 'foo\303';\n"
1105 " (function fun",
1106 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1107 // Broken 2 byte encoding of \u007f should be a 1 byte encoding.
1108 {" 'foo\301\277';\n"
1109 " (function fun",
1110 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1111 // Illegal 5 byte encoding.
1112 {" 'foo\370\277\277\277\277';\n"
1113 " (function fun",
1114 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1115 // Illegal 6 byte encoding.
1116 {" 'foo\374\277\277\277\277\277';\n"
1117 " (function fun",
1118 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1119 // Illegal 0xfe byte
1120 {" 'foo\376\277\277\277\277\277\277';\n"
1121 " (function fun",
1122 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1123 // Illegal 0xff byte
1124 {" 'foo\377\277\277\277\277\277\277\277';\n"
1125 " (function fun",
1126 "(a,b) { infunction; }", ")();", i::FUNCTION_SCOPE, i::SLOPPY},
1127 {" 'foo';\n"
1128 " (function fun",
1129 "(a,b) { 'bar\355\240\201\355\260\213'; }", ")();", i::FUNCTION_SCOPE,
1130 i::SLOPPY},
1131 {" 'foo';\n"
1132 " (function fun",
1133 "(a,b) { 'bar\360\220\220\214'; }", ")();", i::FUNCTION_SCOPE,
1134 i::SLOPPY},
1135 {NULL, NULL, NULL, i::EVAL_SCOPE, i::SLOPPY}};
1147 1136
1148 i::Isolate* isolate = CcTest::i_isolate(); 1137 i::Isolate* isolate = CcTest::i_isolate();
1149 i::Factory* factory = isolate->factory(); 1138 i::Factory* factory = isolate->factory();
1150 1139
1151 v8::HandleScope handles(CcTest::isolate()); 1140 v8::HandleScope handles(CcTest::isolate());
1152 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); 1141 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate());
1153 v8::Context::Scope context_scope(context); 1142 v8::Context::Scope context_scope(context);
1154 1143
1155 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - 1144 isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() -
1156 128 * 1024); 1145 128 * 1024);
(...skipping 7174 matching lines...) Expand 10 before | Expand all | Expand 10 after
8331 const char* data[] = { 8320 const char* data[] = {
8332 "const arguments = 1", 8321 "const arguments = 1",
8333 "let arguments", 8322 "let arguments",
8334 "var arguments", 8323 "var arguments",
8335 NULL 8324 NULL
8336 }; 8325 };
8337 // clang-format on 8326 // clang-format on
8338 RunParserSyncTest(context_data, data, kSuccess); 8327 RunParserSyncTest(context_data, data, kSuccess);
8339 } 8328 }
8340 } 8329 }
OLDNEW
« no previous file with comments | « src/unicode.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698