tor-browser

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

S12.14_A5.js (1410B)


      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 production TryStatement: "try Block Finally" and the production
      7    TryStatement: "try Block Catch Finally"
      8 es5id: 12.14_A5
      9 description: Checking "catch" catches the Identifier in appropriate way
     10 ---*/
     11 
     12 // CHECK#1
     13 try {
     14  throw "catchme";	
     15  throw "dontcatchme";
     16  throw new Test262Error('#1.1: throw "catchme" lead to throwing exception');
     17 }
     18 catch (e) {
     19  if(e==="dontcatchme"){
     20    throw new Test262Error('#1.2: Exception !== "dontcatchme"');
     21  }
     22  if (e!=="catchme") {
     23    throw new Test262Error('#1.3: Exception === "catchme". Actual:  Exception ==='+ e  );
     24  }
     25 }
     26 
     27 // CHECK#2
     28 function SwitchTest1(value){
     29  var result = 0;
     30  try{  
     31    switch(value) {
     32      case 1:
     33        result += 4;
     34        throw result;
     35        break;
     36      case 4:
     37        result += 64;
     38        throw "ex";
     39    }
     40  return result;
     41  }
     42  catch(e){	
     43    if ((value===1)&&(e!==4)) throw new Test262Error('#2.1: Exception === 4. Actual: '+e);
     44    if ((value===4)&&(e!=="ex"))throw new Test262Error('#2.2: Exception === "ex". Actual: '+e);
     45  }
     46  finally{
     47    return result;
     48  }
     49 }
     50 if (SwitchTest1(1)!==4) throw new Test262Error('#2.3: "finally" block must be evaluated');
     51 if (SwitchTest1(4)!==64)throw new Test262Error('#2.4: "finally" block must be evaluated');
     52 
     53 reportCompare(0, 0);