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

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

Issue 136413003: Deprecate ScriptData::PreCompile which takes const char*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: just removing Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-api.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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 "var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n", 137 "var x = 42; /* precomment\n */ --> is eol-comment\nvar y = 37;\n",
138 NULL 138 NULL
139 }; 139 };
140 140
141 // Parser/Scanner needs a stack limit. 141 // Parser/Scanner needs a stack limit.
142 int marker; 142 int marker;
143 CcTest::i_isolate()->stack_guard()->SetStackLimit( 143 CcTest::i_isolate()->stack_guard()->SetStackLimit(
144 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 144 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
145 145
146 for (int i = 0; tests[i]; i++) { 146 for (int i = 0; tests[i]; i++) {
147 v8::ScriptData* data = 147 v8::Handle<v8::String> source = v8::String::NewFromUtf8(
148 v8::ScriptData::PreCompile(isolate, tests[i], i::StrLength(tests[i])); 148 isolate, tests[i], v8::String::kNormalString, i::StrLength(tests[i]));
149 v8::ScriptData* data = v8::ScriptData::PreCompile(source);
149 CHECK(data != NULL && !data->HasError()); 150 CHECK(data != NULL && !data->HasError());
150 delete data; 151 delete data;
151 } 152 }
152 153
153 for (int i = 0; fail_tests[i]; i++) { 154 for (int i = 0; fail_tests[i]; i++) {
154 v8::ScriptData* data = v8::ScriptData::PreCompile( 155 v8::Handle<v8::String> source =
155 isolate, fail_tests[i], i::StrLength(fail_tests[i])); 156 v8::String::NewFromUtf8(isolate,
157 fail_tests[i],
158 v8::String::kNormalString,
159 i::StrLength(fail_tests[i]));
160 v8::ScriptData* data = v8::ScriptData::PreCompile(source);
156 CHECK(data == NULL || data->HasError()); 161 CHECK(data == NULL || data->HasError());
157 delete data; 162 delete data;
158 } 163 }
159 } 164 }
160 165
161 166
162 class ScriptResource : public v8::String::ExternalAsciiStringResource { 167 class ScriptResource : public v8::String::ExternalAsciiStringResource {
163 public: 168 public:
164 ScriptResource(const char* data, size_t length) 169 ScriptResource(const char* data, size_t length)
165 : data_(data), length_(length) { } 170 : data_(data), length_(length) { }
(...skipping 26 matching lines...) Expand all
192 " 42: 'number literal', for: 'keyword as propertyName', " 197 " 42: 'number literal', for: 'keyword as propertyName', "
193 " f\\u006fr: 'keyword propertyname with escape'};" 198 " f\\u006fr: 'keyword propertyname with escape'};"
194 "var v = /RegExp Literal/;" 199 "var v = /RegExp Literal/;"
195 "var w = /RegExp Literal\\u0020With Escape/gin;" 200 "var w = /RegExp Literal\\u0020With Escape/gin;"
196 "var y = { get getter() { return 42; }, " 201 "var y = { get getter() { return 42; }, "
197 " set setter(v) { this.value = v; }};"; 202 " set setter(v) { this.value = v; }};";
198 int source_length = i::StrLength(source); 203 int source_length = i::StrLength(source);
199 const char* error_source = "var x = y z;"; 204 const char* error_source = "var x = y z;";
200 int error_source_length = i::StrLength(error_source); 205 int error_source_length = i::StrLength(error_source);
201 206
202 v8::ScriptData* preparse = 207 v8::ScriptData* preparse = v8::ScriptData::PreCompile(v8::String::NewFromUtf8(
203 v8::ScriptData::PreCompile(isolate, source, source_length); 208 isolate, source, v8::String::kNormalString, source_length));
204 CHECK(!preparse->HasError()); 209 CHECK(!preparse->HasError());
205 bool lazy_flag = i::FLAG_lazy; 210 bool lazy_flag = i::FLAG_lazy;
206 { 211 {
207 i::FLAG_lazy = true; 212 i::FLAG_lazy = true;
208 ScriptResource* resource = new ScriptResource(source, source_length); 213 ScriptResource* resource = new ScriptResource(source, source_length);
209 v8::Local<v8::String> script_source = 214 v8::Local<v8::String> script_source =
210 v8::String::NewExternal(isolate, resource); 215 v8::String::NewExternal(isolate, resource);
211 v8::Script::Compile(script_source, NULL, preparse); 216 v8::Script::Compile(script_source, NULL, preparse);
212 } 217 }
213 218
214 { 219 {
215 i::FLAG_lazy = false; 220 i::FLAG_lazy = false;
216 221
217 ScriptResource* resource = new ScriptResource(source, source_length); 222 ScriptResource* resource = new ScriptResource(source, source_length);
218 v8::Local<v8::String> script_source = 223 v8::Local<v8::String> script_source =
219 v8::String::NewExternal(isolate, resource); 224 v8::String::NewExternal(isolate, resource);
220 v8::Script::New(script_source, NULL, preparse, v8::Local<v8::String>()); 225 v8::Script::New(script_source, NULL, preparse, v8::Local<v8::String>());
221 } 226 }
222 delete preparse; 227 delete preparse;
223 i::FLAG_lazy = lazy_flag; 228 i::FLAG_lazy = lazy_flag;
224 229
225 // Syntax error. 230 // Syntax error.
226 v8::ScriptData* error_preparse = 231 v8::ScriptData* error_preparse = v8::ScriptData::PreCompile(
227 v8::ScriptData::PreCompile(isolate, error_source, error_source_length); 232 v8::String::NewFromUtf8(isolate,
233 error_source,
234 v8::String::kNormalString,
235 error_source_length));
228 CHECK(error_preparse->HasError()); 236 CHECK(error_preparse->HasError());
229 i::ScriptDataImpl *pre_impl = 237 i::ScriptDataImpl *pre_impl =
230 reinterpret_cast<i::ScriptDataImpl*>(error_preparse); 238 reinterpret_cast<i::ScriptDataImpl*>(error_preparse);
231 i::Scanner::Location error_location = 239 i::Scanner::Location error_location =
232 pre_impl->MessageLocation(); 240 pre_impl->MessageLocation();
233 // Error is at "z" in source, location 10..11. 241 // Error is at "z" in source, location 10..11.
234 CHECK_EQ(10, error_location.beg_pos); 242 CHECK_EQ(10, error_location.beg_pos);
235 CHECK_EQ(11, error_location.end_pos); 243 CHECK_EQ(11, error_location.end_pos);
236 // Should not crash. 244 // Should not crash.
237 const char* message = pre_impl->BuildMessage(); 245 const char* message = pre_impl->BuildMessage();
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 " b = function() { \n" 1337 " b = function() { \n"
1330 " 01; \n" 1338 " 01; \n"
1331 " }; \n" 1339 " }; \n"
1332 "}; \n"; 1340 "}; \n";
1333 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), script)); 1341 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), script));
1334 CHECK(try_catch.HasCaught()); 1342 CHECK(try_catch.HasCaught());
1335 v8::String::Utf8Value exception(try_catch.Exception()); 1343 v8::String::Utf8Value exception(try_catch.Exception());
1336 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", 1344 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.",
1337 *exception); 1345 *exception);
1338 } 1346 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698