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 4880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4891 "a,\ta, ...args", | 4891 "a,\ta, ...args", |
4892 "a,\ra, ...args", | 4892 "a,\ra, ...args", |
4893 "a,\na, ...args", | 4893 "a,\na, ...args", |
4894 NULL}; | 4894 NULL}; |
4895 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters}; | 4895 static const ParserFlag always_flags[] = {kAllowHarmonyRestParameters}; |
4896 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 4896 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
4897 arraysize(always_flags)); | 4897 arraysize(always_flags)); |
4898 } | 4898 } |
4899 | 4899 |
4900 | 4900 |
| 4901 TEST(SpreadCall) { |
| 4902 const char* context_data[][2] = {{"function fn() { 'use strict';} fn(", ");"}, |
| 4903 {"function fn() {} fn(", ");"}, |
| 4904 {NULL, NULL}}; |
| 4905 |
| 4906 const char* data[] = { |
| 4907 "...([1, 2, 3])", |
| 4908 "...'123', ...'456'", |
| 4909 "...new Set([1, 2, 3]), 4", |
| 4910 "1, ...[2, 3], 4", |
| 4911 "...Array(...[1,2,3,4])", |
| 4912 "...NaN", |
| 4913 NULL}; |
| 4914 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, NULL, 0); |
| 4915 } |
| 4916 |
| 4917 |
| 4918 TEST(SpreadCallErrors) { |
| 4919 const char* context_data[][2] = {{"function fn() { 'use strict';} fn(", ");"}, |
| 4920 {"function fn() {} fn(", ");"}, |
| 4921 {NULL, NULL}}; |
| 4922 |
| 4923 const char* data[] = { |
| 4924 "(...[1, 2, 3])", |
| 4925 "......[1,2,3]", |
| 4926 NULL}; |
| 4927 RunParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0); |
| 4928 } |
| 4929 |
| 4930 |
| 4931 TEST(BadRestSpread) { |
| 4932 const char* context_data[][2] = {{"function fn() { 'use strict';", "} fn();"}, |
| 4933 {"function fn() { ", "} fn();" }, |
| 4934 {NULL, NULL}}; |
| 4935 const char* data[] = { |
| 4936 "return ...[1,2,3];", |
| 4937 "var ...x = [1,2,3];", |
| 4938 "var [...x,] = [1,2,3];", |
| 4939 "var [...x, y] = [1,2,3];", |
| 4940 "var {...x} = [1,2,3];", |
| 4941 "var { x } = {x: ...[1,2,3]}", |
| 4942 NULL}; |
| 4943 RunParserSyncTest(context_data, data, kError, NULL, 0, NULL, 0); |
| 4944 } |
| 4945 |
| 4946 |
4901 TEST(LexicalScopingSloppyMode) { | 4947 TEST(LexicalScopingSloppyMode) { |
4902 const char* context_data[][2] = { | 4948 const char* context_data[][2] = { |
4903 {"", ""}, | 4949 {"", ""}, |
4904 {"function f() {", "}"}, | 4950 {"function f() {", "}"}, |
4905 {"{", "}"}, | 4951 {"{", "}"}, |
4906 {NULL, NULL}}; | 4952 {NULL, NULL}}; |
4907 const char* bad_data[] = { | 4953 const char* bad_data[] = { |
4908 "let x = 1;", | 4954 "let x = 1;", |
4909 "for(let x = 1;;){}", | 4955 "for(let x = 1;;){}", |
4910 "for(let x of []){}", | 4956 "for(let x of []){}", |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5336 "class C {static set arguments(_) {}}", | 5382 "class C {static set arguments(_) {}}", |
5337 | 5383 |
5338 NULL}; | 5384 NULL}; |
5339 | 5385 |
5340 static const ParserFlag always_flags[] = { | 5386 static const ParserFlag always_flags[] = { |
5341 kAllowHarmonyClasses, kAllowHarmonyObjectLiterals, kAllowHarmonyScoping, | 5387 kAllowHarmonyClasses, kAllowHarmonyObjectLiterals, kAllowHarmonyScoping, |
5342 kAllowStrongMode}; | 5388 kAllowStrongMode}; |
5343 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 5389 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
5344 always_flags, arraysize(always_flags)); | 5390 always_flags, arraysize(always_flags)); |
5345 } | 5391 } |
OLD | NEW |