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/non262/object/15.2.3.14-01.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/non262/object/15.2.3.14-01.js')
-rw-r--r-- | js/src/tests/non262/object/15.2.3.14-01.js | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/js/src/tests/non262/object/15.2.3.14-01.js b/js/src/tests/non262/object/15.2.3.14-01.js new file mode 100644 index 0000000000..6cb8965a6c --- /dev/null +++ b/js/src/tests/non262/object/15.2.3.14-01.js @@ -0,0 +1,92 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 307791; +var summary = 'ES5 Object.keys(O)'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +function arraysEqual(a1, a2) +{ + return a1.length === a2.length && + a1.every(function(v, i) { return v === a2[i]; }); +} + +/************** + * BEGIN TEST * + **************/ + +assertEq(Object.keys.length, 1); + +var o, keys; + +o = { a: 3, b: 2 }; +keys = Object.keys(o); +assertEq(arraysEqual(keys, ["a", "b"]), true, + "" + keys); + +o = { get a() { return 17; }, b: 2 }; +keys = Object.keys(o), +assertEq(arraysEqual(keys, ["a", "b"]), true, + "" + keys); + +o = { __iterator__: function() { throw new Error("non-standard __iterator__ called?"); } }; +keys = Object.keys(o); +assertEq(arraysEqual(keys, ["__iterator__"]), true, + "" + keys); + +o = { a: 1, b: 2 }; +delete o.a; +o.a = 3; +keys = Object.keys(o); +assertEq(arraysEqual(keys, ["b", "a"]), true, + "" + keys); + +o = [0, 1, 2]; +keys = Object.keys(o); +assertEq(arraysEqual(keys, ["0", "1", "2"]), true, + "" + keys); + +o = /./.exec("abc"); +keys = Object.keys(o); +assertEq(arraysEqual(keys, ["0", "index", "input", "groups"]), true, + "" + keys); + +o = { a: 1, b: 2, c: 3 }; +delete o.b; +o.b = 5; +keys = Object.keys(o); +assertEq(arraysEqual(keys, ["a", "c", "b"]), true, + "" + keys); + +function f() { } +f.prototype.p = 1; +o = new f(); +o.g = 1; +keys = Object.keys(o); +assertEq(arraysEqual(keys, ["g"]), true, + "" + keys); + +if (typeof Namespace !== "undefined" && typeof QName !== "undefined") +{ + var o2 = {}; + var qn = new QName(new Namespace("foo"), "v"); + o2.f = 1; + o2[qn] = 3; + o2.baz = 4; + var keys2 = Object.keys(o2); + assertEq(arraysEqual(keys2, ["f", "foo::v", "baz"]), true, + "" + keys2); +} + +/******************************************************************************/ + +reportCompare(expect, actual, "Object.keys"); + +printStatus("All tests passed!"); |