deepEqual should not infinitely recurse an infinite lazy getter chain #1325
Open
Description
Tell us about your runtime:
- QUnit version: 2.7.1
- What environment are you running QUnit in? (e.g., browser, Node): Browser
- How are you running QUnit? (e.g., script, testem, Grunt): Script
What are you trying to do?
Code that reproduces the problem:
https://jsfiddle.net/bzomqak8/11/
class Foo {
constructor(a = 1) {
this.a = a;
}
}
Object.defineProperty(Foo.prototype, 'b', {
enumerable: true,
get() {
return new Foo(this.a + 1);
}
})
QUnit.test("hello test", function(assert) {
assert.deepEqual(new Foo(), new Foo());
});
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 a computed
property instead of the code above, but the effect is the same.