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 6800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6811 "for (let x of []) {}", | 6811 "for (let x of []) {}", |
6812 NULL | 6812 NULL |
6813 }; | 6813 }; |
6814 // clang-format on | 6814 // clang-format on |
6815 | 6815 |
6816 static const ParserFlag always_flags[] = {kAllowHarmonySloppy, | 6816 static const ParserFlag always_flags[] = {kAllowHarmonySloppy, |
6817 kAllowHarmonySloppyLet}; | 6817 kAllowHarmonySloppyLet}; |
6818 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6818 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
6819 arraysize(always_flags)); | 6819 arraysize(always_flags)); |
6820 } | 6820 } |
| 6821 |
| 6822 |
| 6823 TEST(LanguageModeDirectivesNonSimpleParameterListErrors) { |
| 6824 // A block declaration scope as a child scope of a function scope |
| 6825 // indicates that a function has a non-simple parameter list. |
| 6826 // TC39 deemed "use strict" directives to be an error in this case, |
| 6827 // on 29/7/2015. https://goo.gl/ueA7Ln |
| 6828 // |
| 6829 // In V8, this also applies to "use strong " directives. |
| 6830 const char* context_data[][2] = { |
| 6831 /* |
| 6832 var a = ({ bindingPattern = {} }) => { 'use strict'; } |
| 6833 */ |
| 6834 |
| 6835 {"function f(", ") { 'use strict'; }"}, |
| 6836 {"function f(", ") { 'use strong'; }"}, |
| 6837 {"function* g(", ") { 'use strict'; }"}, |
| 6838 {"function* g(", ") { 'use strong'; }"}, |
| 6839 {"var a = (", ") => { 'use strict'; }"}, |
| 6840 {"var a = (", ") => { 'use strong'; }"}, |
| 6841 {"var o = { m(", ") { 'use strict'; }"}, |
| 6842 {"var o = { m(", ") { 'use strong'; }"}, |
| 6843 {"var o = { *gm(", ") { 'use strict'; }"}, |
| 6844 {"var o = { *gm(", ") { 'use strong'; }"}, |
| 6845 {"var c = { m(", ") { 'use strict'; }"}, |
| 6846 {"var c = { m(", ") { 'use strong'; }"}, |
| 6847 {"var c = { *gm(", ") { 'use strict'; }"}, |
| 6848 {"var c = { *gm(", ") { 'use strong'; }"}, |
| 6849 |
| 6850 {"'use strict'; function f(", ") { 'use strict'; }"}, |
| 6851 {"'use strict'; function f(", ") { 'use strong'; }"}, |
| 6852 {"'use strict'; function* g(", ") { 'use strict'; }"}, |
| 6853 {"'use strict'; function* g(", ") { 'use strong'; }"}, |
| 6854 {"'use strict'; var a = (", ") => { 'use strict'; }"}, |
| 6855 {"'use strict'; var a = (", ") => { 'use strong'; }"}, |
| 6856 {"'use strict'; var o = { m(", ") { 'use strict'; }"}, |
| 6857 {"'use strict'; var o = { m(", ") { 'use strong'; }"}, |
| 6858 {"'use strict'; var o = { *gm(", ") { 'use strict'; }"}, |
| 6859 {"'use strict'; var o = { *gm(", ") { 'use strong'; }"}, |
| 6860 {"'use strict'; var c = { m(", ") { 'use strict'; }"}, |
| 6861 {"'use strict'; var c = { m(", ") { 'use strong'; }"}, |
| 6862 {"'use strict'; var c = { *gm(", ") { 'use strict'; }"}, |
| 6863 {"'use strict'; var c = { *gm(", ") { 'use strong'; }"}, |
| 6864 |
| 6865 {"'use strong'; function f(", ") { 'use strict'; }"}, |
| 6866 {"'use strong'; function f(", ") { 'use strong'; }"}, |
| 6867 {"'use strong'; function* g(", ") { 'use strict'; }"}, |
| 6868 {"'use strong'; function* g(", ") { 'use strong'; }"}, |
| 6869 {"'use strong'; var a = (", ") => { 'use strict'; }"}, |
| 6870 {"'use strong'; var a = (", ") => { 'use strong'; }"}, |
| 6871 {"'use strong'; var o = { m(", ") { 'use strict'; }"}, |
| 6872 {"'use strong'; var o = { m(", ") { 'use strong'; }"}, |
| 6873 {"'use strong'; var o = { *gm(", ") { 'use strict'; }"}, |
| 6874 {"'use strong'; var o = { *gm(", ") { 'use strong'; }"}, |
| 6875 {"'use strong'; var c = { m(", ") { 'use strict'; }"}, |
| 6876 {"'use strong'; var c = { m(", ") { 'use strong'; }"}, |
| 6877 {"'use strong'; var c = { *gm(", ") { 'use strict'; }"}, |
| 6878 {"'use strong'; var c = { *gm(", ") { 'use strong'; }"}, |
| 6879 {NULL, NULL}}; |
| 6880 |
| 6881 const char* data[] = { |
| 6882 // TODO(@caitp): support formal parameter initializers |
| 6883 "initializer = true" |
| 6884 "...rest", |
| 6885 "{ bindingPattern = {} }", |
| 6886 "{ initializedBindingPattern } = { initializedBindingPattern = true }", |
| 6887 NULL}; |
| 6888 |
| 6889 static const ParserFlag always_flags[] = { |
| 6890 kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring, |
| 6891 kAllowHarmonyRestParameters, kAllowStrongMode}; |
| 6892 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 6893 arraysize(always_flags)); |
| 6894 } |
OLD | NEW |