Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
7 /**
8 File Name: 15.8.2.9.js
9 ECMA Section: 15.8.2.9 Math.floor(x)
10 Description: return the greatest number value that is not greater
11 than the argument and is equal to a mathematical integer.
12 if the number is already an integer, return the number
13 itself. 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.floor(x) == -Math.ceil(-x)
22 Author: christine@netscape.com
23 Date: 7 july 1997
24 */
26 var SECTION = "15.8.2.9";
27 var VERSION = "ECMA_1";
28 startTest();
29 var TITLE = "Math.floor(x)";
31 writeHeaderToLog( SECTION + " "+ TITLE);
33 new TestCase( SECTION,
34 "Math.floor.length",
35 1,
36 Math.floor.length );
38 new TestCase( SECTION,
39 "Math.floor()",
40 Number.NaN,
41 Math.floor() );
43 new TestCase( SECTION,
44 "Math.floor(void 0)",
45 Number.NaN,
46 Math.floor(void 0) );
48 new TestCase( SECTION,
49 "Math.floor(null)",
50 0,
51 Math.floor(null) );
53 new TestCase( SECTION,
54 "Math.floor(true)",
55 1,
56 Math.floor(true) );
58 new TestCase( SECTION,
59 "Math.floor(false)",
60 0,
61 Math.floor(false) );
63 new TestCase( SECTION,
64 "Math.floor('1.1')",
65 1,
66 Math.floor("1.1") );
68 new TestCase( SECTION,
69 "Math.floor('-1.1')",
70 -2,
71 Math.floor("-1.1") );
73 new TestCase( SECTION,
74 "Math.floor('0.1')",
75 0,
76 Math.floor("0.1") );
78 new TestCase( SECTION,
79 "Math.floor('-0.1')",
80 -1,
81 Math.floor("-0.1") );
83 new TestCase( SECTION,
84 "Math.floor(NaN)",
85 Number.NaN,
86 Math.floor(Number.NaN) );
88 new TestCase( SECTION,
89 "Math.floor(NaN)==-Math.ceil(-NaN)",
90 false,
91 Math.floor(Number.NaN) == -Math.ceil(-Number.NaN) );
93 new TestCase( SECTION,
94 "Math.floor(0)",
95 0,
96 Math.floor(0) );
98 new TestCase( SECTION,
99 "Math.floor(0)==-Math.ceil(-0)",
100 true,
101 Math.floor(0) == -Math.ceil(-0) );
103 new TestCase( SECTION,
104 "Math.floor(-0)",
105 -0,
106 Math.floor(-0) );
108 new TestCase( SECTION,
109 "Infinity/Math.floor(-0)",
110 -Infinity,
111 Infinity/Math.floor(-0) );
113 new TestCase( SECTION,
114 "Math.floor(-0)==-Math.ceil(0)",
115 true,
116 Math.floor(-0)== -Math.ceil(0) );
118 new TestCase( SECTION,
119 "Math.floor(Infinity)",
120 Number.POSITIVE_INFINITY,
121 Math.floor(Number.POSITIVE_INFINITY) );
123 new TestCase( SECTION,
124 "Math.floor(Infinity)==-Math.ceil(-Infinity)",
125 true,
126 Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil(Number.NEGATIVE_INFINITY) );
128 new TestCase( SECTION,
129 "Math.floor(-Infinity)",
130 Number.NEGATIVE_INFINITY,
131 Math.floor(Number.NEGATIVE_INFINITY) );
133 new TestCase( SECTION,
134 "Math.floor(-Infinity)==-Math.ceil(Infinity)",
135 true,
136 Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil(Number.POSITIVE_INFINITY) );
138 new TestCase( SECTION,
139 "Math.floor(0.0000001)",
140 0,
141 Math.floor(0.0000001) );
143 new TestCase( SECTION,
144 "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true,
145 Math.floor(0.0000001)==-Math.ceil(-0.0000001) );
147 new TestCase( SECTION,
148 "Math.floor(-0.0000001)",
149 -1,
150 Math.floor(-0.0000001) );
152 new TestCase( SECTION,
153 "Math.floor(0.0000001)==-Math.ceil(0.0000001)",
154 true,
155 Math.floor(-0.0000001)==-Math.ceil(0.0000001) );
157 test();