Debian Codegraph @

js/src/tests/test262/language/statements/try/S12.14_A18_T7.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_T7
7 description: Catching Array
8 ---*/
9
10 var mycars = new Array();
11 mycars[0] = "Saab";
12 mycars[1] = "Volvo";
13 mycars[2] = "BMW";
14
15 var mycars2 = new Array();
16 mycars2[0] = "Mercedes";
17 mycars2[1] = "Jeep";
18 mycars2[2] = "Suzuki";
19
20 // CHECK#1
21 try{
22 throw mycars;
23 }
24 catch(e){
25 for (var i=0;i<3;i++){
26 if (e[i]!==mycars[i]) throw new Test262Error('#1.'+i+': Exception['+i+']===mycars['+i+']. Actual: Exception['+i+']==='+ e[i] );
27 }
28 }
29
30 // CHECK#2
31 try{
32 throw mycars.concat(mycars2);
33 }
34 catch(e){
35 for (var i=0;i<3;i++){
36 if (e[i]!==mycars[i]) throw new Test262Error('#2.'+i+': Exception['+i+']===mycars['+i+']. Actual: Exception['+i+']==='+ e[i] );
37 }
38 for (var i=3;i<6;i++){
39 if (e[i]!==mycars2[i-3]) throw new Test262Error('#2.'+i+': Exception['+i+']===mycars2['+i+']. Actual: Exception['+i+']==='+ e[i] );
40 }
41 }
42
43 // CHECK#3
44 try{
45 throw new Array("Mercedes","Jeep","Suzuki");
46 }
47 catch(e){
48 for (var i=0;i<3;i++){
49 if (e[i]!==mycars2[i]) throw new Test262Error('#3.'+i+': Exception['+i+']===mycars2['+i+']. Actual: Exception['+i+']==='+ e[i]);
50 }
51 }
52
53 // CHECK#4
54 try{
55 throw mycars.concat(new Array("Mercedes","Jeep","Suzuki"));
56 }
57 catch(e){
58 for (var i=0;i<3;i++){
59 if (e[i]!==mycars[i]) throw new Test262Error('#4.'+i+': Exception['+i+']===mycars['+i+']. Actual: Exception['+i+']==='+ e[i] );
60 }
61 for (var i=3;i<6;i++){
62 if (e[i]!==mycars2[i-3]) throw new Test262Error('#4.'+i+': Exception['+i+']===mycars2['+(i-3)+']. Actual: Exception['+i+']==='+ e[i]);
63 }
64 }
65
66 reportCompare(0, 0);