diff options
Diffstat (limited to 'js/src/tests/test262/language/statements/throw')
16 files changed, 591 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A1.js b/js/src/tests/test262/language/statements/throw/S12.13_A1.js new file mode 100644 index 0000000000..0b9edf5d8b --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A1.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Sanity test for throw statement +es5id: 12.13_A1 +description: Trying to throw exception with "throw" +---*/ + +var inCatch = false; + +try { + throw "expected_message"; +} catch (err) { + assert.sameValue(err, "expected_message"); + inCatch = true; +} + +assert.sameValue(inCatch, true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A2_T1.js b/js/src/tests/test262/language/statements/throw/S12.13_A2_T1.js new file mode 100644 index 0000000000..9a43599a9c --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A2_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + "throw Expression" returns (throw, GetValue(Result(1)), empty), where 1 + evaluates Expression +es5id: 12.13_A2_T1 +description: Throwing undefined +---*/ + +// CHECK#1 +try{ + throw undefined; +} +catch(e){ + if (e!==undefined) throw new Test262Error('#1: Exception === undefined. Actual: Exception ==='+ e ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A2_T2.js b/js/src/tests/test262/language/statements/throw/S12.13_A2_T2.js new file mode 100644 index 0000000000..61820854d1 --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A2_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + "throw Expression" returns (throw, GetValue(Result(1)), empty), where 1 + evaluates Expression +es5id: 12.13_A2_T2 +description: Throwing null +---*/ + +// CHECK#1 +try{ + throw null; +} +catch(e){ + if (e!==null) throw new Test262Error('#1: Exception === null. Actual: Exception ==='+ e ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A2_T3.js b/js/src/tests/test262/language/statements/throw/S12.13_A2_T3.js new file mode 100644 index 0000000000..ac443fd51f --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A2_T3.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + "throw Expression" returns (throw, GetValue(Result(1)), empty), where 1 + evaluates Expression +es5id: 12.13_A2_T3 +description: Throwing boolean +---*/ + +// CHECK#1 +try{ + throw true; +} +catch(e){ + if (e!==true) throw new Test262Error('#1: Exception ===true. Actual: Exception ==='+ e ); +} + +// CHECK#2 +try{ + throw false; +} +catch(e){ + if (e!==false) throw new Test262Error('#2: Exception ===false. Actual: Exception ==='+ e ); +} + +// CHECK#3 +var b=false; +try{ + throw b; +} +catch(e){ + if (e!==false) throw new Test262Error('#3: Exception ===false. Actual: Exception ==='+ e ); +} + +// CHECK#4 +var b=true; +try{ + throw b; +} +catch(e){ + if (e!==true) throw new Test262Error('#4: Exception ===true. Actual: Exception ==='+ e ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A2_T4.js b/js/src/tests/test262/language/statements/throw/S12.13_A2_T4.js new file mode 100644 index 0000000000..07ddadc7ab --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A2_T4.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + "throw Expression" returns (throw, GetValue(Result(1)), empty), where 1 + evaluates Expression +es5id: 12.13_A2_T4 +description: Throwing string +---*/ + +// CHECK#1 +try{ + throw "exception #1"; +} +catch(e){ + if (e!=="exception #1") throw new Test262Error('#1: Exception ==="exception #1". Actual: Exception ==='+ e ); +} + +// CHECK#2 +var b="exception #1"; +try{ + throw b; +} +catch(e){ + if (e!=="exception #1") throw new Test262Error('#2: Exception ==="exception #1". Actual: Exception ==='+ e ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A2_T5.js b/js/src/tests/test262/language/statements/throw/S12.13_A2_T5.js new file mode 100644 index 0000000000..ed30274884 --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A2_T5.js @@ -0,0 +1,77 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + "throw Expression" returns (throw, GetValue(Result(1)), empty), where 1 + evaluates Expression +es5id: 12.13_A2_T5 +description: Throwing number +---*/ + +// CHECK#1 +try{ + throw 13; +} +catch(e){ + if (e!==13) throw new Test262Error('#1: Exception ===13. Actual: Exception ==='+ e ); +} + +// CHECK#2 +var b=13; +try{ + throw b; +} +catch(e){ + if (e!==13) throw new Test262Error('#2: Exception ===13. Actual: Exception ==='+ e ); +} + +// CHECK#3 +try{ + throw 2.13; +} +catch(e){ + if (e!==2.13) throw new Test262Error('#3: Exception ===2.13. Actual: Exception ==='+ e ); +} + +// CHECK#4 +try{ + throw NaN; +} +catch(e){ + assert.sameValue(e, NaN, "e is NaN"); +} + +// CHECK#5 +try{ + throw +Infinity; +} +catch(e){ + if (e!==+Infinity) throw new Test262Error('#5: Exception ===+Infinity. Actual: Exception ==='+ e ); +} + +// CHECK#6 +try{ + throw -Infinity; +} +catch(e){ + if (e!==-Infinity) throw new Test262Error('#6: Exception ===-Infinity. Actual: Exception ==='+ e ); +} + +// CHECK#7 +try{ + throw +0; +} +catch(e){ + if (e!==+0) throw new Test262Error('#7: Exception ===+0. Actual: Exception ==='+ e ); +} + +// CHECK#8 +try{ + throw -0; +} +catch(e){ + assert.sameValue(e, -0); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A2_T6.js b/js/src/tests/test262/language/statements/throw/S12.13_A2_T6.js new file mode 100644 index 0000000000..8026a54585 --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A2_T6.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + "throw Expression" returns (throw, GetValue(Result(1)), empty), where 1 + evaluates Expression +es5id: 12.13_A2_T6 +description: Throwing object +---*/ + +var myObj = {p1: 'a', + p2: 'b', + p3: 'c', + value: 'myObj_value', + valueOf : function(){return 'obj_valueOf';}, + parseInt : function(){return 'obj_parseInt';}, + NaN : 'obj_NaN', + Infinity : 'obj_Infinity', + eval : function(){return 'obj_eval';}, + parseFloat : function(){return 'obj_parseFloat';}, + isNaN : function(){return 'obj_isNaN';}, + isFinite : function(){return 'obj_isFinite';}, + i:7 +} + +try{ + throw myObj; +} +catch(e){ +// CHECK#1 + if (e.p1!=="a") throw new Test262Error('#1: e.p1 === "a". Actual: e.p1 ==='+ e.p1 ); +// CHECK#2 + if (e.value!=='myObj_value') throw new Test262Error('#2: e.p1 === \'myObj_value\'. Actual: e.p1 ==='+ e.p1 ); +// CHECK#3 + if (e.eval()!=='obj_eval') throw new Test262Error('#3: e.p1 === \'obj_eval\'. Actual: e.p1 ==='+ e.p1 ); +} + +// CHECK#4 +myObj.i=6 +try{ + throw myObj; +} +catch(e){} +if (myObj.i!==6) throw new Test262Error('#4: Handling of catch must be correct'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A2_T7.js b/js/src/tests/test262/language/statements/throw/S12.13_A2_T7.js new file mode 100644 index 0000000000..14c5459197 --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A2_T7.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + "throw Expression" returns (throw, GetValue(Result(1)), empty), where 1 + evaluates Expression +es5id: 12.13_A2_T7 +description: Throwing Array +---*/ + +var mycars = new Array(); +mycars[0] = "Saab"; +mycars[1] = "Volvo"; +mycars[2] = "BMW"; + +var mycars2 = new Array(); +mycars2[0] = "Mercedes"; +mycars2[1] = "Jeep"; +mycars2[2] = "Suzuki"; + +// CHECK#1 +try{ + throw mycars; +} +catch(e){ + for (var i=0;i<3;i++){ + if (e[i]!==mycars[i]) throw new Test262Error('#1.'+i+': Exception['+i+'] === mycars['+i+']. Actual: Exception['+i+'] ==='+ e[i] ); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A3_T1.js b/js/src/tests/test262/language/statements/throw/S12.13_A3_T1.js new file mode 100644 index 0000000000..1e91187818 --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A3_T1.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: 1. Evaluate Expression +es5id: 12.13_A3_T1 +description: Evaluating boolean expression +---*/ + +// CHECK#1 +var b=true; +try{ + throw b&&false; +} +catch(e){ + if (e!==false) throw new Test262Error('#1: Exception === false(operaton &&). Actual: Exception ==='+ e ); +} + +// CHECK#2 +var b=true; +try{ + throw b||false; +} +catch(e){ + if (e!==true) throw new Test262Error('#2: Exception === true(operaton ||). Actual: Exception ==='+ e ); +} + +// CHECK#3 +try{ + throw !false; +} +catch(e){ + if (e!==true) throw new Test262Error('#3: Exception === true(operaton !). Actual: Exception ==='+ e ); +} + +// CHECK#4 +var b=true; +try{ + throw !(b&&false); +} +catch(e){ + if (e!==true) throw new Test262Error('#4: Exception === true(operaton &&). Actual: Exception ==='+ e ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A3_T2.js b/js/src/tests/test262/language/statements/throw/S12.13_A3_T2.js new file mode 100644 index 0000000000..05704b43aa --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A3_T2.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: 1. Evaluate Expression +es5id: 12.13_A3_T2 +description: Evaluating string expression +---*/ + +// CHECK#1 +try{ + throw "exception"+" #1"; +} +catch(e){ + if (e!=="exception #1") throw new Test262Error('#1: Exception === "exception #1"(operaton +). Actual: Exception ==='+ e ); +} + +// CHECK#2 +var b="exception" +var a=" #1"; +try{ + throw b+a; +} +catch(e){ + if (e!=="exception #1") throw new Test262Error('#2: Exception === "exception #1"(operaton +). Actual: Exception ==='+ e ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A3_T3.js b/js/src/tests/test262/language/statements/throw/S12.13_A3_T3.js new file mode 100644 index 0000000000..4f08ca5a0a --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A3_T3.js @@ -0,0 +1,92 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: 1. Evaluate Expression +es5id: 12.13_A3_T3 +description: Evaluating number expression +---*/ + +// CHECK#1 +try{ + throw 10+3; +} +catch(e){ + if (e!==13) throw new Test262Error('#1: Exception ===13(operaton +). Actual: Exception ==='+ e); +} + +// CHECK#2 +var b=10; +var a=3; +try{ + throw a+b; +} +catch(e){ + if (e!==13) throw new Test262Error('#2: Exception ===13(operaton +). Actual: Exception ==='+ e); +} + +// CHECK#3 +try{ + throw 3.15-1.02; +} +catch(e){ + if (e!==2.13) throw new Test262Error('#3: Exception ===2.13(operaton -). Actual: Exception ==='+ e); +} + +// CHECK#4 +try{ + throw 2*2; +} +catch(e){ + if (e!==4) throw new Test262Error('#4: Exception ===4(operaton *). Actual: Exception ==='+ e); +} + +// CHECK#5 +try{ + throw 1+Infinity; +} +catch(e){ + if (e!==+Infinity) throw new Test262Error('#5: Exception ===+Infinity(operaton +). Actual: Exception ==='+ e); +} + +// CHECK#6 +try{ + throw 1-Infinity; +} +catch(e){ + if (e!==-Infinity) throw new Test262Error('#6: Exception ===-Infinity(operaton -). Actual: Exception ==='+ e); +} + +// CHECK#7 +try{ + throw 10/5; +} +catch(e){ + if (e!==2) throw new Test262Error('#7: Exception ===2(operaton /). Actual: Exception ==='+ e); +} + +// CHECK#8 +try{ + throw 8>>2; +} +catch(e){ + if (e!==2) throw new Test262Error('#8: Exception ===2(operaton >>). Actual: Exception ==='+ e); +} + +// CHECK#9 +try{ + throw 2<<2; +} +catch(e){ + if (e!==8) throw new Test262Error('#9: Exception ===8(operaton <<). Actual: Exception ==='+ e); +} + +// CHECK#10 +try{ + throw 123%100; +} +catch(e){ + if (e!==23) throw new Test262Error('#10: Exception ===23(operaton %). Actual: Exception ==='+ e); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A3_T4.js b/js/src/tests/test262/language/statements/throw/S12.13_A3_T4.js new file mode 100644 index 0000000000..59a3b1e9d2 --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A3_T4.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: 1. Evaluate Expression +es5id: 12.13_A3_T4 +description: Evaluating array expression +---*/ + +var mycars = new Array(); +mycars[0] = "Saab"; +mycars[1] = "Volvo"; +mycars[2] = "BMW"; + +var mycars2 = new Array(); +mycars2[0] = "Mercedes"; +mycars2[1] = "Jeep"; +mycars2[2] = "Suzuki"; + +// CHECK#1 +try{ + throw mycars.concat(mycars2); +} +catch(e){ + for (var i=0;i<3;i++){ + if (e[i]!==mycars[i]) throw new Test262Error('#1.'+i+': Exception['+i+']===mycars['+i+'](operation .concat). Actual: Exception['+i+']==='+ e[i] ); + } + for (var i=3;i<6;i++){ + if (e[i]!==mycars2[i-3]) throw new Test262Error('#1.'+i+': Exception['+i+']===mycars2['+(i-3)+'](operation .concat). Actual: Exception['+i+']==='+ e[i] ); + } +} + +// CHECK#2 +try{ + throw new Array("Mercedes","Jeep","Suzuki"); +} +catch(e){ + for (var i=0;i<3;i++){ + if (e[i]!==mycars2[i]) throw new Test262Error('#2.'+i+': Exception['+i+']===mycars2['+i+'](operation new). Actual: Exception['+i+']==='+ e[i] ); + } +} + +// CHECK#3 +try{ + throw mycars.concat(new Array("Mercedes","Jeep","Suzuki")); +} +catch(e){ + for (var i=0;i<3;i++){ + if (e[i]!==mycars[i]) throw new Test262Error('#3.'+i+': Exception['+i+']===mycars['+i+'](operation .concat(new)). Actual: Exception['+i+']==='+ e[i] ); + } + for (var i=3;i<6;i++){ + if (e[i]!==mycars2[i-3]) throw new Test262Error('#3.'+i+': Exception['+i+']===mycars2['+(i-3)+'](operation .concat(new)). Actual: Exception['+i+']==='+ e[i] ); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A3_T5.js b/js/src/tests/test262/language/statements/throw/S12.13_A3_T5.js new file mode 100644 index 0000000000..eaa5b6a238 --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A3_T5.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: 1. Evaluate Expression +es5id: 12.13_A3_T5 +description: Evaluating equation expression +---*/ + +// CHECK#1 +var a=true; +var b=false; +try{ + throw ((a&&(!b))?"exception":" #1"); +} +catch(e){ + if (e!=="exception") throw new Test262Error('#1: Exception ==="exception"(operaton ? , ). Actual: Exception ==='+e ); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/S12.13_A3_T6.js b/js/src/tests/test262/language/statements/throw/S12.13_A3_T6.js new file mode 100644 index 0000000000..9034b80747 --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/S12.13_A3_T6.js @@ -0,0 +1,58 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: 1. Evaluate Expression +es5id: 12.13_A3_T6 +description: Evaluating functions +---*/ + +// CHECK#1 +var i=0; +function adding1(){ + i++; + return 1; +} +try{ + throw (adding1()); +} +catch(e){ + if (e!==1) throw new Test262Error('#1: Exception ===1. Actual: Exception ==='+ e); +} + +// CHECK#2 +var i=0; +function adding2(){ + i++; + return i; +} +try{ + throw adding2(); +} +catch(e){} +if (i!==1) throw new Test262Error('#2: i===1. Actual: i==='+ i); + +// CHECK#3 +var i=0; +function adding3(){ + i++; +} +try{ + throw adding3(); +} +catch(e){} +if (i!==1) throw new Test262Error('#3: i===1. Actual: i==='+i); + +// CHECK#4 +function adding4(i){ + i++; + return i; +} +try{ + throw (adding4(1)); +} +catch(e){ + if (e!==2) throw new Test262Error('#4: Exception ===2. Actual: Exception ==='+ e); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/throw/browser.js b/js/src/tests/test262/language/statements/throw/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/browser.js diff --git a/js/src/tests/test262/language/statements/throw/shell.js b/js/src/tests/test262/language/statements/throw/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/throw/shell.js |