| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-383674.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 383674; |
| 9 |
var summary = 'Statement that implicitly calls toString should not be optimized away as a "useless expression"'; |
| 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 |
options("strict"); |
| 25 |
options("werror"); |
| 26 |
|
| 27 |
expect = 'toString called'; |
| 28 |
actual = 'toString not called'; |
| 29 |
try |
| 30 |
{ |
| 31 |
var x = {toString: function() { |
| 32 |
actual = 'toString called'; |
| 33 |
print(actual); |
| 34 |
} |
| 35 |
}; |
| 36 |
var f = function() { var j = x; j + ""; } |
| 37 |
f(); |
| 38 |
reportCompare(expect, actual, summary + ': 1'); |
| 39 |
} |
| 40 |
catch(ex) |
| 41 |
{ |
| 42 |
reportCompare("No Error", ex + "", summary + ': 1'); |
| 43 |
} |
| 44 |
|
| 45 |
actual = 'toString not called'; |
| 46 |
try |
| 47 |
{ |
| 48 |
(function() { const a = |
| 49 |
({toString: function(){ |
| 50 |
actual = 'toString called'; print(actual)} }); a += ""; })(); |
| 51 |
reportCompare(expect, actual, summary + ': 2'); |
| 52 |
} |
| 53 |
catch(ex) |
| 54 |
{ |
| 55 |
reportCompare("No Error", ex + "", summary + ': 2'); |
| 56 |
} |
| 57 |
|
| 58 |
exitFunc ('test'); |
| 59 |
} |