diff --git a/test/built-ins/Object/assign/ObjectOverride-sameproperty.js b/test/built-ins/Object/assign/ObjectOverride-sameproperty.js new file mode 100644 index 0000000000..1527a27049 --- /dev/null +++ b/test/built-ins/Object/assign/ObjectOverride-sameproperty.js @@ -0,0 +1,13 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*-- +description: Object properties are assigned to target in ascending index order, + i.e. a later assignment to the same property overrides an earlier assignment. +es6id: 19.1.2.1 +--*/ + +var target = {a: 1}; +var result = Object.assign(target,{a:2},{a:"c"}); + +assert.sameValue(result.a, "c", "The value should be 'c'."); diff --git a/test/built-ins/Object/assign/OnlyOneArgument.js b/test/built-ins/Object/assign/OnlyOneArgument.js new file mode 100644 index 0000000000..9131e1146a --- /dev/null +++ b/test/built-ins/Object/assign/OnlyOneArgument.js @@ -0,0 +1,13 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: test Object.Assign(target,...sources),only one argument was passed, + return ToObject(target) +es6id: 19.1.2.1.3 +---*/ + +var target = "a"; +var result = Object.assign(target); + +assert.sameValue(result.valueOf(), "a", "The value should be 'a'."); diff --git a/test/built-ins/Object/assign/Override-notstringtarget.js b/test/built-ins/Object/assign/Override-notstringtarget.js new file mode 100644 index 0000000000..49ade3cb54 --- /dev/null +++ b/test/built-ins/Object/assign/Override-notstringtarget.js @@ -0,0 +1,17 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Test override of Object.Assign(target,...sources), + Every string from sources will be wrapped to objects, and override from the first letter(result[0]) all the time +es6id: 19.1.2.1 +---*/ + +var target = 12; +var result = Object.assign(target,"aaa","bb2b","1c"); + +assert.sameValue(Object.keys(result).length, 4 , "The length should be 4 in the final object."); +assert.sameValue(result[0], "1", "The value should be {\"0\":\"1\"}."); +assert.sameValue(result[1], "c", "The value should be {\"1\":\"c\"}."); +assert.sameValue(result[2], "2", "The value should be {\"2\":\"2\"}."); +assert.sameValue(result[3], "b", "The value should be {\"3\":\"b\"}."); diff --git a/test/built-ins/Object/assign/Override.js b/test/built-ins/Object/assign/Override.js new file mode 100644 index 0000000000..0a7d694385 --- /dev/null +++ b/test/built-ins/Object/assign/Override.js @@ -0,0 +1,27 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Test Object.Assign(target,...sources). +es6id: 19.1.2.1.5.c +---*/ + +//"a" will be an property of the final object and the value should be 1 +var target = {a:1}; +/*--- +"1a2c3" have own enumerable properties, so it Should be wrapped to objects; +{b:6} is an object,should be assigned to final object. +undefined and null should be ignored; +125 is a number,it cannot has own enumerable properties; +{a:"c"},{a:5} will override property a, the value should be 5. +---*/ +var result = Object.assign(target,"1a2c3",{a:"c"},undefined,{b:6},null,125,{a:5}); + +assert.sameValue(Object.keys(result).length, 7 , "The length should be 7 in the final object."); +assert.sameValue(result.a, 5, "The value should be {a:5}."); +assert.sameValue(result[0], "1", "The value should be {\"0\":\"1\"}."); +assert.sameValue(result[1], "a", "The value should be {\"1\":\"a\"}."); +assert.sameValue(result[2], "2", "The value should be {\"2\":\"2\"}."); +assert.sameValue(result[3], "c", "The value should be {\"3\":\"c\"}."); +assert.sameValue(result[4], "3", "The value should be {\"4\":\"3\"}."); +assert.sameValue(result.b, 6, "The value should be {b:6}."); diff --git a/test/built-ins/Object/assign/Source-Null-Undefined.js b/test/built-ins/Object/assign/Source-Null-Undefined.js new file mode 100644 index 0000000000..881768a977 --- /dev/null +++ b/test/built-ins/Object/assign/Source-Null-Undefined.js @@ -0,0 +1,12 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: null and undefined source should be ignored,result should be original object. +es6id: 19.1.2.1.5.a +---*/ + +var target = new Object(); +var result = Object.assign(target,undefined,null); + +assert.sameValue(result, target, "null and undefined should be ignored, result should be original object."); diff --git a/test/built-ins/Object/assign/Source-Number-Boolen-Symbol.js b/test/built-ins/Object/assign/Source-Number-Boolen-Symbol.js new file mode 100644 index 0000000000..3a00c7d9a5 --- /dev/null +++ b/test/built-ins/Object/assign/Source-Number-Boolen-Symbol.js @@ -0,0 +1,13 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*-- +description: Number,Boolean,Symbol cannot have own enumerable properties, + So cannot be Assigned.Here result should be original object. +es6id: 19.1.2.1.5.c +--*/ + +var target = new Object(); +var result = Object.assign(target,123,true,Symbol('foo')); + +assert.sameValue(result, target, "Numbers, booleans, and symbols cannot have wrappers with own enumerable properties."); diff --git a/test/built-ins/Object/assign/Source-String.js b/test/built-ins/Object/assign/Source-String.js new file mode 100644 index 0000000000..3516cefa29 --- /dev/null +++ b/test/built-ins/Object/assign/Source-String.js @@ -0,0 +1,14 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Test Object.Assign(target,...sources), string have own enumerable properties, so it can be wrapped to objects. +es6id: 19.1.2.1.5.c +---*/ + +var target = new Object(); +var result = Object.assign(target,"123"); + +assert.sameValue(result[0], "1", "The value should be {\"0\":\"1\"}."); +assert.sameValue(result[1], "2", "The value should be {\"1\":\"2\"}."); +assert.sameValue(result[2], "3", "The value should be {\"2\":\"3\"}."); diff --git a/test/built-ins/Object/assign/Target-Boolean.js b/test/built-ins/Object/assign/Target-Boolean.js new file mode 100644 index 0000000000..d41c4ba5d0 --- /dev/null +++ b/test/built-ins/Object/assign/Target-Boolean.js @@ -0,0 +1,12 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Test the first argument(target) of Object.Assign(target,...sources), + if target is Boolean,the return value should be a new object whose value is target. +es6id: 19.1.2.1.1 +---*/ + +var result = Object.assign(true,{a:1}); +assert.sameValue(typeof result, "object", "Return value should be an object."); +assert.sameValue(result.valueOf(), true, "Return value should be true."); diff --git a/test/built-ins/Object/assign/Target-Null.js b/test/built-ins/Object/assign/Target-Null.js new file mode 100644 index 0000000000..d5eb7803e3 --- /dev/null +++ b/test/built-ins/Object/assign/Target-Null.js @@ -0,0 +1,10 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Test the first argument(target) of Object.Assign(target,...sources), + if target is null,Should Throw a TypeError exception. +es6id: 19.1.2.1.1 +---*/ + +assert.throws(TypeError, function(){Object.assign(null, {a:1});}); diff --git a/test/built-ins/Object/assign/Target-Number.js b/test/built-ins/Object/assign/Target-Number.js new file mode 100644 index 0000000000..0971ca3d10 --- /dev/null +++ b/test/built-ins/Object/assign/Target-Number.js @@ -0,0 +1,12 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Test the first argument(target) of Object.Assign(target,...sources), + if target is Number,the return value should be a new object whose value is target. +es6id: 19.1.2.1.1 +---*/ + +var result = Object.assign(1,{a:1}); +assert.sameValue(typeof result, "object", "Return value should be an object."); +assert.sameValue(result.valueOf(), 1, "Return value should be 1."); diff --git a/test/built-ins/Object/assign/Target-Object.js b/test/built-ins/Object/assign/Target-Object.js new file mode 100644 index 0000000000..d3ba7da0f8 --- /dev/null +++ b/test/built-ins/Object/assign/Target-Object.js @@ -0,0 +1,14 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Test the first argument(target) of Object.Assign(target,...sources), + if target is Object,its properties will be the properties of new object. +es6id: 19.1.2.1.1 +---*/ + +var target = {foo: 1}; +var result = Object.assign(target,{a:2}); + +assert.sameValue(result.foo, 1, "The value should be {foo: 1}."); +assert.sameValue(result.a, 2, "The value should be {a: 2}."); diff --git a/test/built-ins/Object/assign/Target-String.js b/test/built-ins/Object/assign/Target-String.js new file mode 100644 index 0000000000..2adecfb31f --- /dev/null +++ b/test/built-ins/Object/assign/Target-String.js @@ -0,0 +1,12 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Test the first argument(target) of Object.Assign(target,...sources), + if target is String,the return value should be a new object whose value is target. +es6id: 19.1.2.1.1 +---*/ + +var result = Object.assign("test",{a:1}); +assert.sameValue(typeof result, "object", "Return value should be an object."); +assert.sameValue(result.valueOf(), "test", "Return value should be 'test'."); diff --git a/test/built-ins/Object/assign/Target-Symbol.js b/test/built-ins/Object/assign/Target-Symbol.js new file mode 100644 index 0000000000..ef1335a425 --- /dev/null +++ b/test/built-ins/Object/assign/Target-Symbol.js @@ -0,0 +1,14 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Test the first argument(target) of Object.Assign(target,...sources), + if target is Symbol,the return value should be a new Symbol object whose [[SymbolData]] value is target. +es6id: 19.1.2.1.1 +---*/ + +var target = Symbol('foo'); +var result = Object.assign(target,{a:1}); + +assert.sameValue(typeof result, "object", "Return value should be a symbol object."); +assert.sameValue(result.toString(), "Symbol(foo)", "Return value should be 'Symbol(foo)'."); diff --git a/test/built-ins/Object/assign/Target-Undefined.js b/test/built-ins/Object/assign/Target-Undefined.js new file mode 100644 index 0000000000..9df5bee105 --- /dev/null +++ b/test/built-ins/Object/assign/Target-Undefined.js @@ -0,0 +1,10 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Test the first argument(target) of Object.Assign(target,...sources), + if target is Undefined,Should Throw a TypeError exception. +es6id: 19.1.2.1.1 +---*/ + +assert.throws(TypeError, function(){Object.assign(undefined, {a:1});}); diff --git a/test/built-ins/Object/assign/assign-descriptor.js b/test/built-ins/Object/assign/assign-descriptor.js new file mode 100644 index 0000000000..d0d73ea425 --- /dev/null +++ b/test/built-ins/Object/assign/assign-descriptor.js @@ -0,0 +1,13 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Testing descriptor property of Object.assign +includes: + - propertyHelper.js +es6id: 19.1.2.1 +---*/ + +verifyWritable(Object, "assign"); +verifyNotEnumerable(Object, "assign"); +verifyConfigurable(Object, "assign"); diff --git a/test/built-ins/Object/assign/assign-length.js b/test/built-ins/Object/assign/assign-length.js new file mode 100644 index 0000000000..b49b0a7149 --- /dev/null +++ b/test/built-ins/Object/assign/assign-length.js @@ -0,0 +1,9 @@ +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: The length property of the assign method should be 2 +es6id: 19.1.2.1 +---*/ + +assert.sameValue(Object.assign.length, 2, "The length property of the assign method should be 2.");