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 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2361 // If there is a newline before the next token, we don't look for RHS. | 2361 // If there is a newline before the next token, we don't look for RHS. |
2362 "yield\nfor (;;) {}", | 2362 "yield\nfor (;;) {}", |
2363 NULL | 2363 NULL |
2364 }; | 2364 }; |
2365 | 2365 |
2366 RunParserSyncTest(context_data, statement_data, kSuccess); | 2366 RunParserSyncTest(context_data, statement_data, kSuccess); |
2367 } | 2367 } |
2368 | 2368 |
2369 | 2369 |
2370 TEST(ErrorsYieldGenerator) { | 2370 TEST(ErrorsYieldGenerator) { |
2371 // clang-format off | |
2371 const char* context_data[][2] = { | 2372 const char* context_data[][2] = { |
2372 { "function * gen() {", "}" }, | 2373 { "function * gen() {", "}" }, |
2373 { "\"use strict\"; function * gen() {", "}" }, | 2374 { "\"use strict\"; function * gen() {", "}" }, |
2374 { NULL, NULL } | 2375 { NULL, NULL } |
2375 }; | 2376 }; |
2376 | 2377 |
2377 const char* statement_data[] = { | 2378 const char* statement_data[] = { |
2378 // Invalid yield expressions inside generators. | 2379 // Invalid yield expressions inside generators. |
2379 "var yield;", | 2380 "var yield;", |
2380 "var foo, yield;", | 2381 "var foo, yield;", |
(...skipping 20 matching lines...) Expand all Loading... | |
2401 "yield / yield", | 2402 "yield / yield", |
2402 "+ yield", | 2403 "+ yield", |
2403 "+ yield 3", | 2404 "+ yield 3", |
2404 // Invalid (no newline allowed between yield and *). | 2405 // Invalid (no newline allowed between yield and *). |
2405 "yield\n*3", | 2406 "yield\n*3", |
2406 // Invalid (we see a newline, so we parse {yield:42} as a statement, not an | 2407 // Invalid (we see a newline, so we parse {yield:42} as a statement, not an |
2407 // object literal, and yield is not a valid label). | 2408 // object literal, and yield is not a valid label). |
2408 "yield\n{yield: 42}", | 2409 "yield\n{yield: 42}", |
2409 "yield /* comment */\n {yield: 42}", | 2410 "yield /* comment */\n {yield: 42}", |
2410 "yield //comment\n {yield: 42}", | 2411 "yield //comment\n {yield: 42}", |
2412 // Destructuring binding and assignment are both disallowed | |
2413 "var [yield] = [42];", | |
2414 "var {foo: yield} = {a: 42};", | |
2415 "[yield] = [42];", | |
2416 "({a: yield} = {a: 42});", | |
2417 // Also disallow full yield expressions on LHS | |
2418 "var [yield 24] = [42];", | |
2419 "var {foo: yield 24} = {a: 42};", | |
2420 "[yield 24] = [42];", | |
2421 "({a: yield 24} = {a: 42});", | |
rossberg
2016/01/26 19:33:09
Maybe add cases for {[yield]: x} = {...}, just to
adamk
2016/01/26 19:39:57
Do you mean for valid parsing of {[yield]: x} (tha
rossberg
2016/01/26 19:56:26
The former.
| |
2411 NULL | 2422 NULL |
2412 }; | 2423 }; |
2424 // clang-format on | |
2413 | 2425 |
2414 RunParserSyncTest(context_data, statement_data, kError); | 2426 RunParserSyncTest(context_data, statement_data, kError); |
2415 } | 2427 } |
2416 | 2428 |
2417 | 2429 |
2418 TEST(ErrorsNameOfStrictFunction) { | 2430 TEST(ErrorsNameOfStrictFunction) { |
2419 // Tests that illegal tokens as names of a strict function produce the correct | 2431 // Tests that illegal tokens as names of a strict function produce the correct |
2420 // errors. | 2432 // errors. |
2421 const char* context_data[][2] = { | 2433 const char* context_data[][2] = { |
2422 { "function ", ""}, | 2434 { "function ", ""}, |
(...skipping 5533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7956 } | 7968 } |
7957 | 7969 |
7958 | 7970 |
7959 TEST(MiscSyntaxErrors) { | 7971 TEST(MiscSyntaxErrors) { |
7960 const char* context_data[][2] = { | 7972 const char* context_data[][2] = { |
7961 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; | 7973 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; |
7962 const char* error_data[] = {"for (();;) {}", NULL}; | 7974 const char* error_data[] = {"for (();;) {}", NULL}; |
7963 | 7975 |
7964 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); | 7976 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); |
7965 } | 7977 } |
OLD | NEW |