| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
try { |
| 13 |
host.throwError("Aboo!"); |
| 14 |
throw 'Unreachable 1!'; |
| 15 |
} catch (e) { |
| 16 |
var act = e.toString(); |
| 17 |
if (act !== 'Error: Aboo!') throw 'Test 1: Wrong toString(): ' + act; |
| 18 |
if (e.name !== 'Error') throw 'Test 2: Wrong name: ' + e.name; |
| 19 |
|
| 20 |
|
| 21 |
if (e.lineNumber !== 13) throw 'Test 4: Wrong source line: ' + e.lineNumber; |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
function MyBang(msg, file, line) { |
| 29 |
this.foo = 'Bar'; |
| 30 |
this.msg = msg; |
| 31 |
this.file = file; |
| 32 |
this.line = line; |
| 33 |
} |
| 34 |
|
| 35 |
try { |
| 36 |
host.throwCustomError("MyBang", "Aboo!"); |
| 37 |
throw 'Unreachable 2!'; |
| 38 |
} catch (e) { |
| 39 |
if (e.foo !== 'Bar') throw 'Test 5: Wrong foo: ' + e.foo + " (" + e + ")"; |
| 40 |
if (e.msg !== 'Aboo!') throw 'Test 6: Wrong msg: ' + e.msg+ " (" + e + ")"; |
| 41 |
if (e.file !== 'Issue176.js') throw 'Test 7: Wrong file: ' + e.file+ " (" + e + ")"; |
| 42 |
if (e.line !== 36) throw 'Test 8: Wrong line: ' + e.line+ " (" + e + ")"; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
TypeError = function() { this.msg = 'Wrong!' }; |
| 51 |
|
| 52 |
try { |
| 53 |
Object.create(void 0); |
| 54 |
throw 'Unreachable 3!'; |
| 55 |
} catch (e) { |
| 56 |
|
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
"success"; |