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