| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-347559.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 347559; |
| 9 |
var summary = 'Let declarations should not warn that function does not ' + |
| 10 |
'return a value'; |
| 11 |
var actual = ''; |
| 12 |
var expect = ''; |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
test(); |
| 17 |
|
| 18 |
|
| 19 |
function test() |
| 20 |
{ |
| 21 |
enterFunc ('test'); |
| 22 |
printBugNumber(BUGNUMBER); |
| 23 |
printStatus (summary); |
| 24 |
|
| 25 |
actual = 'No Warning'; |
| 26 |
expect = 'No Warning'; |
| 27 |
|
| 28 |
if (!options().match(/strict/)) |
| 29 |
{ |
| 30 |
options('strict'); |
| 31 |
} |
| 32 |
if (!options().match(/werror/)) |
| 33 |
{ |
| 34 |
options('werror'); |
| 35 |
} |
| 36 |
|
| 37 |
try |
| 38 |
{ |
| 39 |
eval('function f() { let a = 2; return a; }'); |
| 40 |
} |
| 41 |
catch(ex) |
| 42 |
{ |
| 43 |
actual = ex + ''; |
| 44 |
} |
| 45 |
|
| 46 |
reportCompare(expect, actual, summary + ': 1'); |
| 47 |
|
| 48 |
actual = 'No Warning'; |
| 49 |
expect = 'TypeError: function f does not always return a value'; |
| 50 |
|
| 51 |
try |
| 52 |
{ |
| 53 |
eval('function f() { if (asdf) return 3; let x; }'); |
| 54 |
} |
| 55 |
catch(ex) |
| 56 |
{ |
| 57 |
actual = ex + ''; |
| 58 |
} |
| 59 |
|
| 60 |
reportCompare(expect, actual, summary + ': 2'); |
| 61 |
|
| 62 |
actual = 'No Warning'; |
| 63 |
expect = 'No Warning'; |
| 64 |
|
| 65 |
try |
| 66 |
{ |
| 67 |
eval('function f() { if (asdf) return 3; let (x) { return 4; } }'); |
| 68 |
} |
| 69 |
catch(ex) |
| 70 |
{ |
| 71 |
actual = ex + ''; |
| 72 |
} |
| 73 |
|
| 74 |
reportCompare(expect, actual, summary + ': 3'); |
| 75 |
|
| 76 |
exitFunc ('test'); |
| 77 |
} |