| Index: mozilla-tests/shell.js
 | 
| ===================================================================
 | 
| --- mozilla-tests/shell.js	(revision 43940)
 | 
| +++ mozilla-tests/shell.js	(working copy)
 | 
| @@ -75,7 +75,7 @@
 | 
|  /*
 | 
|   * constant strings
 | 
|   */
 | 
| -var GLOBAL = "[object global]";
 | 
| +var GLOBAL = this + '';
 | 
|  var PASSED = " PASSED! ";
 | 
|  var FAILED = " FAILED! ";
 | 
|  
 | 
| @@ -274,6 +274,23 @@
 | 
|  }
 | 
|  
 | 
|  /*
 | 
| + * assertEq(actual, expected)
 | 
| + *           Throw if the two arguments are not ===
 | 
| + * see https://bugzilla.mozilla.org/show_bug.cgi?id=480199
 | 
| + */
 | 
| +if (typeof assertEq == 'undefined')
 | 
| +{
 | 
| +  var assertEq =
 | 
| +    function (actual, expected)
 | 
| +    {
 | 
| +      if (actual !== expected)
 | 
| +      {
 | 
| +        throw new TypeError('Assertion failed: got "' + actual + '", expected "' + expected);
 | 
| +      }
 | 
| +    };
 | 
| +}
 | 
| +
 | 
| +/*
 | 
|   * Compare expected result to actual result, if they differ (in value and/or
 | 
|   * type) report a failure.  If description is provided, include it in the
 | 
|   * failure report.
 | 
| @@ -676,13 +693,21 @@
 | 
|  
 | 
|  function optionsReset() {
 | 
|  
 | 
| -  optionsClear();
 | 
| +  try
 | 
| +  {
 | 
| +    optionsClear();
 | 
|  
 | 
| -  // turn on initial settings
 | 
| -  for (optionName in options.initvalues)
 | 
| +    // turn on initial settings
 | 
| +    for (optionName in options.initvalues)
 | 
| +    {
 | 
| +      options(optionName);
 | 
| +    }
 | 
| +  }
 | 
| +  catch(ex)
 | 
|    {
 | 
| -    options(optionName);
 | 
| +    print('optionsReset: caught ' + ex);
 | 
|    }
 | 
| +
 | 
|  }
 | 
|  
 | 
|  if (typeof options == 'function')
 | 
| @@ -693,48 +718,30 @@
 | 
|  
 | 
|  function getTestCaseResult(expected, actual)
 | 
|  {
 | 
| -  var expected_t = typeof expected;
 | 
| -  var actual_t = typeof actual;
 | 
| -  var passed = true;
 | 
| - 
 | 
| -  // because ( NaN == NaN ) always returns false, need to do
 | 
| -  // a special compare to see if we got the right result.
 | 
| -  if ( actual != actual ) 
 | 
| -  {
 | 
| -    if ( actual_t == "object" ) 
 | 
| -    {
 | 
| -      actual = "NaN object";
 | 
| -    } 
 | 
| -    else 
 | 
| -    {
 | 
| -      actual = "NaN number";
 | 
| -    }
 | 
| -  }
 | 
| -  if ( expected != expected ) 
 | 
| -  {
 | 
| -    if ( expected_t == "object" ) 
 | 
| -    {
 | 
| -      expected = "NaN object";
 | 
| -    } 
 | 
| -    else 
 | 
| -    {
 | 
| -      expected = "NaN number";
 | 
| -    }
 | 
| -  }
 | 
| +  if (typeof expected != typeof actual)
 | 
| +    return false;
 | 
| +  if (typeof expected != 'number')
 | 
| +    // Note that many tests depend on the use of '==' here, not '==='.
 | 
| +    return actual == expected;
 | 
|  
 | 
| -  if (expected_t != actual_t)
 | 
| -  {
 | 
| -    passed = false;
 | 
| -  }
 | 
| -  else if (expected != actual)
 | 
| -  {
 | 
| -    if (expected_t != 'number' || (Math.abs(actual - expected) > 1E-10))
 | 
| -    {
 | 
| -      passed = false;
 | 
| -    }
 | 
| -  }
 | 
| - 
 | 
| -  return passed;
 | 
| +  // Distinguish NaN from other values.  Using x != x comparisons here
 | 
| +  // works even if tests redefine isNaN.
 | 
| +  if (actual != actual)
 | 
| +    return expected != expected;
 | 
| +  if (expected != expected)
 | 
| +    return false;
 | 
| +
 | 
| +  // Tolerate a certain degree of error.
 | 
| +  if (actual != expected)
 | 
| +    return Math.abs(actual - expected) <= 1E-10;
 | 
| +
 | 
| +  // Here would be a good place to distinguish 0 and -0, if we wanted
 | 
| +  // to.  However, doing so would introduce a number of failures in
 | 
| +  // areas where they don't seem important.  For example, the WeekDay
 | 
| +  // function in ECMA-262 returns -0 for Sundays before the epoch, but
 | 
| +  // the Date functions in SpiderMonkey specified in terms of WeekDay
 | 
| +  // often don't.  This seems unimportant.
 | 
| +  return true;
 | 
|  }
 | 
|  
 | 
|  if (typeof dump == 'undefined')
 | 
| @@ -851,6 +858,18 @@
 | 
|  
 | 
|  }
 | 
|  
 | 
| +function jit(on)
 | 
| +{
 | 
| +  if (on && !options().match(/jit/))
 | 
| +  {
 | 
| +    options('jit');
 | 
| +  }
 | 
| +  else if (!on && options().match(/jit/))
 | 
| +  {
 | 
| +    options('jit');
 | 
| +  }
 | 
| +}
 | 
| +
 | 
|  /*
 | 
|   * Some tests need to know if we are in Rhino as opposed to SpiderMonkey
 | 
|   */
 | 
| 
 |