diff --git a/test/language/expressions/tagged-template/call-expression-argument-list-evaluation.js b/test/language/expressions/tagged-template/call-expression-argument-list-evaluation.js new file mode 100644 index 0000000000..8c46b4b4db --- /dev/null +++ b/test/language/expressions/tagged-template/call-expression-argument-list-evaluation.js @@ -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'); diff --git a/test/language/expressions/tagged-template/call-expression-context.js b/test/language/expressions/tagged-template/call-expression-context.js new file mode 100644 index 0000000000..e58ff26b73 --- /dev/null +++ b/test/language/expressions/tagged-template/call-expression-context.js @@ -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); diff --git a/test/language/expressions/template-literal/invalid-hexidecimal-character-escape-sequence-truncated.js b/test/language/expressions/template-literal/invalid-hexidecimal-character-escape-sequence-truncated.js index 49403e12d8..4f1f3f6e6e 100644 --- a/test/language/expressions/template-literal/invalid-hexidecimal-character-escape-sequence-truncated.js +++ b/test/language/expressions/template-literal/invalid-hexidecimal-character-escape-sequence-truncated.js @@ -8,4 +8,4 @@ description: > negative: SyntaxError ---*/ -(function() {})`\x`; +`\x0`; diff --git a/test/language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js b/test/language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js index 56a7611d88..20e308e69c 100644 --- a/test/language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js +++ b/test/language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js @@ -8,4 +8,4 @@ description: > negative: SyntaxError ---*/ -(function() {})`\00`; +`\00`; diff --git a/test/language/expressions/template-literal/invalid-unicode-escape-sequence-truncated.js b/test/language/expressions/template-literal/invalid-unicode-escape-sequence-truncated.js index 4a228da532..f614cc00fa 100644 --- a/test/language/expressions/template-literal/invalid-unicode-escape-sequence-truncated.js +++ b/test/language/expressions/template-literal/invalid-unicode-escape-sequence-truncated.js @@ -8,4 +8,4 @@ description: > negative: SyntaxError ---*/ -(function() {})`\u`; +`\u0`; diff --git a/test/language/expressions/template-literal/literal-expr-abrupt.js b/test/language/expressions/template-literal/literal-expr-abrupt.js new file mode 100644 index 0000000000..33c17272aa --- /dev/null +++ b/test/language/expressions/template-literal/literal-expr-abrupt.js @@ -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(); }()}`; +}); diff --git a/test/language/expressions/template-literal/literal-expr-member-expr.js b/test/language/expressions/template-literal/literal-expr-member-expr.js index 0653e520a6..65aea5ae76 100644 --- a/test/language/expressions/template-literal/literal-expr-member-expr.js +++ b/test/language/expressions/template-literal/literal-expr-member-expr.js @@ -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)' +); diff --git a/test/language/expressions/template-literal/literal-expr-tostr-error.js b/test/language/expressions/template-literal/literal-expr-tostr-error.js new file mode 100644 index 0000000000..d3534ecbac --- /dev/null +++ b/test/language/expressions/template-literal/literal-expr-tostr-error.js @@ -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}`; +}); diff --git a/test/language/expressions/template-literal/middle-list-many-expr-abrupt.js b/test/language/expressions/template-literal/middle-list-many-expr-abrupt.js new file mode 100644 index 0000000000..41ec352c3e --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-many-expr-abrupt.js @@ -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(); }()}`; +}); diff --git a/test/language/expressions/template-literal/middle-list-many-expr-function.js b/test/language/expressions/template-literal/middle-list-many-expr-function.js new file mode 100644 index 0000000000..3ed6abe6ee --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-many-expr-function.js @@ -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'); diff --git a/test/language/expressions/template-literal/middle-list-many-expr-member-expr.js b/test/language/expressions/template-literal/middle-list-many-expr-member-expr.js new file mode 100644 index 0000000000..fa01c95cec --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-many-expr-member-expr.js @@ -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)' +); diff --git a/test/language/expressions/template-literal/middle-list-many-expr-method.js b/test/language/expressions/template-literal/middle-list-many-expr-method.js new file mode 100644 index 0000000000..053518dd0a --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-many-expr-method.js @@ -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'); diff --git a/test/language/expressions/template-literal/middle-list-many-expr-obj.js b/test/language/expressions/template-literal/middle-list-many-expr-obj.js new file mode 100644 index 0000000000..7580a0a03b --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-many-expr-obj.js @@ -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'); diff --git a/test/language/expressions/template-literal/middle-list-many-expr-primitive.js b/test/language/expressions/template-literal/middle-list-many-expr-primitive.js new file mode 100644 index 0000000000..f123586be3 --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-many-expr-primitive.js @@ -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'); diff --git a/test/language/expressions/template-literal/middle-list-many-expr-template.js b/test/language/expressions/template-literal/middle-list-many-expr-template.js new file mode 100644 index 0000000000..6cd92054fb --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-many-expr-template.js @@ -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'); diff --git a/test/language/expressions/template-literal/middle-list-many-expr-tostr-error.js b/test/language/expressions/template-literal/middle-list-many-expr-tostr-error.js new file mode 100644 index 0000000000..5b0a555050 --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-many-expr-tostr-error.js @@ -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}`; +}); diff --git a/test/language/expressions/template-literal/middle-list-one-expr-abrupt.js b/test/language/expressions/template-literal/middle-list-one-expr-abrupt.js new file mode 100644 index 0000000000..9e26b89b0a --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-one-expr-abrupt.js @@ -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(); }()}`; +}); diff --git a/test/language/expressions/template-literal/middle-list-one-expr-function.js b/test/language/expressions/template-literal/middle-list-one-expr-function.js new file mode 100644 index 0000000000..d7edd372e3 --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-one-expr-function.js @@ -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'); diff --git a/test/language/expressions/template-literal/middle-list-one-expr-member-expr.js b/test/language/expressions/template-literal/middle-list-one-expr-member-expr.js new file mode 100644 index 0000000000..3686d145fd --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-one-expr-member-expr.js @@ -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)' +); diff --git a/test/language/expressions/template-literal/middle-list-one-expr-method.js b/test/language/expressions/template-literal/middle-list-one-expr-method.js new file mode 100644 index 0000000000..024cc8e0d8 --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-one-expr-method.js @@ -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'); diff --git a/test/language/expressions/template-literal/middle-list-one-expr-obj.js b/test/language/expressions/template-literal/middle-list-one-expr-obj.js new file mode 100644 index 0000000000..12a11c0b98 --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-one-expr-obj.js @@ -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'); diff --git a/test/language/expressions/template-literal/middle-list-one-expr-primitive.js b/test/language/expressions/template-literal/middle-list-one-expr-primitive.js new file mode 100644 index 0000000000..1bf8de2600 --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-one-expr-primitive.js @@ -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'); diff --git a/test/language/expressions/template-literal/middle-list-one-expr-template.js b/test/language/expressions/template-literal/middle-list-one-expr-template.js new file mode 100644 index 0000000000..d906250e1a --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-one-expr-template.js @@ -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'); diff --git a/test/language/expressions/template-literal/middle-list-one-expr-tostr-error.js b/test/language/expressions/template-literal/middle-list-one-expr-tostr-error.js new file mode 100644 index 0000000000..6ed334c6f2 --- /dev/null +++ b/test/language/expressions/template-literal/middle-list-one-expr-tostr-error.js @@ -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}`; +}); diff --git a/test/language/expressions/template-literal/no-sub.js b/test/language/expressions/template-literal/no-sub.js new file mode 100644 index 0000000000..3bf27aaac8 --- /dev/null +++ b/test/language/expressions/template-literal/no-sub.js @@ -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'); diff --git a/test/language/expressions/template-literal/trv-character-escape-sequence.js b/test/language/expressions/template-literal/trv-character-escape-sequence.js deleted file mode 100644 index cf3fecbd97..0000000000 --- a/test/language/expressions/template-literal/trv-character-escape-sequence.js +++ /dev/null @@ -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); diff --git a/test/language/expressions/template-literal/trv-escape-sequence.js b/test/language/expressions/template-literal/trv-escape-sequence.js deleted file mode 100644 index e3e0ee8275..0000000000 --- a/test/language/expressions/template-literal/trv-escape-sequence.js +++ /dev/null @@ -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); diff --git a/test/language/expressions/template-literal/trv-template-character.js b/test/language/expressions/template-literal/trv-template-character.js deleted file mode 100644 index 7b2e0aae6b..0000000000 --- a/test/language/expressions/template-literal/trv-template-character.js +++ /dev/null @@ -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); diff --git a/test/language/expressions/template-literal/trv-template-characters.js b/test/language/expressions/template-literal/trv-template-characters.js deleted file mode 100644 index 8d1b7fb357..0000000000 --- a/test/language/expressions/template-literal/trv-template-characters.js +++ /dev/null @@ -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'); diff --git a/test/language/expressions/template-literal/trv-zwnbsp.js b/test/language/expressions/template-literal/trv-zwnbsp.js deleted file mode 100644 index f4d095dc99..0000000000 --- a/test/language/expressions/template-literal/trv-zwnbsp.js +++ /dev/null @@ -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' -); diff --git a/test/language/expressions/template-literal/tv-character-escape-sequence.js b/test/language/expressions/template-literal/tv-character-escape-sequence.js new file mode 100644 index 0000000000..c686272c76 --- /dev/null +++ b/test/language/expressions/template-literal/tv-character-escape-sequence.js @@ -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); diff --git a/test/language/expressions/template-literal/trv-utf16-escape-sequence.js b/test/language/expressions/template-literal/tv-hex-escape-sequence.js similarity index 53% rename from test/language/expressions/template-literal/trv-utf16-escape-sequence.js rename to test/language/expressions/template-literal/tv-hex-escape-sequence.js index 14fa3b500a..a6ad55d147 100644 --- a/test/language/expressions/template-literal/trv-utf16-escape-sequence.js +++ b/test/language/expressions/template-literal/tv-hex-escape-sequence.js @@ -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); diff --git a/test/language/expressions/template-literal/trv-line-continuation.js b/test/language/expressions/template-literal/tv-line-continuation.js similarity index 76% rename from test/language/expressions/template-literal/trv-line-continuation.js rename to test/language/expressions/template-literal/tv-line-continuation.js index c19fe0c53b..92f5ff13f4 100644 --- a/test/language/expressions/template-literal/trv-line-continuation.js +++ b/test/language/expressions/template-literal/tv-line-continuation.js @@ -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); diff --git a/test/language/expressions/template-literal/trv-line-terminator-sequence.js b/test/language/expressions/template-literal/tv-line-terminator-sequence.js similarity index 73% rename from test/language/expressions/template-literal/trv-line-terminator-sequence.js rename to test/language/expressions/template-literal/tv-line-terminator-sequence.js index e9ecd41336..475a583766 100644 --- a/test/language/expressions/template-literal/trv-line-terminator-sequence.js +++ b/test/language/expressions/template-literal/tv-line-terminator-sequence.js @@ -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 :: is the code unit value 0x000A. The TRV of LineTerminatorSequence :: is the code unit value 0x000A. The TRV of LineTerminatorSequence :: is the code unit value 0x2028. @@ -10,11 +12,14 @@ description: > The TRV of LineTerminatorSequence :: 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); diff --git a/test/language/expressions/template-literal/trv-no-substitution.js b/test/language/expressions/template-literal/tv-no-substitution.js similarity index 80% rename from test/language/expressions/template-literal/trv-no-substitution.js rename to test/language/expressions/template-literal/tv-no-substitution.js index 6812185834..7976b042d0 100644 --- a/test/language/expressions/template-literal/trv-no-substitution.js +++ b/test/language/expressions/template-literal/tv-no-substitution.js @@ -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); diff --git a/test/language/expressions/template-literal/trv-null-character-escape-sequence.js b/test/language/expressions/template-literal/tv-null-character-escape-sequence.js similarity index 80% rename from test/language/expressions/template-literal/trv-null-character-escape-sequence.js rename to test/language/expressions/template-literal/tv-null-character-escape-sequence.js index c7eadf0365..afeef1c8c2 100644 --- a/test/language/expressions/template-literal/trv-null-character-escape-sequence.js +++ b/test/language/expressions/template-literal/tv-null-character-escape-sequence.js @@ -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); diff --git a/test/language/expressions/template-literal/tv-template-character.js b/test/language/expressions/template-literal/tv-template-character.js new file mode 100644 index 0000000000..3ae02815bd --- /dev/null +++ b/test/language/expressions/template-literal/tv-template-character.js @@ -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); diff --git a/test/language/expressions/template-literal/tv-template-characters.js b/test/language/expressions/template-literal/tv-template-characters.js new file mode 100644 index 0000000000..34faf28d50 --- /dev/null +++ b/test/language/expressions/template-literal/tv-template-characters.js @@ -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'); diff --git a/test/language/expressions/template-literal/tv-template-middle.js b/test/language/expressions/template-literal/tv-template-middle.js index db100e9239..836e2e1ee0 100644 --- a/test/language/expressions/template-literal/tv-template-middle.js +++ b/test/language/expressions/template-literal/tv-template-middle.js @@ -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. ---*/ diff --git a/test/language/expressions/template-literal/tv-utf16-escape-sequence.js b/test/language/expressions/template-literal/tv-utf16-escape-sequence.js new file mode 100644 index 0000000000..fdb5f01c12 --- /dev/null +++ b/test/language/expressions/template-literal/tv-utf16-escape-sequence.js @@ -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); diff --git a/test/language/expressions/template-literal/tv-zwnbsp.js b/test/language/expressions/template-literal/tv-zwnbsp.js new file mode 100644 index 0000000000..68111045b9 --- /dev/null +++ b/test/language/expressions/template-literal/tv-zwnbsp.js @@ -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);