OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 14 matching lines...) Expand all Loading... |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <stdlib.h> | 28 #include <stdlib.h> |
29 | 29 |
30 #include "v8.h" | 30 #include "v8.h" |
31 | 31 |
32 #include "token.h" | 32 #include "token.h" |
33 #include "scanner.h" | 33 #include "scanner.h" |
34 #include "utils.h" | 34 #include "utils.h" |
| 35 #include "execution.h" |
35 | 36 |
36 #include "cctest.h" | 37 #include "cctest.h" |
37 | 38 |
38 namespace i = ::v8::internal; | 39 namespace i = ::v8::internal; |
39 | 40 |
40 TEST(KeywordMatcher) { | 41 TEST(KeywordMatcher) { |
41 struct KeywordToken { | 42 struct KeywordToken { |
42 const char* keyword; | 43 const char* keyword; |
43 i::Token::Value token; | 44 i::Token::Value token; |
44 }; | 45 }; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // If we mark it as failure, continuing won't help. | 121 // If we mark it as failure, continuing won't help. |
121 i::KeywordMatcher full_stop; | 122 i::KeywordMatcher full_stop; |
122 full_stop.AddChar('i'); | 123 full_stop.AddChar('i'); |
123 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); | 124 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); |
124 full_stop.Fail(); | 125 full_stop.Fail(); |
125 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); | 126 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); |
126 full_stop.AddChar('f'); | 127 full_stop.AddChar('f'); |
127 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); | 128 CHECK_EQ(i::Token::IDENTIFIER, full_stop.token()); |
128 } | 129 } |
129 | 130 |
| 131 |
| 132 TEST(ScanHTMLEndComments) { |
| 133 // Regression test. See: |
| 134 // http://code.google.com/p/chromium/issues/detail?id=53548 |
| 135 // Tests that --> is correctly interpreted as comment-to-end-of-line if there |
| 136 // is only whitespace before it on the line, even after a multiline-comment |
| 137 // comment. This was not the case if it occurred before the first real token |
| 138 // in the input. |
| 139 const char* tests[] = { |
| 140 // Before first real token. |
| 141 "--> is eol-comment\nvar y = 37;\n", |
| 142 "\n --> is eol-comment\nvar y = 37;\n", |
| 143 "/* precomment */ --> is eol-comment\nvar y = 37;\n", |
| 144 "\n/* precomment */ --> is eol-comment\nvar y = 37;\n", |
| 145 // After first real token. |
| 146 "var x = 42;\n--> is eol-comment\nvar y = 37;\n", |
| 147 "var x = 42;\n/* precomment */ --> is eol-comment\nvar y = 37;\n", |
| 148 NULL |
| 149 }; |
| 150 |
| 151 // Parser needs a stack limit. |
| 152 int marker; |
| 153 i::StackGuard::SetStackLimit( |
| 154 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); |
| 155 |
| 156 for (int i = 0; tests[i]; i++) { |
| 157 v8::ScriptData* data = |
| 158 v8::ScriptData::PreCompile(tests[i], strlen(tests[i])); |
| 159 CHECK(data != NULL && !data->HasError()); |
| 160 delete data; |
| 161 } |
| 162 } |
OLD | NEW |