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

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

Issue 1125183008: [es6] Spread in array literals (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup Created 5 years, 7 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
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/mjsunit/harmony/spread-array.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 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 kAllowHarmonyModules, 1359 kAllowHarmonyModules,
1360 kAllowHarmonyArrowFunctions, 1360 kAllowHarmonyArrowFunctions,
1361 kAllowHarmonyClasses, 1361 kAllowHarmonyClasses,
1362 kAllowHarmonyObjectLiterals, 1362 kAllowHarmonyObjectLiterals,
1363 kAllowHarmonyRestParameters, 1363 kAllowHarmonyRestParameters,
1364 kAllowHarmonySloppy, 1364 kAllowHarmonySloppy,
1365 kAllowHarmonyUnicode, 1365 kAllowHarmonyUnicode,
1366 kAllowHarmonyComputedPropertyNames, 1366 kAllowHarmonyComputedPropertyNames,
1367 kAllowHarmonySpreadCalls, 1367 kAllowHarmonySpreadCalls,
1368 kAllowHarmonyDestructuring, 1368 kAllowHarmonyDestructuring,
1369 kAllowHarmonySpreadArrays,
1369 kAllowStrongMode 1370 kAllowStrongMode
1370 }; 1371 };
1371 1372
1372 1373
1373 enum ParserSyncTestResult { 1374 enum ParserSyncTestResult {
1374 kSuccessOrError, 1375 kSuccessOrError,
1375 kSuccess, 1376 kSuccess,
1376 kError 1377 kError
1377 }; 1378 };
1378 1379
(...skipping 11 matching lines...) Expand all
1390 parser->set_allow_harmony_rest_params( 1391 parser->set_allow_harmony_rest_params(
1391 flags.Contains(kAllowHarmonyRestParameters)); 1392 flags.Contains(kAllowHarmonyRestParameters));
1392 parser->set_allow_harmony_spreadcalls( 1393 parser->set_allow_harmony_spreadcalls(
1393 flags.Contains(kAllowHarmonySpreadCalls)); 1394 flags.Contains(kAllowHarmonySpreadCalls));
1394 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy)); 1395 parser->set_allow_harmony_sloppy(flags.Contains(kAllowHarmonySloppy));
1395 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode)); 1396 parser->set_allow_harmony_unicode(flags.Contains(kAllowHarmonyUnicode));
1396 parser->set_allow_harmony_computed_property_names( 1397 parser->set_allow_harmony_computed_property_names(
1397 flags.Contains(kAllowHarmonyComputedPropertyNames)); 1398 flags.Contains(kAllowHarmonyComputedPropertyNames));
1398 parser->set_allow_harmony_destructuring( 1399 parser->set_allow_harmony_destructuring(
1399 flags.Contains(kAllowHarmonyDestructuring)); 1400 flags.Contains(kAllowHarmonyDestructuring));
1401 parser->set_allow_harmony_spread_arrays(
1402 flags.Contains(kAllowHarmonySpreadArrays));
1400 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode)); 1403 parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode));
1401 } 1404 }
1402 1405
1403 1406
1404 void TestParserSyncWithFlags(i::Handle<i::String> source, 1407 void TestParserSyncWithFlags(i::Handle<i::String> source,
1405 i::EnumSet<ParserFlag> flags, 1408 i::EnumSet<ParserFlag> flags,
1406 ParserSyncTestResult result) { 1409 ParserSyncTestResult result) {
1407 i::Isolate* isolate = CcTest::i_isolate(); 1410 i::Isolate* isolate = CcTest::i_isolate();
1408 i::Factory* factory = isolate->factory(); 1411 i::Factory* factory = isolate->factory();
1409 1412
(...skipping 5103 matching lines...) Expand 10 before | Expand all | Expand 10 after
6513 const char* data[] = { 6516 const char* data[] = {
6514 "yield", 6517 "yield",
6515 "[yield]", 6518 "[yield]",
6516 "{ x : yield }", 6519 "{ x : yield }",
6517 NULL}; 6520 NULL};
6518 // clang-format on 6521 // clang-format on
6519 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6522 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6520 arraysize(always_flags)); 6523 arraysize(always_flags));
6521 } 6524 }
6522 } 6525 }
6526
6527
6528 TEST(SpreadArray) {
6529 i::FLAG_harmony_spread_arrays = true;
6530
6531 const char* context_data[][2] = {
6532 {"'use strict';", ""}, {"", ""}, {NULL, NULL}};
6533
6534 // clang-format off
6535 const char* data[] = {
6536 "[...a]",
6537 "[a, ...b]",
6538 "[...a,]",
6539 "[...a, ,]",
6540 "[, ...a]",
6541 "[...a, ...b]",
6542 "[...a, , ...b]",
6543 "[...[...a]]",
6544 "[, ...a]",
6545 "[, , ...a]",
6546 NULL};
6547 // clang-format on
6548 static const ParserFlag always_flags[] = {kAllowHarmonySpreadArrays};
6549 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
6550 arraysize(always_flags));
6551 }
6552
6553
6554 TEST(SpreadArrayError) {
6555 i::FLAG_harmony_spread_arrays = true;
6556
6557 const char* context_data[][2] = {
6558 {"'use strict';", ""}, {"", ""}, {NULL, NULL}};
6559
6560 // clang-format off
6561 const char* data[] = {
6562 "[...]",
6563 "[a, ...]",
6564 "[..., ]",
6565 "[..., ...]",
6566 "[ (...a)]",
6567 NULL};
6568 // clang-format on
6569 static const ParserFlag always_flags[] = {kAllowHarmonySpreadArrays};
6570 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6571 arraysize(always_flags));
6572 }
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/mjsunit/harmony/spread-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698