summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/testUnaryImacros.js
blob: 884d856d26bac1b1de08ba239b6c3ebf3a1e1330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function testUnaryImacros()
{
  function checkArg(x)
  {
    return 1;
  }

  var o = { valueOf: checkArg, toString: null };
  var count = 0;
  var v = 0;
  for (var i = 0; i < 5; i++)
    v += +o + -(-o);

  var results = [v === 10 ? "valueOf passed" : "valueOf failed"];

  o.valueOf = null;
  o.toString = checkArg;

  for (var i = 0; i < 5; i++)
    v += +o + -(-o);

  results.push(v === 20 ? "toString passed" : "toString failed");

  return results.join(", ");
}
assertEq(testUnaryImacros(), "valueOf passed, toString passed");