| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-350312-02.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 350312; |
| 9 |
var summary = 'Accessing wrong stack slot with nested catch/finally'; |
| 10 |
var actual = ''; |
| 11 |
var expect = ''; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
test(); |
| 16 |
|
| 17 |
|
| 18 |
function test() |
| 19 |
{ |
| 20 |
enterFunc ('test'); |
| 21 |
printBugNumber(BUGNUMBER); |
| 22 |
printStatus (summary); |
| 23 |
|
| 24 |
function createPrint(obj) |
| 25 |
{ |
| 26 |
return new Function("actual += " + obj + " + ','; " + |
| 27 |
"print(" + obj + ");"); |
| 28 |
} |
| 29 |
|
| 30 |
function createThrow(obj) |
| 31 |
{ |
| 32 |
return new Function("throw " + obj + "; "); |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
function f(a, b, c) |
| 37 |
{ |
| 38 |
try { |
| 39 |
a(); |
| 40 |
} catch (e if e == null) { |
| 41 |
b(); |
| 42 |
} finally { |
| 43 |
c(); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
print('test 1'); |
| 48 |
expect = 'a,c,'; |
| 49 |
actual = ''; |
| 50 |
try |
| 51 |
{ |
| 52 |
f(createPrint("'a'"), createPrint("'b'"), createPrint("'c'")); |
| 53 |
} |
| 54 |
catch(ex) |
| 55 |
{ |
| 56 |
actual += 'caught ' + ex; |
| 57 |
} |
| 58 |
reportCompare(expect, actual, summary + ': 1'); |
| 59 |
|
| 60 |
print('test 2'); |
| 61 |
expect = 'c,caught a'; |
| 62 |
actual = ''; |
| 63 |
try |
| 64 |
{ |
| 65 |
f(createThrow("'a'"), createPrint("'b'"), createPrint("'c'")); |
| 66 |
} |
| 67 |
catch(ex) |
| 68 |
{ |
| 69 |
actual += 'caught ' + ex; |
| 70 |
} |
| 71 |
reportCompare(expect, actual, summary + ': 2'); |
| 72 |
|
| 73 |
print('test 3'); |
| 74 |
expect = 'b,c,'; |
| 75 |
actual = ''; |
| 76 |
try |
| 77 |
{ |
| 78 |
f(createThrow("null"), createPrint("'b'"), createPrint("'c'")); |
| 79 |
} |
| 80 |
catch(ex) |
| 81 |
{ |
| 82 |
actual += 'caught ' + ex; |
| 83 |
} |
| 84 |
reportCompare(expect, actual, summary + ': 3'); |
| 85 |
|
| 86 |
print('test 4'); |
| 87 |
expect = 'a,c,'; |
| 88 |
actual = ''; |
| 89 |
try |
| 90 |
{ |
| 91 |
f(createPrint("'a'"), createThrow("'b'"), createPrint("'c'")); |
| 92 |
} |
| 93 |
catch(ex) |
| 94 |
{ |
| 95 |
actual += 'caught ' + ex; |
| 96 |
} |
| 97 |
reportCompare(expect, actual, summary + ': 4'); |
| 98 |
|
| 99 |
print('test 5'); |
| 100 |
expect = 'c,caught b'; |
| 101 |
actual = ''; |
| 102 |
try |
| 103 |
{ |
| 104 |
f(createThrow("null"), createThrow("'b'"), createPrint("'c'")); |
| 105 |
} |
| 106 |
catch(ex) |
| 107 |
{ |
| 108 |
actual += 'caught ' + ex; |
| 109 |
} |
| 110 |
reportCompare(expect, actual, summary + ': 5'); |
| 111 |
|
| 112 |
exitFunc ('test'); |
| 113 |
} |