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 4531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4542 "`foo${\r a`", | 4542 "`foo${\r a`", |
4543 "`foo${fn(}`", | 4543 "`foo${fn(}`", |
4544 "`foo${1 if}`", | 4544 "`foo${1 if}`", |
4545 NULL}; | 4545 NULL}; |
4546 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; | 4546 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; |
4547 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 4547 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
4548 arraysize(always_flags)); | 4548 arraysize(always_flags)); |
4549 } | 4549 } |
4550 | 4550 |
4551 | 4551 |
| 4552 TEST(TemplateLiteralsIllegalTokens) { |
| 4553 const char* context_data[][2] = {{"'use strict';", ""}, |
| 4554 {"function foo(){ 'use strict';" |
| 4555 " var a, b, c; return ", "}"}, |
| 4556 {NULL, NULL}}; |
| 4557 const char* data[] = { |
| 4558 "`hello\\x`", |
| 4559 "`hello\\x${1}`", |
| 4560 "`hello${1}\\x`", |
| 4561 "`hello${1}\\x${2}`", |
| 4562 "`hello\\x\n`", |
| 4563 "`hello\\x\n${1}`", |
| 4564 "`hello${1}\\x\n`", |
| 4565 "`hello${1}\\x\n${2}`", |
| 4566 NULL}; |
| 4567 |
| 4568 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; |
| 4569 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 4570 arraysize(always_flags)); |
| 4571 } |
| 4572 |
| 4573 |
4552 TEST(LexicalScopingSloppyMode) { | 4574 TEST(LexicalScopingSloppyMode) { |
4553 const char* context_data[][2] = { | 4575 const char* context_data[][2] = { |
4554 {"", ""}, | 4576 {"", ""}, |
4555 {"function f() {", "}"}, | 4577 {"function f() {", "}"}, |
4556 {"{", "}"}, | 4578 {"{", "}"}, |
4557 {NULL, NULL}}; | 4579 {NULL, NULL}}; |
4558 const char* bad_data[] = { | 4580 const char* bad_data[] = { |
4559 "let x = 1;", | 4581 "let x = 1;", |
4560 "for(let x = 1;;){}", | 4582 "for(let x = 1;;){}", |
4561 "for(let x of []){}", | 4583 "for(let x of []){}", |
(...skipping 13 matching lines...) Expand all Loading... |
4575 always_false_flags, arraysize(always_false_flags)); | 4597 always_false_flags, arraysize(always_false_flags)); |
4576 | 4598 |
4577 const char* good_data[] = { | 4599 const char* good_data[] = { |
4578 "let = 1;", | 4600 "let = 1;", |
4579 "for(let = 1;;){}", | 4601 "for(let = 1;;){}", |
4580 NULL}; | 4602 NULL}; |
4581 RunParserSyncTest(context_data, good_data, kSuccess, NULL, 0, | 4603 RunParserSyncTest(context_data, good_data, kSuccess, NULL, 0, |
4582 always_true_flags, arraysize(always_true_flags), | 4604 always_true_flags, arraysize(always_true_flags), |
4583 always_false_flags, arraysize(always_false_flags)); | 4605 always_false_flags, arraysize(always_false_flags)); |
4584 } | 4606 } |
OLD | NEW |