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.7.js |
michael@0 | 9 | ECMA Section: 15.8.2.7 cos( x ) |
michael@0 | 10 | Description: return an approximation to the cosine of the |
michael@0 | 11 | argument. argument is expressed in radians |
michael@0 | 12 | Author: christine@netscape.com |
michael@0 | 13 | Date: 7 july 1997 |
michael@0 | 14 | |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | var SECTION = "15.8.2.7"; |
michael@0 | 18 | var VERSION = "ECMA_1"; |
michael@0 | 19 | startTest(); |
michael@0 | 20 | var TITLE = "Math.cos(x)"; |
michael@0 | 21 | |
michael@0 | 22 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 23 | |
michael@0 | 24 | new TestCase( SECTION, |
michael@0 | 25 | "Math.cos.length", |
michael@0 | 26 | 1, |
michael@0 | 27 | Math.cos.length ); |
michael@0 | 28 | |
michael@0 | 29 | new TestCase( SECTION, |
michael@0 | 30 | "Math.cos()", |
michael@0 | 31 | Number.NaN, |
michael@0 | 32 | Math.cos() ); |
michael@0 | 33 | |
michael@0 | 34 | new TestCase( SECTION, |
michael@0 | 35 | "Math.cos(void 0)", |
michael@0 | 36 | Number.NaN, |
michael@0 | 37 | Math.cos(void 0) ); |
michael@0 | 38 | |
michael@0 | 39 | new TestCase( SECTION, |
michael@0 | 40 | "Math.cos(false)", |
michael@0 | 41 | 1, |
michael@0 | 42 | Math.cos(false) ); |
michael@0 | 43 | |
michael@0 | 44 | new TestCase( SECTION, |
michael@0 | 45 | "Math.cos(null)", |
michael@0 | 46 | 1, |
michael@0 | 47 | Math.cos(null) ); |
michael@0 | 48 | |
michael@0 | 49 | new TestCase( SECTION, |
michael@0 | 50 | "Math.cos('0')", |
michael@0 | 51 | 1, |
michael@0 | 52 | Math.cos('0') ); |
michael@0 | 53 | |
michael@0 | 54 | new TestCase( SECTION, |
michael@0 | 55 | "Math.cos('Infinity')", |
michael@0 | 56 | Number.NaN, |
michael@0 | 57 | Math.cos("Infinity") ); |
michael@0 | 58 | |
michael@0 | 59 | new TestCase( SECTION, |
michael@0 | 60 | "Math.cos('3.14159265359')", |
michael@0 | 61 | -1, |
michael@0 | 62 | Math.cos('3.14159265359') ); |
michael@0 | 63 | |
michael@0 | 64 | new TestCase( SECTION, |
michael@0 | 65 | "Math.cos(NaN)", |
michael@0 | 66 | Number.NaN, |
michael@0 | 67 | Math.cos(Number.NaN) ); |
michael@0 | 68 | |
michael@0 | 69 | new TestCase( SECTION, |
michael@0 | 70 | "Math.cos(0)", |
michael@0 | 71 | 1, |
michael@0 | 72 | Math.cos(0) ); |
michael@0 | 73 | |
michael@0 | 74 | new TestCase( SECTION, |
michael@0 | 75 | "Math.cos(-0)", |
michael@0 | 76 | 1, |
michael@0 | 77 | Math.cos(-0) ); |
michael@0 | 78 | |
michael@0 | 79 | new TestCase( SECTION, |
michael@0 | 80 | "Math.cos(Infinity)", |
michael@0 | 81 | Number.NaN, |
michael@0 | 82 | Math.cos(Number.POSITIVE_INFINITY) ); |
michael@0 | 83 | |
michael@0 | 84 | new TestCase( SECTION, |
michael@0 | 85 | "Math.cos(-Infinity)", |
michael@0 | 86 | Number.NaN, |
michael@0 | 87 | Math.cos(Number.NEGATIVE_INFINITY) ); |
michael@0 | 88 | |
michael@0 | 89 | new TestCase( SECTION, |
michael@0 | 90 | "Math.cos(0.7853981633974)", |
michael@0 | 91 | 0.7071067811865, |
michael@0 | 92 | Math.cos(0.7853981633974) ); |
michael@0 | 93 | |
michael@0 | 94 | new TestCase( SECTION, |
michael@0 | 95 | "Math.cos(1.570796326795)", |
michael@0 | 96 | 0, |
michael@0 | 97 | Math.cos(1.570796326795) ); |
michael@0 | 98 | |
michael@0 | 99 | new TestCase( SECTION, |
michael@0 | 100 | "Math.cos(2.356194490192)", |
michael@0 | 101 | -0.7071067811865, |
michael@0 | 102 | Math.cos(2.356194490192) ); |
michael@0 | 103 | |
michael@0 | 104 | new TestCase( SECTION, |
michael@0 | 105 | "Math.cos(3.14159265359)", |
michael@0 | 106 | -1, |
michael@0 | 107 | Math.cos(3.14159265359) ); |
michael@0 | 108 | |
michael@0 | 109 | new TestCase( SECTION, |
michael@0 | 110 | "Math.cos(3.926990816987)", |
michael@0 | 111 | -0.7071067811865, |
michael@0 | 112 | Math.cos(3.926990816987) ); |
michael@0 | 113 | |
michael@0 | 114 | new TestCase( SECTION, |
michael@0 | 115 | "Math.cos(4.712388980385)", |
michael@0 | 116 | 0, |
michael@0 | 117 | Math.cos(4.712388980385) ); |
michael@0 | 118 | |
michael@0 | 119 | new TestCase( SECTION, |
michael@0 | 120 | "Math.cos(5.497787143782)", |
michael@0 | 121 | 0.7071067811865, |
michael@0 | 122 | Math.cos(5.497787143782) ); |
michael@0 | 123 | |
michael@0 | 124 | new TestCase( SECTION, |
michael@0 | 125 | "Math.cos(Math.PI*2)", |
michael@0 | 126 | 1, |
michael@0 | 127 | Math.cos(Math.PI*2) ); |
michael@0 | 128 | |
michael@0 | 129 | new TestCase( SECTION, |
michael@0 | 130 | "Math.cos(Math.PI/4)", |
michael@0 | 131 | Math.SQRT2/2, |
michael@0 | 132 | Math.cos(Math.PI/4) ); |
michael@0 | 133 | |
michael@0 | 134 | new TestCase( SECTION, |
michael@0 | 135 | "Math.cos(Math.PI/2)", |
michael@0 | 136 | 0, |
michael@0 | 137 | Math.cos(Math.PI/2) ); |
michael@0 | 138 | |
michael@0 | 139 | new TestCase( SECTION, |
michael@0 | 140 | "Math.cos(3*Math.PI/4)", |
michael@0 | 141 | -Math.SQRT2/2, |
michael@0 | 142 | Math.cos(3*Math.PI/4) ); |
michael@0 | 143 | |
michael@0 | 144 | new TestCase( SECTION, |
michael@0 | 145 | "Math.cos(Math.PI)", |
michael@0 | 146 | -1, |
michael@0 | 147 | Math.cos(Math.PI) ); |
michael@0 | 148 | |
michael@0 | 149 | new TestCase( SECTION, |
michael@0 | 150 | "Math.cos(5*Math.PI/4)", |
michael@0 | 151 | -Math.SQRT2/2, |
michael@0 | 152 | Math.cos(5*Math.PI/4) ); |
michael@0 | 153 | |
michael@0 | 154 | new TestCase( SECTION, |
michael@0 | 155 | "Math.cos(3*Math.PI/2)", |
michael@0 | 156 | 0, |
michael@0 | 157 | Math.cos(3*Math.PI/2) ); |
michael@0 | 158 | |
michael@0 | 159 | new TestCase( SECTION, |
michael@0 | 160 | "Math.cos(7*Math.PI/4)", |
michael@0 | 161 | Math.SQRT2/2, |
michael@0 | 162 | Math.cos(7*Math.PI/4) ); |
michael@0 | 163 | |
michael@0 | 164 | new TestCase( SECTION, |
michael@0 | 165 | "Math.cos(Math.PI*2)", |
michael@0 | 166 | 1, |
michael@0 | 167 | Math.cos(2*Math.PI) ); |
michael@0 | 168 | |
michael@0 | 169 | new TestCase( SECTION, |
michael@0 | 170 | "Math.cos(-0.7853981633974)", |
michael@0 | 171 | 0.7071067811865, |
michael@0 | 172 | Math.cos(-0.7853981633974) ); |
michael@0 | 173 | |
michael@0 | 174 | new TestCase( SECTION, |
michael@0 | 175 | "Math.cos(-1.570796326795)", |
michael@0 | 176 | 0, |
michael@0 | 177 | Math.cos(-1.570796326795) ); |
michael@0 | 178 | |
michael@0 | 179 | new TestCase( SECTION, |
michael@0 | 180 | "Math.cos(-2.3561944901920)", |
michael@0 | 181 | -.7071067811865, |
michael@0 | 182 | Math.cos(2.3561944901920) ); |
michael@0 | 183 | |
michael@0 | 184 | new TestCase( SECTION, |
michael@0 | 185 | "Math.cos(-3.14159265359)", |
michael@0 | 186 | -1, |
michael@0 | 187 | Math.cos(3.14159265359) ); |
michael@0 | 188 | |
michael@0 | 189 | new TestCase( SECTION, |
michael@0 | 190 | "Math.cos(-3.926990816987)", |
michael@0 | 191 | -0.7071067811865, |
michael@0 | 192 | Math.cos(3.926990816987) ); |
michael@0 | 193 | |
michael@0 | 194 | new TestCase( SECTION, |
michael@0 | 195 | "Math.cos(-4.712388980385)", |
michael@0 | 196 | 0, |
michael@0 | 197 | Math.cos(4.712388980385) ); |
michael@0 | 198 | |
michael@0 | 199 | new TestCase( SECTION, |
michael@0 | 200 | "Math.cos(-5.497787143782)", |
michael@0 | 201 | 0.7071067811865, |
michael@0 | 202 | Math.cos(5.497787143782) ); |
michael@0 | 203 | |
michael@0 | 204 | new TestCase( SECTION, |
michael@0 | 205 | "Math.cos(-6.28318530718)", |
michael@0 | 206 | 1, |
michael@0 | 207 | Math.cos(6.28318530718) ); |
michael@0 | 208 | |
michael@0 | 209 | new TestCase( SECTION, |
michael@0 | 210 | "Math.cos(-Math.PI/4)", |
michael@0 | 211 | Math.SQRT2/2, |
michael@0 | 212 | Math.cos(-Math.PI/4) ); |
michael@0 | 213 | |
michael@0 | 214 | new TestCase( SECTION, |
michael@0 | 215 | "Math.cos(-Math.PI/2)", |
michael@0 | 216 | 0, |
michael@0 | 217 | Math.cos(-Math.PI/2) ); |
michael@0 | 218 | |
michael@0 | 219 | new TestCase( SECTION, |
michael@0 | 220 | "Math.cos(-3*Math.PI/4)", |
michael@0 | 221 | -Math.SQRT2/2, |
michael@0 | 222 | Math.cos(-3*Math.PI/4) ); |
michael@0 | 223 | |
michael@0 | 224 | new TestCase( SECTION, |
michael@0 | 225 | "Math.cos(-Math.PI)", |
michael@0 | 226 | -1, |
michael@0 | 227 | Math.cos(-Math.PI) ); |
michael@0 | 228 | |
michael@0 | 229 | new TestCase( SECTION, |
michael@0 | 230 | "Math.cos(-5*Math.PI/4)", |
michael@0 | 231 | -Math.SQRT2/2, |
michael@0 | 232 | Math.cos(-5*Math.PI/4) ); |
michael@0 | 233 | |
michael@0 | 234 | new TestCase( SECTION, |
michael@0 | 235 | "Math.cos(-3*Math.PI/2)", |
michael@0 | 236 | 0, |
michael@0 | 237 | Math.cos(-3*Math.PI/2) ); |
michael@0 | 238 | |
michael@0 | 239 | new TestCase( SECTION, |
michael@0 | 240 | "Math.cos(-7*Math.PI/4)", |
michael@0 | 241 | Math.SQRT2/2, |
michael@0 | 242 | Math.cos(-7*Math.PI/4) ); |
michael@0 | 243 | |
michael@0 | 244 | new TestCase( SECTION, |
michael@0 | 245 | "Math.cos(-Math.PI*2)", |
michael@0 | 246 | 1, |
michael@0 | 247 | Math.cos(-Math.PI*2) ); |
michael@0 | 248 | |
michael@0 | 249 | test(); |