tor-browser

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

trunc-sampleTests.js (2529B)


      1 // Copyright 2015 Microsoft Corporation. All rights reserved.
      2 // This code is governed by the license found in the LICENSE file.
      3 
      4 /*---
      5 description: sample tests for trunc
      6 es6id: 20.2.2.35
      7 ---*/
      8 
      9 assert.sameValue(1 / Math.trunc(0.02047410048544407), Number.POSITIVE_INFINITY,
     10  "Math.trunc should produce +0 for values between 0 and 1");
     11 assert.sameValue(1 / Math.trunc(0.00000000000000001), Number.POSITIVE_INFINITY,
     12  "Math.trunc should produce +0 for values between 0 and 1");
     13 assert.sameValue(1 / Math.trunc(0.9999999999999999), Number.POSITIVE_INFINITY,
     14  "Math.trunc should produce +0 for values between 0 and 1");
     15 assert.sameValue(1 / Math.trunc(Number.EPSILON), Number.POSITIVE_INFINITY,
     16  "Math.trunc should produce +0 for values between 0 and 1");
     17 assert.sameValue(1 / Math.trunc(Number.MIN_VALUE), Number.POSITIVE_INFINITY,
     18  "Math.trunc should produce +0 for values between 0 and 1");
     19 
     20 assert.sameValue(1 / Math.trunc(-0.02047410048544407), Number.NEGATIVE_INFINITY,
     21  "Math.trunc should produce -0 for values between -1 and 0");
     22 assert.sameValue(1 / Math.trunc(-0.00000000000000001), Number.NEGATIVE_INFINITY,
     23  "Math.trunc should produce -0 for values between -1 and 0");
     24 assert.sameValue(1 / Math.trunc(-0.9999999999999999), Number.NEGATIVE_INFINITY,
     25  "Math.trunc should produce -0 for values between -1 and 0");
     26 assert.sameValue(1 / Math.trunc(-Number.EPSILON), Number.NEGATIVE_INFINITY,
     27  "Math.trunc should produce -0 for values between -1 and 0");
     28 assert.sameValue(1 / Math.trunc(-Number.MIN_VALUE), Number.NEGATIVE_INFINITY,
     29  "Math.trunc should produce -0 for values between -1 and 0");
     30 
     31 assert.sameValue(Math.trunc(Number.MAX_VALUE), Math.floor(Number.MAX_VALUE),
     32  "Math.trunc produces incorrect result for Number.MAX_VALUE");
     33 assert.sameValue(Math.trunc(10), Math.floor(10),
     34  "Math.trunc produces incorrect result for 10");
     35 assert.sameValue(Math.trunc(3.9), Math.floor(3.9),
     36  "Math.trunc produces incorrect result for 3.9");
     37 assert.sameValue(Math.trunc(4.9), Math.floor(4.9),
     38  "Math.trunc produces incorrect result for 4.9");
     39 
     40 assert.sameValue(Math.trunc(-Number.MAX_VALUE), Math.ceil(-Number.MAX_VALUE),
     41  "Math.trunc produces incorrect result for -Number.MAX_VALUE");
     42 assert.sameValue(Math.trunc(-10), Math.ceil(-10),
     43  "Math.trunc produces incorrect result for -10");
     44 assert.sameValue(Math.trunc(-3.9), Math.ceil(-3.9),
     45  "Math.trunc produces incorrect result for -3.9");
     46 assert.sameValue(Math.trunc(-4.9), Math.ceil(-4.9),
     47  "Math.trunc produces incorrect result for -4.9");
     48 
     49 reportCompare(0, 0);