| 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_T5 |
| 7 |
description: Catching Number |
| 8 |
---*/ |
| 9 |
|
| 10 |
// CHECK#1 |
| 11 |
try{ |
| 12 |
throw 13; |
| 13 |
} |
| 14 |
catch(e){ |
| 15 |
if (e!==13) throw new Test262Error('#1: Exception ===13. Actual: Exception ==='+ e ); |
| 16 |
} |
| 17 |
|
| 18 |
// CHECK#2 |
| 19 |
try{ |
| 20 |
throw 10+3; |
| 21 |
} |
| 22 |
catch(e){ |
| 23 |
if (e!==13) throw new Test262Error('#2: Exception ===13. Actual: Exception ==='+ e ); |
| 24 |
} |
| 25 |
|
| 26 |
// CHECK#3 |
| 27 |
var b=13; |
| 28 |
try{ |
| 29 |
throw b; |
| 30 |
} |
| 31 |
catch(e){ |
| 32 |
if (e!==13) throw new Test262Error('#3: Exception ===13. Actual: Exception ==='+ e ); |
| 33 |
} |
| 34 |
|
| 35 |
// CHECK#4 |
| 36 |
var a=3; |
| 37 |
var b=10; |
| 38 |
try{ |
| 39 |
throw a+b; |
| 40 |
} |
| 41 |
catch(e){ |
| 42 |
if (e!==13) throw new Test262Error('#4: Exception ===13. Actual: Exception ==='+ e ); |
| 43 |
} |
| 44 |
|
| 45 |
// CHECK#5 |
| 46 |
try{ |
| 47 |
throw 2.13; |
| 48 |
} |
| 49 |
catch(e){ |
| 50 |
if (e!==2.13) throw new Test262Error('#5: Exception ===2.13. Actual: Exception ==='+ e ); |
| 51 |
} |
| 52 |
|
| 53 |
// CHECK#6 |
| 54 |
var ex=2/3; |
| 55 |
try{ |
| 56 |
throw 2/3; |
| 57 |
} |
| 58 |
catch(e){ |
| 59 |
if (e!==ex) throw new Test262Error('#6: Exception ===2/3. Actual: Exception ==='+ e ); |
| 60 |
} |
| 61 |
|
| 62 |
// CHECK#7 |
| 63 |
try{ |
| 64 |
throw NaN; |
| 65 |
} |
| 66 |
catch(e){ |
| 67 |
assert.sameValue(e, NaN, "e is NaN"); |
| 68 |
} |
| 69 |
|
| 70 |
// CHECK#8 |
| 71 |
try{ |
| 72 |
throw +Infinity; |
| 73 |
} |
| 74 |
catch(e){ |
| 75 |
if (e!==+Infinity) throw new Test262Error('#8: Exception ===+Infinity. Actual: Exception ==='+ e ); |
| 76 |
} |
| 77 |
|
| 78 |
// CHECK#9 |
| 79 |
try{ |
| 80 |
throw -Infinity; |
| 81 |
} |
| 82 |
catch(e){ |
| 83 |
if (e!==-Infinity) throw new Test262Error('#9: Exception ===-Infinity. Actual: Exception ==='+ e ); |
| 84 |
} |
| 85 |
|
| 86 |
// CHECK#10 |
| 87 |
try{ |
| 88 |
throw +0; |
| 89 |
} |
| 90 |
catch(e){ |
| 91 |
if (e!==+0) throw new Test262Error('#10: Exception ===+0. Actual: Exception ==='+ e ); |
| 92 |
} |
| 93 |
|
| 94 |
// CHECK#11 |
| 95 |
try{ |
| 96 |
throw -0; |
| 97 |
} |
| 98 |
catch(e){ |
| 99 |
assert.sameValue(e, -0); |
| 100 |
} |
| 101 |
|
| 102 |
reportCompare(0, 0); |