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

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

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

mercurial