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

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

Issue 949763003: WIP: new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
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 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 enum ParserFlag { 1377 enum ParserFlag {
1378 kAllowLazy, 1378 kAllowLazy,
1379 kAllowNatives, 1379 kAllowNatives,
1380 kAllowHarmonyScoping, 1380 kAllowHarmonyScoping,
1381 kAllowHarmonyModules, 1381 kAllowHarmonyModules,
1382 kAllowHarmonyNumericLiterals, 1382 kAllowHarmonyNumericLiterals,
1383 kAllowHarmonyArrowFunctions, 1383 kAllowHarmonyArrowFunctions,
1384 kAllowHarmonyClasses, 1384 kAllowHarmonyClasses,
1385 kAllowHarmonyObjectLiterals, 1385 kAllowHarmonyObjectLiterals,
1386 kAllowHarmonyRestParameters, 1386 kAllowHarmonyRestParameters,
1387 kAllowHarmonyNewTarget,
1387 kAllowHarmonyTemplates, 1388 kAllowHarmonyTemplates,
1388 kAllowHarmonySloppy, 1389 kAllowHarmonySloppy,
1389 kAllowHarmonyUnicode, 1390 kAllowHarmonyUnicode,
1390 kAllowHarmonyComputedPropertyNames, 1391 kAllowHarmonyComputedPropertyNames,
1391 kAllowStrongMode 1392 kAllowStrongMode
1392 }; 1393 };
1393 1394
1394 1395
1395 enum ParserSyncTestResult { 1396 enum ParserSyncTestResult {
1396 kSuccessOrError, 1397 kSuccessOrError,
(...skipping 11 matching lines...) Expand all
1408 parser->set_allow_harmony_numeric_literals( 1409 parser->set_allow_harmony_numeric_literals(
1409 flags.Contains(kAllowHarmonyNumericLiterals)); 1410 flags.Contains(kAllowHarmonyNumericLiterals));
1410 parser->set_allow_harmony_object_literals( 1411 parser->set_allow_harmony_object_literals(
1411 flags.Contains(kAllowHarmonyObjectLiterals)); 1412 flags.Contains(kAllowHarmonyObjectLiterals));
1412 parser->set_allow_harmony_arrow_functions( 1413 parser->set_allow_harmony_arrow_functions(
1413 flags.Contains(kAllowHarmonyArrowFunctions)); 1414 flags.Contains(kAllowHarmonyArrowFunctions));
1414 parser->set_allow_harmony_classes(flags.Contains(kAllowHarmonyClasses)); 1415 parser->set_allow_harmony_classes(flags.Contains(kAllowHarmonyClasses));
1415 parser->set_allow_harmony_templates(flags.Contains(kAllowHarmonyTemplates)); 1416 parser->set_allow_harmony_templates(flags.Contains(kAllowHarmonyTemplates));
1416 parser->set_allow_harmony_rest_params( 1417 parser->set_allow_harmony_rest_params(
1417 flags.Contains(kAllowHarmonyRestParameters)); 1418 flags.Contains(kAllowHarmonyRestParameters));
1419 parser->set_allow_harmony_new_target(
1420 flags.Contains(kAllowHarmonyNewTarget));
1418 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); 1421 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy));
1419 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); 1422 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode));
1420 parser->set_allow_harmony_computed_property_names( 1423 parser->set_allow_harmony_computed_property_names(
1421 flags.Contains(kAllowHarmonyComputedPropertyNames)); 1424 flags.Contains(kAllowHarmonyComputedPropertyNames));
1422 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); 1425 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode));
1423 } 1426 }
1424 1427
1425 1428
1426 void TestParserSyncWithFlags(i::Handle<i::String> source, 1429 void TestParserSyncWithFlags(i::Handle<i::String> source,
1427 i::EnumSet<ParserFlag> flags, 1430 i::EnumSet<ParserFlag> flags,
(...skipping 4076 matching lines...) Expand 10 before | Expand all | Expand 10 after
5504 static const ParserFlag always_flags[] = { 5507 static const ParserFlag always_flags[] = {
5505 kAllowStrongMode, kAllowHarmonyScoping 5508 kAllowStrongMode, kAllowHarmonyScoping
5506 }; 5509 };
5507 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags, 5510 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags,
5508 arraysize(always_flags)); 5511 arraysize(always_flags));
5509 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, 5512 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags,
5510 arraysize(always_flags)); 5513 arraysize(always_flags));
5511 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, 5514 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags,
5512 arraysize(always_flags)); 5515 arraysize(always_flags));
5513 } 5516 }
5517
5518
5519 TEST(NewTarget) {
5520 const char* bad_context_data[][2] = {
5521 {"", ""},
5522 {"'use strict';", ""},
5523 {NULL}
5524 };
5525 const char* good_context_data[][2] = {
5526 {"function f() {", "}"},
5527 {"'use strict'; function f() {", "}"},
5528 {"var f = function() {", "}"},
5529 {"'use strict'; var f = function() {", "}"},
5530 {"({m: function() {", "}})"},
5531 {"'use strict'; ({m: function() {", "}})"},
5532 {"({m() {", "}})"},
5533 {"'use strict'; ({m() {", "}})"},
5534 {"({get x() {", "}})"},
5535 {"'use strict'; ({get x() {", "}})"},
5536 {"({set x(_) {", "}})"},
5537 {"'use strict'; ({set x(_) {", "}})"},
5538 {"class C {m() {", "}}"},
5539 {"class C {get x() {", "}}"},
5540 {"class C {set x(_) {", "}}"},
5541 {NULL}
5542 };
5543
5544 const char* data[] = {
5545 "new.target",
5546 "{ new.target }",
5547 "() => { new.target }",
5548 "() => new.target",
5549 "if (1) { new.target }",
5550 "if (1) {} else { new.target }",
5551 "while (0) { new.target }",
5552 "do { new.target } while (0)",
5553 NULL
5554 };
5555
5556 static const ParserFlag always_flags[] = {
5557 kAllowHarmonyArrowFunctions,
5558 kAllowHarmonyClasses,
5559 kAllowHarmonyNewTarget,
5560 kAllowHarmonyObjectLiterals,
5561 kAllowHarmonySloppy,
5562 };
5563
5564 RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags,
5565 arraysize(always_flags));
5566 RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags,
5567 arraysize(always_flags));
5568 }
OLDNEW
« src/scopes.cc ('K') | « src/scopes.cc ('k') | test/mjsunit/harmony/new-target.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698