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 4534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4545 "`foo${\r a`", | 4545 "`foo${\r a`", |
4546 "`foo${fn(}`", | 4546 "`foo${fn(}`", |
4547 "`foo${1 if}`", | 4547 "`foo${1 if}`", |
4548 NULL}; | 4548 NULL}; |
4549 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; | 4549 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; |
4550 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 4550 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
4551 arraysize(always_flags)); | 4551 arraysize(always_flags)); |
4552 } | 4552 } |
4553 | 4553 |
4554 | 4554 |
| 4555 TEST(TemplateLiteralsIllegalTokens) { |
| 4556 const char* context_data[][2] = {{"'use strict';", ""}, |
| 4557 {"function foo(){ 'use strict';" |
| 4558 " var a, b, c; return ", "}"}, |
| 4559 {NULL, NULL}}; |
| 4560 const char* data[] = { |
| 4561 "`hello\\x`", |
| 4562 "`hello\\x${1}`", |
| 4563 "`hello${1}\\x`", |
| 4564 "`hello${1}\\x${2}`", |
| 4565 "`hello\\x\n`", |
| 4566 "`hello\\x\n${1}`", |
| 4567 "`hello${1}\\x\n`", |
| 4568 "`hello${1}\\x\n${2}`", |
| 4569 NULL}; |
| 4570 |
| 4571 static const ParserFlag always_flags[] = {kAllowHarmonyTemplates}; |
| 4572 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 4573 arraysize(always_flags)); |
| 4574 } |
| 4575 |
| 4576 |
4555 TEST(LexicalScopingSloppyMode) { | 4577 TEST(LexicalScopingSloppyMode) { |
4556 const char* context_data[][2] = { | 4578 const char* context_data[][2] = { |
4557 {"", ""}, | 4579 {"", ""}, |
4558 {"function f() {", "}"}, | 4580 {"function f() {", "}"}, |
4559 {"{", "}"}, | 4581 {"{", "}"}, |
4560 {NULL, NULL}}; | 4582 {NULL, NULL}}; |
4561 const char* bad_data[] = { | 4583 const char* bad_data[] = { |
4562 "let x = 1;", | 4584 "let x = 1;", |
4563 "for(let x = 1;;){}", | 4585 "for(let x = 1;;){}", |
4564 "for(let x of []){}", | 4586 "for(let x of []){}", |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4636 | 4658 |
4637 static const ParserFlag always_flags[] = { | 4659 static const ParserFlag always_flags[] = { |
4638 kAllowHarmonyClasses, | 4660 kAllowHarmonyClasses, |
4639 kAllowHarmonyComputedPropertyNames, | 4661 kAllowHarmonyComputedPropertyNames, |
4640 kAllowHarmonyObjectLiterals, | 4662 kAllowHarmonyObjectLiterals, |
4641 kAllowHarmonySloppy, | 4663 kAllowHarmonySloppy, |
4642 }; | 4664 }; |
4643 RunParserSyncTest(context_data, error_data, kError, NULL, 0, | 4665 RunParserSyncTest(context_data, error_data, kError, NULL, 0, |
4644 always_flags, arraysize(always_flags)); | 4666 always_flags, arraysize(always_flags)); |
4645 } | 4667 } |
OLD | NEW |