michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * The production TryStatement: "try Block Catch Finally" michael@0: * michael@0: * @path ch12/12.14/S12.14_A6.js michael@0: * @description Executing sequence of "try" statements, using counters with varying values within michael@0: */ michael@0: michael@0: // CHECK#1 michael@0: var c1=0; michael@0: try { michael@0: c1+=1; michael@0: y; michael@0: $ERROR('#1.1: "y" lead to throwing exception'); michael@0: } michael@0: catch (e) { michael@0: c1*=2; michael@0: } michael@0: if (c1!==2){ michael@0: $ERROR('#1.2: Sequence evaluation of commands try/catch is 1. try, 2. catch'); michael@0: } michael@0: michael@0: // CHECK#2 michael@0: var c2=0; michael@0: try{ michael@0: c2+=1; michael@0: } michael@0: finally{ michael@0: c2*=2; michael@0: } michael@0: if (c2!==2){ michael@0: $ERROR('#2: Sequence evaluation of commands try/finally is 1. try, 2. finally'); michael@0: } michael@0: michael@0: // CHECK#3 michael@0: var c3=0; michael@0: try{ michael@0: c3=1; michael@0: z; michael@0: } michael@0: catch(err){ michael@0: c3*=2; michael@0: } michael@0: finally{ michael@0: c3+=1; michael@0: } michael@0: if (c3!==3){ michael@0: $ERROR('#3: Sequence evaluation of commands try/catch/finally(with exception) is 1. try, 2. catch, 3. finally'); michael@0: } michael@0: michael@0: // CHECK#4 michael@0: var c4=0; michael@0: try{ michael@0: c4=1; michael@0: } michael@0: catch(err){ michael@0: c4*=3; michael@0: } michael@0: finally{ michael@0: c4+=1; michael@0: } michael@0: if (c4!==2){ michael@0: $ERROR('#4: Sequence evaluation of commands try/catch/finally(without exception) is 1. try, 2. finally'); michael@0: } michael@0: