/js/src/jit-test/tests/basic/math-jit-tests.js

http://github.com/zpao/v8monkey · JavaScript · 520 lines · 469 code · 29 blank · 22 comment · 18 complexity · 4ad1742312bf01db561b6140204ec315 MD5 · raw file

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