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

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

Issue 1129083009: [destructuring] Support computed property names in patterns. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor test fix 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
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 6338 matching lines...) Expand 10 before | Expand all | Expand 10 after
6349 strcmp( 6349 strcmp(
6350 "ReferenceError: In strong mode, using an undeclared global " 6350 "ReferenceError: In strong mode, using an undeclared global "
6351 "variable 'not_there3' is not allowed", 6351 "variable 'not_there3' is not allowed",
6352 *exception)); 6352 *exception));
6353 } 6353 }
6354 } 6354 }
6355 6355
6356 6356
6357 TEST(DestructuringPositiveTests) { 6357 TEST(DestructuringPositiveTests) {
6358 i::FLAG_harmony_destructuring = true; 6358 i::FLAG_harmony_destructuring = true;
6359 i::FLAG_harmony_computed_property_names = true;
6359 6360
6360 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, 6361 const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
6361 {"var ", " = {};"}, 6362 {"var ", " = {};"},
6362 {"'use strict'; const ", " = {};"}, 6363 {"'use strict'; const ", " = {};"},
6363 {NULL, NULL}}; 6364 {NULL, NULL}};
6364 6365
6365 // clang-format off 6366 // clang-format off
6366 const char* data[] = { 6367 const char* data[] = {
6367 "a", 6368 "a",
6368 "{ x : y }", 6369 "{ x : y }",
(...skipping 14 matching lines...) Expand all
6383 "{x = 42, y = 15}", 6384 "{x = 42, y = 15}",
6384 "[a,,b]", 6385 "[a,,b]",
6385 "{42 : x}", 6386 "{42 : x}",
6386 "{42 : x = 42}", 6387 "{42 : x = 42}",
6387 "{42e-2 : x}", 6388 "{42e-2 : x}",
6388 "{42e-2 : x = 42}", 6389 "{42e-2 : x = 42}",
6389 "{'hi' : x}", 6390 "{'hi' : x}",
6390 "{'hi' : x = 42}", 6391 "{'hi' : x = 42}",
6391 "{var: x}", 6392 "{var: x}",
6392 "{var: x = 42}", 6393 "{var: x = 42}",
6394 "{[x] : z}",
6395 "{[1+1] : z}",
6396 "{[foo()] : z}",
6393 "{}", 6397 "{}",
6394 NULL}; 6398 NULL};
6395 // clang-format on 6399 // clang-format on
6396 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, 6400 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals,
6401 kAllowHarmonyComputedPropertyNames,
6397 kAllowHarmonyDestructuring}; 6402 kAllowHarmonyDestructuring};
6398 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, 6403 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags,
6399 arraysize(always_flags)); 6404 arraysize(always_flags));
6400 } 6405 }
6401 6406
6402 6407
6403 TEST(DestructuringNegativeTests) { 6408 TEST(DestructuringNegativeTests) {
6404 i::FLAG_harmony_destructuring = true; 6409 i::FLAG_harmony_destructuring = true;
6410 i::FLAG_harmony_computed_property_names = true;
6405 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals, 6411 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals,
6412 kAllowHarmonyComputedPropertyNames,
6406 kAllowHarmonyDestructuring}; 6413 kAllowHarmonyDestructuring};
6407 6414
6408 { // All modes. 6415 { // All modes.
6409 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, 6416 const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
6410 {"var ", " = {};"}, 6417 {"var ", " = {};"},
6411 {"'use strict'; const ", " = {};"}, 6418 {"'use strict'; const ", " = {};"},
6412 {NULL, NULL}}; 6419 {NULL, NULL}};
6413 6420
6414 // clang-format off 6421 // clang-format off
6415 const char* data[] = { 6422 const char* data[] = {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
6452 "() => x", 6459 "() => x",
6453 "{+2 : x}", 6460 "{+2 : x}",
6454 "{-2 : x}", 6461 "{-2 : x}",
6455 "var", 6462 "var",
6456 "[var]", 6463 "[var]",
6457 "{x : {y : var}}", 6464 "{x : {y : var}}",
6458 "{x : x = a+}", 6465 "{x : x = a+}",
6459 "{x : x = (a+)}", 6466 "{x : x = (a+)}",
6460 "{x : x += a}", 6467 "{x : x += a}",
6461 "{m() {} = 0}", 6468 "{m() {} = 0}",
6469 "{[1+1]}",
6462 NULL}; 6470 NULL};
6463 // clang-format on 6471 // clang-format on
6464 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6472 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6465 arraysize(always_flags)); 6473 arraysize(always_flags));
6466 } 6474 }
6467 6475
6468 { // Strict mode. 6476 { // Strict mode.
6469 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, 6477 const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
6470 {"'use strict'; const ", " = {};"}, 6478 {"'use strict'; const ", " = {};"},
6471 {NULL, NULL}}; 6479 {NULL, NULL}};
(...skipping 21 matching lines...) Expand all
6493 const char* data[] = { 6501 const char* data[] = {
6494 "yield", 6502 "yield",
6495 "[yield]", 6503 "[yield]",
6496 "{ x : yield }", 6504 "{ x : yield }",
6497 NULL}; 6505 NULL};
6498 // clang-format on 6506 // clang-format on
6499 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6507 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6500 arraysize(always_flags)); 6508 arraysize(always_flags));
6501 } 6509 }
6502 } 6510 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698