re-add template literals tests, add ones that were missing (#6169)
This commit is contained in:
parent
d79a7920a1
commit
d70603ffa9
@ -0,0 +1,9 @@
|
||||
var foo = 5;
|
||||
var bar = 10;
|
||||
var baz = 15;
|
||||
|
||||
var example = `${"a"}`;
|
||||
var example2 = `${1}`;
|
||||
var example3 = 1 + `${foo}${bar}${baz}`;
|
||||
var example4 = 1 + `${foo}bar${baz}`;
|
||||
var example5 = `${""}`;
|
||||
@ -0,0 +1,9 @@
|
||||
var foo = 5;
|
||||
var bar = 10;
|
||||
var baz = 15;
|
||||
var example = "a";
|
||||
var example2 = "".concat(1);
|
||||
var example3 = 1 + "".concat(foo).concat(bar).concat(baz);
|
||||
var example4 = 1 + "".concat(foo, "bar").concat(baz);
|
||||
var example5 = "";
|
||||
|
||||
@ -1 +1 @@
|
||||
var foo = `${1}${f}oo${true}${b}ar${0}${baz}`;
|
||||
var foo = `${1}${f}oo${true}${b}ar${0}${baz}`;
|
||||
|
||||
3
packages/babel-plugin-transform-es2015-template-literals/test/fixtures/default/tag/actual.js
vendored
Normal file
3
packages/babel-plugin-transform-es2015-template-literals/test/fixtures/default/tag/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
var foo = bar`wow\na${ 42 }b ${_.foobar()}`;
|
||||
var bar = bar`wow\nab${ 42 } ${_.foobar()}`;
|
||||
var bar = bar`wow\naB${ 42 } ${_.baz()}`;
|
||||
@ -0,0 +1,9 @@
|
||||
var _templateObject = _taggedTemplateLiteral(["wow\na", "b ", ""], ["wow\\na", "b ", ""]),
|
||||
_templateObject2 = _taggedTemplateLiteral(["wow\nab", " ", ""], ["wow\\nab", " ", ""]),
|
||||
_templateObject3 = _taggedTemplateLiteral(["wow\naB", " ", ""], ["wow\\naB", " ", ""]);
|
||||
|
||||
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
||||
|
||||
var foo = bar(_templateObject, 42, _.foobar());
|
||||
var bar = bar(_templateObject2, 42, _.foobar());
|
||||
var bar = bar(_templateObject3, 42, _.baz());
|
||||
@ -0,0 +1 @@
|
||||
var foo = `${1}${f}oo${true}${b}ar${0}${baz}`;
|
||||
@ -0,0 +1 @@
|
||||
var foo = "" + 1 + f + "oo" + true + b + "ar" + 0 + baz;
|
||||
24
packages/babel-plugin-transform-es2015-template-literals/test/fixtures/loose/order/exec.js
vendored
Normal file
24
packages/babel-plugin-transform-es2015-template-literals/test/fixtures/loose/order/exec.js
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
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]);
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"minNodeVersion": "6.0.0"
|
||||
}
|
||||
19
packages/babel-plugin-transform-es2015-template-literals/test/fixtures/loose/order2/exec.js
vendored
Normal file
19
packages/babel-plugin-transform-es2015-template-literals/test/fixtures/loose/order2/exec.js
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
const calls = [];
|
||||
|
||||
`
|
||||
${{
|
||||
[Symbol.toPrimitive]() {
|
||||
calls.push(1);
|
||||
return "foo";
|
||||
}
|
||||
}}
|
||||
${1 +
|
||||
{
|
||||
valueOf() {
|
||||
calls.push(2);
|
||||
return 2;
|
||||
}
|
||||
}}
|
||||
`;
|
||||
|
||||
assert.deepEqual(calls, [1, 2]);
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"minNodeVersion": "6.0.0"
|
||||
}
|
||||
3
packages/babel-plugin-transform-es2015-template-literals/test/fixtures/loose/symbol/exec.js
vendored
Normal file
3
packages/babel-plugin-transform-es2015-template-literals/test/fixtures/loose/symbol/exec.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
const fn = () => `${Symbol()}`;
|
||||
|
||||
assert.throws(fn, TypeError);
|
||||
@ -1 +1,3 @@
|
||||
var foo = bar`wow\na${ 42 }b ${_.foobar()}`;
|
||||
var bar = bar`wow\nab${ 42 } ${_.foobar()}`;
|
||||
var bar = bar`wow\naB${ 42 } ${_.baz()}`;
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
var _templateObject = _taggedTemplateLiteralLoose(["wow\na", "b ", ""], ["wow\\na", "b ", ""]);
|
||||
var _templateObject = _taggedTemplateLiteralLoose(["wow\na", "b ", ""], ["wow\\na", "b ", ""]),
|
||||
_templateObject2 = _taggedTemplateLiteralLoose(["wow\nab", " ", ""], ["wow\\nab", " ", ""]),
|
||||
_templateObject3 = _taggedTemplateLiteralLoose(["wow\naB", " ", ""], ["wow\\naB", " ", ""]);
|
||||
|
||||
function _taggedTemplateLiteralLoose(strings, raw) { strings.raw = raw; return strings; }
|
||||
|
||||
var foo = bar(_templateObject, 42, _.foobar());
|
||||
var bar = bar(_templateObject2, 42, _.foobar());
|
||||
var bar = bar(_templateObject3, 42, _.baz());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user