tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

substitutions-are-appended-on-same-index.js (1367B)


      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  Returns the string value appending the substitutions on the same index order.
      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    f. If nextIndex < numberOfSubstitutions, let next be substitutions[nextIndex].
     24    g. Else, let next be the empty String.
     25    h. Let nextSub be ToString(next).
     26    i. ReturnIfAbrupt(nextSub).
     27    j. Append in order the code unit elements of nextSub to the end of stringElements.
     28    k. Let nextIndex be nextIndex + 1.
     29 ---*/
     30 
     31 var template = {
     32  raw: ['a', 'b', 'd', 'f']
     33 };
     34 
     35 assert.sameValue(String.raw(template, '', 'c', 'e'), 'abcdef');
     36 assert.sameValue(String.raw(template, 1), 'a1bdf');
     37 
     38 reportCompare(0, 0);