Artem Yavorsky c4fd05c0c2 Spec compatibility for template literals. (#5791)
* Spec compatibility for template literals.

* Update preset-es2015 `spec` expected case.

* Prevent array mutability by replacing `shift`.

* Fix condition for single item.

* Group concats to ensure toPrimitive sequence.

* Update function test case.

* Add semi for function test case.

* Simplify concat call expressions creating.

* Fix some cases with multiple idengifiers.

* Add test case with different literals.

* Add test case for `Symbol()` and toPrimitive order

* Add actual literal case.

* Add minNodeVersion to template literals order.

* Flip the logical expression.

* Update README for template literals spec option.

* docs [skip ci]
2017-06-05 08:53:10 -04:00

25 lines
310 B
JavaScript

const calls = [];
`
${
calls.push(1),
{
[Symbol.toPrimitive](){
calls.push(2);
return 'foo';
}
}
}
${
calls.push(3),
{
[Symbol.toPrimitive](){
calls.push(4);
return 'bar';
}
}
}
`;
assert.deepEqual(calls, [1, 2, 3, 4]);