|
1 function testAddInconvertibleObjectAny() |
|
2 { |
|
3 var count = 0; |
|
4 function toString() |
|
5 { |
|
6 ++count; |
|
7 if (count == 95) |
|
8 return {}; |
|
9 return "" + count; |
|
10 } |
|
11 var o = {valueOf: undefined, toString: toString}; |
|
12 |
|
13 var threw = false; |
|
14 try |
|
15 { |
|
16 for (var i = 0; i < 100; i++) |
|
17 var q = o + 5; |
|
18 } |
|
19 catch (e) |
|
20 { |
|
21 threw = true; |
|
22 if (i !== 94) |
|
23 return "expected i === 94, got " + i; |
|
24 if (q !== "945") |
|
25 return "expected q === '945', got " + q + " (type " + typeof q + ")"; |
|
26 if (count !== 95) |
|
27 return "expected count === 95, got " + count; |
|
28 } |
|
29 if (!threw) |
|
30 return "expected throw with o + 5"; |
|
31 |
|
32 return "pass"; |
|
33 } |
|
34 assertEq(testAddInconvertibleObjectAny(), "pass"); |