I found a case where there is inifinite recursion with QUnit.same and a patch:
test('qunit same', function(){
var top = {owner:null, parent:null, children:[], type:1};
var a = {owner:top, parent:top, children:[], type:2};
var b = {owner:top, parent:top, children:[], type:2};
var c = {owner:top, parent:a, children:[], type:3};
var d = {owner:top, parent:b, children:[], type:4};
top.children.push(a, b);
a.children.push(c);
b.children.push(d);
//prevent jsDump stack overflow
QUnit.jsDump.parse=function(thing){return thing+'';};
//this will cause its own overflow
same(a, b, 'will this ever return?');
//This will cause a stack overflow
//QUnit.jsDump.parse(a);
});
The reason is beuase in innerEquiv
if (a === b) {
return true; // catch the most you can
} else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || hoozit(a) !== hoozit(b)) {
return false; // don't lose time with error prone cases
} else {
return bindCallbacks(a, callbacks, [b, a]);
}
when a and b are 'type' with respective values the bindCallbacks return false but:
in QUnit.equiv callback for 'object' we see
for (i in a) { // be strict: don't ensures hasOwnProperty and go deep
aProperties.push(i); // collect a's properties
if ( ! innerEquiv(a[i], b[i])) {
eq = false;
//why bother continue? should break;
}
}
The one line patch to break; under eq = false; fixes the issue for me and Envjs can run through jQuery 1.4.1 tests.
Thatcher