aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Waldron <waldron.rick@gmail.com>2013-02-03 12:51:54 -0500
committerRick Waldron <waldron.rick@gmail.com>2013-02-03 12:52:08 -0500
commited0e2d1e8a5005a80d0dd127dc4019f696471ad6 (patch)
tree3073bc94039bcf3d61b52debd7976898b4cbee19
parentd12b26ced63e1593b1ffd84c6d95113126bf1d66 (diff)
downloadjquery-ed0e2d1e8a5005a80d0dd127dc4019f696471ad6.tar.gz
jquery-ed0e2d1e8a5005a80d0dd127dc4019f696471ad6.zip
Adds test for jQuery.extend deep copy with array, followed by object. Refutes and Closes #1154
-rw-r--r--test/unit/core.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/unit/core.js b/test/unit/core.js
index 141792110..3fe3a2301 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -1019,6 +1019,27 @@ test("jQuery.extend(Object, Object)", function() {
deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" );
});
+test("jQuery.extend(true,{},{a:[], o:{}}); deep copy with array, followed by object", function() {
+ expect(2);
+
+ var result, initial = {
+ // This will make "copyIsArray" true
+ array: [ 1, 2, 3, 4 ],
+ // If "copyIsArray" doesn't get reset to false, the check
+ // will evaluate true and enter the array copy block
+ // instead of the object copy block. Since the ternary in the
+ // "copyIsArray" block will will evaluate to false
+ // (check if operating on an array with ), this will be
+ // replaced by an empty array.
+ object: {}
+ };
+
+ result = jQuery.extend( true, {}, initial );
+
+ deepEqual( result, initial, "The [result] and [initial] have equal shape and values" );
+ ok( !jQuery.isArray( result.object ), "result.object wasn't paved with an empty array" );
+});
+
test("jQuery.each(Object,Function)", function() {
expect( 23 );