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

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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

mercurial