-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deepEqual should not infinitely recurse an infinite lazy getter chain #1325
Comments
Should be fixed by #1326. |
Per #1326, I don't think is is feasible for QUnit to solve the problem of predicting whether infinite getter chains will be considered equivalent by some definition. @gibson042 pointed there to #1327, and indeed an QUnit assertion plugin could work here. Having said that, I do think that this ticket still represents a bug we should solve. Namely that QUnit should not infinitely recurse or timeout without some meaningful feedback. Two ideas come to mind, not mutually exclusive:
|
For comparison to Node.js, the following passes on Node.js 10 and Node.js 16: class Foo {
constructor(a = 1) {
this.a = a;
}
}
Object.defineProperty(Foo.prototype, 'b', {
enumerable: true,
get() {
return new Foo(Math.random());
}
});
const assert = require('assert');
assert.deepEqual(new Foo(), new Foo()); |
Sure, but Node.js |
Counter-example, unaffected by the lack of prototype comparison in Node.js' assert module: Ostensibly equal (non-random): class Foo {
constructor(a = 1) {
this.a = a;
Object.defineProperty(this, 'b', {
enumerable: true,
get() {
return new Foo(a + 1);
}
});
}
}
const assert = require('assert');
assert.deepEqual(new Foo(), new Foo());
Ostensibly non-equal (random): class Foo {
constructor(a = 1) {
this.a = a;
Object.defineProperty(this, 'b', {
enumerable: true,
get() {
return new Foo(Math.random());
}
});
}
}
const assert = require('assert');
assert.deepEqual(new Foo(), new Foo());
|
Tell us about your runtime:
What are you trying to do?
Code that reproduces the problem:
https://jsfiddle.net/bzomqak8/11/
If you have any relevant configuration information, please include that here:
What did you expect to happen?
I expected QUnit to not compare computed properties.
What actually happened?
QUnit compares computed properties by using a
for..in
loop which (due to BFS) recurses infinitely without ever hitting a stack limit.This is a minimal reproduction extracted from one of our Ember apps. In the actual app we use an
Ember.Object
and acomputed
property instead of the code above, but the effect is the same.The text was updated successfully, but these errors were encountered: