Introduce additional tests for ES6 templates

This commit is contained in:
Mike Pennisi 2015-06-11 13:19:07 -04:00
parent bd3d160ba1
commit 5ca7a58e75
41 changed files with 763 additions and 215 deletions

View File

@ -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');

View File

@ -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);

View File

@ -8,4 +8,4 @@ description: >
negative: SyntaxError
---*/
(function() {})`\x`;
`\x0`;

View File

@ -8,4 +8,4 @@ description: >
negative: SyntaxError
---*/
(function() {})`\00`;
`\00`;

View File

@ -8,4 +8,4 @@ description: >
negative: SyntaxError
---*/
(function() {})`\u`;
`\u0`;

View File

@ -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(); }()}`;
});

View File

@ -22,3 +22,13 @@ assert.sameValue(
assert.sameValue(
`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)'
);

View File

@ -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}`;
});

View File

@ -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(); }()}`;
});

View File

@ -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');

View File

@ -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)'
);

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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}`;
});

View File

@ -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(); }()}`;
});

View File

@ -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');

View File

@ -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)'
);

View File

@ -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');

View File

@ -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');

View File

@ -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');

View 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: 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');

View File

@ -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}`;
});

View 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');

View File

@ -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);

View File

@ -1,39 +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 :: \ EscapeSequence is the SV of
EscapeSequence.
The TRV of EscapeSequence :: 0 is the code unit value 0x0030.
The TRV of EscapeSequence :: HexEscapeSequence is the TRV of the
HexEscapeSequence.
The TRV of EscapeSequence :: UnicodeEscapeSequence is the TRV of the
UnicodeEscapeSequence.
---*/
var calls;
calls = 0;
(function(s) {
calls++;
assert.sameValue(s[0], '', '`\\0` sequence template value');
assert.sameValue(s.raw[0], '\\0', '`\\0` sequence template raw value');
})`\0`;
assert.sameValue(calls, 1);
calls = 0;
(function(s) {
calls++;
assert.sameValue(s[0], 'ÿ', 'HexEscapeSequence template value');
assert.sameValue(s.raw[0], '\\xff', 'HexEscapeSequence template raw value');
})`\xff`;
assert.sameValue(calls, 1);
calls = 0;
(function(s) {
calls++;
assert.sameValue(
s.raw[0], '\\uc548', 'UnicodeEscapeSequence template raw value'
);
})`\uc548`;
assert.sameValue(calls, 1);

View File

@ -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);

View File

@ -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');

View File

@ -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'
);

View File

@ -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);

View File

@ -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.
/*---
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{ HexDigits } is the sequence
@ -15,15 +17,7 @@ var calls;
calls = 0;
(function(s) {
calls++;
assert.sameValue(s[0], 'abc', '`` sequence template value');
assert.sameValue(s.raw[0], 'a\\u{62}c', '`` sequence template raw value');
})`a\u{62}c`;
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(s[0], 'A', 'TV');
assert.sameValue(s.raw[0], '\\x41', 'TRV');
})`\x41`;
assert.sameValue(calls, 1);

View File

@ -3,15 +3,19 @@
/*---
es6id: 11.8.6
description: >
The TV of LineContinuation :: \ LineTerminatorSequence is the empty code
unit sequence.
The TRV of LineContinuation :: \ LineTerminatorSequence is the sequence
consisting of the code unit value 0x005C followed by the code units of TRV
of LineTerminatorSequence.
---*/
var calls;
calls = 0;
(function(cs) {
calls++;
assert.sameValue(cs[0], '', 'Line Feed and Carriage Return');
assert.sameValue(
cs.raw[0], '\u005C\n\u005C\n\u005C\n', 'Line Feed and Carriage Return'
);
@ -23,6 +27,7 @@ assert.sameValue(calls, 1);
calls = 0;
(function(cs) {
calls++;
assert.sameValue(cs[0], '', 'Line Separator');
assert.sameValue(cs.raw[0], '\\\u2028', 'Line Separator');
})`\`
assert.sameValue(calls, 1);
@ -30,6 +35,7 @@ assert.sameValue(calls, 1);
calls = 0;
(function(cs) {
calls++;
assert.sameValue(cs[0], '', 'Paragraph Separater');
assert.sameValue(cs.raw[0], '\\\u2029', 'Paragraph Separator');
})`\`
assert.sameValue(calls, 1);

View File

@ -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.
/*---
es6id: 11.8.6
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 :: <CR> is the code unit value 0x000A.
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 code unit value 0x000A.
---*/
var calls;
calls = 0;
(function(s) {
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');
})`
@ -24,6 +29,7 @@ assert.sameValue(calls, 1);
calls = 0;
(function(cs) {
calls++;
assert.sameValue(cs[0], '\u2028', 'Line Separator');
assert.sameValue(cs.raw[0], '\u2028', 'Line Separator');
})``
assert.sameValue(calls, 1);
@ -31,6 +37,7 @@ assert.sameValue(calls, 1);
calls = 0;
(function(cs) {
calls++;
assert.sameValue(cs[0], '\u2029', 'Paragraph Separator');
assert.sameValue(cs.raw[0], '\u2029', 'Paragraph Separator');
})``
assert.sameValue(calls, 1);

View File

@ -7,6 +7,8 @@ description: >
sequence.
The TV of NoSubstitutionTemplate :: ` TemplateCharacters ` is the TV of
TemplateCharacters.
The TRV of NoSubstitutionTemplate :: ` TemplateCharacters ` is the TRV of
TemplateCharacters.
---*/
var calls;
@ -23,5 +25,6 @@ calls = 0;
(function(s) {
calls++;
assert.sameValue(s[0], 'foo', 'Template value (with content)');
assert.sameValue(s.raw[0], 'foo', 'Template raw value (with content)');
})`foo`;
assert.sameValue(calls, 1);

View File

@ -7,11 +7,12 @@ description: >
EscapeSequence.
The TRV of EscapeSequence :: 0 is the code unit value 0x0030.
---*/
var calls = 0;
(function(s) {
calls++;
assert.sameValue(s[0], '', '"Cookied" value');
assert.sameValue(s.raw[0], '\\0', '"Raw" value');
assert.sameValue(s[0], '');
assert.sameValue(s.raw[0], '\\0');
})`\0`;
assert.sameValue(calls, 1);

View File

@ -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);

View File

@ -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');

View File

@ -4,8 +4,6 @@
es6id: 11.8.6
description: >
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
TemplateCharacters.
---*/

View File

@ -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);

View 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);