aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/emscripten_get_now.cpp6
-rwxr-xr-xtests/runner.py2
-rw-r--r--tests/test_core.py27
3 files changed, 31 insertions, 4 deletions
diff --git a/tests/emscripten_get_now.cpp b/tests/emscripten_get_now.cpp
index 17aa7d32..5ededb23 100644
--- a/tests/emscripten_get_now.cpp
+++ b/tests/emscripten_get_now.cpp
@@ -14,10 +14,10 @@ int main() {
// b) Values returned by emscripten_get_now() are strictly nondecreasing.
// c) emscripten_get_now() is able to return sub-millisecond precision timer values.
bool detected_good_timer_precision = false;
- float smallest_delta = 0.f;
+ double smallest_delta = 0.f;
for(int x = 0; x < 1000; ++x) { // Have several attempts to find a good small delta, i.e. give time to JS engine to warm up the code and so on.
- float t = emscripten_get_now();
- float t2 = emscripten_get_now();
+ double t = emscripten_get_now();
+ double t2 = emscripten_get_now();
for(int i = 0; i < 100 && t == t2; ++i) {
t2 = emscripten_get_now();
}
diff --git a/tests/runner.py b/tests/runner.py
index 867f7113..483df36e 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -36,7 +36,7 @@ except:
# Core test runner class, shared between normal tests and benchmarks
checked_sanity = False
-test_modes = ['default', 'o1', 'o2', 'asm1', 'asm2', 'asm2g', 'asm2x86', 's_0_0', 's_0_1']
+test_modes = ['default', 'o1', 'o2', 'asm1', 'asm1f', 'asm2', 'asm2g', 'asm2x86', 's_0_0', 's_0_1']
test_index = 0
class RunnerCore(unittest.TestCase):
diff --git a/tests/test_core.py b/tests/test_core.py
index 0cd619b0..a19cde10 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -882,6 +882,32 @@ nada
'''
self.do_run(src, 'OK!\n');
+ def test_float32_precise(self):
+ if self.emcc_args == None or 'PRECISE_F32=1' not in self.emcc_args: return self.skip('needs precise float32')
+
+ src = r'''
+ #include <stdio.h>
+
+ int main(int argc, char **argv) {
+ float x = 1.23456789123456789;
+ float y = 5.20456089123406709;
+ while (argc > 10 || argc % 19 == 15) {
+ // confuse optimizer
+ x /= y;
+ y = 2*y - 1;
+ argc--;
+ }
+ x = x - y;
+ y = 3*y - x/2;
+ x = x*y;
+ y += 0.000000000123123123123;
+ x -= y/7.654;
+ printf("\n%.20f, %.20f\n", x, y);
+ return 0;
+ }
+ '''
+ self.do_run(src, '\n-72.16590881347656250000, 17.59867858886718750000\n')
+
def test_negative_zero(self):
src = r'''
#include <stdio.h>
@@ -10706,6 +10732,7 @@ o2 = make_run("o2", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=0", "-s", "J
# asm.js
asm1 = make_run("asm1", compiler=CLANG, emcc_args=["-O1"])
+asm1f = make_run("asm1f", compiler=CLANG, emcc_args=["-O1", "-s", "PRECISE_F32=1"])
asm2 = make_run("asm2", compiler=CLANG, emcc_args=["-O2"])
asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "ASSERTIONS=1", "--memory-init-file", "1", "-s", "CHECK_HEAP_ALIGN=1"])
asm2x86 = make_run("asm2x86", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "CHECK_HEAP_ALIGN=1"], env={"EMCC_LLVM_TARGET": "i386-pc-linux-gnu"})