tor-browser

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

coerce-bigint-to-string.js (1362B)


      1 // Copyright (C) 2017 Robin Templeton. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: ToString is applied BigInt values in an additive expression with another string
      6 esid: prod-AdditiveExpression
      7 info: |
      8  AdditiveExpression: AdditiveExpression + MultiplicativeExpression
      9 
     10  ...
     11  7. If Type(lprim) is String or Type(rprim) is String, then
     12    a. Let lstr be ? ToString(lprim).
     13    b. Let rstr be ? ToString(rprim).
     14    c. Return the String that is the result of concatenating lstr and rstr.
     15  ...
     16 
     17  ToString Applied to the BigInt Type
     18 
     19  1. If i is less than zero, return the String concatenation of the String "-" and ToString(-i).
     20  2. Return the String consisting of the code units of the digits of the decimal representation of i.
     21 features: [BigInt]
     22 ---*/
     23 
     24 assert.sameValue(-1n + "", "-1");
     25 assert.sameValue("" + -1n, "-1");
     26 assert.sameValue(0n + "", "0");
     27 assert.sameValue("" + 0n, "0");
     28 assert.sameValue(1n + "", "1");
     29 assert.sameValue("" + 1n, "1");
     30 assert.sameValue(123456789000000000000000n + "", "123456789000000000000000");
     31 assert.sameValue("" + 123456789000000000000000n, "123456789000000000000000");
     32 assert.sameValue(-123456789000000000000000n + "", "-123456789000000000000000");
     33 assert.sameValue("" + -123456789000000000000000n, "-123456789000000000000000");
     34 
     35 reportCompare(0, 0);