substitutions-are-limited-to-template-raw-length.js (1059B)
1 // Copyright (C) 2015 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 es6id: 21.1.2.4 5 description: > 6 Limit appended substitutions arguments to template.raw.length - 1. 7 info: | 8 21.1.2.4 String.raw ( template , ...substitutions ) 9 10 ... 11 10. Let stringElements be a new List. 12 11. Let nextIndex be 0. 13 12. Repeat 14 a. Let nextKey be ToString(nextIndex). 15 b. Let nextSeg be ToString(Get(raw, nextKey)). 16 c. ReturnIfAbrupt(nextSeg). 17 d. Append in order the code unit elements of nextSeg to the end of 18 stringElements. 19 e. If nextIndex + 1 = literalSegments, then 20 i. Return the String value whose code units are, in order, the elements in 21 the List stringElements. If stringElements has no elements, the empty 22 string is returned. 23 ... 24 ---*/ 25 26 var template = { 27 raw: ['a', 'c', 'e'] 28 }; 29 var obj = { 30 toString: function() { 31 throw new Test262Error(); 32 } 33 }; 34 35 assert.sameValue(String.raw(template, 'b', 'd', obj), 'abcde'); 36 37 reportCompare(0, 0);