OLD | NEW |
---|---|
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 6371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6382 i::FLAG_harmony_destructuring = true; | 6382 i::FLAG_harmony_destructuring = true; |
6383 i::FLAG_harmony_arrow_functions = true; | 6383 i::FLAG_harmony_arrow_functions = true; |
6384 i::FLAG_harmony_computed_property_names = true; | 6384 i::FLAG_harmony_computed_property_names = true; |
6385 | 6385 |
6386 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, | 6386 const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, |
6387 {"var ", " = {};"}, | 6387 {"var ", " = {};"}, |
6388 {"'use strict'; const ", " = {};"}, | 6388 {"'use strict'; const ", " = {};"}, |
6389 {"function f(", ") {}"}, | 6389 {"function f(", ") {}"}, |
6390 {"function f(argument1, ", ") {}"}, | 6390 {"function f(argument1, ", ") {}"}, |
6391 {"var f = (", ") => {};"}, | 6391 {"var f = (", ") => {};"}, |
6392 {"var f = ", " => {};"}, | |
6393 {"var f = (argument1,", ") => {};"}, | 6392 {"var f = (argument1,", ") => {};"}, |
6394 {NULL, NULL}}; | 6393 {NULL, NULL}}; |
6395 | 6394 |
6396 // clang-format off | 6395 // clang-format off |
6397 const char* data[] = { | 6396 const char* data[] = { |
6398 "a", | 6397 "a", |
6399 "{ x : y }", | 6398 "{ x : y }", |
6400 "{ x : y = 1 }", | 6399 "{ x : y = 1 }", |
6401 "[a]", | 6400 "[a]", |
6402 "[a = 1]", | 6401 "[a = 1]", |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6598 // clang-format off | 6597 // clang-format off |
6599 const char* success_data[] = { | 6598 const char* success_data[] = { |
6600 "for (var x = {} in null);", | 6599 "for (var x = {} in null);", |
6601 NULL}; | 6600 NULL}; |
6602 // clang-format on | 6601 // clang-format on |
6603 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags, | 6602 RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags, |
6604 arraysize(always_flags)); | 6603 arraysize(always_flags)); |
6605 } | 6604 } |
6606 | 6605 |
6607 | 6606 |
6607 TEST(DestructuringDuplicateParams) { | |
6608 i::FLAG_harmony_destructuring = true; | |
6609 i::FLAG_harmony_arrow_functions = true; | |
6610 i::FLAG_harmony_computed_property_names = true; | |
6611 static const ParserFlag always_flags[] = { | |
6612 kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames, | |
6613 kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring}; | |
6614 const char* context_data[][2] = {{"'use strict';", ""}, | |
6615 {"function outer() { 'use strict';", "}"}, | |
6616 {nullptr, nullptr}}; | |
6617 | |
6618 | |
6619 // clang-format off | |
6620 const char* error_data[] = { | |
6621 "function f(x,x){}", | |
6622 "function f(x, {x : x}){}", | |
6623 "function f(x, {x}){}", | |
6624 "function f({x,x}) {}", | |
6625 // non-simple parameter list causes duplicates to be errors in sloppy mode. | |
6626 "function f(x, x, {a}) {}", | |
6627 "var f = {x,y} => {};", | |
rossberg
2015/06/19 16:26:35
{x,x} ? But isn't this a plain syntax error anyway
Dmitry Lomov (no reviews)
2015/06/22 10:14:10
Moved to separate test.
| |
6628 nullptr}; | |
6629 // clang-format on | |
6630 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | |
6631 arraysize(always_flags)); | |
6632 } | |
6633 | |
6634 | |
6635 TEST(DestructuringDuplicateParamsSloppy) { | |
6636 i::FLAG_harmony_destructuring = true; | |
6637 i::FLAG_harmony_arrow_functions = true; | |
6638 i::FLAG_harmony_computed_property_names = true; | |
6639 static const ParserFlag always_flags[] = { | |
6640 kAllowHarmonyObjectLiterals, kAllowHarmonyComputedPropertyNames, | |
6641 kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring}; | |
6642 const char* context_data[][2] = { | |
6643 {"", ""}, {"function outer() {", "}"}, {nullptr, nullptr}}; | |
6644 | |
6645 | |
6646 // clang-format off | |
6647 const char* error_data[] = { | |
6648 // non-simple parameter list causes duplicates to be errors in sloppy mode. | |
6649 "function f(x, {x : x}){}", | |
6650 "function f(x, {x}){}", | |
6651 "function f({x,x}) {}", | |
6652 "function f(x, x, {a}) {}", | |
6653 "var f = {x} => {};", | |
rossberg
2015/06/19 16:26:35
Same here, this test is unrelated to duplicates.
Dmitry Lomov (no reviews)
2015/06/22 10:14:10
Moved to separate test.
| |
6654 nullptr}; | |
6655 // clang-format on | |
6656 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | |
6657 arraysize(always_flags)); | |
6658 } | |
6659 | |
6660 | |
6608 TEST(SpreadArray) { | 6661 TEST(SpreadArray) { |
6609 i::FLAG_harmony_spread_arrays = true; | 6662 i::FLAG_harmony_spread_arrays = true; |
6610 | 6663 |
6611 const char* context_data[][2] = { | 6664 const char* context_data[][2] = { |
6612 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; | 6665 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; |
6613 | 6666 |
6614 // clang-format off | 6667 // clang-format off |
6615 const char* data[] = { | 6668 const char* data[] = { |
6616 "[...a]", | 6669 "[...a]", |
6617 "[a, ...b]", | 6670 "[a, ...b]", |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6698 kAllowHarmonyObjectLiterals, | 6751 kAllowHarmonyObjectLiterals, |
6699 kAllowHarmonySloppy, | 6752 kAllowHarmonySloppy, |
6700 }; | 6753 }; |
6701 // clang-format on | 6754 // clang-format on |
6702 | 6755 |
6703 RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags, | 6756 RunParserSyncTest(good_context_data, data, kSuccess, NULL, 0, always_flags, |
6704 arraysize(always_flags)); | 6757 arraysize(always_flags)); |
6705 RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags, | 6758 RunParserSyncTest(bad_context_data, data, kError, NULL, 0, always_flags, |
6706 arraysize(always_flags)); | 6759 arraysize(always_flags)); |
6707 } | 6760 } |
OLD | NEW |