Skip to content

Commit

Permalink
Add failing test for #2215
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig authored and mroderick committed Feb 19, 2020
1 parent 10a9182 commit 8c8336c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/util/core/function-to-string-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,32 @@ describe("util/core/functionToString", function() {

assert.equals(functionToString.call(obj.doStuff), "doStuff");
});

// https://github.com/sinonjs/sinon/issues/2215
it("ignores errors thrown by property accessors on thisValue", function() {
var obj = {};

Object.defineProperty(obj, "foo", {
enumerable: true,
get: function() {
throw new Error();
}
});

// this will cause `fn` to be after `foo` when enumerated
obj.fn = function() {
return "foo";
};

// validate that the keys are in the expected order that will cause the bug
var keys = Object.keys(obj);
assert.equals(keys[0], "foo");
assert.equals(keys[1], "fn");

var spy = createSpy(obj, "fn");

obj.fn();

assert.equals(spy.toString(), "fn");
});
});

0 comments on commit 8c8336c

Please sign in to comment.