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 2894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2905 const char* statement_data[] = { | 2905 const char* statement_data[] = { |
2906 ",", | 2906 ",", |
2907 // Wrong number of parameters | 2907 // Wrong number of parameters |
2908 "get bar(x) {}", | 2908 "get bar(x) {}", |
2909 "get bar(x, y) {}", | 2909 "get bar(x, y) {}", |
2910 "set bar() {}", | 2910 "set bar() {}", |
2911 "set bar(x, y) {}", | 2911 "set bar(x, y) {}", |
2912 // Parsing FunctionLiteral for getter or setter fails | 2912 // Parsing FunctionLiteral for getter or setter fails |
2913 "get foo( +", | 2913 "get foo( +", |
2914 "get foo() \"error\"", | 2914 "get foo() \"error\"", |
2915 // Various forbidden forms | |
2916 "static x: 0", | |
2917 "static x(){}", | |
adamk
2016/08/31 17:37:07
Please add some tests with async (you'll have to a
bakkot
2016/08/31 19:46:28
Done.
| |
2918 "*x: 0", | |
2919 "*x", | |
2920 "*get x(){}", | |
2921 "*set x(y){}", | |
2922 "get *x(){}", | |
2923 "set *x(y){}", | |
2924 "get x*(){}", | |
2925 "set x*(y){}", | |
2926 "x = 0", | |
2927 "* *x(){}", | |
2928 "x*(){}", | |
2915 NULL | 2929 NULL |
2916 }; | 2930 }; |
2917 | 2931 |
2918 RunParserSyncTest(context_data, statement_data, kError); | 2932 RunParserSyncTest(context_data, statement_data, kError); |
2919 } | 2933 } |
2920 | 2934 |
2921 | 2935 |
2922 TEST(NoErrorsObjectLiteralChecking) { | 2936 TEST(NoErrorsObjectLiteralChecking) { |
2923 const char* context_data[][2] = { | 2937 const char* context_data[][2] = { |
2924 {"var myobject = {", "};"}, | 2938 {"var myobject = {", "};"}, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2961 "set 1(v) {}", | 2975 "set 1(v) {}", |
2962 // Non-colliding getters and setters -> no errors | 2976 // Non-colliding getters and setters -> no errors |
2963 "foo: 1, get bar() {}", | 2977 "foo: 1, get bar() {}", |
2964 "foo: 1, set bar(v) {}", | 2978 "foo: 1, set bar(v) {}", |
2965 "\"foo\": 1, get \"bar\"() {}", | 2979 "\"foo\": 1, get \"bar\"() {}", |
2966 "\"foo\": 1, set \"bar\"(v) {}", | 2980 "\"foo\": 1, set \"bar\"(v) {}", |
2967 "1: 1, get 2() {}", | 2981 "1: 1, get 2() {}", |
2968 "1: 1, set 2(v) {}", | 2982 "1: 1, set 2(v) {}", |
2969 "get: 1, get foo() {}", | 2983 "get: 1, get foo() {}", |
2970 "set: 1, set foo(_) {}", | 2984 "set: 1, set foo(_) {}", |
2985 // Potentially confusing cases | |
2986 "*get() {}", | |
2987 "*set() {}", | |
2988 "*static() {}", | |
2989 "get : 0", | |
adamk
2016/08/31 17:37:07
Maybe some positive async tests too?
bakkot
2016/08/31 19:46:28
Done.
| |
2990 "set : 0", | |
2971 // Keywords, future reserved and strict future reserved are also allowed as | 2991 // Keywords, future reserved and strict future reserved are also allowed as |
2972 // property names. | 2992 // property names. |
2973 "if: 4", | 2993 "if: 4", |
2974 "interface: 5", | 2994 "interface: 5", |
2975 "super: 6", | 2995 "super: 6", |
2976 "eval: 7", | 2996 "eval: 7", |
2977 "arguments: 8", | 2997 "arguments: 8", |
2978 NULL | 2998 NULL |
2979 }; | 2999 }; |
2980 | 3000 |
(...skipping 5198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8179 "(a,);", | 8199 "(a,);", |
8180 "(a,b,c,);", | 8200 "(a,b,c,);", |
8181 NULL | 8201 NULL |
8182 }; | 8202 }; |
8183 // clang-format on | 8203 // clang-format on |
8184 | 8204 |
8185 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 8205 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
8186 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 8206 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
8187 arraysize(always_flags)); | 8207 arraysize(always_flags)); |
8188 } | 8208 } |
OLD | NEW |