Chromium Code Reviews| 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 6861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6872 "for (let x of []) {}", | 6872 "for (let x of []) {}", |
| 6873 NULL | 6873 NULL |
| 6874 }; | 6874 }; |
| 6875 // clang-format on | 6875 // clang-format on |
| 6876 | 6876 |
| 6877 static const ParserFlag always_flags[] = {kAllowHarmonySloppy, | 6877 static const ParserFlag always_flags[] = {kAllowHarmonySloppy, |
| 6878 kAllowHarmonySloppyLet}; | 6878 kAllowHarmonySloppyLet}; |
| 6879 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6879 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 6880 arraysize(always_flags)); | 6880 arraysize(always_flags)); |
| 6881 } | 6881 } |
| 6882 | |
| 6883 | |
| 6884 TEST(LanguageModeDirectivesNonSimpleParameterListErrors) { | |
| 6885 // A block declaration scope as a child scope of a function scope | |
|
rossberg
2015/08/24 13:11:08
Same here.
conradw
2015/08/25 11:31:20
Done.
| |
| 6886 // indicates that a function has a non-simple parameter list. | |
| 6887 // TC39 deemed "use strict" directives to be an error in this case, | |
| 6888 // on 29/7/2015. https://goo.gl/ueA7Ln | |
| 6889 // | |
| 6890 // In V8, this also applies to "use strong " directives. | |
| 6891 const char* context_data[][2] = { | |
| 6892 {"function f(", ") { 'use strict'; }"}, | |
| 6893 {"function f(", ") { 'use strong'; }"}, | |
| 6894 {"function* g(", ") { 'use strict'; }"}, | |
| 6895 {"function* g(", ") { 'use strong'; }"}, | |
| 6896 {"class c { foo(", ") { 'use strict' }"}, | |
| 6897 {"class c { foo(", ") { 'use strong' }"}, | |
| 6898 {"var a = (", ") => { 'use strict'; }"}, | |
| 6899 {"var a = (", ") => { 'use strong'; }"}, | |
| 6900 {"var o = { m(", ") { 'use strict'; }"}, | |
| 6901 {"var o = { m(", ") { 'use strong'; }"}, | |
| 6902 {"var o = { *gm(", ") { 'use strict'; }"}, | |
| 6903 {"var o = { *gm(", ") { 'use strong'; }"}, | |
| 6904 {"var c = { m(", ") { 'use strict'; }"}, | |
| 6905 {"var c = { m(", ") { 'use strong'; }"}, | |
| 6906 {"var c = { *gm(", ") { 'use strict'; }"}, | |
| 6907 {"var c = { *gm(", ") { 'use strong'; }"}, | |
| 6908 | |
| 6909 {"'use strict'; function f(", ") { 'use strict'; }"}, | |
| 6910 {"'use strict'; function f(", ") { 'use strong'; }"}, | |
| 6911 {"'use strict'; function* g(", ") { 'use strict'; }"}, | |
| 6912 {"'use strict'; function* g(", ") { 'use strong'; }"}, | |
| 6913 {"'use strict'; class c { foo(", ") { 'use strict' }"}, | |
| 6914 {"'use strict'; class c { foo(", ") { 'use strong' }"}, | |
| 6915 {"'use strict'; var a = (", ") => { 'use strict'; }"}, | |
| 6916 {"'use strict'; var a = (", ") => { 'use strong'; }"}, | |
| 6917 {"'use strict'; var o = { m(", ") { 'use strict'; }"}, | |
| 6918 {"'use strict'; var o = { m(", ") { 'use strong'; }"}, | |
| 6919 {"'use strict'; var o = { *gm(", ") { 'use strict'; }"}, | |
| 6920 {"'use strict'; var o = { *gm(", ") { 'use strong'; }"}, | |
| 6921 {"'use strict'; var c = { m(", ") { 'use strict'; }"}, | |
| 6922 {"'use strict'; var c = { m(", ") { 'use strong'; }"}, | |
| 6923 {"'use strict'; var c = { *gm(", ") { 'use strict'; }"}, | |
| 6924 {"'use strict'; var c = { *gm(", ") { 'use strong'; }"}, | |
| 6925 | |
| 6926 {"'use strong'; function f(", ") { 'use strict'; }"}, | |
| 6927 {"'use strong'; function f(", ") { 'use strong'; }"}, | |
| 6928 {"'use strong'; function* g(", ") { 'use strict'; }"}, | |
| 6929 {"'use strong'; function* g(", ") { 'use strong'; }"}, | |
| 6930 {"'use strong'; class c { foo(", ") { 'use strict' }"}, | |
| 6931 {"'use strong'; class c { foo(", ") { 'use strong' }"}, | |
| 6932 {"'use strong'; var a = (", ") => { 'use strict'; }"}, | |
| 6933 {"'use strong'; var a = (", ") => { 'use strong'; }"}, | |
| 6934 {"'use strong'; var o = { m(", ") { 'use strict'; }"}, | |
| 6935 {"'use strong'; var o = { m(", ") { 'use strong'; }"}, | |
| 6936 {"'use strong'; var o = { *gm(", ") { 'use strict'; }"}, | |
| 6937 {"'use strong'; var o = { *gm(", ") { 'use strong'; }"}, | |
| 6938 {"'use strong'; var c = { m(", ") { 'use strict'; }"}, | |
| 6939 {"'use strong'; var c = { m(", ") { 'use strong'; }"}, | |
| 6940 {"'use strong'; var c = { *gm(", ") { 'use strict'; }"}, | |
| 6941 {"'use strong'; var c = { *gm(", ") { 'use strong'; }"}, | |
| 6942 | |
| 6943 {NULL, NULL}}; | |
| 6944 | |
| 6945 const char* data[] = { | |
| 6946 // TODO(@caitp): support formal parameter initializers | |
| 6947 "{}", | |
| 6948 "[]", | |
| 6949 "[{}]", | |
| 6950 "{a}", | |
| 6951 "a, {b}", | |
| 6952 "a, b, {c, d, e}", | |
| 6953 "initializer = true", | |
| 6954 "a, b, c = 1", | |
| 6955 "...args", | |
| 6956 "a, b, ...rest", | |
| 6957 "[a, b, ...rest]", | |
| 6958 "{ bindingPattern = {} }", | |
| 6959 "{ initializedBindingPattern } = { initializedBindingPattern: true }", | |
| 6960 NULL}; | |
| 6961 | |
| 6962 static const ParserFlag always_flags[] = { | |
| 6963 kAllowHarmonyArrowFunctions, kAllowHarmonyDestructuring, | |
| 6964 kAllowHarmonyRestParameters, kAllowHarmonySloppy, kAllowStrongMode}; | |
| 6965 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | |
| 6966 arraysize(always_flags)); | |
| 6967 } | |
| OLD | NEW |