js/src/jit-test/tests/basic/testAddInconvertibleObjectAny.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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};
    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";
    32   return "pass";
    33 }
    34 assertEq(testAddInconvertibleObjectAny(), "pass");

mercurial