tor-browser

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

S12.11_A1_T2.js (2358B)


      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    If Result.type is break and Result.target is in the current
      7    label set, return (normal, Result.value, empty)
      8 es5id: 12.11_A1_T2
      9 description: Switch with different types of variables
     10 ---*/
     11 
     12 var x = new Number(2);
     13 
     14 function SwitchTest(value){
     15  var result = 0;
     16  
     17  switch(value) {
     18    case 0:
     19      result += 2;
     20    case '1':
     21      result += 4;
     22      break;
     23    case new Number(2):
     24      result += 8;
     25    case 3:
     26      result += 16;
     27    default:
     28      result += 32;
     29      break;
     30    case 4:
     31      result += 64;
     32      break;
     33    case x:
     34      result += 128;
     35      break;
     36    case 0:
     37      result += 256;
     38    case 1:
     39      result += 512;
     40  }
     41  
     42  return result;
     43 }
     44        
     45 if(!(SwitchTest(0) === 6)){
     46  throw new Test262Error("#1: SwitchTest(0) === 6. Actual:  SwitchTest(0) ==="+ SwitchTest(0)  );
     47 }
     48 
     49 if(!(SwitchTest(1) === 512)){
     50  throw new Test262Error("#2: SwitchTest(1) === 512. Actual:  SwitchTest(1) ==="+ SwitchTest(1)  );
     51 }
     52 
     53 if(!(SwitchTest(2) === 32)){
     54  throw new Test262Error("#3: SwitchTest(2) === 32. Actual:  SwitchTest(2) ==="+ SwitchTest(2)  );
     55 }
     56 
     57 if(!(SwitchTest(3) === 48)){
     58  throw new Test262Error("#4: SwitchTest(3) === 48. Actual:  SwitchTest(3) ==="+ SwitchTest(3)  );
     59 }
     60 
     61 if(!(SwitchTest(4) === 64)){
     62  throw new Test262Error("#5: SwitchTest(4) === 64. Actual:  SwitchTest(4) ==="+ SwitchTest(4)  );
     63 }
     64 
     65 if(!(SwitchTest(true) === 32)){
     66  throw new Test262Error("#6: SwitchTest(true) === 32. Actual:  SwitchTest(true) ==="+ SwitchTest(true)  );
     67 }
     68 
     69 if(!(SwitchTest(false) === 32)){
     70  throw new Test262Error("#7: SwitchTest(false) === 32. Actual:  SwitchTest(false) ==="+ SwitchTest(false)  );
     71 }
     72 
     73 if(!(SwitchTest(null) === 32)){
     74  throw new Test262Error("#8: SwitchTest(null) === 32. Actual:  SwitchTest(null) ==="+ SwitchTest(null)  );
     75 }
     76 
     77 if(!(SwitchTest(void 0) === 32)){
     78  throw new Test262Error("#9: SwitchTest(void 0) === 32. Actual:  SwitchTest(void 0) ==="+ SwitchTest(void 0)  );
     79 }
     80 
     81 if(!(SwitchTest('0') === 32)){
     82  throw new Test262Error("#10: SwitchTest('0') === 32. Actual:  SwitchTest('0') ==="+ SwitchTest('0')  );
     83 }
     84 
     85 if(!(SwitchTest(x) === 128)){
     86  throw new Test262Error("#10: SwitchTest(x) === 128. Actual:  SwitchTest(x) ==="+ SwitchTest(x)  );
     87 }
     88 
     89 reportCompare(0, 0);