mirror of
https://github.com/tc39/test262.git
synced 2025-07-22 21:45:04 +02:00
Introduce additional tests for ES6 templates
This commit is contained in:
parent
bd3d160ba1
commit
5ca7a58e75
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.3.7
|
||||||
|
description: Argument list evalution for call expresions
|
||||||
|
info: >
|
||||||
|
A tagged template is a function call where the arguments of the call are
|
||||||
|
derived from a TemplateLiteral. The actual arguments include a template
|
||||||
|
object and the values produced by evaluating the expressions embedded
|
||||||
|
within the TemplateLiteral.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var number = 5;
|
||||||
|
var string = 'str';
|
||||||
|
var object = {};
|
||||||
|
function fn() { return 'result'; }
|
||||||
|
var calls;
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function() {
|
||||||
|
return function() {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(
|
||||||
|
arguments.length, 1, 'NoSubstitutionTemplate arguments length'
|
||||||
|
);
|
||||||
|
};
|
||||||
|
})()`NoSubstitutionTemplate`;
|
||||||
|
assert.sameValue(calls, 1, 'NoSubstitutionTemplate function invocation');
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function() {
|
||||||
|
return function(site, n, s, o, f, r) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(n, number);
|
||||||
|
assert.sameValue(s, string);
|
||||||
|
assert.sameValue(o, object);
|
||||||
|
assert.sameValue(f, fn);
|
||||||
|
assert.sameValue(r, 'result');
|
||||||
|
assert.sameValue(arguments.length, 6, 'TemplateHead arguments length');
|
||||||
|
};
|
||||||
|
})()`TemplateHead${number}TemplateSpans${string}${object}${fn}${fn()}`;
|
||||||
|
assert.sameValue(calls, 1, 'TemplateHead function invocation');
|
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.3.7
|
||||||
|
description: Invocation context for call expressions
|
||||||
|
info: >
|
||||||
|
A tagged template is a function call where the arguments of the call are
|
||||||
|
derived from a TemplateLiteral. The actual arguments include a template
|
||||||
|
object and the values produced by evaluating the expressions embedded
|
||||||
|
within the TemplateLiteral.
|
||||||
|
---*/
|
||||||
|
var context;
|
||||||
|
var fn = function() {
|
||||||
|
return function() {
|
||||||
|
context = this;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
fn`NoSubstitutionTemplate`;
|
||||||
|
|
||||||
|
assert.sameValue(context, undefined);
|
@ -8,4 +8,4 @@ description: >
|
|||||||
negative: SyntaxError
|
negative: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
(function() {})`\x`;
|
`\x0`;
|
||||||
|
@ -8,4 +8,4 @@ description: >
|
|||||||
negative: SyntaxError
|
negative: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
(function() {})`\00`;
|
`\00`;
|
||||||
|
@ -8,4 +8,4 @@ description: >
|
|||||||
negative: SyntaxError
|
negative: SyntaxError
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
(function() {})`\u`;
|
`\u0`;
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Abrupt completion when evaluating expression of TemplateLiteral
|
||||||
|
info: >
|
||||||
|
TemplateLiteral : TemplateHead Expression TemplateSpans
|
||||||
|
|
||||||
|
1. Let head be the TV of TemplateHead as defined in 11.8.6.
|
||||||
|
2. Let sub be the result of evaluating Expression.
|
||||||
|
3. Let middle be ToString(sub).
|
||||||
|
4. ReturnIfAbrupt(middle).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
`${function() { throw new Test262Error(); }()}`;
|
||||||
|
});
|
@ -22,3 +22,13 @@ assert.sameValue(
|
|||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
`foo ${object.string} bar`, 'foo stringValue bar', 'string value property'
|
`foo ${object.string} bar`, 'foo stringValue bar', 'string value property'
|
||||||
);
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
`foo ${object['string']} bar`,
|
||||||
|
'foo stringValue bar',
|
||||||
|
'string value property (single-quote string dereference)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
`foo ${object["string"]} bar`,
|
||||||
|
'foo stringValue bar',
|
||||||
|
'string value property (double-quote string dereference)'
|
||||||
|
);
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Abrupt completion when converting expression value of TemplateLiteral
|
||||||
|
info: >
|
||||||
|
TemplateLiteral : TemplateHead Expression TemplateSpans
|
||||||
|
|
||||||
|
1. Let head be the TV of TemplateHead as defined in 11.8.6.
|
||||||
|
2. Let sub be the result of evaluating Expression.
|
||||||
|
3. Let middle be ToString(sub).
|
||||||
|
4. ReturnIfAbrupt(middle).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = {
|
||||||
|
toString: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
`${obj}`;
|
||||||
|
});
|
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Abrupt completion when evaluating expression of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let rest be the result of evaluating TemplateMiddleList .
|
||||||
|
2. ReturnIfAbrupt(rest).
|
||||||
|
3. Let middle be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
4. Let sub be the result of evaluating Expression.
|
||||||
|
5. Let last be ToString(sub).
|
||||||
|
6. ReturnIfAbrupt(last).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
`${0}${1}${function() { throw new Test262Error(); }()}`;
|
||||||
|
});
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Function invocation in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let rest be the result of evaluating TemplateMiddleList .
|
||||||
|
2. ReturnIfAbrupt(rest).
|
||||||
|
3. Let middle be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
4. Let sub be the result of evaluating Expression.
|
||||||
|
5. Let last be ToString(sub).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function fn() { return 'result'; }
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${1} ${fn()}`, '0 1 result');
|
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: MemberExpression in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let rest be the result of evaluating TemplateMiddleList .
|
||||||
|
2. ReturnIfAbrupt(rest).
|
||||||
|
3. Let middle be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
4. Let sub be the result of evaluating Expression.
|
||||||
|
5. Let last be ToString(sub).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var object = {
|
||||||
|
number: 5,
|
||||||
|
string: 'stringValue'
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
`${0} ${1} ${object.number} bar`, '0 1 5 bar', 'number value property'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
`${0} ${1} ${object.string} bar`,
|
||||||
|
'0 1 stringValue bar',
|
||||||
|
'string value property'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
`${0} ${1} ${object['string']} bar`,
|
||||||
|
'0 1 stringValue bar',
|
||||||
|
'string value property (single-quote string dereference)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
`${0} ${1} ${object["string"]} bar`,
|
||||||
|
'0 1 stringValue bar',
|
||||||
|
'string value property (double-quote string dereference)'
|
||||||
|
);
|
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Method invocation in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let rest be the result of evaluating TemplateMiddleList .
|
||||||
|
2. ReturnIfAbrupt(rest).
|
||||||
|
3. Let middle be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
4. Let sub be the result of evaluating Expression.
|
||||||
|
5. Let last be ToString(sub).
|
||||||
|
---*/
|
||||||
|
var object = {
|
||||||
|
fn: function() { return 'result'; }
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${1} ${object.fn()} bar`, '0 1 result bar');
|
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Object reference in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let rest be the result of evaluating TemplateMiddleList .
|
||||||
|
2. ReturnIfAbrupt(rest).
|
||||||
|
3. Let middle be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
4. Let sub be the result of evaluating Expression.
|
||||||
|
5. Let last be ToString(sub).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var plain = {};
|
||||||
|
var custom = {
|
||||||
|
toString: function() {
|
||||||
|
return '"own" toString';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${1} ${plain}`, '0 1 [object Object]');
|
||||||
|
assert.sameValue(`${0} ${1} ${plain}`, '0 1 [object Object]');
|
||||||
|
assert.sameValue(`${0} ${1} ${plain}2`, '0 1 [object Object]2');
|
||||||
|
assert.sameValue(`${0} ${1} ${plain}2`, '0 1 [object Object]2');
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${1} ${custom}`, '0 1 "own" toString');
|
||||||
|
assert.sameValue(`${0} ${1} ${custom}`, '0 1 "own" toString');
|
||||||
|
assert.sameValue(`${0} ${1} ${custom}2`, '0 1 "own" toString2');
|
||||||
|
assert.sameValue(`${0} ${1} ${custom}2`, '0 1 "own" toString2');
|
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Primitive value in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let rest be the result of evaluating TemplateMiddleList .
|
||||||
|
2. ReturnIfAbrupt(rest).
|
||||||
|
3. Let middle be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
4. Let sub be the result of evaluating Expression.
|
||||||
|
5. Let last be ToString(sub).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${1} ${5} bar`, '0 1 5 bar', 'number value');
|
||||||
|
assert.sameValue(`${0} ${1} ${'string'} bar`, '0 1 string bar', 'string value');
|
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Template literal in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let rest be the result of evaluating TemplateMiddleList .
|
||||||
|
2. ReturnIfAbrupt(rest).
|
||||||
|
3. Let middle be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
4. Let sub be the result of evaluating Expression.
|
||||||
|
5. Let last be ToString(sub).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${1} ${`bar ${5} baz`} qux`, '0 1 bar 5 baz qux');
|
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Abrupt completion when converting expression value of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let rest be the result of evaluating TemplateMiddleList .
|
||||||
|
2. ReturnIfAbrupt(rest).
|
||||||
|
3. Let middle be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
4. Let sub be the result of evaluating Expression.
|
||||||
|
5. Let last be ToString(sub).
|
||||||
|
6. ReturnIfAbrupt(last).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = {
|
||||||
|
toString: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
`${0} ${1} ${obj}`;
|
||||||
|
});
|
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Abrupt completion when evaluating expression of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let head be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
2. Let sub be the result of evaluating Expression.
|
||||||
|
3. Let middle be ToString(sub).
|
||||||
|
4. ReturnIfAbrupt(middle).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
`${0}${function() { throw new Test262Error(); }()}`;
|
||||||
|
});
|
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Function invocation in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let head be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
2. Let sub be the result of evaluating Expression.
|
||||||
|
3. Let middle be ToString(sub).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
function fn() { return 'result'; }
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${fn()}`, '0 result');
|
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: MemberExpression in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let head be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
2. Let sub be the result of evaluating Expression.
|
||||||
|
3. Let middle be ToString(sub).
|
||||||
|
4. ReturnIfAbrupt(middle).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var object = {
|
||||||
|
number: 5,
|
||||||
|
string: 'stringValue'
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
`${0} ${object.number} bar`, '0 5 bar', 'number value property'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
`${0} ${object.string} bar`, '0 stringValue bar', 'string value property'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
`${0} ${object['string']} bar`,
|
||||||
|
'0 stringValue bar',
|
||||||
|
'string value property (single-quote string dereference)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
`${0} ${object["string"]} bar`,
|
||||||
|
'0 stringValue bar',
|
||||||
|
'string value property (double-quote string dereference)'
|
||||||
|
);
|
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Method invocation in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let head be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
2. Let sub be the result of evaluating Expression.
|
||||||
|
3. Let middle be ToString(sub).
|
||||||
|
4. ReturnIfAbrupt(middle).
|
||||||
|
---*/
|
||||||
|
var object = {
|
||||||
|
fn: function() { return 'result'; }
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${object.fn()} bar`, '0 result bar');
|
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Object reference in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let head be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
2. Let sub be the result of evaluating Expression.
|
||||||
|
3. Let middle be ToString(sub).
|
||||||
|
4. ReturnIfAbrupt(middle).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var plain = {};
|
||||||
|
var custom = {
|
||||||
|
toString: function() {
|
||||||
|
return '"own" toString';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${plain}`, '0 [object Object]');
|
||||||
|
assert.sameValue(`${0} ${plain}`, '0 [object Object]');
|
||||||
|
assert.sameValue(`${0} ${plain}2`, '0 [object Object]2');
|
||||||
|
assert.sameValue(`${0} ${plain}2`, '0 [object Object]2');
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${custom}`, '0 "own" toString');
|
||||||
|
assert.sameValue(`${0} ${custom}`, '0 "own" toString');
|
||||||
|
assert.sameValue(`${0} ${custom}2`, '0 "own" toString2');
|
||||||
|
assert.sameValue(`${0} ${custom}2`, '0 "own" toString2');
|
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Primitive value in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let head be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
2. Let sub be the result of evaluating Expression.
|
||||||
|
3. Let middle be ToString(sub).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${5} bar`, '0 5 bar', 'number value');
|
||||||
|
assert.sameValue(`${0} ${'string'} bar`, '0 string bar', 'string value');
|
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Template literal in expression position of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let head be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
2. Let sub be the result of evaluating Expression.
|
||||||
|
3. Let middle be ToString(sub).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(`${0} ${`bar ${5} baz`} qux`, '0 bar 5 baz qux');
|
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Abrupt completion when converting expression value of TemplateMiddleList
|
||||||
|
info: >
|
||||||
|
TemplateMiddleList : TemplateMiddle Expression
|
||||||
|
|
||||||
|
1. Let head be the TV of TemplateMiddle as defined in 11.8.6.
|
||||||
|
2. Let sub be the result of evaluating Expression.
|
||||||
|
3. Let middle be ToString(sub).
|
||||||
|
4. ReturnIfAbrupt(middle).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = {
|
||||||
|
toString: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
`${0} ${obj}`;
|
||||||
|
});
|
14
test/language/expressions/template-literal/no-sub.js
Normal file
14
test/language/expressions/template-literal/no-sub.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 12.2.8.5
|
||||||
|
description: Evaluation of NoSubstitutionTemplate
|
||||||
|
info: >
|
||||||
|
12.2.8.5 Runtime Semantics: Evaluation
|
||||||
|
TemplateLiteral : NoSubstitutionTemplate
|
||||||
|
|
||||||
|
1. Return the string value whose code units are the elements of the TV of
|
||||||
|
NoSubstitutionTemplate as defined in 11.8.6.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(`NoSubstitutionTemplate`, 'NoSubstitutionTemplate');
|
@ -1,88 +0,0 @@
|
|||||||
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
es6id: 11.8.6
|
|
||||||
description: >
|
|
||||||
The TRV of CharacterEscapeSequence :: SingleEscapeCharacter is the TRV of
|
|
||||||
the SingleEscapeCharacter.
|
|
||||||
The TRV of CharacterEscapeSequence :: NonEscapeCharacter is the CV of the
|
|
||||||
NonEscapeCharacter.
|
|
||||||
---*/
|
|
||||||
var calls;
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005C\u0027");
|
|
||||||
})`\'`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005C\u0022");
|
|
||||||
})`\"`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005C\u005C");
|
|
||||||
})`\\`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005Cb");
|
|
||||||
})`\b`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005Cf");
|
|
||||||
})`\f`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005Cn");
|
|
||||||
})`\n`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005Cr");
|
|
||||||
})`\r`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005Ct");
|
|
||||||
})`\t`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005Cv");
|
|
||||||
})`\v`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005C`");
|
|
||||||
})`\``;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s.raw[0], "\u005Cz");
|
|
||||||
})`\z`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
Binary file not shown.
@ -1,29 +0,0 @@
|
|||||||
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
es6id: 11.8.6
|
|
||||||
description: >
|
|
||||||
The TV of TemplateCharacter :: $ is the code unit value 0x0024.
|
|
||||||
The TV of TemplateCharacter :: \ EscapeSequence is the CV of
|
|
||||||
EscapeSequence.
|
|
||||||
The TV of TemplateCharacter :: LineContinuation is the TV of
|
|
||||||
LineContinuation. The TV of LineContinuation :: \ LineTerminatorSequence is
|
|
||||||
the empty code unit sequence.
|
|
||||||
The TRV of TemplateCharacter :: $ is the code unit value 0x0024.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var calls;
|
|
||||||
|
|
||||||
assert.sameValue(`\uc548\uB155`, "안녕");
|
|
||||||
assert.sameValue(`\xff`, "\xff");
|
|
||||||
assert.sameValue(`\n`, "\n");
|
|
||||||
assert.sameValue(`\
|
|
||||||
`, '');
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s[0], '$', '`$` character template value');
|
|
||||||
assert.sameValue(s.raw[0], '$', '`$` character template raw value');
|
|
||||||
})`$`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
@ -1,24 +0,0 @@
|
|||||||
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
es6id: 11.8.6
|
|
||||||
description: >
|
|
||||||
The TV of TemplateCharacters :: TemplateCharacter is the TV of
|
|
||||||
TemplateCharacter.
|
|
||||||
The TV of NoSubstitutionTemplate :: ` TemplateCharacters ` is the TV of
|
|
||||||
TemplateCharacters.
|
|
||||||
The TRV of TemplateCharacters :: TemplateCharacter is the TRV of
|
|
||||||
TemplateCharacter.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var calls;
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s[0], 'f', 'TemplateCharacters template value');
|
|
||||||
assert.sameValue(s.raw[0], 'f', 'TemplateCharacters template raw value');
|
|
||||||
})`f`;
|
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
assert.sameValue(`test`, 'test', 'TemplateCharacters template value');
|
|
@ -1,15 +0,0 @@
|
|||||||
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
es6id: 11.1
|
|
||||||
description: >
|
|
||||||
The zero width no-break space format-control character may be used within
|
|
||||||
template literals.
|
|
||||||
---*/
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
`\uFEFFtest`, 'test', 'Specified via unicode escape sequence'
|
|
||||||
);
|
|
||||||
assert.sameValue(
|
|
||||||
`test`, 'test', 'Specified via literal character'
|
|
||||||
);
|
|
@ -0,0 +1,116 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 11.8.6
|
||||||
|
description: >
|
||||||
|
The TV of TemplateCharacter :: \ EscapeSequence is the SV of
|
||||||
|
EscapeSequence.
|
||||||
|
The TRV of TemplateCharacter :: \ EscapeSequence is the sequence consisting
|
||||||
|
of the code unit value 0x005C followed by the code units of TRV of
|
||||||
|
EscapeSequence.
|
||||||
|
The TRV of CharacterEscapeSequence :: SingleEscapeCharacter is the TRV of
|
||||||
|
the SingleEscapeCharacter.
|
||||||
|
The TRV of CharacterEscapeSequence :: NonEscapeCharacter is the SV of the
|
||||||
|
NonEscapeCharacter.
|
||||||
|
---*/
|
||||||
|
var calls;
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], "'", "TV of NonEscapeCharacter");
|
||||||
|
assert.sameValue(s.raw[0], "\u005C\u0027", "TRV of NonEscapeCharacter");
|
||||||
|
})`\'`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], "\"", "TV of SingleEscapeCharacter (double quote)");
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], "\u005C\u0022", "TRV of SingleEscapeCharacter (double quote)"
|
||||||
|
);
|
||||||
|
})`\"`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], "\\", "TV of SingleEscapeCharacter (backslash)");
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], "\u005C\u005C", "TRV of SingleEscapeCharacter (backslash)"
|
||||||
|
);
|
||||||
|
})`\\`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], "\b", "TV of SingleEscapeCharacter (backspace)");
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], "\u005Cb", "TRV of SingleEscapeCharacter (backspace)"
|
||||||
|
);
|
||||||
|
})`\b`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], "\f", "TV of SingleEscapeCharacter (form feed)");
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], "\u005Cf", "TRV of SingleEscapeCharacter (form feed)"
|
||||||
|
);
|
||||||
|
})`\f`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], "\n", "TV of SingleEscapeCharacter (new line)");
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], "\u005Cn", "TRV of SingleEscapeCharacter (new line)"
|
||||||
|
);
|
||||||
|
})`\n`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(
|
||||||
|
s[0], "\r", "TV of SingleEscapeCharacter (carriage return)"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], "\u005Cr", "TRV of SingleEscapeCharacter (carriage return)"
|
||||||
|
);
|
||||||
|
})`\r`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], " ", "TV of SingleEscapeCharacter (tab)");
|
||||||
|
assert.sameValue(s.raw[0], "\u005Ct", "TRV of SingleEscapeCharacter (tab)");
|
||||||
|
})`\t`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(
|
||||||
|
s[0], "\v", "TV of SingleEscapeCharacter (line tabulation)"
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], "\u005Cv", "TRV of SingleEscapeCharacter (line tabulation)"
|
||||||
|
);
|
||||||
|
})`\v`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], "`", "TV of SingleEscapeCharacter (backtick)");
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], "\u005C`", "TRV of SingleEscapeCharacter (backtick)"
|
||||||
|
);
|
||||||
|
})`\``;
|
||||||
|
assert.sameValue(calls, 1);
|
@ -1,8 +1,10 @@
|
|||||||
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
es6id: 11.1
|
es6id: 11.1
|
||||||
description: >
|
description: >
|
||||||
|
The TV of TemplateCharacter :: \ EscapeSequence is the SV of
|
||||||
|
EscapeSequence.
|
||||||
The SV of UnicodeEscapeSequence :: u{ HexDigits } is the UTF16Encoding
|
The SV of UnicodeEscapeSequence :: u{ HexDigits } is the UTF16Encoding
|
||||||
(10.1.1) of the MV of HexDigits.
|
(10.1.1) of the MV of HexDigits.
|
||||||
The TRV of UnicodeEscapeSequence :: u{ HexDigits } is the sequence
|
The TRV of UnicodeEscapeSequence :: u{ HexDigits } is the sequence
|
||||||
@ -15,15 +17,7 @@ var calls;
|
|||||||
calls = 0;
|
calls = 0;
|
||||||
(function(s) {
|
(function(s) {
|
||||||
calls++;
|
calls++;
|
||||||
assert.sameValue(s[0], 'abc', '`` sequence template value');
|
assert.sameValue(s[0], 'A', 'TV');
|
||||||
assert.sameValue(s.raw[0], 'a\\u{62}c', '`` sequence template raw value');
|
assert.sameValue(s.raw[0], '\\x41', 'TRV');
|
||||||
})`a\u{62}c`;
|
})`\x41`;
|
||||||
assert.sameValue(calls, 1);
|
|
||||||
|
|
||||||
calls = 0;
|
|
||||||
(function(s) {
|
|
||||||
calls++;
|
|
||||||
assert.sameValue(s[0], 'abc', 'HexEscapeSequence template value');
|
|
||||||
assert.sameValue(s.raw[0], 'a\\u{000062}c', 'HexEscapeSequence template raw value');
|
|
||||||
})`a\u{000062}c`;
|
|
||||||
assert.sameValue(calls, 1);
|
assert.sameValue(calls, 1);
|
@ -3,15 +3,19 @@
|
|||||||
/*---
|
/*---
|
||||||
es6id: 11.8.6
|
es6id: 11.8.6
|
||||||
description: >
|
description: >
|
||||||
|
The TV of LineContinuation :: \ LineTerminatorSequence is the empty code
|
||||||
|
unit sequence.
|
||||||
The TRV of LineContinuation :: \ LineTerminatorSequence is the sequence
|
The TRV of LineContinuation :: \ LineTerminatorSequence is the sequence
|
||||||
consisting of the code unit value 0x005C followed by the code units of TRV
|
consisting of the code unit value 0x005C followed by the code units of TRV
|
||||||
of LineTerminatorSequence.
|
of LineTerminatorSequence.
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var calls;
|
var calls;
|
||||||
|
|
||||||
calls = 0;
|
calls = 0;
|
||||||
(function(cs) {
|
(function(cs) {
|
||||||
calls++;
|
calls++;
|
||||||
|
assert.sameValue(cs[0], '', 'Line Feed and Carriage Return');
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
cs.raw[0], '\u005C\n\u005C\n\u005C\n', 'Line Feed and Carriage Return'
|
cs.raw[0], '\u005C\n\u005C\n\u005C\n', 'Line Feed and Carriage Return'
|
||||||
);
|
);
|
||||||
@ -23,6 +27,7 @@ assert.sameValue(calls, 1);
|
|||||||
calls = 0;
|
calls = 0;
|
||||||
(function(cs) {
|
(function(cs) {
|
||||||
calls++;
|
calls++;
|
||||||
|
assert.sameValue(cs[0], '', 'Line Separator');
|
||||||
assert.sameValue(cs.raw[0], '\\\u2028', 'Line Separator');
|
assert.sameValue(cs.raw[0], '\\\u2028', 'Line Separator');
|
||||||
})`\
`
|
})`\
`
|
||||||
assert.sameValue(calls, 1);
|
assert.sameValue(calls, 1);
|
||||||
@ -30,6 +35,7 @@ assert.sameValue(calls, 1);
|
|||||||
calls = 0;
|
calls = 0;
|
||||||
(function(cs) {
|
(function(cs) {
|
||||||
calls++;
|
calls++;
|
||||||
|
assert.sameValue(cs[0], '', 'Paragraph Separater');
|
||||||
assert.sameValue(cs.raw[0], '\\\u2029', 'Paragraph Separator');
|
assert.sameValue(cs.raw[0], '\\\u2029', 'Paragraph Separator');
|
||||||
})`\
`
|
})`\
`
|
||||||
assert.sameValue(calls, 1);
|
assert.sameValue(calls, 1);
|
@ -1,8 +1,10 @@
|
|||||||
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
// Copyright (C) Copyright 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
es6id: 11.8.6
|
es6id: 11.8.6
|
||||||
description: >
|
description: >
|
||||||
|
The TV of TemplateCharacter :: LineTerminatorSequence is the TRV of
|
||||||
|
LineTerminatorSequence.
|
||||||
The TRV of LineTerminatorSequence :: <LF> is the code unit value 0x000A.
|
The TRV of LineTerminatorSequence :: <LF> is the code unit value 0x000A.
|
||||||
The TRV of LineTerminatorSequence :: <CR> is the code unit value 0x000A.
|
The TRV of LineTerminatorSequence :: <CR> is the code unit value 0x000A.
|
||||||
The TRV of LineTerminatorSequence :: <LS> is the code unit value 0x2028.
|
The TRV of LineTerminatorSequence :: <LS> is the code unit value 0x2028.
|
||||||
@ -10,11 +12,14 @@ description: >
|
|||||||
The TRV of LineTerminatorSequence :: <CR><LF> is the sequence consisting of
|
The TRV of LineTerminatorSequence :: <CR><LF> is the sequence consisting of
|
||||||
the code unit value 0x000A.
|
the code unit value 0x000A.
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
|
||||||
var calls;
|
var calls;
|
||||||
|
|
||||||
calls = 0;
|
calls = 0;
|
||||||
(function(s) {
|
(function(s) {
|
||||||
calls++;
|
calls++;
|
||||||
|
assert.sameValue(s[0], '\n\n\n', 'Line Feed and Carriage Return');
|
||||||
assert.sameValue(s.raw[0], '\n\n\n', 'Line Feed and Carriage Return');
|
assert.sameValue(s.raw[0], '\n\n\n', 'Line Feed and Carriage Return');
|
||||||
})`
|
})`
|
||||||
|
|
||||||
@ -24,6 +29,7 @@ assert.sameValue(calls, 1);
|
|||||||
calls = 0;
|
calls = 0;
|
||||||
(function(cs) {
|
(function(cs) {
|
||||||
calls++;
|
calls++;
|
||||||
|
assert.sameValue(cs[0], '\u2028', 'Line Separator');
|
||||||
assert.sameValue(cs.raw[0], '\u2028', 'Line Separator');
|
assert.sameValue(cs.raw[0], '\u2028', 'Line Separator');
|
||||||
})`
`
|
})`
`
|
||||||
assert.sameValue(calls, 1);
|
assert.sameValue(calls, 1);
|
||||||
@ -31,6 +37,7 @@ assert.sameValue(calls, 1);
|
|||||||
calls = 0;
|
calls = 0;
|
||||||
(function(cs) {
|
(function(cs) {
|
||||||
calls++;
|
calls++;
|
||||||
|
assert.sameValue(cs[0], '\u2029', 'Paragraph Separator');
|
||||||
assert.sameValue(cs.raw[0], '\u2029', 'Paragraph Separator');
|
assert.sameValue(cs.raw[0], '\u2029', 'Paragraph Separator');
|
||||||
})`
`
|
})`
`
|
||||||
assert.sameValue(calls, 1);
|
assert.sameValue(calls, 1);
|
@ -7,6 +7,8 @@ description: >
|
|||||||
sequence.
|
sequence.
|
||||||
The TV of NoSubstitutionTemplate :: ` TemplateCharacters ` is the TV of
|
The TV of NoSubstitutionTemplate :: ` TemplateCharacters ` is the TV of
|
||||||
TemplateCharacters.
|
TemplateCharacters.
|
||||||
|
The TRV of NoSubstitutionTemplate :: ` TemplateCharacters ` is the TRV of
|
||||||
|
TemplateCharacters.
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var calls;
|
var calls;
|
||||||
@ -23,5 +25,6 @@ calls = 0;
|
|||||||
(function(s) {
|
(function(s) {
|
||||||
calls++;
|
calls++;
|
||||||
assert.sameValue(s[0], 'foo', 'Template value (with content)');
|
assert.sameValue(s[0], 'foo', 'Template value (with content)');
|
||||||
|
assert.sameValue(s.raw[0], 'foo', 'Template raw value (with content)');
|
||||||
})`foo`;
|
})`foo`;
|
||||||
assert.sameValue(calls, 1);
|
assert.sameValue(calls, 1);
|
Binary file not shown.
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 11.8.6
|
||||||
|
description: >
|
||||||
|
The TV of TemplateCharacters :: TemplateCharacter is the TV of
|
||||||
|
TemplateCharacter.
|
||||||
|
The TV of TemplateCharacter :: SourceCharacter but not one of ` or \ or $
|
||||||
|
or LineTerminator is the UTF16Encoding (10.1.1) of the code point value of
|
||||||
|
SourceCharacter.
|
||||||
|
The TV of TemplateCharacter :: $ is the code unit value 0x0024.
|
||||||
|
|
||||||
|
The TRV of TemplateCharacters :: TemplateCharacter is the TRV of
|
||||||
|
TemplateCharacter.
|
||||||
|
The TRV of TemplateCharacter :: SourceCharacter but not one of ` or \ or $
|
||||||
|
or LineTerminator is the UTF16Encoding (10.1.1) of the code point value of
|
||||||
|
SourceCharacter.
|
||||||
|
The TRV of TemplateCharacter :: $ is the code unit value 0x0024.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var calls;
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], 'a', '`a` character TV');
|
||||||
|
assert.sameValue(s.raw[0], 'a', '`a` character TRV');
|
||||||
|
})`a`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], '$', '`$` character TV');
|
||||||
|
assert.sameValue(s.raw[0], '$', '`$` character TRV');
|
||||||
|
})`$`;
|
||||||
|
assert.sameValue(calls, 1);
|
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 11.8.6
|
||||||
|
description: >
|
||||||
|
The TV of TemplateCharacters :: TemplateCharacter TemplateCharacters is a
|
||||||
|
sequence consisting of the code units in the TV of TemplateCharacter
|
||||||
|
followed by all the code units in the TV of TemplateCharacters in order.
|
||||||
|
The TRV of TemplateCharacters :: TemplateCharacter TemplateCharacters is a
|
||||||
|
sequence consisting of the code units in the TRV of TemplateCharacter
|
||||||
|
followed by all the code units in the TRV of TemplateCharacters, in order.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var calls = 0;
|
||||||
|
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s.raw[0], 'test');
|
||||||
|
})`test`;
|
||||||
|
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
assert.sameValue(`test`, 'test');
|
@ -4,8 +4,6 @@
|
|||||||
es6id: 11.8.6
|
es6id: 11.8.6
|
||||||
description: >
|
description: >
|
||||||
The TV and TRV of TemplateMiddle :: }${ is the empty code unit sequence.
|
The TV and TRV of TemplateMiddle :: }${ is the empty code unit sequence.
|
||||||
The TV of TemplateMiddle :: } TemplateCharacters ${ is the TV of
|
|
||||||
TemplateCharacters.
|
|
||||||
The TRV of TemplateMiddle :: } TemplateCharacters ${ is the TRV of
|
The TRV of TemplateMiddle :: } TemplateCharacters ${ is the TRV of
|
||||||
TemplateCharacters.
|
TemplateCharacters.
|
||||||
---*/
|
---*/
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 11.1
|
||||||
|
description: >
|
||||||
|
The TV of TemplateCharacter :: \ EscapeSequence is the SV of
|
||||||
|
EscapeSequence.
|
||||||
|
The SV of UnicodeEscapeSequence :: u{ HexDigits } is the UTF16Encoding
|
||||||
|
(10.1.1) of the MV of HexDigits.
|
||||||
|
The TRV of UnicodeEscapeSequence :: u Hex4Digits is the sequence consisting
|
||||||
|
of code unit value 0x0075 followed by TRV of Hex4Digits.
|
||||||
|
The TRV of UnicodeEscapeSequence :: u{ HexDigits } is the sequence
|
||||||
|
consisting of code unit value 0x0075 followed by code unit value 0x007B
|
||||||
|
followed by TRV of HexDigits followed by code unit value 0x007D.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var calls;
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], 'b', 'u Hex4Digits template value');
|
||||||
|
assert.sameValue(s.raw[0], '\\u0062', 'u Hex4Digits template raw value');
|
||||||
|
})`\u0062`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(s[0], 'b', 'u{ HexDigits } template value');
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], '\\u{62}', 'u{ Hex4Digits } template raw value'
|
||||||
|
);
|
||||||
|
})`\u{62}`;
|
||||||
|
assert.sameValue(calls, 1);
|
||||||
|
|
||||||
|
calls = 0;
|
||||||
|
(function(s) {
|
||||||
|
calls++;
|
||||||
|
assert.sameValue(
|
||||||
|
s[0], 'b', 'u{ HexDigits } template value (with leading zeros)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0],
|
||||||
|
'\\u{000062}',
|
||||||
|
'u{ HexDigits } template raw value (with leading zeros)'
|
||||||
|
);
|
||||||
|
})`\u{000062}`;
|
||||||
|
assert.sameValue(calls, 1);
|
32
test/language/expressions/template-literal/tv-zwnbsp.js
Normal file
32
test/language/expressions/template-literal/tv-zwnbsp.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) Copyright 2014 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
es6id: 11.1
|
||||||
|
description: >
|
||||||
|
The zero width no-break space format-control character may be used within
|
||||||
|
template literals.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var callCount;
|
||||||
|
|
||||||
|
callCount = 0;
|
||||||
|
(function(s) {
|
||||||
|
callCount++;
|
||||||
|
assert.sameValue(
|
||||||
|
s[0], 'test', 'TV (specified via unicode escape sequence)'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], '\\uFEFFtest', 'TV (specified via unicode escape sequence)'
|
||||||
|
);
|
||||||
|
})`\uFEFFtest`;
|
||||||
|
assert.sameValue(callCount, 1);
|
||||||
|
|
||||||
|
callCount = 0;
|
||||||
|
(function(s) {
|
||||||
|
callCount++;
|
||||||
|
assert.sameValue(s[0], 'test', 'TV (specified via literal character)');
|
||||||
|
assert.sameValue(
|
||||||
|
s.raw[0], 'test', 'TV (specified via literal character)'
|
||||||
|
);
|
||||||
|
})`test`;
|
||||||
|
assert.sameValue(callCount, 1);
|
Loading…
x
Reference in New Issue
Block a user