summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/S9.9_A4.js
blob: 495c21b43a8856fe1de0f3b425148298b2baf3c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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);