js/src/tests/test262/ch12/12.14/S12.14_A2.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Copyright 2009 the Sputnik authors.  All rights reserved.
     2 // This code is governed by the BSD license found in the LICENSE file.
     4 /**
     5  * Throwing exception with "throw" and catching it with "try" statement
     6  *
     7  * @path ch12/12.14/S12.14_A2.js
     8  * @description Checking if execution of "catch" catches an exception thrown with "throw"
     9  */
    11 // CHECK#1
    12 try {
    13   throw "catchme";	
    14   $ERROR('#1: throw "catchme" lead to throwing exception');
    15 }
    16 catch(e){}
    18 // CHECK#2
    19 var c2=0;
    20 try{
    21   try{
    22     throw "exc";
    23     $ERROR('#2.1: throw "exc" lead to throwing exception');
    24   }finally{
    25     c2=1;
    26   }
    27 }
    28 catch(e){
    29   if (c2!==1){
    30     $ERROR('#2.2: "finally" block must be evaluated');
    31   }
    32 }
    34 // CHECK#3
    35 var c3=0;
    36 try{
    37   throw "exc";
    38   $ERROR('#3.1: throw "exc" lead to throwing exception');
    39 }
    40 catch(err){  	
    41   var x3=1;
    42 }
    43 finally{
    44   c3=1;
    45 }
    46 if (x3!==1){
    47   $ERROR('#3.2: "catch" block must be evaluated');
    48 }  
    49 if (c3!==1){
    50   $ERROR('#3.3: "finally" block must be evaluated');
    51 }

mercurial