tor-browser

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

S12.14_A2.js (1074B)


      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: Throwing exception with "throw" and catching it with "try" statement
      6 es5id: 12.14_A2
      7 description: >
      8    Checking if execution of "catch" catches an exception thrown with
      9    "throw"
     10 ---*/
     11 
     12 // CHECK#1
     13 try {
     14  throw "catchme";	
     15  throw new Test262Error('#1: throw "catchme" lead to throwing exception');
     16 }
     17 catch(e){}
     18 
     19 // CHECK#2
     20 var c2=0;
     21 try{
     22  try{
     23    throw "exc";
     24    throw new Test262Error('#2.1: throw "exc" lead to throwing exception');
     25  }finally{
     26    c2=1;
     27  }
     28 }
     29 catch(e){
     30  if (c2!==1){
     31    throw new Test262Error('#2.2: "finally" block must be evaluated');
     32  }
     33 }
     34 
     35 // CHECK#3
     36 var c3=0;
     37 try{
     38  throw "exc";
     39  throw new Test262Error('#3.1: throw "exc" lead to throwing exception');
     40 }
     41 catch(err){  	
     42  var x3=1;
     43 }
     44 finally{
     45  c3=1;
     46 }
     47 if (x3!==1){
     48  throw new Test262Error('#3.2: "catch" block must be evaluated');
     49 }  
     50 if (c3!==1){
     51  throw new Test262Error('#3.3: "finally" block must be evaluated');
     52 }
     53 
     54 reportCompare(0, 0);