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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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. |
125 "--> is eol-comment\nvar y = 37;\n", | 126 "--> is eol-comment\nvar y = 37;\n", |
126 "\n --> is eol-comment\nvar y = 37;\n", | 127 "\n --> is eol-comment\nvar y = 37;\n", |
127 "/* precomment */ --> is eol-comment\nvar y = 37;\n", | 128 "/* precomment */ --> is eol-comment\nvar y = 37;\n", |
128 "\n/* precomment */ --> is eol-comment\nvar y = 37;\n", | 129 "\n/* precomment */ --> is eol-comment\nvar y = 37;\n", |
129 // After first real token. | 130 // After first real token. |
130 "var x = 42;\n--> is eol-comment\nvar y = 37;\n", | 131 "var x = 42;\n--> is eol-comment\nvar y = 37;\n", |
131 "var x = 42;\n/* precomment */ --> is eol-comment\nvar y = 37;\n", | 132 "var x = 42;\n/* precomment */ --> is eol-comment\nvar y = 37;\n", |
133 "x/* precomment\n */ --> is eol-comment\nvar y = 37;\n", | |
134 "var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n", | |
nickie
2016/07/04 08:27:10
According to the spec [1], the end of a real multi
| |
132 NULL | 135 NULL |
133 }; | 136 }; |
134 | 137 |
135 const char* fail_tests[] = { | 138 const char* fail_tests[] = { |
136 "x --> is eol-comment\nvar y = 37;\n", | 139 "x --> is eol-comment\nvar y = 37;\n", |
137 "\"\\n\" --> is eol-comment\nvar y = 37;\n", | 140 "\"\\n\" --> is eol-comment\nvar y = 37;\n", |
138 "x/* precomment */ --> is eol-comment\nvar y = 37;\n", | 141 "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", | 142 "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 | 143 NULL |
143 }; | 144 }; |
145 // clang-format on | |
144 | 146 |
145 // Parser/Scanner needs a stack limit. | 147 // Parser/Scanner needs a stack limit. |
146 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 148 CcTest::i_isolate()->stack_guard()->SetStackLimit( |
147 i::GetCurrentStackPosition() - 128 * 1024); | 149 i::GetCurrentStackPosition() - 128 * 1024); |
148 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 150 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); |
149 for (int i = 0; tests[i]; i++) { | 151 for (int i = 0; tests[i]; i++) { |
150 const i::byte* source = | 152 const i::byte* source = |
151 reinterpret_cast<const i::byte*>(tests[i]); | 153 reinterpret_cast<const i::byte*>(tests[i]); |
152 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i])); | 154 i::Utf8ToUtf16CharacterStream stream(source, i::StrLength(tests[i])); |
153 i::CompleteParserRecorder log; | 155 i::CompleteParserRecorder log; |
(...skipping 7786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7940 "(a,);", | 7942 "(a,);", |
7941 "(a,b,c,);", | 7943 "(a,b,c,);", |
7942 NULL | 7944 NULL |
7943 }; | 7945 }; |
7944 // clang-format on | 7946 // clang-format on |
7945 | 7947 |
7946 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 7948 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
7947 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 7949 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
7948 arraysize(always_flags)); | 7950 arraysize(always_flags)); |
7949 } | 7951 } |
OLD | NEW |