Skip to content

Ensure that extendDeepNoArrays includes typed arrays by reference #866

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

Merged
merged 4 commits into from
Aug 19, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reify that regular extendDeep doesn't deep-copy typed arrays
(cherry picked from commit 65aeac5)
  • Loading branch information
monfera committed Aug 19, 2016
commit 0948e58040e3d073d24981af117186ec6a7bb74f
16 changes: 16 additions & 0 deletions test/jasmine/tests/extend_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,20 @@ describe('array by reference vs deep-copy', function() {
expect(ext.foo.bop).toBe(tar.foo.bop);
});

it('extendDeep ALSO includes by reference typed arrays from source', function() {
var src = {foo: {bar: new Int32Array([1, 2, 3]), baz: new Float32Array([5, 4, 3])}};
var tar = {foo: {bar: new Int16Array([4, 5, 6]), bop: new Float64Array([8, 2, 1])}};
var ext = extendDeep(tar, src);

expect(ext).not.toBe(src);
expect(ext).toBe(tar);

expect(ext.foo).not.toBe(src.foo);
expect(ext.foo).toBe(tar.foo);

expect(ext.foo.bar).toBe(src.foo.bar);
expect(ext.foo.baz).toBe(src.foo.baz);
expect(ext.foo.bop).toBe(tar.foo.bop);
});

});