Debian Codegraph @

js/src/tests/test262/built-ins/Object/S9.9_A4.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: |
6 ToObject conversion from Number: create a new Number object
7 whose [[value]] property is set to the value of the number
8 es5id: 9.9_A4
9 description: Converting from various numbers to Object
10 ---*/
11 assert.sameValue(Object(0).valueOf(), 0, 'Object(0).valueOf() must return 0');
12 assert.sameValue(typeof Object(0), "object", 'The value of `typeof Object(0)` is expected to be "object"');
13
14 assert.sameValue(
15 Object(0).constructor.prototype,
16 Number.prototype,
17 'The value of Object(0).constructor.prototype is expected to equal the value of Number.prototype'
18 );
19
20 assert.sameValue(Object(-0).valueOf(), -0, 'Object(-0).valueOf() must return -0');
21 assert.sameValue(typeof Object(-0), "object", 'The value of `typeof Object(-0)` is expected to be "object"');
22
23 assert.sameValue(
24 Object(-0).constructor.prototype,
25 Number.prototype,
26 'The value of Object(-0).constructor.prototype is expected to equal the value of Number.prototype'
27 );
28
29 assert.sameValue(Object(1).valueOf(), 1, 'Object(1).valueOf() must return 1');
30 assert.sameValue(typeof Object(1), "object", 'The value of `typeof Object(1)` is expected to be "object"');
31
32 assert.sameValue(
33 Object(1).constructor.prototype,
34 Number.prototype,
35 'The value of Object(1).constructor.prototype is expected to equal the value of Number.prototype'
36 );
37
38 assert.sameValue(Object(-1).valueOf(), -1, 'Object(-1).valueOf() must return -1');
39 assert.sameValue(typeof Object(-1), "object", 'The value of `typeof Object(-1)` is expected to be "object"');
40
41 assert.sameValue(
42 Object(-1).constructor.prototype,
43 Number.prototype,
44 'The value of Object(-1).constructor.prototype is expected to equal the value of Number.prototype'
45 );
46
47 assert.sameValue(
48 Object(Number.MIN_VALUE).valueOf(),
49 Number.MIN_VALUE,
50 'Object(Number.MIN_VALUE).valueOf() returns Number.MIN_VALUE'
51 );
52
53 assert.sameValue(
54 typeof Object(Number.MIN_VALUE),
55 "object",
56 'The value of `typeof Object(Number.MIN_VALUE)` is expected to be "object"'
57 );
58
59 assert.sameValue(
60 Object(Number.MIN_VALUE).constructor.prototype,
61 Number.prototype,
62 'The value of Object(Number.MIN_VALUE).constructor.prototype is expected to equal the value of Number.prototype'
63 );
64
65 assert.sameValue(
66 Object(Number.MAX_VALUE).valueOf(),
67 Number.MAX_VALUE,
68 'Object(Number.MAX_VALUE).valueOf() returns Number.MAX_VALUE'
69 );
70
71 assert.sameValue(
72 typeof Object(Number.MAX_VALUE),
73 "object",
74 'The value of `typeof Object(Number.MAX_VALUE)` is expected to be "object"'
75 );
76
77 assert.sameValue(
78 Object(Number.MAX_VALUE).constructor.prototype,
79 Number.prototype,
80 'The value of Object(Number.MAX_VALUE).constructor.prototype is expected to equal the value of Number.prototype'
81 );
82
83 assert.sameValue(
84 Object(Number.POSITIVE_INFINITY).valueOf(),
85 Number.POSITIVE_INFINITY,
86 'Object(Number.POSITIVE_INFINITY).valueOf() returns Number.POSITIVE_INFINITY'
87 );
88
89 assert.sameValue(
90 typeof Object(Number.POSITIVE_INFINITY),
91 "object",
92 'The value of `typeof Object(Number.POSITIVE_INFINITY)` is expected to be "object"'
93 );
94
95 assert.sameValue(
96 Object(Number.POSITIVE_INFINITY).constructor.prototype,
97 Number.prototype,
98 'The value of Object(Number.POSITIVE_INFINITY).constructor.prototype is expected to equal the value of Number.prototype'
99 );
100
101 assert.sameValue(
102 Object(Number.NEGATIVE_INFINITY).valueOf(),
103 Number.NEGATIVE_INFINITY,
104 'Object(Number.NEGATIVE_INFINITY).valueOf() returns Number.NEGATIVE_INFINITY'
105 );
106
107 assert.sameValue(
108 typeof Object(Number.NEGATIVE_INFINITY),
109 "object",
110 'The value of `typeof Object(Number.NEGATIVE_INFINITY)` is expected to be "object"'
111 );
112
113 assert.sameValue(
114 Object(Number.NEGATIVE_INFINITY).constructor.prototype,
115 Number.prototype,
116 'The value of Object(Number.NEGATIVE_INFINITY).constructor.prototype is expected to equal the value of Number.prototype'
117 );
118
119 assert.sameValue(Object(NaN).valueOf(), NaN, 'Object(NaN).valueOf() returns NaN');
120
121 assert.sameValue(
122 typeof Object(Number.NaN),
123 "object",
124 'The value of `typeof Object(Number.NaN)` is expected to be "object"'
125 );
126
127 assert.sameValue(
128 Object(Number.NaN).constructor.prototype,
129 Number.prototype,
130 'The value of Object(Number.NaN).constructor.prototype is expected to equal the value of Number.prototype'
131 );
132
133 assert.sameValue(Object(1.2345).valueOf(), 1.2345, 'Object(1.2345).valueOf() must return 1.2345');
134 assert.sameValue(typeof Object(1.2345), "object", 'The value of `typeof Object(1.2345)` is expected to be "object"');
135
136 assert.sameValue(
137 Object(1.2345).constructor.prototype,
138 Number.prototype,
139 'The value of Object(1.2345).constructor.prototype is expected to equal the value of Number.prototype'
140 );
141
142 assert.sameValue(Object(-1.2345).valueOf(), -1.2345, 'Object(-1.2345).valueOf() must return -1.2345');
143 assert.sameValue(typeof Object(-1.2345), "object", 'The value of `typeof Object(-1.2345)` is expected to be "object"');
144
145 assert.sameValue(
146 Object(-1.2345).constructor.prototype,
147 Number.prototype,
148 'The value of Object(-1.2345).constructor.prototype is expected to equal the value of Number.prototype'
149 );
150
151 reportCompare(0, 0);