tor-browser

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

S11.5.3_A4_T7.js (1952B)


      1 // Copyright 2009 the Sputnik authors.  All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 info: |
      6    The result of a ECMAScript floating-point remainder operation is
      7    determined by the rules of IEEE arithmetics
      8 es5id: 11.5.3_A4_T7
      9 description: >
     10    If operands neither an infinity, nor a zero, nor NaN, return x -
     11    truncate(x / y) * y
     12 ---*/
     13 
     14 function truncate(x) {
     15  if (x > 0) {
     16    return Math.floor(x);
     17  } else {
     18    return Math.ceil(x);
     19  }
     20 }
     21 
     22 var x, y;
     23 
     24 //CHECK#1
     25 x = 1.3; 
     26 y = 1.1;
     27 if (x % y !== 0.19999999999999996) {
     28  throw new Test262Error('#1: x = 1.3; y = 1.1; x % y === 0.19999999999999996. Actual: ' + (x % y));
     29 }
     30 
     31 //CHECK#2
     32 x = -1.3; 
     33 y = 1.1; 
     34 if (x % y !== -0.19999999999999996) {
     35  throw new Test262Error('#2: x = -1.3; y = 1.1; x % y === -0.19999999999999996. Actual: ' + (x % y));
     36 }
     37 
     38 //CHECK#3
     39 x = 1.3; 
     40 y = -1.1;
     41 if (x % y !== 0.19999999999999996) {
     42  throw new Test262Error('#3: x = 1.3; y = -1.1; x % y === 0.19999999999999996. Actual: ' + (x % y));
     43 }
     44 
     45 //CHECK#4
     46 x = -1.3; 
     47 y = -1.1;
     48 if (x % y !== -0.19999999999999996) {
     49  throw new Test262Error('#4: x = -1.3; y = -1.1; x % y === -0.19999999999999996. Actual: ' + (x % y));
     50 }
     51 
     52 //CHECK#5
     53 x = 1.3; 
     54 y = 1.1;
     55 if (x % y !== x - truncate(x / y) * y) {
     56  throw new Test262Error('#5: x = 1.3; y = 1.1; x % y === x - truncate(x / y) * y. Actual: ' + (x % y));
     57 }
     58 
     59 //CHECK#6
     60 x = -1.3; 
     61 y = 1.1; 
     62 if (x % y !== x - truncate(x / y) * y) {
     63  throw new Test262Error('#6: x = -1.3; y = 1.1; x % y === x - truncate(x / y) * y. Actual: ' + (x % y));
     64 }
     65 
     66 //CHECK#7
     67 x = 1.3; 
     68 y = -1.1;
     69 if (x % y !== x - truncate(x / y) * y) {
     70  throw new Test262Error('#7: x = 1.3; y = -1.1; x % y === x - truncate(x / y) * y. Actual: ' + (x % y));
     71 }
     72 
     73 //CHECK#8
     74 x = -1.3; 
     75 y = -1.1;
     76 if (x % y !== x - truncate(x / y) * y) {
     77  throw new Test262Error('#8: x = -1.3; y = -1.1; x % y === x - truncate(x / y) * y. Actual: ' + (x % y));
     78 }
     79 
     80 reportCompare(0, 0);