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: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | |
michael@0 | 3 | // Apply FUNCNAME to ARGS, and check against EXPECTED. |
michael@0 | 4 | // Expect a loop containing such a call to be traced. |
michael@0 | 5 | // FUNCNAME and ARGS are both strings. |
michael@0 | 6 | // ARGS has the form of an argument list: a comma-separated list of expressions. |
michael@0 | 7 | // Certain Tracemonkey limitations require us to pass FUNCNAME as a string. |
michael@0 | 8 | // Passing ARGS as a string allows us to assign better test names: |
michael@0 | 9 | // expressions like Math.PI/4 haven't been evaluated to big hairy numbers. |
michael@0 | 10 | function testmath(funcname, args, expected) { |
michael@0 | 11 | var i, j; |
michael@0 | 12 | |
michael@0 | 13 | var arg_value_list = eval("[" + args + "]"); |
michael@0 | 14 | var arity = arg_value_list.length; |
michael@0 | 15 | |
michael@0 | 16 | // Build the string "a[i][0],...,a[i][ARITY-1]". |
michael@0 | 17 | var actuals = [] |
michael@0 | 18 | for (i = 0; i < arity; i++) |
michael@0 | 19 | actuals.push("a[i][" + i + "]"); |
michael@0 | 20 | actuals = actuals.join(","); |
michael@0 | 21 | |
michael@0 | 22 | // Create a function that maps FUNCNAME across an array of input values. |
michael@0 | 23 | // Unless we eval here, the call to funcname won't get traced. |
michael@0 | 24 | // FUNCNAME="Infinity/Math.abs" and cases like that happen to |
michael@0 | 25 | // parse, too, in a twisted way. |
michael@0 | 26 | var mapfunc = eval("(function(a) {\n" |
michael@0 | 27 | + " for (var i = 0; i < a.length; i++)\n" |
michael@0 | 28 | + " a[i] = " + funcname + "(" + actuals +");\n" |
michael@0 | 29 | + " })\n"); |
michael@0 | 30 | |
michael@0 | 31 | // To prevent the compiler from doing constant folding, produce an |
michael@0 | 32 | // array to pass to mapfunc that contains enough dummy |
michael@0 | 33 | // values at the front to get the loop body jitted, and then our |
michael@0 | 34 | // actual test value. |
michael@0 | 35 | var dummies_and_input = []; |
michael@0 | 36 | for (i = 0; i < 9; i++) { |
michael@0 | 37 | var dummy_list = []; |
michael@0 | 38 | for (j = 0; j < arity; j++) |
michael@0 | 39 | dummy_list[j] = .0078125 * ((i + j) % 128); |
michael@0 | 40 | dummies_and_input[i] = dummy_list; |
michael@0 | 41 | } |
michael@0 | 42 | dummies_and_input[9] = arg_value_list; |
michael@0 | 43 | |
michael@0 | 44 | function testfunc() { |
michael@0 | 45 | // Map the function across the dummy values and the test input. |
michael@0 | 46 | mapfunc(dummies_and_input); |
michael@0 | 47 | return dummies_and_input[9]; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | assertEq(close_enough(testfunc(), expected), true); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | function close_enough(expected, actual) |
michael@0 | 54 | { |
michael@0 | 55 | if (typeof expected != typeof actual) |
michael@0 | 56 | return false; |
michael@0 | 57 | if (typeof expected != 'number') |
michael@0 | 58 | return actual == expected; |
michael@0 | 59 | |
michael@0 | 60 | // Distinguish NaN from other values. Using x != x comparisons here |
michael@0 | 61 | // works even if tests redefine isNaN. |
michael@0 | 62 | if (actual != actual) |
michael@0 | 63 | return expected != expected |
michael@0 | 64 | if (expected != expected) |
michael@0 | 65 | return false; |
michael@0 | 66 | |
michael@0 | 67 | // Tolerate a certain degree of error. |
michael@0 | 68 | if (actual != expected) |
michael@0 | 69 | return Math.abs(actual - expected) <= 1E-10; |
michael@0 | 70 | |
michael@0 | 71 | // Distinguish 0 and -0. |
michael@0 | 72 | if (actual == 0) |
michael@0 | 73 | return (1 / actual > 0) == (1 / expected > 0); |
michael@0 | 74 | |
michael@0 | 75 | return true; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | testmath("Math.abs", "void 0", Number.NaN) |
michael@0 | 79 | testmath("Math.abs", "null", 0) |
michael@0 | 80 | testmath("Math.abs", "true", 1) |
michael@0 | 81 | testmath("Math.abs", "false", 0) |
michael@0 | 82 | testmath("Math.abs", "\"a string primitive\"", Number.NaN) |
michael@0 | 83 | testmath("Math.abs", "new String( 'a String object' )", Number.NaN) |
michael@0 | 84 | testmath("Math.abs", "Number.NaN", Number.NaN) |
michael@0 | 85 | testmath("Math.abs", "0", 0) |
michael@0 | 86 | testmath("Math.abs", "-0", 0) |
michael@0 | 87 | testmath("Infinity/Math.abs", "-0", Infinity) |
michael@0 | 88 | testmath("Math.abs", "Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 89 | testmath("Math.abs", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 90 | testmath("Math.abs", "- Number.MAX_VALUE", Number.MAX_VALUE) |
michael@0 | 91 | testmath("Math.abs", "-Number.MIN_VALUE", Number.MIN_VALUE) |
michael@0 | 92 | testmath("Math.abs", "Number.MAX_VALUE", Number.MAX_VALUE) |
michael@0 | 93 | testmath("Math.abs", "Number.MIN_VALUE", Number.MIN_VALUE) |
michael@0 | 94 | testmath("Math.abs", "-1", 1) |
michael@0 | 95 | testmath("Math.abs", "new Number(-1)", 1) |
michael@0 | 96 | testmath("Math.abs", "1", 1) |
michael@0 | 97 | testmath("Math.abs", "Math.PI", Math.PI) |
michael@0 | 98 | testmath("Math.abs", "-Math.PI", Math.PI) |
michael@0 | 99 | testmath("Math.abs", "-1/100000000", 1/100000000) |
michael@0 | 100 | testmath("Math.abs", "-Math.pow(2,32)", Math.pow(2,32)) |
michael@0 | 101 | testmath("Math.abs", "Math.pow(2,32)", Math.pow(2,32)) |
michael@0 | 102 | testmath("Math.abs", "-0xfff", 4095) |
michael@0 | 103 | testmath("Math.abs", "-0777", 511) |
michael@0 | 104 | testmath("Math.abs", "'-1e-1'", 0.1) |
michael@0 | 105 | testmath("Math.abs", "'0xff'", 255) |
michael@0 | 106 | testmath("Math.abs", "'077'", 77) |
michael@0 | 107 | testmath("Math.abs", "'Infinity'", Infinity) |
michael@0 | 108 | testmath("Math.abs", "'-Infinity'", Infinity) |
michael@0 | 109 | |
michael@0 | 110 | testmath("Math.acos", "void 0", Number.NaN) |
michael@0 | 111 | testmath("Math.acos", "null", Math.PI/2) |
michael@0 | 112 | testmath("Math.acos", "Number.NaN", Number.NaN) |
michael@0 | 113 | testmath("Math.acos", "\"a string\"", Number.NaN) |
michael@0 | 114 | testmath("Math.acos", "'0'", Math.PI/2) |
michael@0 | 115 | testmath("Math.acos", "'1'", 0) |
michael@0 | 116 | testmath("Math.acos", "'-1'", Math.PI) |
michael@0 | 117 | testmath("Math.acos", "1.00000001", Number.NaN) |
michael@0 | 118 | testmath("Math.acos", "-1.00000001", Number.NaN) |
michael@0 | 119 | testmath("Math.acos", "1", 0) |
michael@0 | 120 | testmath("Math.acos", "-1", Math.PI) |
michael@0 | 121 | testmath("Math.acos", "0", Math.PI/2) |
michael@0 | 122 | testmath("Math.acos", "-0", Math.PI/2) |
michael@0 | 123 | testmath("Math.acos", "Math.SQRT1_2", Math.PI/4) |
michael@0 | 124 | testmath("Math.acos", "-Math.SQRT1_2", Math.PI/4*3) |
michael@0 | 125 | testmath("Math.acos", "0.9999619230642", Math.PI/360) |
michael@0 | 126 | testmath("Math.acos", "-3.0", Number.NaN) |
michael@0 | 127 | |
michael@0 | 128 | testmath("Math.asin", "void 0", Number.NaN) |
michael@0 | 129 | testmath("Math.asin", "null", 0) |
michael@0 | 130 | testmath("Math.asin", "Number.NaN", Number.NaN) |
michael@0 | 131 | testmath("Math.asin", "\"string\"", Number.NaN) |
michael@0 | 132 | testmath("Math.asin", "\"0\"", 0) |
michael@0 | 133 | testmath("Math.asin", "\"1\"", Math.PI/2) |
michael@0 | 134 | testmath("Math.asin", "\"-1\"", -Math.PI/2) |
michael@0 | 135 | testmath("Math.asin", "Math.SQRT1_2+''", Math.PI/4) |
michael@0 | 136 | testmath("Math.asin", "-Math.SQRT1_2+''", -Math.PI/4) |
michael@0 | 137 | testmath("Math.asin", "1.000001", Number.NaN) |
michael@0 | 138 | testmath("Math.asin", "-1.000001", Number.NaN) |
michael@0 | 139 | testmath("Math.asin", "0", 0) |
michael@0 | 140 | testmath("Math.asin", "-0", -0) |
michael@0 | 141 | testmath("Infinity/Math.asin", "-0", -Infinity) |
michael@0 | 142 | testmath("Math.asin", "1", Math.PI/2) |
michael@0 | 143 | testmath("Math.asin", "-1", -Math.PI/2) |
michael@0 | 144 | testmath("Math.asin", "Math.SQRT1_2", Math.PI/4) |
michael@0 | 145 | testmath("Math.asin", "-Math.SQRT1_2", -Math.PI/4) |
michael@0 | 146 | |
michael@0 | 147 | testmath("Math.atan", "void 0", Number.NaN) |
michael@0 | 148 | testmath("Math.atan", "null", 0) |
michael@0 | 149 | testmath("Math.atan", "Number.NaN", Number.NaN) |
michael@0 | 150 | testmath("Math.atan", "\"a string\"", Number.NaN) |
michael@0 | 151 | testmath("Math.atan", "'0'", 0) |
michael@0 | 152 | testmath("Math.atan", "'1'", Math.PI/4) |
michael@0 | 153 | testmath("Math.atan", "'-1'", -Math.PI/4) |
michael@0 | 154 | testmath("Math.atan", "'Infinity'", Math.PI/2) |
michael@0 | 155 | testmath("Math.atan", "'-Infinity'", -Math.PI/2) |
michael@0 | 156 | testmath("Math.atan", "0", 0) |
michael@0 | 157 | testmath("Math.atan", "-0", -0) |
michael@0 | 158 | testmath("Infinity/Math.atan", "-0", -Infinity) |
michael@0 | 159 | testmath("Math.atan", "Number.POSITIVE_INFINITY", Math.PI/2) |
michael@0 | 160 | testmath("Math.atan", "Number.NEGATIVE_INFINITY", -Math.PI/2) |
michael@0 | 161 | testmath("Math.atan", "1", Math.PI/4) |
michael@0 | 162 | testmath("Math.atan", "-1", -Math.PI/4) |
michael@0 | 163 | |
michael@0 | 164 | testmath("Math.atan2", "Number.NaN,0", Number.NaN) |
michael@0 | 165 | testmath("Math.atan2", "null, null", 0) |
michael@0 | 166 | testmath("Math.atan2", "void 0, void 0", Number.NaN) |
michael@0 | 167 | testmath("Math.atan2", "0,Number.NaN", Number.NaN) |
michael@0 | 168 | testmath("Math.atan2", "1,0", Math.PI/2) |
michael@0 | 169 | testmath("Math.atan2", "1,-0", Math.PI/2) |
michael@0 | 170 | testmath("Math.atan2", "0,0.001", 0) |
michael@0 | 171 | testmath("Math.atan2", "0,0", 0) |
michael@0 | 172 | testmath("Math.atan2", "0,-0", Math.PI) |
michael@0 | 173 | testmath("Math.atan2", "0, -1", Math.PI) |
michael@0 | 174 | testmath("Math.atan2", "-0, 1", -0) |
michael@0 | 175 | testmath("Infinity/Math.atan2", "-0,1", -Infinity) |
michael@0 | 176 | testmath("Math.atan2", "-0,0", -0) |
michael@0 | 177 | testmath("Math.atan2", "-0, -0", -Math.PI) |
michael@0 | 178 | testmath("Math.atan2", "-0, -1", -Math.PI) |
michael@0 | 179 | testmath("Math.atan2", "-1, 0", -Math.PI/2) |
michael@0 | 180 | testmath("Math.atan2", "-1, -0", -Math.PI/2) |
michael@0 | 181 | testmath("Math.atan2", "1, Number.POSITIVE_INFINITY", 0) |
michael@0 | 182 | testmath("Math.atan2", "1, Number.NEGATIVE_INFINITY", Math.PI) |
michael@0 | 183 | testmath("Math.atan2", "-1,Number.POSITIVE_INFINITY", -0) |
michael@0 | 184 | testmath("Infinity/Math.atan2", "-1,Infinity", -Infinity) |
michael@0 | 185 | testmath("Math.atan2", "-1,Number.NEGATIVE_INFINITY", -Math.PI) |
michael@0 | 186 | testmath("Math.atan2", "Number.POSITIVE_INFINITY, 0", Math.PI/2) |
michael@0 | 187 | testmath("Math.atan2", "Number.POSITIVE_INFINITY, 1", Math.PI/2) |
michael@0 | 188 | testmath("Math.atan2", "Number.POSITIVE_INFINITY,-1", Math.PI/2) |
michael@0 | 189 | testmath("Math.atan2", "Number.POSITIVE_INFINITY,-0", Math.PI/2) |
michael@0 | 190 | testmath("Math.atan2", "Number.NEGATIVE_INFINITY, 0", -Math.PI/2) |
michael@0 | 191 | testmath("Math.atan2", "Number.NEGATIVE_INFINITY,-0", -Math.PI/2) |
michael@0 | 192 | testmath("Math.atan2", "Number.NEGATIVE_INFINITY, 1", -Math.PI/2) |
michael@0 | 193 | testmath("Math.atan2", "Number.NEGATIVE_INFINITY,-1", -Math.PI/2) |
michael@0 | 194 | testmath("Math.atan2", "Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY", Math.PI/4) |
michael@0 | 195 | testmath("Math.atan2", "Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY", 3*Math.PI/4) |
michael@0 | 196 | testmath("Math.atan2", "Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY", -Math.PI/4) |
michael@0 | 197 | testmath("Math.atan2", "Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY", -3*Math.PI/4) |
michael@0 | 198 | testmath("Math.atan2", "-1, 1", -Math.PI/4) |
michael@0 | 199 | |
michael@0 | 200 | testmath("Math.ceil", "Number.NaN", Number.NaN) |
michael@0 | 201 | testmath("Math.ceil", "null", 0) |
michael@0 | 202 | testmath("Math.ceil", "void 0", Number.NaN) |
michael@0 | 203 | testmath("Math.ceil", "'0'", 0) |
michael@0 | 204 | testmath("Math.ceil", "'-0'", -0) |
michael@0 | 205 | testmath("Infinity/Math.ceil", "'0'", Infinity) |
michael@0 | 206 | testmath("Infinity/Math.ceil", "'-0'", -Infinity) |
michael@0 | 207 | testmath("Math.ceil", "0", 0) |
michael@0 | 208 | testmath("Math.ceil", "-0", -0) |
michael@0 | 209 | testmath("Infinity/Math.ceil", "0", Infinity) |
michael@0 | 210 | testmath("Infinity/Math.ceil", "-0", -Infinity) |
michael@0 | 211 | testmath("Math.ceil", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 212 | testmath("Math.ceil", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY) |
michael@0 | 213 | testmath("Math.ceil", "-Number.MIN_VALUE", -0) |
michael@0 | 214 | testmath("Infinity/Math.ceil", "-Number.MIN_VALUE", -Infinity) |
michael@0 | 215 | testmath("Math.ceil", "1", 1) |
michael@0 | 216 | testmath("Math.ceil", "-1", -1) |
michael@0 | 217 | testmath("Math.ceil", "-0.9", -0) |
michael@0 | 218 | testmath("Infinity/Math.ceil", "-0.9", -Infinity) |
michael@0 | 219 | testmath("Math.ceil", "0.9", 1) |
michael@0 | 220 | testmath("Math.ceil", "-1.1", -1) |
michael@0 | 221 | testmath("Math.ceil", "1.1", 2) |
michael@0 | 222 | testmath("Math.ceil", "Number.POSITIVE_INFINITY", -Math.floor(-Infinity)) |
michael@0 | 223 | testmath("Math.ceil", "Number.NEGATIVE_INFINITY", -Math.floor(Infinity)) |
michael@0 | 224 | testmath("Math.ceil", "-Number.MIN_VALUE", -Math.floor(Number.MIN_VALUE)) |
michael@0 | 225 | testmath("Math.ceil", "1", -Math.floor(-1)) |
michael@0 | 226 | testmath("Math.ceil", "-1", -Math.floor(1)) |
michael@0 | 227 | testmath("Math.ceil", "-0.9", -Math.floor(0.9)) |
michael@0 | 228 | testmath("Math.ceil", "0.9", -Math.floor(-0.9)) |
michael@0 | 229 | testmath("Math.ceil", "-1.1", -Math.floor(1.1)) |
michael@0 | 230 | testmath("Math.ceil", "1.1", -Math.floor(-1.1)) |
michael@0 | 231 | |
michael@0 | 232 | testmath("Math.cos", "void 0", Number.NaN) |
michael@0 | 233 | testmath("Math.cos", "false", 1) |
michael@0 | 234 | testmath("Math.cos", "null", 1) |
michael@0 | 235 | testmath("Math.cos", "'0'", 1) |
michael@0 | 236 | testmath("Math.cos", "\"Infinity\"", Number.NaN) |
michael@0 | 237 | testmath("Math.cos", "'3.14159265359'", -1) |
michael@0 | 238 | testmath("Math.cos", "Number.NaN", Number.NaN) |
michael@0 | 239 | testmath("Math.cos", "0", 1) |
michael@0 | 240 | testmath("Math.cos", "-0", 1) |
michael@0 | 241 | testmath("Math.cos", "Number.POSITIVE_INFINITY", Number.NaN) |
michael@0 | 242 | testmath("Math.cos", "Number.NEGATIVE_INFINITY", Number.NaN) |
michael@0 | 243 | testmath("Math.cos", "0.7853981633974", 0.7071067811865) |
michael@0 | 244 | testmath("Math.cos", "1.570796326795", 0) |
michael@0 | 245 | testmath("Math.cos", "2.356194490192", -0.7071067811865) |
michael@0 | 246 | testmath("Math.cos", "3.14159265359", -1) |
michael@0 | 247 | testmath("Math.cos", "3.926990816987", -0.7071067811865) |
michael@0 | 248 | testmath("Math.cos", "4.712388980385", 0) |
michael@0 | 249 | testmath("Math.cos", "5.497787143782", 0.7071067811865) |
michael@0 | 250 | testmath("Math.cos", "Math.PI*2", 1) |
michael@0 | 251 | testmath("Math.cos", "Math.PI/4", Math.SQRT2/2) |
michael@0 | 252 | testmath("Math.cos", "Math.PI/2", 0) |
michael@0 | 253 | testmath("Math.cos", "3*Math.PI/4", -Math.SQRT2/2) |
michael@0 | 254 | testmath("Math.cos", "Math.PI", -1) |
michael@0 | 255 | testmath("Math.cos", "5*Math.PI/4", -Math.SQRT2/2) |
michael@0 | 256 | testmath("Math.cos", "3*Math.PI/2", 0) |
michael@0 | 257 | testmath("Math.cos", "7*Math.PI/4", Math.SQRT2/2) |
michael@0 | 258 | testmath("Math.cos", "2*Math.PI", 1) |
michael@0 | 259 | testmath("Math.cos", "-0.7853981633974", 0.7071067811865) |
michael@0 | 260 | testmath("Math.cos", "-1.570796326795", 0) |
michael@0 | 261 | testmath("Math.cos", "2.3561944901920", -.7071067811865) |
michael@0 | 262 | testmath("Math.cos", "3.14159265359", -1) |
michael@0 | 263 | testmath("Math.cos", "3.926990816987", -0.7071067811865) |
michael@0 | 264 | testmath("Math.cos", "4.712388980385", 0) |
michael@0 | 265 | testmath("Math.cos", "5.497787143782", 0.7071067811865) |
michael@0 | 266 | testmath("Math.cos", "6.28318530718", 1) |
michael@0 | 267 | testmath("Math.cos", "-Math.PI/4", Math.SQRT2/2) |
michael@0 | 268 | testmath("Math.cos", "-Math.PI/2", 0) |
michael@0 | 269 | testmath("Math.cos", "-3*Math.PI/4", -Math.SQRT2/2) |
michael@0 | 270 | testmath("Math.cos", "-Math.PI", -1) |
michael@0 | 271 | testmath("Math.cos", "-5*Math.PI/4", -Math.SQRT2/2) |
michael@0 | 272 | testmath("Math.cos", "-3*Math.PI/2", 0) |
michael@0 | 273 | testmath("Math.cos", "-7*Math.PI/4", Math.SQRT2/2) |
michael@0 | 274 | testmath("Math.cos", "-Math.PI*2", 1) |
michael@0 | 275 | |
michael@0 | 276 | testmath("Math.exp", "null", 1) |
michael@0 | 277 | testmath("Math.exp", "void 0", Number.NaN) |
michael@0 | 278 | testmath("Math.exp", "1", Math.E) |
michael@0 | 279 | testmath("Math.exp", "true", Math.E) |
michael@0 | 280 | testmath("Math.exp", "false", 1) |
michael@0 | 281 | testmath("Math.exp", "'1'", Math.E) |
michael@0 | 282 | testmath("Math.exp", "'0'", 1) |
michael@0 | 283 | testmath("Math.exp", "Number.NaN", Number.NaN) |
michael@0 | 284 | testmath("Math.exp", "0", 1) |
michael@0 | 285 | testmath("Math.exp", "-0", 1) |
michael@0 | 286 | testmath("Math.exp", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 287 | testmath("Math.exp", "Number.NEGATIVE_INFINITY", 0) |
michael@0 | 288 | |
michael@0 | 289 | testmath("Math.floor", "void 0", Number.NaN) |
michael@0 | 290 | testmath("Math.floor", "null", 0) |
michael@0 | 291 | testmath("Math.floor", "true", 1) |
michael@0 | 292 | testmath("Math.floor", "false", 0) |
michael@0 | 293 | testmath("Math.floor", "\"1.1\"", 1) |
michael@0 | 294 | testmath("Math.floor", "\"-1.1\"", -2) |
michael@0 | 295 | testmath("Math.floor", "\"0.1\"", 0) |
michael@0 | 296 | testmath("Math.floor", "\"-0.1\"", -1) |
michael@0 | 297 | testmath("Math.floor", "Number.NaN", Number.NaN) |
michael@0 | 298 | testmath("Math.floor(Number.NaN) == -Math.ceil", "-Number.NaN", false) |
michael@0 | 299 | testmath("Math.floor", "0", 0) |
michael@0 | 300 | testmath("Math.floor(0) == -Math.ceil", "-0", true) |
michael@0 | 301 | testmath("Math.floor", "-0", -0) |
michael@0 | 302 | testmath("Infinity/Math.floor", "-0", -Infinity) |
michael@0 | 303 | testmath("Math.floor(-0)== -Math.ceil", "0", true) |
michael@0 | 304 | testmath("Math.floor", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 305 | testmath("Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil", "Number.NEGATIVE_INFINITY", true) |
michael@0 | 306 | testmath("Math.floor", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY) |
michael@0 | 307 | testmath("Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil", "Number.POSITIVE_INFINITY", true) |
michael@0 | 308 | testmath("Math.floor", "0.0000001", 0) |
michael@0 | 309 | testmath("Math.floor(0.0000001)==-Math.ceil", "-0.0000001", true) |
michael@0 | 310 | testmath("Math.floor", "-0.0000001", -1) |
michael@0 | 311 | testmath("Math.floor(-0.0000001)==-Math.ceil", "0.0000001", true) |
michael@0 | 312 | |
michael@0 | 313 | testmath("Math.log", "void 0", Number.NaN) |
michael@0 | 314 | testmath("Math.log", "null", Number.NEGATIVE_INFINITY) |
michael@0 | 315 | testmath("Math.log", "true", 0) |
michael@0 | 316 | testmath("Math.log", "false", -Infinity) |
michael@0 | 317 | testmath("Math.log", "'0'", -Infinity) |
michael@0 | 318 | testmath("Math.log", "'1'", 0) |
michael@0 | 319 | testmath("Math.log", "\"Infinity\"", Infinity) |
michael@0 | 320 | testmath("Math.log", "Number.NaN", Number.NaN) |
michael@0 | 321 | testmath("Math.log", "-0.000001", Number.NaN) |
michael@0 | 322 | testmath("Math.log", "-1", Number.NaN) |
michael@0 | 323 | testmath("Math.log", "0", Number.NEGATIVE_INFINITY) |
michael@0 | 324 | testmath("Math.log", "-0", Number.NEGATIVE_INFINITY) |
michael@0 | 325 | testmath("Math.log", "1", 0) |
michael@0 | 326 | testmath("Math.log", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 327 | testmath("Math.log", "Number.NEGATIVE_INFINITY", Number.NaN) |
michael@0 | 328 | |
michael@0 | 329 | testmath("Math.max", "void 0, 1", Number.NaN) |
michael@0 | 330 | testmath("Math.max", "void 0, void 0", Number.NaN) |
michael@0 | 331 | testmath("Math.max", "null, 1", 1) |
michael@0 | 332 | testmath("Math.max", "-1, null", 0) |
michael@0 | 333 | testmath("Math.max", "true,false", 1) |
michael@0 | 334 | testmath("Math.max", "\"-99\",\"99\"", 99) |
michael@0 | 335 | testmath("Math.max", "Number.NaN,Number.POSITIVE_INFINITY", Number.NaN) |
michael@0 | 336 | testmath("Math.max", "Number.NaN, 0", Number.NaN) |
michael@0 | 337 | testmath("Math.max", "\"a string\", 0", Number.NaN) |
michael@0 | 338 | testmath("Math.max", "Number.NaN,1", Number.NaN) |
michael@0 | 339 | testmath("Math.max", "\"a string\", Number.POSITIVE_INFINITY", Number.NaN) |
michael@0 | 340 | testmath("Math.max", "Number.POSITIVE_INFINITY, Number.NaN", Number.NaN) |
michael@0 | 341 | testmath("Math.max", "Number.NaN, Number.NaN", Number.NaN) |
michael@0 | 342 | testmath("Math.max", "0,Number.NaN", Number.NaN) |
michael@0 | 343 | testmath("Math.max", "1, Number.NaN", Number.NaN) |
michael@0 | 344 | testmath("Math.max", "0,0", 0) |
michael@0 | 345 | testmath("Math.max", "0,-0", 0) |
michael@0 | 346 | testmath("Math.max", "-0,0", 0) |
michael@0 | 347 | testmath("Math.max", "-0,-0", -0) |
michael@0 | 348 | testmath("Infinity/Math.max", "-0,-0", -Infinity) |
michael@0 | 349 | testmath("Math.max", "Number.POSITIVE_INFINITY, Number.MAX_VALUE", Number.POSITIVE_INFINITY) |
michael@0 | 350 | testmath("Math.max", "Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 351 | testmath("Math.max", "Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY) |
michael@0 | 352 | testmath("Math.max", "1,.99999999999999", 1) |
michael@0 | 353 | testmath("Math.max", "-1,-.99999999999999", -.99999999999999) |
michael@0 | 354 | |
michael@0 | 355 | testmath("Math.min", "void 0, 1", Number.NaN) |
michael@0 | 356 | testmath("Math.min", "void 0, void 0", Number.NaN) |
michael@0 | 357 | testmath("Math.min", "null, 1", 0) |
michael@0 | 358 | testmath("Math.min", "-1, null", -1) |
michael@0 | 359 | testmath("Math.min", "true,false", 0) |
michael@0 | 360 | testmath("Math.min", "\"-99\",\"99\"", -99) |
michael@0 | 361 | testmath("Math.min", "Number.NaN,0", Number.NaN) |
michael@0 | 362 | testmath("Math.min", "Number.NaN,1", Number.NaN) |
michael@0 | 363 | testmath("Math.min", "Number.NaN,-1", Number.NaN) |
michael@0 | 364 | testmath("Math.min", "0,Number.NaN", Number.NaN) |
michael@0 | 365 | testmath("Math.min", "1,Number.NaN", Number.NaN) |
michael@0 | 366 | testmath("Math.min", "-1,Number.NaN", Number.NaN) |
michael@0 | 367 | testmath("Math.min", "Number.NaN,Number.NaN", Number.NaN) |
michael@0 | 368 | testmath("Math.min", "1,1.0000000001", 1) |
michael@0 | 369 | testmath("Math.min", "1.0000000001,1", 1) |
michael@0 | 370 | testmath("Math.min", "0,0", 0) |
michael@0 | 371 | testmath("Math.min", "0,-0", -0) |
michael@0 | 372 | testmath("Math.min", "-0,-0", -0) |
michael@0 | 373 | testmath("Infinity/Math.min", "0,-0", -Infinity) |
michael@0 | 374 | testmath("Infinity/Math.min", "-0,-0", -Infinity) |
michael@0 | 375 | |
michael@0 | 376 | testmath("Math.pow", "null,null", 1) |
michael@0 | 377 | testmath("Math.pow", "void 0, void 0", Number.NaN) |
michael@0 | 378 | testmath("Math.pow", "true, false", 1) |
michael@0 | 379 | testmath("Math.pow", "false,true", 0) |
michael@0 | 380 | testmath("Math.pow", "'2','32'", 4294967296) |
michael@0 | 381 | testmath("Math.pow", "1,Number.NaN", Number.NaN) |
michael@0 | 382 | testmath("Math.pow", "0,Number.NaN", Number.NaN) |
michael@0 | 383 | testmath("Math.pow", "Number.NaN,0", 1) |
michael@0 | 384 | testmath("Math.pow", "Number.NaN,-0", 1) |
michael@0 | 385 | testmath("Math.pow", "Number.NaN, 1", Number.NaN) |
michael@0 | 386 | testmath("Math.pow", "Number.NaN, .5", Number.NaN) |
michael@0 | 387 | testmath("Math.pow", "1.00000001, Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 388 | testmath("Math.pow", "1.00000001, Number.NEGATIVE_INFINITY", 0) |
michael@0 | 389 | testmath("Math.pow", "-1.00000001,Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 390 | testmath("Math.pow", "-1.00000001,Number.NEGATIVE_INFINITY", 0) |
michael@0 | 391 | testmath("Math.pow", "1, Number.POSITIVE_INFINITY", Number.NaN) |
michael@0 | 392 | testmath("Math.pow", "1, Number.NEGATIVE_INFINITY", Number.NaN) |
michael@0 | 393 | testmath("Math.pow", "-1, Number.POSITIVE_INFINITY", Number.NaN) |
michael@0 | 394 | testmath("Math.pow", "-1, Number.NEGATIVE_INFINITY", Number.NaN) |
michael@0 | 395 | testmath("Math.pow", ".0000000009, Number.POSITIVE_INFINITY", 0) |
michael@0 | 396 | testmath("Math.pow", "-.0000000009, Number.POSITIVE_INFINITY", 0) |
michael@0 | 397 | testmath("Math.pow", "-.0000000009, Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 398 | testmath("Math.pow", "Number.POSITIVE_INFINITY,.00000000001", Number.POSITIVE_INFINITY) |
michael@0 | 399 | testmath("Math.pow", "Number.POSITIVE_INFINITY, 1", Number.POSITIVE_INFINITY) |
michael@0 | 400 | testmath("Math.pow", "Number.POSITIVE_INFINITY, -.00000000001", 0) |
michael@0 | 401 | testmath("Math.pow", "Number.POSITIVE_INFINITY, -1", 0) |
michael@0 | 402 | testmath("Math.pow", "Number.NEGATIVE_INFINITY, 1", Number.NEGATIVE_INFINITY) |
michael@0 | 403 | testmath("Math.pow", "Number.NEGATIVE_INFINITY, 333", Number.NEGATIVE_INFINITY) |
michael@0 | 404 | testmath("Math.pow", "Number.POSITIVE_INFINITY, 2", Number.POSITIVE_INFINITY) |
michael@0 | 405 | testmath("Math.pow", "Number.NEGATIVE_INFINITY, 666", Number.POSITIVE_INFINITY) |
michael@0 | 406 | testmath("Math.pow", "Number.NEGATIVE_INFINITY, 0.5", Number.POSITIVE_INFINITY) |
michael@0 | 407 | testmath("Math.pow", "Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 408 | testmath("Math.pow", "Number.NEGATIVE_INFINITY, -1", -0) |
michael@0 | 409 | testmath("Infinity/Math.pow", "Number.NEGATIVE_INFINITY, -1", -Infinity) |
michael@0 | 410 | testmath("Math.pow", "Number.NEGATIVE_INFINITY, -3", -0) |
michael@0 | 411 | testmath("Math.pow", "Number.NEGATIVE_INFINITY, -2", 0) |
michael@0 | 412 | testmath("Math.pow", "Number.NEGATIVE_INFINITY,-0.5", 0) |
michael@0 | 413 | testmath("Math.pow", "Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY", 0) |
michael@0 | 414 | testmath("Math.pow", "0,1", 0) |
michael@0 | 415 | testmath("Math.pow", "0,0", 1) |
michael@0 | 416 | testmath("Math.pow", "1,0", 1) |
michael@0 | 417 | testmath("Math.pow", "-1,0", 1) |
michael@0 | 418 | testmath("Math.pow", "0,0.5", 0) |
michael@0 | 419 | testmath("Math.pow", "0,1000", 0) |
michael@0 | 420 | testmath("Math.pow", "0, Number.POSITIVE_INFINITY", 0) |
michael@0 | 421 | testmath("Math.pow", "0, -1", Number.POSITIVE_INFINITY) |
michael@0 | 422 | testmath("Math.pow", "0, -0.5", Number.POSITIVE_INFINITY) |
michael@0 | 423 | testmath("Math.pow", "0, -1000", Number.POSITIVE_INFINITY) |
michael@0 | 424 | testmath("Math.pow", "0, Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 425 | testmath("Math.pow", "-0, 1", -0) |
michael@0 | 426 | testmath("Math.pow", "-0,3", -0) |
michael@0 | 427 | testmath("Infinity/Math.pow", "-0, 1", -Infinity) |
michael@0 | 428 | testmath("Infinity/Math.pow", "-0,3", -Infinity) |
michael@0 | 429 | testmath("Math.pow", "-0,2", 0) |
michael@0 | 430 | testmath("Math.pow", "-0, Number.POSITIVE_INFINITY", 0) |
michael@0 | 431 | testmath("Math.pow", "-0, -1", Number.NEGATIVE_INFINITY) |
michael@0 | 432 | testmath("Math.pow", "-0, -10001", Number.NEGATIVE_INFINITY) |
michael@0 | 433 | testmath("Math.pow", "-0, -2", Number.POSITIVE_INFINITY) |
michael@0 | 434 | testmath("Math.pow", "-0, 0.5", 0) |
michael@0 | 435 | testmath("Math.pow", "-0, Number.POSITIVE_INFINITY", 0) |
michael@0 | 436 | testmath("Math.pow", "-1, 0.5", Number.NaN) |
michael@0 | 437 | testmath("Math.pow", "-1, Number.NaN", Number.NaN) |
michael@0 | 438 | testmath("Math.pow", "-1, -0.5", Number.NaN) |
michael@0 | 439 | |
michael@0 | 440 | testmath("Math.round", "0", 0) |
michael@0 | 441 | testmath("Math.round", "void 0", Number.NaN) |
michael@0 | 442 | testmath("Math.round", "true", 1) |
michael@0 | 443 | testmath("Math.round", "false", 0) |
michael@0 | 444 | testmath("Math.round", "'.99999'", 1) |
michael@0 | 445 | testmath("Math.round", "'12345e-2'", 123) |
michael@0 | 446 | testmath("Math.round", "Number.NaN", Number.NaN) |
michael@0 | 447 | testmath("Math.round", "0", 0) |
michael@0 | 448 | testmath("Math.round", "-0", -0) |
michael@0 | 449 | testmath("Infinity/Math.round", "-0", -Infinity) |
michael@0 | 450 | testmath("Math.round", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 451 | testmath("Math.round", "Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY) |
michael@0 | 452 | testmath("Math.round", "0.49", 0) |
michael@0 | 453 | testmath("Math.round", "0.5", 1) |
michael@0 | 454 | testmath("Math.round", "0.51", 1) |
michael@0 | 455 | testmath("Math.round", "-0.49", -0) |
michael@0 | 456 | testmath("Math.round", "-0.5", -0) |
michael@0 | 457 | testmath("Infinity/Math.round", "-0.49", -Infinity) |
michael@0 | 458 | testmath("Infinity/Math.round", "-0.5", -Infinity) |
michael@0 | 459 | testmath("Math.round", "-0.51", -1) |
michael@0 | 460 | testmath("Math.round", "3.5", 4) |
michael@0 | 461 | testmath("Math.round", "-3", -3) |
michael@0 | 462 | |
michael@0 | 463 | testmath("Math.sin", "null", 0) |
michael@0 | 464 | testmath("Math.sin", "void 0", Number.NaN) |
michael@0 | 465 | testmath("Math.sin", "false", 0) |
michael@0 | 466 | testmath("Math.sin", "'2.356194490192'", 0.7071067811865) |
michael@0 | 467 | testmath("Math.sin", "Number.NaN", Number.NaN) |
michael@0 | 468 | testmath("Math.sin", "0", 0) |
michael@0 | 469 | testmath("Math.sin", "-0", -0) |
michael@0 | 470 | testmath("Math.sin", "Number.POSITIVE_INFINITY", Number.NaN) |
michael@0 | 471 | testmath("Math.sin", "Number.NEGATIVE_INFINITY", Number.NaN) |
michael@0 | 472 | testmath("Math.sin", "0.7853981633974", 0.7071067811865) |
michael@0 | 473 | testmath("Math.sin", "1.570796326795", 1) |
michael@0 | 474 | testmath("Math.sin", "2.356194490192", 0.7071067811865) |
michael@0 | 475 | testmath("Math.sin", "3.14159265359", 0) |
michael@0 | 476 | |
michael@0 | 477 | testmath("Math.sqrt", "void 0", Number.NaN) |
michael@0 | 478 | testmath("Math.sqrt", "null", 0) |
michael@0 | 479 | testmath("Math.sqrt", "1", 1) |
michael@0 | 480 | testmath("Math.sqrt", "false", 0) |
michael@0 | 481 | testmath("Math.sqrt", "'225'", 15) |
michael@0 | 482 | testmath("Math.sqrt", "Number.NaN", Number.NaN) |
michael@0 | 483 | testmath("Math.sqrt", "Number.NEGATIVE_INFINITY", Number.NaN) |
michael@0 | 484 | testmath("Math.sqrt", "-1", Number.NaN) |
michael@0 | 485 | testmath("Math.sqrt", "-0.5", Number.NaN) |
michael@0 | 486 | testmath("Math.sqrt", "0", 0) |
michael@0 | 487 | testmath("Math.sqrt", "-0", -0) |
michael@0 | 488 | testmath("Infinity/Math.sqrt", "-0", -Infinity) |
michael@0 | 489 | testmath("Math.sqrt", "Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY) |
michael@0 | 490 | testmath("Math.sqrt", "1", 1) |
michael@0 | 491 | testmath("Math.sqrt", "2", Math.SQRT2) |
michael@0 | 492 | testmath("Math.sqrt", "0.5", Math.SQRT1_2) |
michael@0 | 493 | testmath("Math.sqrt", "4", 2) |
michael@0 | 494 | testmath("Math.sqrt", "9", 3) |
michael@0 | 495 | testmath("Math.sqrt", "16", 4) |
michael@0 | 496 | testmath("Math.sqrt", "25", 5) |
michael@0 | 497 | testmath("Math.sqrt", "36", 6) |
michael@0 | 498 | testmath("Math.sqrt", "49", 7) |
michael@0 | 499 | testmath("Math.sqrt", "64", 8) |
michael@0 | 500 | testmath("Math.sqrt", "256", 16) |
michael@0 | 501 | testmath("Math.sqrt", "10000", 100) |
michael@0 | 502 | testmath("Math.sqrt", "65536", 256) |
michael@0 | 503 | testmath("Math.sqrt", "0.09", 0.3) |
michael@0 | 504 | testmath("Math.sqrt", "0.01", 0.1) |
michael@0 | 505 | testmath("Math.sqrt", "0.00000001", 0.0001) |
michael@0 | 506 | |
michael@0 | 507 | testmath("Math.tan", "void 0", Number.NaN) |
michael@0 | 508 | testmath("Math.tan", "null", 0) |
michael@0 | 509 | testmath("Math.tan", "false", 0) |
michael@0 | 510 | testmath("Math.tan", "Number.NaN", Number.NaN) |
michael@0 | 511 | testmath("Math.tan", "0", 0) |
michael@0 | 512 | testmath("Math.tan", "-0", -0) |
michael@0 | 513 | testmath("Math.tan", "Number.POSITIVE_INFINITY", Number.NaN) |
michael@0 | 514 | testmath("Math.tan", "Number.NEGATIVE_INFINITY", Number.NaN) |
michael@0 | 515 | testmath("Math.tan", "Math.PI/4", 1) |
michael@0 | 516 | testmath("Math.tan", "3*Math.PI/4", -1) |
michael@0 | 517 | testmath("Math.tan", "Math.PI", -0) |
michael@0 | 518 | testmath("Math.tan", "5*Math.PI/4", 1) |
michael@0 | 519 | testmath("Math.tan", "7*Math.PI/4", -1) |
michael@0 | 520 | testmath("Infinity/Math.tan", "-0", -Infinity) |