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

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

Issue 2119763003: Recognize HTMLCloseComment after multiline comment (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add more test cases Created 4 years, 5 months 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/parsing/scanner.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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 v8::Isolate* isolate = CcTest::isolate(); 113 v8::Isolate* isolate = CcTest::isolate();
114 v8::HandleScope handles(isolate); 114 v8::HandleScope handles(isolate);
115 115
116 // Regression test. See: 116 // Regression test. See:
117 // http://code.google.com/p/chromium/issues/detail?id=53548 117 // http://code.google.com/p/chromium/issues/detail?id=53548
118 // Tests that --> is correctly interpreted as comment-to-end-of-line if there 118 // Tests that --> is correctly interpreted as comment-to-end-of-line if there
119 // is only whitespace before it on the line (with comments considered as 119 // is only whitespace before it on the line (with comments considered as
120 // whitespace, even a multiline-comment containing a newline). 120 // whitespace, even a multiline-comment containing a newline).
121 // This was not the case if it occurred before the first real token 121 // This was not the case if it occurred before the first real token
122 // in the input. 122 // in the input.
123 // clang-format off
123 const char* tests[] = { 124 const char* tests[] = {
124 // Before first real token. 125 // Before first real token.
126 "-->",
127 "--> is eol-comment",
125 "--> is eol-comment\nvar y = 37;\n", 128 "--> is eol-comment\nvar y = 37;\n",
126 "\n --> is eol-comment\nvar y = 37;\n", 129 "\n --> is eol-comment\nvar y = 37;\n",
130 "\n-->is eol-comment\nvar y = 37;\n",
131 "\n-->\nvar y = 37;\n",
127 "/* precomment */ --> is eol-comment\nvar y = 37;\n", 132 "/* precomment */ --> is eol-comment\nvar y = 37;\n",
133 "/* precomment */-->eol-comment\nvar y = 37;\n",
128 "\n/* precomment */ --> is eol-comment\nvar y = 37;\n", 134 "\n/* precomment */ --> is eol-comment\nvar y = 37;\n",
135 "\n/*precomment*/-->eol-comment\nvar y = 37;\n",
129 // After first real token. 136 // After first real token.
130 "var x = 42;\n--> is eol-comment\nvar y = 37;\n", 137 "var x = 42;\n--> is eol-comment\nvar y = 37;\n",
131 "var x = 42;\n/* precomment */ --> is eol-comment\nvar y = 37;\n", 138 "var x = 42;\n/* precomment */ --> is eol-comment\nvar y = 37;\n",
139 "x/* precomment\n */ --> is eol-comment\nvar y = 37;\n",
140 "var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n",
141 "var x = 42;/*\n*/-->is eol-comment\nvar y = 37;\n",
142 // With multiple comments preceding HTMLEndComment
143 "/* MLC \n */ /* SLDC */ --> is eol-comment\nvar y = 37;\n",
144 "/* MLC \n */ /* SLDC1 */ /* SLDC2 */ --> is eol-comment\nvar y = 37;\n",
145 "/* MLC1 \n */ /* MLC2 \n */ --> is eol-comment\nvar y = 37;\n",
146 "/* SLDC */ /* MLC \n */ --> is eol-comment\nvar y = 37;\n",
147 "/* MLC1 \n */ /* SLDC1 */ /* MLC2 \n */ /* SLDC2 */ --> is eol-comment\n"
148 "var y = 37;\n",
132 NULL 149 NULL
133 }; 150 };
134 151
135 const char* fail_tests[] = { 152 const char* fail_tests[] = {
136 "x --> is eol-comment\nvar y = 37;\n", 153 "x --> is eol-comment\nvar y = 37;\n",
137 "\"\\n\" --> is eol-comment\nvar y = 37;\n", 154 "\"\\n\" --> is eol-comment\nvar y = 37;\n",
138 "x/* precomment */ --> is eol-comment\nvar y = 37;\n", 155 "x/* precomment */ --> is eol-comment\nvar y = 37;\n",
139 "x/* precomment\n */ --> is eol-comment\nvar y = 37;\n",
140 "var x = 42; --> is eol-comment\nvar y = 37;\n", 156 "var x = 42; --> is eol-comment\nvar y = 37;\n",
141 "var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n",
142 NULL 157 NULL
143 }; 158 };
159 // clang-format on
144 160
145 // Parser/Scanner needs a stack limit. 161 // Parser/Scanner needs a stack limit.
146 CcTest::i_isolate()->stack_guard()->SetStackLimit( 162 CcTest::i_isolate()->stack_guard()->SetStackLimit(
147 i::GetCurrentStackPosition() - 128 * 1024); 163 i::GetCurrentStackPosition() - 128 * 1024);
148 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); 164 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
149 for (int i = 0; tests[i]; i++) { 165 for (int i = 0; tests[i]; i++) {
150 const i::byte* source = 166 const i::byte* source =
151 reinterpret_cast<const i::byte*>(tests[i]); 167 reinterpret_cast<const i::byte*>(tests[i]);
152 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i])); 168 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i]));
153 i::CompleteParserRecorder log; 169 i::CompleteParserRecorder log;
(...skipping 7786 matching lines...) Expand 10 before | Expand all | Expand 10 after
7940 "(a,);", 7956 "(a,);",
7941 "(a,b,c,);", 7957 "(a,b,c,);",
7942 NULL 7958 NULL
7943 }; 7959 };
7944 // clang-format on 7960 // clang-format on
7945 7961
7946 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; 7962 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas};
7947 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 7963 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
7948 arraysize(always_flags)); 7964 arraysize(always_flags));
7949 } 7965 }
OLDNEW
« no previous file with comments | « src/parsing/scanner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698