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

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

Issue 350353002: Test that trailing commas in object literals are allowed (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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
« src/preparser.h ('K') | « src/preparser.h ('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 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 NULL 2233 NULL
2234 }; 2234 };
2235 2235
2236 RunParserSyncTest(context_data, statement_data, kError); 2236 RunParserSyncTest(context_data, statement_data, kError);
2237 } 2237 }
2238 2238
2239 2239
2240 TEST(StrictObjectLiteralChecking) { 2240 TEST(StrictObjectLiteralChecking) {
2241 const char* strict_context_data[][2] = { 2241 const char* strict_context_data[][2] = {
2242 {"\"use strict\"; var myobject = {", "};"}, 2242 {"\"use strict\"; var myobject = {", "};"},
2243 {"\"use strict\"; var myobject = {", ",};"},
2243 { NULL, NULL } 2244 { NULL, NULL }
2244 }; 2245 };
2245 const char* non_strict_context_data[][2] = { 2246 const char* non_strict_context_data[][2] = {
2246 {"var myobject = {", "};"}, 2247 {"var myobject = {", "};"},
2248 {"var myobject = {", ",};"},
2247 { NULL, NULL } 2249 { NULL, NULL }
2248 }; 2250 };
2249 2251
2250 // These are only errors in strict mode. 2252 // These are only errors in strict mode.
2251 const char* statement_data[] = { 2253 const char* statement_data[] = {
2252 "foo: 1, foo: 2", 2254 "foo: 1, foo: 2",
2253 "\"foo\": 1, \"foo\": 2", 2255 "\"foo\": 1, \"foo\": 2",
2254 "foo: 1, \"foo\": 2", 2256 "foo: 1, \"foo\": 2",
2255 "1: 1, 1: 2", 2257 "1: 1, 1: 2",
2256 "1: 1, \"1\": 2", 2258 "1: 1, \"1\": 2",
2257 "get: 1, get: 2", // Not a getter for real, just a property called get. 2259 "get: 1, get: 2", // Not a getter for real, just a property called get.
2258 "set: 1, set: 2", // Not a setter for real, just a property called set. 2260 "set: 1, set: 2", // Not a setter for real, just a property called set.
2259 NULL 2261 NULL
2260 }; 2262 };
2261 2263
2262 RunParserSyncTest(non_strict_context_data, statement_data, kSuccess); 2264 RunParserSyncTest(non_strict_context_data, statement_data, kSuccess);
2263 RunParserSyncTest(strict_context_data, statement_data, kError); 2265 RunParserSyncTest(strict_context_data, statement_data, kError);
2264 } 2266 }
2265 2267
2266 2268
2267 TEST(ErrorsObjectLiteralChecking) { 2269 TEST(ErrorsObjectLiteralChecking) {
2268 const char* context_data[][2] = { 2270 const char* context_data[][2] = {
2269 {"\"use strict\"; var myobject = {", "};"}, 2271 {"\"use strict\"; var myobject = {", "};"},
2270 {"var myobject = {", "};"}, 2272 {"var myobject = {", "};"},
2271 { NULL, NULL } 2273 { NULL, NULL }
2272 }; 2274 };
2273 2275
2274 const char* statement_data[] = { 2276 const char* statement_data[] = {
2277 ",",
2275 "foo: 1, get foo() {}", 2278 "foo: 1, get foo() {}",
2276 "foo: 1, set foo(v) {}", 2279 "foo: 1, set foo(v) {}",
2277 "\"foo\": 1, get \"foo\"() {}", 2280 "\"foo\": 1, get \"foo\"() {}",
2278 "\"foo\": 1, set \"foo\"(v) {}", 2281 "\"foo\": 1, set \"foo\"(v) {}",
2279 "1: 1, get 1() {}", 2282 "1: 1, get 1() {}",
2280 "1: 1, set 1() {}", 2283 "1: 1, set 1() {}",
2281 // It's counter-intuitive, but these collide too (even in classic 2284 // It's counter-intuitive, but these collide too (even in classic
2282 // mode). Note that we can have "foo" and foo as properties in classic mode, 2285 // mode). Note that we can have "foo" and foo as properties in classic mode,
2283 // but we cannot have "foo" and get foo, or foo and get "foo". 2286 // but we cannot have "foo" and get foo, or foo and get "foo".
2284 "foo: 1, get \"foo\"() {}", 2287 "foo: 1, get \"foo\"() {}",
(...skipping 15 matching lines...) Expand all
2300 NULL 2303 NULL
2301 }; 2304 };
2302 2305
2303 RunParserSyncTest(context_data, statement_data, kError); 2306 RunParserSyncTest(context_data, statement_data, kError);
2304 } 2307 }
2305 2308
2306 2309
2307 TEST(NoErrorsObjectLiteralChecking) { 2310 TEST(NoErrorsObjectLiteralChecking) {
2308 const char* context_data[][2] = { 2311 const char* context_data[][2] = {
2309 {"var myobject = {", "};"}, 2312 {"var myobject = {", "};"},
2313 {"var myobject = {", ",};"},
2310 {"\"use strict\"; var myobject = {", "};"}, 2314 {"\"use strict\"; var myobject = {", "};"},
2315 {"\"use strict\"; var myobject = {", ",};"},
2311 { NULL, NULL } 2316 { NULL, NULL }
2312 }; 2317 };
2313 2318
2314 const char* statement_data[] = { 2319 const char* statement_data[] = {
2315 "foo: 1, bar: 2", 2320 "foo: 1, bar: 2",
2316 "\"foo\": 1, \"bar\": 2", 2321 "\"foo\": 1, \"bar\": 2",
2317 "1: 1, 2: 2", 2322 "1: 1, 2: 2",
2318 // Syntax: IdentifierName ':' AssignmentExpression 2323 // Syntax: IdentifierName ':' AssignmentExpression
2319 "foo: bar = 5 + baz", 2324 "foo: bar = 5 + baz",
2320 // Syntax: 'get' PropertyName '(' ')' '{' FunctionBody '}' 2325 // Syntax: 'get' PropertyName '(' ')' '{' FunctionBody '}'
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 v8::Isolate* isolate = CcTest::isolate(); 2607 v8::Isolate* isolate = CcTest::isolate();
2603 v8::HandleScope scope(isolate); 2608 v8::HandleScope scope(isolate);
2604 LocalContext env; 2609 LocalContext env;
2605 i::FLAG_lazy = true; 2610 i::FLAG_lazy = true;
2606 i::FLAG_min_preparse_length = 0; 2611 i::FLAG_min_preparse_length = 0;
2607 CompileRun("function this_is_lazy() {\n" 2612 CompileRun("function this_is_lazy() {\n"
2608 " break p;\n" 2613 " break p;\n"
2609 "}\n" 2614 "}\n"
2610 "this_is_lazy();\n"); 2615 "this_is_lazy();\n");
2611 } 2616 }
OLDNEW
« src/preparser.h ('K') | « src/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698