Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0948e58

Browse files
committed
Reify that regular extendDeep doesn't deep-copy typed arrays
(cherry picked from commit 65aeac5)
1 parent 1466f35 commit 0948e58

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/jasmine/tests/extend_test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,20 @@ describe('array by reference vs deep-copy', function() {
505505
expect(ext.foo.bop).toBe(tar.foo.bop);
506506
});
507507

508+
it('extendDeep ALSO includes by reference typed arrays from source', function() {
509+
var src = {foo: {bar: new Int32Array([1, 2, 3]), baz: new Float32Array([5, 4, 3])}};
510+
var tar = {foo: {bar: new Int16Array([4, 5, 6]), bop: new Float64Array([8, 2, 1])}};
511+
var ext = extendDeep(tar, src);
512+
513+
expect(ext).not.toBe(src);
514+
expect(ext).toBe(tar);
515+
516+
expect(ext.foo).not.toBe(src.foo);
517+
expect(ext.foo).toBe(tar.foo);
518+
519+
expect(ext.foo.bar).toBe(src.foo.bar);
520+
expect(ext.foo.baz).toBe(src.foo.baz);
521+
expect(ext.foo.bop).toBe(tar.foo.bop);
522+
});
523+
508524
});

0 commit comments

Comments
 (0)