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

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

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