Debian Codegraph @

rhino/testsrc/tests/ecma/Math/15.8.2.9.js

raw symbols SCIP
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 gTestfile = '15.8.2.9.js';
7
8 /**
9 File Name: 15.8.2.9.js
10 ECMA Section: 15.8.2.9 Math.floor(x)
11 Description: return the greatest number value that is not greater
12 than the argument and is equal to a mathematical integer.
13 if the number is already an integer, return the number
14 itself. special cases:
15 - if x is NaN return NaN
16 - if x = +0 return +0
17 - if x = -0 return -0
18 - if x = Infinity return Infinity
19 - if x = -Infinity return -Infinity
20 - if ( -1 < x < 0 ) return -0
21 also:
22 - the value of Math.floor(x) == -Math.ceil(-x)
23 Author: [email protected]
24 Date: 7 july 1997
25 */
26
27 var SECTION = "15.8.2.9";
28 var VERSION = "ECMA_1";
29 startTest();
30 var TITLE = "Math.floor(x)";
31
32 writeHeaderToLog( SECTION + " "+ TITLE);
33
34 new TestCase( SECTION,
35 "Math.floor.length",
36 1,
37 Math.floor.length );
38
39 new TestCase( SECTION,
40 "Math.floor()",
41 Number.NaN,
42 Math.floor() );
43
44 new TestCase( SECTION,
45 "Math.floor(void 0)",
46 Number.NaN,
47 Math.floor(void 0) );
48
49 new TestCase( SECTION,
50 "Math.floor(null)",
51 0,
52 Math.floor(null) );
53
54 new TestCase( SECTION,
55 "Math.floor(true)",
56 1,
57 Math.floor(true) );
58
59 new TestCase( SECTION,
60 "Math.floor(false)",
61 0,
62 Math.floor(false) );
63
64 new TestCase( SECTION,
65 "Math.floor('1.1')",
66 1,
67 Math.floor("1.1") );
68
69 new TestCase( SECTION,
70 "Math.floor('-1.1')",
71 -2,
72 Math.floor("-1.1") );
73
74 new TestCase( SECTION,
75 "Math.floor('0.1')",
76 0,
77 Math.floor("0.1") );
78
79 new TestCase( SECTION,
80 "Math.floor('-0.1')",
81 -1,
82 Math.floor("-0.1") );
83
84 new TestCase( SECTION,
85 "Math.floor(NaN)",
86 Number.NaN,
87 Math.floor(Number.NaN) );
88
89 new TestCase( SECTION,
90 "Math.floor(NaN)==-Math.ceil(-NaN)",
91 false,
92 Math.floor(Number.NaN) == -Math.ceil(-Number.NaN) );
93
94 new TestCase( SECTION,
95 "Math.floor(0)",
96 0,
97 Math.floor(0) );
98
99 new TestCase( SECTION,
100 "Math.floor(0)==-Math.ceil(-0)",
101 true,
102 Math.floor(0) == -Math.ceil(-0) );
103
104 new TestCase( SECTION,
105 "Math.floor(-0)",
106 -0,
107 Math.floor(-0) );
108
109 new TestCase( SECTION,
110 "Infinity/Math.floor(-0)",
111 -Infinity,
112 Infinity/Math.floor(-0) );
113
114 new TestCase( SECTION,
115 "Math.floor(-0)==-Math.ceil(0)",
116 true,
117 Math.floor(-0)== -Math.ceil(0) );
118
119 new TestCase( SECTION,
120 "Math.floor(Infinity)",
121 Number.POSITIVE_INFINITY,
122 Math.floor(Number.POSITIVE_INFINITY) );
123
124 new TestCase( SECTION,
125 "Math.floor(Infinity)==-Math.ceil(-Infinity)",
126 true,
127 Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil(Number.NEGATIVE_INFINITY) );
128
129 new TestCase( SECTION,
130 "Math.floor(-Infinity)",
131 Number.NEGATIVE_INFINITY,
132 Math.floor(Number.NEGATIVE_INFINITY) );
133
134 new TestCase( SECTION,
135 "Math.floor(-Infinity)==-Math.ceil(Infinity)",
136 true,
137 Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil(Number.POSITIVE_INFINITY) );
138
139 new TestCase( SECTION,
140 "Math.floor(0.0000001)",
141 0,
142 Math.floor(0.0000001) );
143
144 new TestCase( SECTION,
145 "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true,
146 Math.floor(0.0000001)==-Math.ceil(-0.0000001) );
147
148 new TestCase( SECTION,
149 "Math.floor(-0.0000001)",
150 -1,
151 Math.floor(-0.0000001) );
152
153 new TestCase( SECTION,
154 "Math.floor(0.0000001)==-Math.ceil(0.0000001)",
155 true,
156 Math.floor(-0.0000001)==-Math.ceil(0.0000001) );
157
158 test();