1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/ch12/12.14/S12.14_A19_T1.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +// Copyright 2009 the Sputnik authors. All rights reserved. 1.5 +// This code is governed by the BSD license found in the LICENSE file. 1.6 + 1.7 +/** 1.8 + * Catching system exceptions of different types with try statement 1.9 + * 1.10 + * @path ch12/12.14/S12.14_A19_T1.js 1.11 + * @description Testing try/catch syntax construction 1.12 + */ 1.13 + 1.14 +// CHECK#1 1.15 +try{ 1.16 + throw (Error("hello")); 1.17 +} 1.18 +catch(e){ 1.19 + if (e.toString()!=="Error: hello") $ERROR('#1: Exception.toString()==="Error: hello". Actual: Exception is '+e); 1.20 +} 1.21 + 1.22 +// CHECK#2 1.23 +try{ 1.24 + throw (new Error("hello")); 1.25 +} 1.26 +catch(e){ 1.27 + if (e.toString()!=="Error: hello") $ERROR('#2: Exception.toString()==="Error: hello". Actual: Exception is '+e); 1.28 +} 1.29 + 1.30 +// CHECK#3 1.31 +var c3=0; 1.32 +try{ 1.33 + throw EvalError(1); 1.34 +} 1.35 +catch(e){ 1.36 + if (e.toString()!=="EvalError: 1") $ERROR('#3: Exception.toString()==="EvalError: 1". Actual: Exception is '+e); 1.37 +} 1.38 + 1.39 +// CHECK#4 1.40 +try{ 1.41 + throw RangeError(1); 1.42 +} 1.43 +catch(e){ 1.44 + if (e.toString()!=="RangeError: 1") $ERROR('#4: Exception.toString()==="RangeError: 1". Actual: Exception is '+e); 1.45 +} 1.46 + 1.47 +// CHECK#5 1.48 +try{ 1.49 + throw ReferenceError(1); 1.50 +} 1.51 +catch(e){ 1.52 + if (e.toString()!=="ReferenceError: 1") $ERROR('#5: Exception.toString()==="ReferenceError: 1". Actual: Exception is '+e); 1.53 +} 1.54 + 1.55 +// CHECK#6 1.56 +var c6=0; 1.57 +try{ 1.58 + throw TypeError(1); 1.59 +} 1.60 +catch(e){ 1.61 + if (e.toString()!=="TypeError: 1") $ERROR('#6: Exception.toString()==="TypeError: 1". Actual: Exception is '+e); 1.62 +} 1.63 + 1.64 +// CHECK#7 1.65 +try{ 1.66 + throw URIError("message", "fileName", "1"); 1.67 +} 1.68 +catch(e){ 1.69 + if (e.toString()!=="URIError: message") $ERROR('#7: Exception.toString()==="URIError: message". Actual: Exception is '+e); 1.70 +} 1.71 +