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/S9.9_A4.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/S9.9_A4.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Object/S9.9_A4.js | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/S9.9_A4.js b/js/src/tests/test262/built-ins/Object/S9.9_A4.js new file mode 100644 index 0000000000..495c21b43a --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/S9.9_A4.js @@ -0,0 +1,151 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + ToObject conversion from Number: create a new Number object + whose [[value]] property is set to the value of the number +es5id: 9.9_A4 +description: Converting from various numbers to Object +---*/ +assert.sameValue(Object(0).valueOf(), 0, 'Object(0).valueOf() must return 0'); +assert.sameValue(typeof Object(0), "object", 'The value of `typeof Object(0)` is expected to be "object"'); + +assert.sameValue( + Object(0).constructor.prototype, + Number.prototype, + 'The value of Object(0).constructor.prototype is expected to equal the value of Number.prototype' +); + +assert.sameValue(Object(-0).valueOf(), -0, 'Object(-0).valueOf() must return -0'); +assert.sameValue(typeof Object(-0), "object", 'The value of `typeof Object(-0)` is expected to be "object"'); + +assert.sameValue( + Object(-0).constructor.prototype, + Number.prototype, + 'The value of Object(-0).constructor.prototype is expected to equal the value of Number.prototype' +); + +assert.sameValue(Object(1).valueOf(), 1, 'Object(1).valueOf() must return 1'); +assert.sameValue(typeof Object(1), "object", 'The value of `typeof Object(1)` is expected to be "object"'); + +assert.sameValue( + Object(1).constructor.prototype, + Number.prototype, + 'The value of Object(1).constructor.prototype is expected to equal the value of Number.prototype' +); + +assert.sameValue(Object(-1).valueOf(), -1, 'Object(-1).valueOf() must return -1'); +assert.sameValue(typeof Object(-1), "object", 'The value of `typeof Object(-1)` is expected to be "object"'); + +assert.sameValue( + Object(-1).constructor.prototype, + Number.prototype, + 'The value of Object(-1).constructor.prototype is expected to equal the value of Number.prototype' +); + +assert.sameValue( + Object(Number.MIN_VALUE).valueOf(), + Number.MIN_VALUE, + 'Object(Number.MIN_VALUE).valueOf() returns Number.MIN_VALUE' +); + +assert.sameValue( + typeof Object(Number.MIN_VALUE), + "object", + 'The value of `typeof Object(Number.MIN_VALUE)` is expected to be "object"' +); + +assert.sameValue( + Object(Number.MIN_VALUE).constructor.prototype, + Number.prototype, + 'The value of Object(Number.MIN_VALUE).constructor.prototype is expected to equal the value of Number.prototype' +); + +assert.sameValue( + Object(Number.MAX_VALUE).valueOf(), + Number.MAX_VALUE, + 'Object(Number.MAX_VALUE).valueOf() returns Number.MAX_VALUE' +); + +assert.sameValue( + typeof Object(Number.MAX_VALUE), + "object", + 'The value of `typeof Object(Number.MAX_VALUE)` is expected to be "object"' +); + +assert.sameValue( + Object(Number.MAX_VALUE).constructor.prototype, + Number.prototype, + 'The value of Object(Number.MAX_VALUE).constructor.prototype is expected to equal the value of Number.prototype' +); + +assert.sameValue( + Object(Number.POSITIVE_INFINITY).valueOf(), + Number.POSITIVE_INFINITY, + 'Object(Number.POSITIVE_INFINITY).valueOf() returns Number.POSITIVE_INFINITY' +); + +assert.sameValue( + typeof Object(Number.POSITIVE_INFINITY), + "object", + 'The value of `typeof Object(Number.POSITIVE_INFINITY)` is expected to be "object"' +); + +assert.sameValue( + Object(Number.POSITIVE_INFINITY).constructor.prototype, + Number.prototype, + 'The value of Object(Number.POSITIVE_INFINITY).constructor.prototype is expected to equal the value of Number.prototype' +); + +assert.sameValue( + Object(Number.NEGATIVE_INFINITY).valueOf(), + Number.NEGATIVE_INFINITY, + 'Object(Number.NEGATIVE_INFINITY).valueOf() returns Number.NEGATIVE_INFINITY' +); + +assert.sameValue( + typeof Object(Number.NEGATIVE_INFINITY), + "object", + 'The value of `typeof Object(Number.NEGATIVE_INFINITY)` is expected to be "object"' +); + +assert.sameValue( + Object(Number.NEGATIVE_INFINITY).constructor.prototype, + Number.prototype, + 'The value of Object(Number.NEGATIVE_INFINITY).constructor.prototype is expected to equal the value of Number.prototype' +); + +assert.sameValue(Object(NaN).valueOf(), NaN, 'Object(NaN).valueOf() returns NaN'); + +assert.sameValue( + typeof Object(Number.NaN), + "object", + 'The value of `typeof Object(Number.NaN)` is expected to be "object"' +); + +assert.sameValue( + Object(Number.NaN).constructor.prototype, + Number.prototype, + 'The value of Object(Number.NaN).constructor.prototype is expected to equal the value of Number.prototype' +); + +assert.sameValue(Object(1.2345).valueOf(), 1.2345, 'Object(1.2345).valueOf() must return 1.2345'); +assert.sameValue(typeof Object(1.2345), "object", 'The value of `typeof Object(1.2345)` is expected to be "object"'); + +assert.sameValue( + Object(1.2345).constructor.prototype, + Number.prototype, + 'The value of Object(1.2345).constructor.prototype is expected to equal the value of Number.prototype' +); + +assert.sameValue(Object(-1.2345).valueOf(), -1.2345, 'Object(-1.2345).valueOf() must return -1.2345'); +assert.sameValue(typeof Object(-1.2345), "object", 'The value of `typeof Object(-1.2345)` is expected to be "object"'); + +assert.sameValue( + Object(-1.2345).constructor.prototype, + Number.prototype, + 'The value of Object(-1.2345).constructor.prototype is expected to equal the value of Number.prototype' +); + +reportCompare(0, 0); |