Chromium Code Reviews

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

Issue 2695973003: ParserBase should accept ESCAPED_STRICT_RESERVED_WORD as an identifier (Closed)
Patch Set: Add cctest, improve mjsunit Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « src/parsing/parser-base.h ('k') | test/mjsunit/regress/regress-v8-5692.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 1696 matching lines...)
1707 "++arguments;", 1707 "++arguments;",
1708 "eval++;", 1708 "eval++;",
1709 "arguments++;", 1709 "arguments++;",
1710 NULL 1710 NULL
1711 }; 1711 };
1712 1712
1713 RunParserSyncTest(context_data, statement_data, kError); 1713 RunParserSyncTest(context_data, statement_data, kError);
1714 } 1714 }
1715 1715
1716 1716
1717 TEST(NoErrorsEvalAndArgumentsSloppy) { 1717 TEST(NoErrorsEvalAndArgumentsSloppy) {
adamk 2017/02/15 00:29:06 This is an example of the kind of test I had in mi
1718 // Tests that both preparsing and parsing accept "eval" and "arguments" as 1718 // Tests that both preparsing and parsing accept "eval" and "arguments" as
1719 // identifiers when needed. 1719 // identifiers when needed.
1720 const char* context_data[][2] = { 1720 const char* context_data[][2] = {
1721 { "", "" }, 1721 { "", "" },
1722 { "function test_func() {", "}"}, 1722 { "function test_func() {", "}"},
1723 { NULL, NULL } 1723 { NULL, NULL }
1724 }; 1724 };
1725 1725
1726 const char* statement_data[] = { 1726 const char* statement_data[] = {
1727 "var eval;", 1727 "var eval;",
(...skipping 7714 matching lines...)
9442 DCHECK_NULL(scope->sibling()); 9442 DCHECK_NULL(scope->sibling());
9443 DCHECK(scope->is_function_scope()); 9443 DCHECK(scope->is_function_scope());
9444 const i::AstRawString* var_name = 9444 const i::AstRawString* var_name =
9445 info.ast_value_factory()->GetOneByteString("my_var"); 9445 info.ast_value_factory()->GetOneByteString("my_var");
9446 i::Variable* var = scope->Lookup(var_name); 9446 i::Variable* var = scope->Lookup(var_name);
9447 CHECK_EQ(inners[i].ctxt_allocate, 9447 CHECK_EQ(inners[i].ctxt_allocate,
9448 i::ScopeTestHelper::MustAllocateInContext(var)); 9448 i::ScopeTestHelper::MustAllocateInContext(var));
9449 } 9449 }
9450 } 9450 }
9451 } 9451 }
9452
9453 TEST(EscapedStrictReservedWord) {
9454 // Test that identifiers which are both escaped and only reserved in the
9455 // strict mode are accepted in non-strict mode.
9456 v8::V8::Initialize();
9457 v8::HandleScope scope(CcTest::isolate());
9458 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
9459 const char* scripts[] = {
9460 "if (true) l\u0065t: ;", "function l\u0065t() { }",
9461 "(function l\u0065t() { })", "async function l\u0065t() { }",
9462 "(async function l\u0065t() { })", "async l\u0065t => 42"};
9463 for (const char* script : scripts) {
9464 v8::TryCatch try_catch(CcTest::isolate());
9465 v8_compile(script);
vabr (Chromium) 2017/02/14 23:58:53 I'm not at all sure that I'm doing the right thing
9466 if (try_catch.HasCaught()) {
9467 v8::String::Utf8Value exception(try_catch.Exception());
9468 v8::base::OS::Print("Compiling %s failed with %s.", script, *exception);
9469 CHECK(false);
9470 }
9471 }
9472 }
OLDNEW
« no previous file with comments | « src/parsing/parser-base.h ('k') | test/mjsunit/regress/regress-v8-5692.js » ('j') | no next file with comments »

Powered by Google App Engine