diff options
-rw-r--r-- | test/float_ops.cpp | 16 | ||||
-rw-r--r-- | test/float_ops.post.js | 15 | ||||
-rw-r--r-- | test/float_ops.txt | 70 |
3 files changed, 101 insertions, 0 deletions
diff --git a/test/float_ops.cpp b/test/float_ops.cpp index ae1c913de..ddd8bcae6 100644 --- a/test/float_ops.cpp +++ b/test/float_ops.cpp @@ -25,5 +25,21 @@ int EMSCRIPTEN_KEEPALIVE dle(double x, double y) { return x <= y; } int EMSCRIPTEN_KEEPALIVE dgt(double x, double y) { return x > y; } int EMSCRIPTEN_KEEPALIVE dge(double x, double y) { return x >= y; } +double EMSCRIPTEN_KEEPALIVE int_to_double(int x) { + double d = x; + return d + 1.23; +} + +double EMSCRIPTEN_KEEPALIVE uint_to_double(unsigned x) { + double d = x; + return d + 1.23; +} + +int EMSCRIPTEN_KEEPALIVE double_to_int(double d) { + d += 1.23; + int x = d; + return x; +} + } diff --git a/test/float_ops.post.js b/test/float_ops.post.js index 17616ca0a..2b6ea075d 100644 --- a/test/float_ops.post.js +++ b/test/float_ops.post.js @@ -14,6 +14,16 @@ function testUnary(name) { doTest(-1.4); doTest(1.6); doTest(-1.6); + doTest(5.1); + doTest(5.3); + doTest(5.7); + doTest(5.9); + doTest(-1 | 0); + doTest((-1 | 0) + 1); + doTest((-1 | 0) - 1); + doTest(-1 >>> 0); + doTest((-1 >>> 0) + 1); + doTest((-1 >>> 0) - 1); } testUnary('dfloor'); @@ -62,5 +72,10 @@ testBinary('dle'); testBinary('dgt'); testBinary('dge'); +// conversions +testUnary('int_to_double'); +testUnary('uint_to_double'); +testUnary('double_to_int'); + Module.print('done.'); diff --git a/test/float_ops.txt b/test/float_ops.txt index 35106b6e7..768be6061 100644 --- a/test/float_ops.txt +++ b/test/float_ops.txt @@ -8,6 +8,16 @@ dfloor -1.4 ==> -2 1.6 ==> 1 -1.6 ==> -2 + 5.1 ==> 5 + 5.3 ==> 5 + 5.7 ==> 5 + 5.9 ==> 5 + -1 ==> -1 + 0 ==> 0 + -2 ==> -2 + 4294967295 ==> 4294967295 + 4294967296 ==> 4294967296 + 4294967294 ==> 4294967294 dadd 0,0 ==> 0 0,1 ==> 1 @@ -284,4 +294,64 @@ dge -1,5.123 ==> 0 5,-1.123 ==> 1 -1,-1.123 ==> 1 +int_to_double + 0 ==> 1.23 + 1 ==> 2.23 + -1 ==> 0.22999999999999998 + 0.5 ==> 1.23 + -0.5 ==> 1.23 + 1.4 ==> 2.23 + -1.4 ==> 0.22999999999999998 + 1.6 ==> 2.23 + -1.6 ==> 0.22999999999999998 + 5.1 ==> 6.23 + 5.3 ==> 6.23 + 5.7 ==> 6.23 + 5.9 ==> 6.23 + -1 ==> 0.22999999999999998 + 0 ==> 1.23 + -2 ==> -0.77 + 4294967295 ==> 0.22999999999999998 + 4294967296 ==> 1.23 + 4294967294 ==> -0.77 +uint_to_double + 0 ==> 1.23 + 1 ==> 2.23 + -1 ==> 4294967296.23 + 0.5 ==> 1.23 + -0.5 ==> 1.23 + 1.4 ==> 2.23 + -1.4 ==> 4294967296.23 + 1.6 ==> 2.23 + -1.6 ==> 4294967296.23 + 5.1 ==> 6.23 + 5.3 ==> 6.23 + 5.7 ==> 6.23 + 5.9 ==> 6.23 + -1 ==> 4294967296.23 + 0 ==> 1.23 + -2 ==> 4294967295.23 + 4294967295 ==> 4294967296.23 + 4294967296 ==> 1.23 + 4294967294 ==> 4294967295.23 +double_to_int + 0 ==> 1 + 1 ==> 2 + -1 ==> 0 + 0.5 ==> 1 + -0.5 ==> 0 + 1.4 ==> 2 + -1.4 ==> 0 + 1.6 ==> 2 + -1.6 ==> 0 + 5.1 ==> 6 + 5.3 ==> 6 + 5.7 ==> 6 + 5.9 ==> 7 + -1 ==> 0 + 0 ==> 1 + -2 ==> 0 + 4294967295 ==> 0 + 4294967296 ==> 1 + 4294967294 ==> -1 done. |