Bug 918163: Tests
authorBenjamin Bouvier <benj@benj.me>
Tue, 22 Oct 2013 14:58:29 +0200
changeset 151643 6bedc085975507a4f3aa025f45ea2a4116186e8b
parent 151642 b3056780fa816cdb8649e1ca95607cead17da525
child 151644 8fcdb3653f5724b24c5618571593d1a4027e8c8a
push id35266
push userbenj@benj.me
push dateTue, 22 Oct 2013 12:59:08 +0000
treeherdermozilla-inbound@6bedc0859755 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs918163
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 918163: Tests
js/src/jit-test/tests/ion/testFloat32-correctness.js
--- a/js/src/jit-test/tests/ion/testFloat32-correctness.js
+++ b/js/src/jit-test/tests/ion/testFloat32-correctness.js
@@ -164,8 +164,66 @@ test(setupToInt32, testToInt32);
 function setupBailoutToInt32() {
     f32[0] = .5;
 }
 function testBailoutToInt32() {
     assertEq(typeof str[f32[0]], 'undefined');
 }
 test(setupBailoutToInt32, testBailoutToInt32);
 
+// MMath
+function assertNear(a, b) {
+    return ( a != a && b != b ) ||
+           Math.abs(a-b) < 1e-7;
+}
+function setupTrigo() {
+    f32[0] = 0;
+    f32[1] = Math.PI / 2;
+    f32[2] = Math.PI;
+    f32[3] = 3 * Math.PI / 2;
+}
+function trigo() {
+    // Cos
+    assertNear(Math.fround(Math.cos(f32[0])), Math.cos(0));
+    assertNear(Math.fround(Math.cos(f32[1])), Math.cos(Math.PI / 2));
+    assertNear(Math.fround(Math.cos(f32[2])), Math.cos(Math.PI));
+    assertNear(Math.fround(Math.cos(f32[3])), Math.cos(3 * Math.PI / 2));
+
+    // Sin
+    assertNear(Math.fround(Math.sin(f32[0])), Math.sin(0));
+    assertNear(Math.fround(Math.sin(f32[1])), Math.sin(Math.PI / 2));
+    assertNear(Math.fround(Math.sin(f32[2])), Math.sin(Math.PI));
+    assertNear(Math.fround(Math.sin(f32[3])), Math.sin(3 * Math.PI / 2));
+
+    // Tan
+    assertNear(Math.fround(Math.tan(f32[0])), Math.tan(0));
+    assertNear(Math.fround(Math.tan(f32[1])), Math.tan(Math.PI / 2));
+    assertNear(Math.fround(Math.tan(f32[2])), Math.tan(Math.PI));
+    assertNear(Math.fround(Math.tan(f32[3])), Math.tan(3 * Math.PI / 2));
+
+    // ACos
+    assertNear(Math.fround(Math.acos(f32[0])), Math.acos(0));
+    assertNear(Math.fround(Math.acos(f32[1])), Math.acos(Math.PI / 2));
+    assertNear(Math.fround(Math.acos(f32[2])), Math.acos(Math.PI));
+    assertNear(Math.fround(Math.acos(f32[3])), Math.acos(3 * Math.PI / 2));
+
+    // ASin
+    assertNear(Math.fround(Math.asin(f32[0])), Math.asin(0));
+    assertNear(Math.fround(Math.asin(f32[1])), Math.asin(Math.PI / 2));
+    assertNear(Math.fround(Math.asin(f32[2])), Math.asin(Math.PI));
+    assertNear(Math.fround(Math.asin(f32[3])), Math.asin(3 * Math.PI / 2));
+
+    // ATan
+    assertNear(Math.fround(Math.atan(f32[0])), Math.atan(0));
+    assertNear(Math.fround(Math.atan(f32[1])), Math.atan(Math.PI / 2));
+    assertNear(Math.fround(Math.atan(f32[2])), Math.atan(Math.PI));
+    assertNear(Math.fround(Math.atan(f32[3])), Math.atan(3 * Math.PI / 2));
+}
+test(setupTrigo, trigo);
+
+function otherMath() {
+    for (var i = 0; i < 10; ++i) {
+        assertNear(Math.fround(Math.exp(f32[i])), Math.exp(f32[i]));
+        assertNear(Math.fround(Math.log(f32[i])), Math.log(f32[i]));
+    }
+};
+test(setupComp, otherMath);
+