diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Object/assign/Override.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/assign/Override.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Object/assign/Override.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/assign/Override.js b/js/src/tests/test262/built-ins/Object/assign/Override.js new file mode 100644 index 0000000000..af125dcca7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/assign/Override.js @@ -0,0 +1,37 @@ +// 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). +esid: sec-object.assign +---*/ + +//"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.getOwnPropertyNames(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}."); + +reportCompare(0, 0); |