tor-browser

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

S12.11_A1_T1.js (2051B)


      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_T1
      9 description: Simple test using switch statement
     10 ---*/
     11 
     12 function SwitchTest(value){
     13  var result = 0;
     14  
     15  switch(value) {
     16    case 0:
     17      result += 2;
     18    case 1:
     19      result += 4;
     20      break;
     21    case 2:
     22      result += 8;
     23    case 3:
     24      result += 16;
     25    default:
     26      result += 32;
     27      break;
     28    case 4:
     29      result += 64;
     30  }
     31  
     32  return result;
     33 }
     34        
     35 if(!(SwitchTest(0) === 6)){
     36  throw new Test262Error("#1: SwitchTest(0) === 6. Actual:  SwitchTest(0) ==="+ SwitchTest(0)  );
     37 }
     38 
     39 if(!(SwitchTest(1) === 4)){
     40  throw new Test262Error("#2: SwitchTest(1) === 4. Actual:  SwitchTest(1) ==="+ SwitchTest(1)  );
     41 }
     42 
     43 if(!(SwitchTest(2) === 56)){
     44  throw new Test262Error("#3: SwitchTest(2) === 56. Actual:  SwitchTest(2) ==="+ SwitchTest(2)  );
     45 }
     46 
     47 if(!(SwitchTest(3) === 48)){
     48  throw new Test262Error("#4: SwitchTest(3) === 48. Actual:  SwitchTest(3) ==="+ SwitchTest(3)  );
     49 }
     50 
     51 if(!(SwitchTest(4) === 64)){
     52  throw new Test262Error("#5: SwitchTest(4) === 64. Actual:  SwitchTest(4) ==="+ SwitchTest(4)  );
     53 }
     54 
     55 if(!(SwitchTest(true) === 32)){
     56  throw new Test262Error("#6: SwitchTest(true) === 32. Actual:  SwitchTest(true) ==="+ SwitchTest(true)  );
     57 }
     58 
     59 if(!(SwitchTest(false) === 32)){
     60  throw new Test262Error("#7: SwitchTest(false) === 32. Actual:  SwitchTest(false) ==="+ SwitchTest(false)  );
     61 }
     62 
     63 if(!(SwitchTest(null) === 32)){
     64  throw new Test262Error("#8: SwitchTest(null) === 32. Actual:  SwitchTest(null) ==="+ SwitchTest(null)  );
     65 }
     66 
     67 if(!(SwitchTest(void 0) === 32)){
     68  throw new Test262Error("#9: SwitchTest(void 0) === 32. Actual:  SwitchTest(void 0) ==="+ SwitchTest(void 0)  );
     69 }
     70 
     71 if(!(SwitchTest('0') === 32)){
     72  throw new Test262Error("#10: SwitchTest('0') === 32. Actual:  SwitchTest('0') ==="+ SwitchTest('0')  );
     73 }
     74 
     75 reportCompare(0, 0);