]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Math/15.8.2.6.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 File Name: 15.8.2.6.js
24 ECMA Section: 15.8.2.6 Math.ceil(x)
25 Description: return the smallest number value that is not less than the
26 argument and is equal to a mathematical integer. if the
27 number is already an integer, return the number itself.
29 - if x is NaN return NaN
32 - if x = Infinity return Infinity
33 - if x = -Infinity return -Infinity
34 - if ( -1 < x < 0 ) return -0
36 - the value of Math.ceil(x) == -Math.ceil(-x)
37 Author: christine@netscape.com
40 var SECTION
= "15.8.2.6";
41 var VERSION
= "ECMA_1";
43 var TITLE
= "Math.ceil(x)";
45 writeHeaderToLog( SECTION
+ " "+ TITLE
);
47 var testcases
= getTestCases();
50 function getTestCases() {
51 var array
= new Array();
54 array
[item
++] = new TestCase( SECTION
, "Math.ceil.length", 1, Math
.ceil
.length
);
56 array
[item
++] = new TestCase( SECTION
, "Math.ceil(NaN)", Number
.NaN
, Math
.ceil(Number
.NaN
) );
57 array
[item
++] = new TestCase( SECTION
, "Math.ceil(null)", 0, Math
.ceil(null) );
58 array
[item
++] = new TestCase( SECTION
, "Math.ceil()", Number
.NaN
, Math
.ceil() );
59 array
[item
++] = new TestCase( SECTION
, "Math.ceil(void 0)", Number
.NaN
, Math
.ceil(void 0) );
61 array
[item
++] = new TestCase( SECTION
, "Math.ceil('0')", 0, Math
.ceil('0') );
62 array
[item
++] = new TestCase( SECTION
, "Math.ceil('-0')", -0, Math
.ceil('-0') );
63 array
[item
++] = new TestCase( SECTION
, "Infinity/Math.ceil('0')", Infinity
, Infinity
/Math
.ceil('0'));
64 array
[item
++] = new TestCase( SECTION
, "Infinity/Math.ceil('-0')", -Infinity
, Infinity
/Math
.ceil('-0'));
66 array
[item
++] = new TestCase( SECTION
, "Math.ceil(0)", 0, Math
.ceil(0) );
67 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-0)", -0, Math
.ceil(-0) );
68 array
[item
++] = new TestCase( SECTION
, "Infinity/Math.ceil(0)", Infinity
, Infinity
/Math
.ceil(0));
69 array
[item
++] = new TestCase( SECTION
, "Infinity/Math.ceil(-0)", -Infinity
, Infinity
/Math
.ceil(-0));
71 array
[item
++] = new TestCase( SECTION
, "Math.ceil(Infinity)", Number
.POSITIVE_INFINITY
, Math
.ceil(Number
.POSITIVE_INFINITY
) );
72 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-Infinity)", Number
.NEGATIVE_INFINITY
, Math
.ceil(Number
.NEGATIVE_INFINITY
) );
73 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-Number.MIN_VALUE)", -0, Math
.ceil(-Number
.MIN_VALUE
) );
74 array
[item
++] = new TestCase( SECTION
, "Infinity/Math.ceil(-Number.MIN_VALUE)", -Infinity
, Infinity
/Math
.ceil(-Number
.MIN_VALUE
) );
75 array
[item
++] = new TestCase( SECTION
, "Math.ceil(1)", 1, Math
.ceil(1) );
76 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-1)", -1, Math
.ceil(-1) );
77 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-0.9)", -0, Math
.ceil(-0.9) );
78 array
[item
++] = new TestCase( SECTION
, "Infinity/Math.ceil(-0.9)", -Infinity
, Infinity
/Math
.ceil(-0.9) );
79 array
[item
++] = new TestCase( SECTION
, "Math.ceil(0.9 )", 1, Math
.ceil( 0.9) );
80 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-1.1)", -1, Math
.ceil( -1.1));
81 array
[item
++] = new TestCase( SECTION
, "Math.ceil( 1.1)", 2, Math
.ceil( 1.1));
83 array
[item
++] = new TestCase( SECTION
, "Math.ceil(Infinity)", -Math
.floor(-Infinity
), Math
.ceil(Number
.POSITIVE_INFINITY
) );
84 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-Infinity)", -Math
.floor(Infinity
), Math
.ceil(Number
.NEGATIVE_INFINITY
) );
85 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-Number.MIN_VALUE)", -Math
.floor(Number
.MIN_VALUE
), Math
.ceil(-Number
.MIN_VALUE
) );
86 array
[item
++] = new TestCase( SECTION
, "Math.ceil(1)", -Math
.floor(-1), Math
.ceil(1) );
87 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-1)", -Math
.floor(1), Math
.ceil(-1) );
88 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-0.9)", -Math
.floor(0.9), Math
.ceil(-0.9) );
89 array
[item
++] = new TestCase( SECTION
, "Math.ceil(0.9 )", -Math
.floor(-0.9), Math
.ceil( 0.9) );
90 array
[item
++] = new TestCase( SECTION
, "Math.ceil(-1.1)", -Math
.floor(1.1), Math
.ceil( -1.1));
91 array
[item
++] = new TestCase( SECTION
, "Math.ceil( 1.1)", -Math
.floor(-1.1), Math
.ceil( 1.1));
97 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
98 testcases
[tc
].passed
= writeTestCaseResult(
100 testcases
[tc
].actual
,
101 testcases
[tc
].description
+" = "+
102 testcases
[tc
].actual
);
104 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
107 return ( testcases
);