tor-browser

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

S9.5_A1_T1.js (1900B)


      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: If value is NaN, +0, -0, +Infinity, or -Infinity, return +0
      6 es5id: 9.5_A1_T1
      7 description: For testing use operator <<0
      8 ---*/
      9 
     10 // CHECK#1
     11 if ((Number.NaN << 0) !== +0) {
     12  throw new Test262Error('#1.1: (Number.NaN << 0) === 0. Actual: ' + ((Number.NaN << 0)));
     13 } else if (1/(Number.NaN << 0) !== Number.POSITIVE_INFINITY) {
     14  throw new Test262Error('#1.2: (Number.NaN << 0) === +0. Actual: -0');
     15 }
     16 
     17 // CHECK#2
     18 if ((Number("abc") << 0) !== +0) {
     19  throw new Test262Error('#2.1: (Number("abc") << 0) === 0. Actual: ' + ((Number("abc") << 0)));
     20 } else if (1/(0 << 0) !== Number.POSITIVE_INFINITY) {
     21  throw new Test262Error('#2.2: (0 << 0) === +0. Actual: -0');
     22 }
     23 
     24 // CHECK#3
     25 if ((0 << 0) !== +0) {
     26  throw new Test262Error('#3.1: (0 << 0) === 0. Actual: ' + ((0 << 0)));
     27 } else if (1/(0 << 0) !== Number.POSITIVE_INFINITY) {
     28  throw new Test262Error('#3.2: (0 << 0) === +0. Actual: -0');
     29 }
     30 
     31 // CHECK#4
     32 if ((-0 << 0) !== +0) {
     33  throw new Test262Error("#4.1: (-0 << 0) === 0");
     34 } else if (1/(-0 << 0) !== Number.POSITIVE_INFINITY) {
     35  throw new Test262Error("#4.2: (-0 << 0) === +0. Actual: -0");
     36 }
     37 
     38 // CHECK#5
     39 if ((Number.POSITIVE_INFINITY << 0) !== +0) {
     40  throw new Test262Error('#5.1: (Number.POSITIVE_INFINITY << 0) === 0. Actual: ' + ((Number.POSITIVE_INFINITY << 0)));
     41 } else if (1/(Number.POSITIVE_INFINITY << 0) !== Number.POSITIVE_INFINITY) {
     42  throw new Test262Error('#5.2: (Number.POSITIVE_INFINITY << 0) === +0. Actual: -0');
     43 }
     44 
     45 // CHECK#6
     46 if ((Number.NEGATIVE_INFINITY << 0) !== +0) {
     47  throw new Test262Error("#6.1: (Number.NEGATIVE_INFINITY << 0) === 0");
     48 } else if (1/(Number.NEGATIVE_INFINITY << 0) !== Number.POSITIVE_INFINITY) {
     49  throw new Test262Error("#6.2: (Number.NEGATIVE_INFINITY << 0) === +0. Actual: -0");
     50 }
     51 
     52 reportCompare(0, 0);