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

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

Issue 352173004: Relax object literal checking to follow ES6 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/mjsunit/strict-mode.js » ('j') | 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 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 "\"foo\": 1, \"foo\": 2", 2255 "\"foo\": 1, \"foo\": 2",
2256 "foo: 1, \"foo\": 2", 2256 "foo: 1, \"foo\": 2",
2257 "1: 1, 1: 2", 2257 "1: 1, 1: 2",
2258 "1: 1, \"1\": 2", 2258 "1: 1, \"1\": 2",
2259 "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.
2260 "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.
2261 NULL 2261 NULL
2262 }; 2262 };
2263 2263
2264 RunParserSyncTest(non_strict_context_data, statement_data, kSuccess); 2264 RunParserSyncTest(non_strict_context_data, statement_data, kSuccess);
2265 RunParserSyncTest(strict_context_data, statement_data, kError); 2265 RunParserSyncTest(strict_context_data, statement_data, kSuccess);
2266 } 2266 }
2267 2267
2268 2268
2269 TEST(ErrorsObjectLiteralChecking) { 2269 TEST(DuplicatePropertyObjectLiteralChecking) {
2270 const char* context_data[][2] = { 2270 const char* context_data[][2] = {
2271 {"\"use strict\"; var myobject = {", "};"}, 2271 {"\"use strict\"; var myobject = {", "};"},
2272 {"var myobject = {", "};"}, 2272 {"var myobject = {", "};"},
2273 { NULL, NULL } 2273 { NULL, NULL }
2274 }; 2274 };
2275 2275
2276 const char* statement_data[] = { 2276 const char* statement_data[] = {
2277 ",",
2278 "foo: 1, get foo() {}", 2277 "foo: 1, get foo() {}",
2279 "foo: 1, set foo(v) {}", 2278 "foo: 1, set foo(v) {}",
2280 "\"foo\": 1, get \"foo\"() {}", 2279 "\"foo\": 1, get \"foo\"() {}",
2281 "\"foo\": 1, set \"foo\"(v) {}", 2280 "\"foo\": 1, set \"foo\"(v) {}",
2282 "1: 1, get 1() {}", 2281 "1: 1, get 1() {}",
2283 "1: 1, set 1() {}", 2282 "1: 1, set 1(v) {}",
2284 // It's counter-intuitive, but these collide too (even in classic
2285 // mode). Note that we can have "foo" and foo as properties in classic mode,
2286 // but we cannot have "foo" and get foo, or foo and get "foo".
2287 "foo: 1, get \"foo\"() {}", 2283 "foo: 1, get \"foo\"() {}",
2288 "foo: 1, set \"foo\"(v) {}", 2284 "foo: 1, set \"foo\"(v) {}",
2289 "\"foo\": 1, get foo() {}", 2285 "\"foo\": 1, get foo() {}",
2290 "\"foo\": 1, set foo(v) {}", 2286 "\"foo\": 1, set foo(v) {}",
2291 "1: 1, get \"1\"() {}", 2287 "1: 1, get \"1\"() {}",
2292 "1: 1, set \"1\"() {}", 2288 "1: 1, set \"1\"(v) {}",
2293 "\"1\": 1, get 1() {}" 2289 "\"1\": 1, get 1() {}",
2294 "\"1\": 1, set 1(v) {}" 2290 "\"1\": 1, set 1(v) {}",
2291 NULL
2292 };
2293
2294 RunParserSyncTest(context_data, statement_data, kSuccess);
2295 }
2296
2297
2298 TEST(ErrorsObjectLiteralChecking) {
2299 const char* context_data[][2] = {
2300 {"\"use strict\"; var myobject = {", "};"},
2301 {"var myobject = {", "};"},
2302 { NULL, NULL }
2303 };
2304
2305 const char* statement_data[] = {
2306 // {,} is invalid
2307 ",",
2295 // Wrong number of parameters 2308 // Wrong number of parameters
2296 "get bar(x) {}", 2309 "get bar(x) {}",
2297 "get bar(x, y) {}", 2310 "get bar(x, y) {}",
2298 "set bar() {}", 2311 "set bar() {}",
2299 "set bar(x, y) {}", 2312 "set bar(x, y) {}",
2313 "set 1() {}",
2314 "set \"1\"() {}",
2300 // Parsing FunctionLiteral for getter or setter fails 2315 // Parsing FunctionLiteral for getter or setter fails
2301 "get foo( +", 2316 "get foo( +",
2302 "get foo() \"error\"", 2317 "get foo() \"error\"",
2303 NULL 2318 NULL
2304 }; 2319 };
2305 2320
2306 RunParserSyncTest(context_data, statement_data, kError); 2321 RunParserSyncTest(context_data, statement_data, kError);
2307 } 2322 }
2308 2323
2309 2324
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2607 v8::Isolate* isolate = CcTest::isolate(); 2622 v8::Isolate* isolate = CcTest::isolate();
2608 v8::HandleScope scope(isolate); 2623 v8::HandleScope scope(isolate);
2609 LocalContext env; 2624 LocalContext env;
2610 i::FLAG_lazy = true; 2625 i::FLAG_lazy = true;
2611 i::FLAG_min_preparse_length = 0; 2626 i::FLAG_min_preparse_length = 0;
2612 CompileRun("function this_is_lazy() {\n" 2627 CompileRun("function this_is_lazy() {\n"
2613 " break p;\n" 2628 " break p;\n"
2614 "}\n" 2629 "}\n"
2615 "this_is_lazy();\n"); 2630 "this_is_lazy();\n");
2616 } 2631 }
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/mjsunit/strict-mode.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698