1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Math/15.8.2.6.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,198 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 15.8.2.6.js 1.12 + ECMA Section: 15.8.2.6 Math.ceil(x) 1.13 + Description: return the smallest number value that is not less than the 1.14 + argument and is equal to a mathematical integer. if the 1.15 + number is already an integer, return the number itself. 1.16 + special cases: 1.17 + - if x is NaN return NaN 1.18 + - if x = +0 return +0 1.19 + - if x = 0 return -0 1.20 + - if x = Infinity return Infinity 1.21 + - if x = -Infinity return -Infinity 1.22 + - if ( -1 < x < 0 ) return -0 1.23 + also: 1.24 + - the value of Math.ceil(x) == -Math.ceil(-x) 1.25 + Author: christine@netscape.com 1.26 + Date: 7 july 1997 1.27 +*/ 1.28 +var SECTION = "15.8.2.6"; 1.29 +var VERSION = "ECMA_1"; 1.30 +startTest(); 1.31 +var TITLE = "Math.ceil(x)"; 1.32 + 1.33 +writeHeaderToLog( SECTION + " "+ TITLE); 1.34 + 1.35 +new TestCase( SECTION, 1.36 + "Math.ceil.length", 1.37 + 1, 1.38 + Math.ceil.length ); 1.39 + 1.40 +new TestCase( SECTION, 1.41 + "Math.ceil(NaN)", 1.42 + Number.NaN, 1.43 + Math.ceil(Number.NaN) ); 1.44 + 1.45 +new TestCase( SECTION, 1.46 + "Math.ceil(null)", 1.47 + 0, 1.48 + Math.ceil(null) ); 1.49 + 1.50 +new TestCase( SECTION, 1.51 + "Math.ceil()", 1.52 + Number.NaN, 1.53 + Math.ceil() ); 1.54 + 1.55 +new TestCase( SECTION, 1.56 + "Math.ceil(void 0)", 1.57 + Number.NaN, 1.58 + Math.ceil(void 0) ); 1.59 + 1.60 +new TestCase( SECTION, 1.61 + "Math.ceil('0')", 1.62 + 0, 1.63 + Math.ceil('0') ); 1.64 + 1.65 +new TestCase( SECTION, 1.66 + "Math.ceil('-0')", 1.67 + -0, 1.68 + Math.ceil('-0') ); 1.69 + 1.70 +new TestCase( SECTION, 1.71 + "Infinity/Math.ceil('0')", 1.72 + Infinity, 1.73 + Infinity/Math.ceil('0')); 1.74 + 1.75 +new TestCase( SECTION, 1.76 + "Infinity/Math.ceil('-0')", 1.77 + -Infinity, 1.78 + Infinity/Math.ceil('-0')); 1.79 + 1.80 +new TestCase( SECTION, 1.81 + "Math.ceil(0)", 1.82 + 0, 1.83 + Math.ceil(0) ); 1.84 + 1.85 +new TestCase( SECTION, 1.86 + "Math.ceil(-0)", 1.87 + -0, 1.88 + Math.ceil(-0) ); 1.89 + 1.90 +new TestCase( SECTION, 1.91 + "Infinity/Math.ceil(0)", 1.92 + Infinity, 1.93 + Infinity/Math.ceil(0)); 1.94 + 1.95 +new TestCase( SECTION, 1.96 + "Infinity/Math.ceil(-0)", 1.97 + -Infinity, 1.98 + Infinity/Math.ceil(-0)); 1.99 + 1.100 + 1.101 +new TestCase( SECTION, 1.102 + "Math.ceil(Infinity)", 1.103 + Number.POSITIVE_INFINITY, 1.104 + Math.ceil(Number.POSITIVE_INFINITY) ); 1.105 + 1.106 +new TestCase( SECTION, 1.107 + "Math.ceil(-Infinity)", 1.108 + Number.NEGATIVE_INFINITY, 1.109 + Math.ceil(Number.NEGATIVE_INFINITY) ); 1.110 + 1.111 +new TestCase( SECTION, 1.112 + "Math.ceil(-Number.MIN_VALUE)", 1.113 + -0, 1.114 + Math.ceil(-Number.MIN_VALUE) ); 1.115 + 1.116 +new TestCase( SECTION, 1.117 + "Infinity/Math.ceil(-Number.MIN_VALUE)", 1.118 + -Infinity, 1.119 + Infinity/Math.ceil(-Number.MIN_VALUE) ); 1.120 + 1.121 +new TestCase( SECTION, 1.122 + "Math.ceil(1)", 1.123 + 1, 1.124 + Math.ceil(1) ); 1.125 + 1.126 +new TestCase( SECTION, 1.127 + "Math.ceil(-1)", 1.128 + -1, 1.129 + Math.ceil(-1) ); 1.130 + 1.131 +new TestCase( SECTION, 1.132 + "Math.ceil(-0.9)", 1.133 + -0, 1.134 + Math.ceil(-0.9) ); 1.135 + 1.136 +new TestCase( SECTION, 1.137 + "Infinity/Math.ceil(-0.9)", 1.138 + -Infinity, 1.139 + Infinity/Math.ceil(-0.9) ); 1.140 + 1.141 +new TestCase( SECTION, 1.142 + "Math.ceil(0.9 )", 1.143 + 1, 1.144 + Math.ceil( 0.9) ); 1.145 + 1.146 +new TestCase( SECTION, 1.147 + "Math.ceil(-1.1)", 1.148 + -1, 1.149 + Math.ceil( -1.1)); 1.150 + 1.151 +new TestCase( SECTION, 1.152 + "Math.ceil( 1.1)", 1.153 + 2, 1.154 + Math.ceil( 1.1)); 1.155 + 1.156 +new TestCase( SECTION, 1.157 + "Math.ceil(Infinity)", 1.158 + -Math.floor(-Infinity), 1.159 + Math.ceil(Number.POSITIVE_INFINITY) ); 1.160 + 1.161 +new TestCase( SECTION, 1.162 + "Math.ceil(-Infinity)", 1.163 + -Math.floor(Infinity), 1.164 + Math.ceil(Number.NEGATIVE_INFINITY) ); 1.165 + 1.166 +new TestCase( SECTION, 1.167 + "Math.ceil(-Number.MIN_VALUE)", 1.168 + -Math.floor(Number.MIN_VALUE), 1.169 + Math.ceil(-Number.MIN_VALUE) ); 1.170 + 1.171 +new TestCase( SECTION, 1.172 + "Math.ceil(1)", 1.173 + -Math.floor(-1), 1.174 + Math.ceil(1) ); 1.175 + 1.176 +new TestCase( SECTION, 1.177 + "Math.ceil(-1)", 1.178 + -Math.floor(1), 1.179 + Math.ceil(-1) ); 1.180 + 1.181 +new TestCase( SECTION, 1.182 + "Math.ceil(-0.9)", 1.183 + -Math.floor(0.9), 1.184 + Math.ceil(-0.9) ); 1.185 + 1.186 +new TestCase( SECTION, 1.187 + "Math.ceil(0.9 )", 1.188 + -Math.floor(-0.9), 1.189 + Math.ceil( 0.9) ); 1.190 + 1.191 +new TestCase( SECTION, 1.192 + "Math.ceil(-1.1)", 1.193 + -Math.floor(1.1), 1.194 + Math.ceil( -1.1)); 1.195 + 1.196 +new TestCase( SECTION, 1.197 + "Math.ceil( 1.1)", 1.198 + -Math.floor(-1.1), 1.199 + Math.ceil( 1.1)); 1.200 + 1.201 +test();