Debian Codegraph @

js/src/tests/test262/language/statements/try/S12.14_A18_T6.js

raw
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: Catching objects with try/catch/finally statement
6 es5id: 12.14_A18_T6
7 description: Catching Object
8 ---*/
9
10 var myObj = {p1: 'a',
11 p2: 'b',
12 p3: 'c',
13 value: 'myObj_value',
14 valueOf : function(){return 'obj_valueOf';},
15 parseInt : function(){return 'obj_parseInt';},
16 NaN : 'obj_NaN',
17 Infinity : 'obj_Infinity',
18 eval : function(){return 'obj_eval';},
19 parseFloat : function(){return 'obj_parseFloat';},
20 isNaN : function(){return 'obj_isNaN';},
21 isFinite : function(){return 'obj_isFinite';},
22 i:7,
23 }
24
25 try{
26 throw myObj;
27 }
28 catch(e){
29 // CHECK#1
30 if (e.p1!=="a") throw new Test262Error('#1: e.p1==="a". Actual: e.p1==='+ e.p1 );
31 // CHECK#2
32 if (e.value!=='myObj_value') throw new Test262Error('#2: e.value===\'myObj_value\'. Actual: e.value==='+ e.value );
33 // CHECK#3
34 if (e.eval()!=='obj_eval') throw new Test262Error('#3: e.eval()===\'obj_eval\'. Actual: e.eval()==='+ e.eval() );
35 }
36
37 // CHECK#4
38 myObj.i=6;
39 try{
40 throw myObj;
41 }
42 catch(e){}
43 if (myObj.i!==6) throw new Test262Error('#4: Handling of catch must be correct');
44
45 // CHECK#5
46 myObj.i=6;
47 try{
48 throw myObj;
49 }
50 catch(e){
51 e.i=10;
52 }
53 if (myObj.i!==10) throw new Test262Error('#5: Handling of catch must be correct');
54
55 reportCompare(0, 0);