diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-01-30 13:46:31 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-01-30 13:46:31 -0800 |
commit | 00ebebfd6c09c4173330c0b661dba6e52a73c0c2 (patch) | |
tree | db856b440f05dcdd7c7771689a63c8f22affc91b /tests | |
parent | 5cae031ff9a7551b6f244b110303e26bfa54076b (diff) | |
parent | 31ae7a3a6ea6841f3eb93b23af1de328e2805e84 (diff) |
Merge branch 'rand' of github.com:coolwanglu/emscripten into incoming
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_core.py | 73 |
1 files changed, 34 insertions, 39 deletions
diff --git a/tests/test_core.py b/tests/test_core.py index 6c2968f6..aa69bc4e 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3550,48 +3550,43 @@ ok ''', post_build=self.dlfcn_post_build) def test_rand(self): - return self.skip('rand() is now random') # FIXME - - src = r''' - #include <stdio.h> - #include <stdlib.h> - - int main() { - printf("%d\n", rand()); - printf("%d\n", rand()); - - srand(123); - printf("%d\n", rand()); - printf("%d\n", rand()); - srand(123); - printf("%d\n", rand()); + src = r'''#include <stdlib.h> +#include <stdio.h> +int main() +{ + srand(0xdeadbeef); + for(int i = 0; i < 10; ++i) printf("%d\n", rand()); - unsigned state = 0; - int r; - r = rand_r(&state); - printf("%d, %u\n", r, state); - r = rand_r(&state); - printf("%d, %u\n", r, state); - state = 0; - r = rand_r(&state); - printf("%d, %u\n", r, state); + unsigned int seed = 0xdeadbeef; + for(int i = 0; i < 10; ++i) + printf("%d\n", rand_r(&seed)); - return 0; - } - ''' - expected = ''' - 1250496027 - 1116302336 - 440917656 - 1476150784 - 440917656 - 1476150784 - 12345, 12345 - 1406932606, 3554416254 - 12345, 12345 - ''' - self.do_run(src, re.sub(r'(^|\n)\s+', r'\1', expected)) + return 0; +} +''' + expected = '''2073540312 +730128159 +1365227432 +1337224527 +792390264 +1952655743 +983994184 +1982845871 +1210574360 +1479617503 +2073540312 +730128159 +1365227432 +1337224527 +792390264 +1952655743 +983994184 +1982845871 +1210574360 +1479617503 +''' + self.do_run(src, expected) def test_strtod(self): if self.emcc_args is None: return self.skip('needs emcc for libc') |