Bug 792108 - Add more truthiness tests to ensure strict equality isn't affected by JSCLASS_EMULATES_UNDEFINED, and that falsy objects don't compare equal unless they're actually the same object. Just tests, they pass locally for me with the --tbpl driver option to do what Tinderbox does, r=sparky

This commit is contained in:
Jeff Walden 2012-12-18 17:01:46 -05:00
Родитель b41f629fc2
Коммит 9807c3a6de
10 изменённых файлов: 378 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,46 @@
var counterF = 0;
function f(v, value)
{
if (v === null)
counterF++;
assertEq(counterF, value,
"failed: " + v + " " + value);
}
f({}, 0);
f({}, 0);
f(null, 1);
f(null, 2);
f(undefined, 2);
f(undefined, 2);
f(objectEmulatingUndefined(), 2);
f(objectEmulatingUndefined(), 2);
f(Object.prototype, 2);
f(Object.prototype, 2);
var counterG = 0;
function g(v, value)
{
if (v === null)
counterG++;
assertEq(counterG, value,
"failed: " + v + " " + value);
}
g({}, 0);
g({}, 0);
var counterH = 0;
function h(v, value)
{
if (v === null)
counterH++;
assertEq(counterH, value,
"failed: " + v + " " + value);
}
h(objectEmulatingUndefined(), 0);
h(objectEmulatingUndefined(), 0);

Просмотреть файл

@ -0,0 +1,46 @@
var counterF = 0;
function f(v, value)
{
if (v === undefined)
counterF++;
assertEq(counterF, value,
"failed: " + v + " " + value);
}
f({}, 0);
f({}, 0);
f(null, 0);
f(null, 0);
f(undefined, 1);
f(undefined, 2);
f(objectEmulatingUndefined(), 2);
f(objectEmulatingUndefined(), 2);
f(Object.prototype, 2);
f(Object.prototype, 2);
var counterG = 0;
function g(v, value)
{
if (v === undefined)
counterG++;
assertEq(counterG, value,
"failed: " + v + " " + value);
}
g({}, 0);
g({}, 0);
var counterH = 0;
function h(v, value)
{
if (v === undefined)
counterH++;
assertEq(counterH, value,
"failed: " + v + " " + value);
}
h(objectEmulatingUndefined(), 0);
h(objectEmulatingUndefined(), 0);

Просмотреть файл

@ -0,0 +1,46 @@
var counterF = 0;
function f(v, value)
{
if (v !== null)
counterF++;
assertEq(counterF, value,
"failed: " + v + " " + value);
}
f({}, 1);
f({}, 2);
f(null, 2);
f(null, 2);
f(undefined, 3);
f(undefined, 4);
f(objectEmulatingUndefined(), 5);
f(objectEmulatingUndefined(), 6);
f(Object.prototype, 7);
f(Object.prototype, 8);
var counterG = 0;
function g(v, value)
{
if (v !== null)
counterG++;
assertEq(counterG, value,
"failed: " + v + " " + value);
}
g({}, 1);
g({}, 2);
var counterH = 0;
function h(v, value)
{
if (v !== null)
counterH++;
assertEq(counterH, value,
"failed: " + v + " " + value);
}
h(objectEmulatingUndefined(), 1);
h(objectEmulatingUndefined(), 2);

Просмотреть файл

@ -0,0 +1,46 @@
var counterF = 0;
function f(v, value)
{
if (v !== undefined)
counterF++;
assertEq(counterF, value,
"failed: " + v + " " + value);
}
f({}, 1);
f({}, 2);
f(null, 3);
f(null, 4);
f(undefined, 4);
f(undefined, 4);
f(objectEmulatingUndefined(), 5);
f(objectEmulatingUndefined(), 6);
f(Object.prototype, 7);
f(Object.prototype, 8);
var counterG = 0;
function g(v, value)
{
if (v !== undefined)
counterG++;
assertEq(counterG, value,
"failed: " + v + " " + value);
}
g({}, 1);
g({}, 2);
var counterH = 0;
function h(v, value)
{
if (v !== undefined)
counterH++;
assertEq(counterH, value,
"failed: " + v + " " + value);
}
h(objectEmulatingUndefined(), 1);
h(objectEmulatingUndefined(), 2);

Просмотреть файл

