diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-01-25 00:46:51 -0500 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-01-25 00:46:51 -0500 |
commit | 093f3afc35d19608539dafdf0955a6a02fae4297 (patch) | |
tree | b1c09aab6a450d784b3775ce6853b8d2a10b1040 | |
parent | 4a26ed4670df89af0f1c98214fa99f71461ae0e3 (diff) |
Add tests for div() and sincos(), and also implement and test sincosf
-rw-r--r-- | src/library.js | 7 | ||||
-rwxr-xr-x | tests/runner.py | 14 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js index 162c3f9e..96153312 100644 --- a/src/library.js +++ b/src/library.js @@ -4714,6 +4714,13 @@ LibraryManager.library = { {{{ makeSetValue('cosine', '0', 'cosineVal', 'double') }}}; }, + sincosf: function(x, sine, cosine) { + var sineVal = Math.sin(x), + cosineVal = Math.cos(x); + {{{ makeSetValue('sine', '0', 'sineVal', 'float') }}}; + {{{ makeSetValue('cosine', '0', 'cosineVal', 'float') }}}; + }, + __div_t_struct_layout: Runtime.generateStructInfo([ ['i32', 'quot'], ['i32', 'rem'], diff --git a/tests/runner.py b/tests/runner.py index 503458c0..b214c202 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -760,6 +760,7 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv): def test_math(self): src = ''' #include <stdio.h> + #include <stdlib.h> #include <cmath> int main() { @@ -772,11 +773,22 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv): printf(",%d", isinf(INFINITY) != 0); printf(",%d", isinf(-INFINITY) != 0); printf(",%d", isinf(12.3) != 0); + div_t div_result = div(23, 10); + printf(",%d", div_result.quot); + printf(",%d", div_result.rem); + double sine = -1.0, cosine = -1.0; + sincos(0.0, &sine, &cosine); + printf(",%1.1lf", sine); + printf(",%1.1lf", cosine); + float fsine = -1.0f, fcosine = -1.0f; + sincosf(0.0, &fsine, &fcosine); + printf(",%1.1f", fsine); + printf(",%1.1f", fcosine); printf("*\\n"); return 0; } ''' - self.do_run(src, '*3.14,-3.14,1,0,0,0,1,0,1,1,0*') + self.do_run(src, '*3.14,-3.14,1,0,0,0,1,0,1,1,0,2,3,0.0,1.0,0.0,1.0*') def test_math_hyperbolic(self): src = open(path_from_root('tests', 'hyperbolic', 'src.c'), 'r').read() |