tor-browser

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

S12.5_A1.2_T2.js (3571B)


      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    1, true, non-empty string and others in expression is evaluated to true
      7    when using operator "new"
      8 es5id: 12.5_A1.2_T2
      9 description: Using "if/else" construction
     10 ---*/
     11 
     12 var c=0;
     13 //////////////////////////////////////////////////////////////////////////////
     14 //CHECK#1
     15 if(!(new Number(1)))
     16 throw new Test262Error('#1.1: new 1 in expression is evaluated to true');
     17 else
     18  c++;
     19 if (c!=1) throw new Test262Error('#1.2: else branch don`t execute');
     20 //
     21 //////////////////////////////////////////////////////////////////////////////
     22 
     23 //////////////////////////////////////////////////////////////////////////////
     24 //CHECK#2
     25 if(!(new Boolean(true)))
     26 throw new Test262Error('#2.1: new true in expression is evaluated to true');
     27 else
     28  c++;
     29 if (c!=2) throw new Test262Error('#2.2: else branch don`t execute');
     30 //
     31 //////////////////////////////////////////////////////////////////////////////
     32 
     33 //////////////////////////////////////////////////////////////////////////////
     34 //CHECK#3
     35 if(!(new String("1")))
     36 throw new Test262Error('#3.1: new "1" in expression is evaluated to true');
     37 else
     38  c++;
     39 if (c!=3) throw new Test262Error('#3.2: else branch don`t execute');
     40 //
     41 //////////////////////////////////////////////////////////////////////////////
     42 
     43 //////////////////////////////////////////////////////////////////////////////
     44 //CHECK#4
     45 if(!(new String("A")))
     46 throw new Test262Error('#4.1: new "A" in expression is evaluated to true');
     47 else
     48  c++;
     49 if (c!=4) throw new Test262Error('#4.2: else branch don`t execute');
     50 //
     51 //////////////////////////////////////////////////////////////////////////////
     52 
     53 //////////////////////////////////////////////////////////////////////////////
     54 //CHECK#5
     55 if(!(new Boolean(false)))
     56    throw new Test262Error('#5.1: new false in expression is evaluated to true ');
     57 else
     58  c++;
     59 if (c!=5) throw new Test262Error('#5.2: else branch don`t execute');
     60 //
     61 //////////////////////////////////////////////////////////////////////////////
     62 
     63 //////////////////////////////////////////////////////////////////////////////
     64 //CHECK#6
     65 if(!(new Number(NaN)))
     66    throw new Test262Error('#6.1: new NaN in expression is evaluated to true ');
     67 else
     68  c++;
     69 if (c!=6) throw new Test262Error('#6.2: else branch don`t execute');
     70 //
     71 //////////////////////////////////////////////////////////////////////////////
     72 
     73 //////////////////////////////////////////////////////////////////////////////
     74 //CHECK#7
     75 if(!(new Number(null)))
     76  throw new Test262Error('#7.1: new null in expression is evaluated to true ');
     77 else
     78  c++;
     79 if (c!=7) throw new Test262Error('#7.2: else branch don`t execute');
     80 //
     81 //////////////////////////////////////////////////////////////////////////////
     82 
     83 //////////////////////////////////////////////////////////////////////////////
     84 //CHECK#8
     85 if(!(new String(undefined)))
     86  throw new Test262Error('#8.1: new undefined in expression is evaluated to true ');
     87 else
     88  c++;
     89 if (c!=8) throw new Test262Error('#8.2: else branch don`t execute');
     90 //
     91 //////////////////////////////////////////////////////////////////////////////
     92 
     93 //////////////////////////////////////////////////////////////////////////////
     94 //CHECK#9
     95 if(!(new String("")))
     96    throw new Test262Error('#9.1: new empty string in expression is evaluated to true ');
     97 else
     98  c++;
     99 if (c!=9) throw new Test262Error('#9.2: else branch don`t execute');
    100 //
    101 //////////////////////////////////////////////////////////////////////////////
    102 
    103 reportCompare(0, 0);