OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var num = 5; | 5 var num = 5; |
6 var str = "str"; | 6 var str = "str"; |
7 function fn() { return "result"; } | 7 function fn() { return "result"; } |
8 var obj = { | 8 var obj = { |
9 num: num, | 9 num: num, |
10 str: str, | 10 str: str, |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 assertEquals("-1-2-3-", tag`-${subs[0]}-${subs[1]}-${subs[2]}-`); | 690 assertEquals("-1-2-3-", tag`-${subs[0]}-${subs[1]}-${subs[2]}-`); |
691 assertArrayEquals(["get0", "get1", "get2"], log); | 691 assertArrayEquals(["get0", "get1", "get2"], log); |
692 assertArrayEquals([1, 2, 3], tagged); | 692 assertArrayEquals([1, 2, 3], tagged); |
693 | 693 |
694 tagged.length = 0; | 694 tagged.length = 0; |
695 log.length = 0; | 695 log.length = 0; |
696 assertEquals("-1-", tag`-${subs[0]}-`); | 696 assertEquals("-1-", tag`-${subs[0]}-`); |
697 assertArrayEquals(["get0"], log); | 697 assertArrayEquals(["get0"], log); |
698 assertArrayEquals([1], tagged); | 698 assertArrayEquals([1], tagged); |
699 })(); | 699 })(); |
| 700 |
| 701 |
| 702 // Since the first argument to the tag function is always an array, |
| 703 // eval calls will always just return that array. |
| 704 (function testEvalTagStrict() { |
| 705 "use strict"; |
| 706 var f = (x) => eval`a${x}b`; |
| 707 var result = f(); |
| 708 assertEquals(["a", "b"], result); |
| 709 assertSame(result, f()); |
| 710 })(); |
| 711 |
| 712 |
| 713 (function testEvalTagSloppy() { |
| 714 var f = (x) => eval`a${x}b`; |
| 715 var result = f(); |
| 716 assertEquals(["a", "b"], result); |
| 717 assertSame(result, f()); |
| 718 })(); |
OLD | NEW |