Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
caub committed Sep 15, 2019
1 parent b506512 commit efb3913
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions spec/stackframe-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ describe('StackFrame', function() {
};
expect(fn).toThrow();
});

it('works with objects with null prototype', function() {
var obj = Object.create(null);
obj.fileName = 'foo.js';
obj.functionName = 'foo';
obj.lineNumber = 1;
obj.columnNumber = 42
var sf = new StackFrame(obj);

expect(sf.fileName).toEqual('foo.js');
});
});

describe('#setFunctionName', function() {
Expand Down
3 changes: 2 additions & 1 deletion stackframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
var props = booleanProps.concat(numericProps, stringProps, arrayProps);

function StackFrame(obj) {
if (!obj) return;
for (var i = 0; i < props.length; i++) {
if (obj && obj[props[i]] !== undefined) {
if (obj[props[i]] !== undefined) {
this['set' + _capitalize(props[i])](obj[props[i]]);
}
}
Expand Down

0 comments on commit efb3913

Please sign in to comment.