| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
var gTestfile = 'regress-49286.js'; |
| 19 |
var UBound = 0; |
| 20 |
var BUGNUMBER = 49286; |
| 21 |
var summary = 'Invoking try...catch through Function.call'; |
| 22 |
var cnErrorCaught = 'Error caught'; |
| 23 |
var cnErrorNotCaught = 'Error NOT caught'; |
| 24 |
var cnGoodSyntax = '1==2'; |
| 25 |
var cnBadSyntax = '1=2'; |
| 26 |
var status = ''; |
| 27 |
var statusitems = []; |
| 28 |
var actual = ''; |
| 29 |
var actualvalues = []; |
| 30 |
var expect= ''; |
| 31 |
var expectedvalues = []; |
| 32 |
|
| 33 |
|
| 34 |
var obj = new testObject(); |
| 35 |
|
| 36 |
status = 'Section A of test: direct call of f'; |
| 37 |
actual = f.call(obj); |
| 38 |
expect = cnErrorCaught; |
| 39 |
addThis(); |
| 40 |
|
| 41 |
status = 'Section B of test: indirect call of f'; |
| 42 |
actual = g.call(obj); |
| 43 |
expect = cnErrorCaught; |
| 44 |
addThis(); |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
test(); |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
function test() |
| 54 |
{ |
| 55 |
enterFunc ('test'); |
| 56 |
printBugNumber(BUGNUMBER); |
| 57 |
printStatus (summary); |
| 58 |
|
| 59 |
for (var i=0; i<UBound; i++) |
| 60 |
{ |
| 61 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 62 |
} |
| 63 |
|
| 64 |
exitFunc ('test'); |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
function testObject() |
| 70 |
{ |
| 71 |
this.badSyntax = cnBadSyntax; |
| 72 |
this.goodSyntax = cnGoodSyntax; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
function f() |
| 78 |
{ |
| 79 |
try |
| 80 |
{ |
| 81 |
eval(this.badSyntax); |
| 82 |
} |
| 83 |
catch(e) |
| 84 |
{ |
| 85 |
return cnErrorCaught; |
| 86 |
} |
| 87 |
return cnErrorNotCaught; |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
function g() |
| 93 |
{ |
| 94 |
return f.call(this); |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
function addThis() |
| 99 |
{ |
| 100 |
statusitems[UBound] = status; |
| 101 |
actualvalues[UBound] = actual; |
| 102 |
expectedvalues[UBound] = expect; |
| 103 |
UBound++; |
| 104 |
} |