mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Adjust the assertEq replacement function in JS tests not run in the shell to use same-value semantics. No bug, driveby fix, r=samantha the wonder dog
This commit is contained in:
parent
553915decf
commit
2d21b7a6d5
@ -274,18 +274,31 @@ function escapeString (str)
|
||||
}
|
||||
|
||||
/*
|
||||
* assertEq(actual, expected)
|
||||
* Throw if the two arguments are not ===
|
||||
* see https://bugzilla.mozilla.org/show_bug.cgi?id=480199
|
||||
* assertEq(actual, expected [, message])
|
||||
* Throw if the two arguments are not the same. The sameness of two values
|
||||
* is determined as follows. If both values are zero, they are the same iff
|
||||
* their signs are the same. Otherwise, if both values are NaN, they are the
|
||||
* same. Otherwise, they are the same if they compare equal using ===.
|
||||
* see https://bugzilla.mozilla.org/show_bug.cgi?id=480199 and
|
||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=515285
|
||||
*/
|
||||
if (typeof assertEq == 'undefined')
|
||||
{
|
||||
var assertEq =
|
||||
function (actual, expected)
|
||||
function (actual, expected, message)
|
||||
{
|
||||
if (actual !== expected)
|
||||
function SameValue(v1, v2)
|
||||
{
|
||||
throw new TypeError('Assertion failed: got "' + actual + '", expected "' + expected);
|
||||
if (v1 === 0 && v2 === 0)
|
||||
return 1 / v1 === 1 / v2;
|
||||
if (v1 !== v1 && v2 !== v2)
|
||||
return true;
|
||||
return v1 === v2;
|
||||
}
|
||||
if (!SameValue(actual, expected))
|
||||
{
|
||||
throw new TypeError('Assertion failed: got "' + actual + '", expected "' + expected +
|
||||
(message ? ": " + message : ""));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user