@ -0,0 +1,23 @@
function f(v1, v2, value)
{
var b = v1 == v2;
assertEq(b, value,
"failed: " + v1 + ", " + v2 + ": " + value);
}
var obj = {};
var emul = objectEmulatingUndefined();
f(obj, obj, true);
f(obj, obj, true);
f(emul, obj, false);
f(emul, obj, false);
f(obj, emul, false);
f(obj, emul, false);
f(Object.prototype, obj, false);
f(Object.prototype, obj, false);
f(emul, emul, true);
f(objectEmulatingUndefined(), emul, false);
f(objectEmulatingUndefined(), emul, false);
f(emul, objectEmulatingUndefined(), false);
f(emul, objectEmulatingUndefined(), false);

Просмотреть файл

@ -0,0 +1,23 @@
function f(v1, v2, value)
{
var b = v1 != v2;
assertEq(b, value,
"failed: " + v1 + ", " + v2 + ": " + value);
}
var obj = {};
var emul = objectEmulatingUndefined();
f(obj, obj, false);
f(obj, obj, false);
f(emul, obj, true);
f(emul, obj, true);
f(obj, emul, true);
f(obj, emul, true);
f(Object.prototype, obj, true);
f(Object.prototype, obj, true);
f(emul, emul, false);
f(objectEmulatingUndefined(), emul, true);
f(objectEmulatingUndefined(), emul, true);
f(emul, objectEmulatingUndefined(), true);
f(emul, objectEmulatingUndefined(), true);

Просмотреть файл

@ -0,0 +1,37 @@
function f(v, value)
{
var b = v === null;
assertEq(b, value,
"failed: " + v + " " + value);
}
f({}, false);
f({}, false);
f(null, true);
f(null, true);
f(undefined, false);
f(undefined, false);
f(objectEmulatingUndefined(), false);
f(objectEmulatingUndefined(), false);
f(Object.prototype, false);
f(Object.prototype, false);
function g(v, value)
{
var b = v === null;
assertEq(b, value,
"failed: " + v + " " + value);
}
g({}, false);
g({}, false);
function h(v, value)
{
var b = v === null;
assertEq(b, value,
"failed: " + v + " " + value);
}
h(objectEmulatingUndefined(), false);
h(objectEmulatingUndefined(), false);

Просмотреть файл

@ -0,0 +1,37 @@
function f(v, value)
{
var b = v === undefined;
assertEq(b, value,
"failed: " + v + " " + value);
}
f({}, false);
f({}, false);
f(null, false);
f(null, false);
f(undefined, true);
f(undefined, true);
f(objectEmulatingUndefined(), false);
f(objectEmulatingUndefined(), false);
f(Object.prototype, false);
f(Object.prototype, false);
function g(v, value)
{
var b = v === undefined;
assertEq(b, value,
"failed: " + v + " " + value);
}
g({}, false);
g({}, false);
function h(v, value)
{
var b = v === undefined;
assertEq(b, value,
"failed: " + v + " " + value);
}
h(objectEmulatingUndefined(), false);
h(objectEmulatingUndefined(), false);

Просмотреть файл

@ -0,0 +1,37 @@
function f(v, value)
{
var b = v !== null;
assertEq(b, value,
"failed: " + v + " " + value);
}
f({}, true);
f({}, true);
f(null, false);
f(null, false);
f(undefined, true);
f(undefined, true);
f(objectEmulatingUndefined(), true);
f(objectEmulatingUndefined(), true);
f(Object.prototype, true);
f(Object.prototype, true);
function g(v, value)
{
var b = v !== null;
assertEq(b, value,
"failed: " + v + " " + value);
}
g({}, true);
g({}, true);
function h(v, value)
{
var b = v !== null;
assertEq(b, value,
"failed: " + v + " " + value);
}
h(objectEmulatingUndefined(), true);
h(objectEmulatingUndefined(), true);

Просмотреть файл

@ -0,0 +1,37 @@
function f(v, value)
{
var b = v !== undefined;
assertEq(b, value,
"failed: " + v + " " + value);
}
f({}, true);
f({}, true);
f(null, true);
f(null, true);
f(undefined, false);
f(undefined, false);
f(objectEmulatingUndefined(), true);
f(objectEmulatingUndefined(), true);
f(Object.prototype, true);
f(Object.prototype, true);
function g(v, value)
{
var b = v !== undefined;
assertEq(b, value,
"failed: " + v + " " + value);
}
g({}, true);
g({}, true);
function h(v, value)
{
var b = v !== undefined;
assertEq(b, value,
"failed: " + v + " " + value);
}
h(objectEmulatingUndefined(), true);
h(objectEmulatingUndefined(), true);