|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 File Name: 15.8.2.6.js |
|
9 ECMA Section: 15.8.2.6 Math.ceil(x) |
|
10 Description: return the smallest number value that is not less than the |
|
11 argument and is equal to a mathematical integer. if the |
|
12 number is already an integer, return the number itself. |
|
13 special cases: |
|
14 - if x is NaN return NaN |
|
15 - if x = +0 return +0 |
|
16 - if x = 0 return -0 |
|
17 - if x = Infinity return Infinity |
|
18 - if x = -Infinity return -Infinity |
|
19 - if ( -1 < x < 0 ) return -0 |
|
20 also: |
|
21 - the value of Math.ceil(x) == -Math.ceil(-x) |
|
22 Author: christine@netscape.com |
|
23 Date: 7 july 1997 |
|
24 */ |
|
25 var SECTION = "15.8.2.6"; |
|
26 var VERSION = "ECMA_1"; |
|
27 startTest(); |
|
28 var TITLE = "Math.ceil(x)"; |
|
29 |
|
30 writeHeaderToLog( SECTION + " "+ TITLE); |
|
31 |
|
32 new TestCase( SECTION, |
|
33 "Math.ceil.length", |
|
34 1, |
|
35 Math.ceil.length ); |
|
36 |
|
37 new TestCase( SECTION, |
|
38 "Math.ceil(NaN)", |
|
39 Number.NaN, |
|
40 Math.ceil(Number.NaN) ); |
|
41 |
|
42 new TestCase( SECTION, |
|
43 "Math.ceil(null)", |
|
44 0, |
|
45 Math.ceil(null) ); |
|
46 |
|
47 new TestCase( SECTION, |
|
48 "Math.ceil()", |
|
49 Number.NaN, |
|
50 Math.ceil() ); |
|
51 |
|
52 new TestCase( SECTION, |
|
53 "Math.ceil(void 0)", |
|
54 Number.NaN, |
|
55 Math.ceil(void 0) ); |
|
56 |
|
57 new TestCase( SECTION, |
|
58 "Math.ceil('0')", |
|
59 0, |
|
60 Math.ceil('0') ); |
|
61 |
|
62 new TestCase( SECTION, |
|
63 "Math.ceil('-0')", |
|
64 -0, |
|
65 Math.ceil('-0') ); |
|
66 |
|
67 new TestCase( SECTION, |
|
68 "Infinity/Math.ceil('0')", |
|
69 Infinity, |
|
70 Infinity/Math.ceil('0')); |
|
71 |
|
72 new TestCase( SECTION, |
|
73 "Infinity/Math.ceil('-0')", |
|
74 -Infinity, |
|
75 Infinity/Math.ceil('-0')); |
|
76 |
|
77 new TestCase( SECTION, |
|
78 "Math.ceil(0)", |
|
79 0, |
|
80 Math.ceil(0) ); |
|
81 |
|
82 new TestCase( SECTION, |
|
83 "Math.ceil(-0)", |
|
84 -0, |
|
85 Math.ceil(-0) ); |
|
86 |
|
87 new TestCase( SECTION, |
|
88 "Infinity/Math.ceil(0)", |
|
89 Infinity, |
|
90 Infinity/Math.ceil(0)); |
|
91 |
|
92 new TestCase( SECTION, |
|
93 "Infinity/Math.ceil(-0)", |
|
94 -Infinity, |
|
95 Infinity/Math.ceil(-0)); |
|
96 |
|
97 |
|
98 new TestCase( SECTION, |
|
99 "Math.ceil(Infinity)", |
|
100 Number.POSITIVE_INFINITY, |
|
101 Math.ceil(Number.POSITIVE_INFINITY) ); |
|
102 |
|
103 new TestCase( SECTION, |
|
104 "Math.ceil(-Infinity)", |
|
105 Number.NEGATIVE_INFINITY, |
|
106 Math.ceil(Number.NEGATIVE_INFINITY) ); |
|
107 |
|
108 new TestCase( SECTION, |
|
109 "Math.ceil(-Number.MIN_VALUE)", |
|
110 -0, |
|
111 Math.ceil(-Number.MIN_VALUE) ); |
|
112 |
|
113 new TestCase( SECTION, |
|
114 "Infinity/Math.ceil(-Number.MIN_VALUE)", |
|
115 -Infinity, |
|
116 Infinity/Math.ceil(-Number.MIN_VALUE) ); |
|
117 |
|
118 new TestCase( SECTION, |
|
119 "Math.ceil(1)", |
|
120 1, |
|
121 Math.ceil(1) ); |
|
122 |
|
123 new TestCase( SECTION, |
|
124 "Math.ceil(-1)", |
|
125 -1, |
|
126 Math.ceil(-1) ); |
|
127 |
|
128 new TestCase( SECTION, |
|
129 "Math.ceil(-0.9)", |
|
130 -0, |
|
131 Math.ceil(-0.9) ); |
|
132 |
|
133 new TestCase( SECTION, |
|
134 "Infinity/Math.ceil(-0.9)", |
|
135 -Infinity, |
|
136 Infinity/Math.ceil(-0.9) ); |
|
137 |
|
138 new TestCase( SECTION, |
|
139 "Math.ceil(0.9 )", |
|
140 1, |
|
141 Math.ceil( 0.9) ); |
|
142 |
|
143 new TestCase( SECTION, |
|
144 "Math.ceil(-1.1)", |
|
145 -1, |
|
146 Math.ceil( -1.1)); |
|
147 |
|
148 new TestCase( SECTION, |
|
149 "Math.ceil( 1.1)", |
|
150 2, |
|
151 Math.ceil( 1.1)); |
|
152 |
|
153 new TestCase( SECTION, |
|
154 "Math.ceil(Infinity)", |
|
155 -Math.floor(-Infinity), |
|
156 Math.ceil(Number.POSITIVE_INFINITY) ); |
|
157 |
|
158 new TestCase( SECTION, |
|
159 "Math.ceil(-Infinity)", |
|
160 -Math.floor(Infinity), |
|
161 Math.ceil(Number.NEGATIVE_INFINITY) ); |
|
162 |
|
163 new TestCase( SECTION, |
|
164 "Math.ceil(-Number.MIN_VALUE)", |
|
165 -Math.floor(Number.MIN_VALUE), |
|
166 Math.ceil(-Number.MIN_VALUE) ); |
|
167 |
|
168 new TestCase( SECTION, |
|
169 "Math.ceil(1)", |
|
170 -Math.floor(-1), |
|
171 Math.ceil(1) ); |
|
172 |
|
173 new TestCase( SECTION, |
|
174 "Math.ceil(-1)", |
|
175 -Math.floor(1), |
|
176 Math.ceil(-1) ); |
|
177 |
|
178 new TestCase( SECTION, |
|
179 "Math.ceil(-0.9)", |
|
180 -Math.floor(0.9), |
|
181 Math.ceil(-0.9) ); |
|
182 |
|
183 new TestCase( SECTION, |
|
184 "Math.ceil(0.9 )", |
|
185 -Math.floor(-0.9), |
|
186 Math.ceil( 0.9) ); |
|
187 |
|
188 new TestCase( SECTION, |
|
189 "Math.ceil(-1.1)", |
|
190 -Math.floor(1.1), |
|
191 Math.ceil( -1.1)); |
|
192 |
|
193 new TestCase( SECTION, |
|
194 "Math.ceil( 1.1)", |
|
195 -Math.floor(-1.1), |
|
196 Math.ceil( 1.1)); |
|
197 |
|
198 test(); |