summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-06 21:10:33 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:35:50 +0200
commit33c01702f81722b4aa17e01e83916af360b1e3f9 (patch)
treebc6d00232be5a87a1230ed1e7b7464184cb483d9 /tests
parent4244ce1d2933c11229a2468d4f41c58b73ed649c (diff)
Use do_run_from_file() for test_i32_mul_semiprecise
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_i32_mul_semiprecise.in28
-rw-r--r--tests/core/test_i32_mul_semiprecise.out10
-rw-r--r--tests/test_core.py41
3 files changed, 41 insertions, 38 deletions
diff --git a/tests/core/test_i32_mul_semiprecise.in b/tests/core/test_i32_mul_semiprecise.in
new file mode 100644
index 00000000..c7b4cb96
--- /dev/null
+++ b/tests/core/test_i32_mul_semiprecise.in
@@ -0,0 +1,28 @@
+
+ #include <stdio.h>
+
+ typedef unsigned int uint;
+
+ // from cube2, zlib licensed
+
+ #define N (624)
+ #define M (397)
+ #define K (0x9908B0DFU)
+
+ static uint state[N];
+ static int next = N;
+
+ void seedMT(uint seed)
+ {
+ state[0] = seed;
+ for(uint i = 1; i < N; i++) // if we do not do this precisely, at least we should coerce to int immediately, not wait
+ state[i] = seed = 1812433253U * (seed ^ (seed >> 30)) + i;
+ next = 0;
+ }
+
+ int main() {
+ seedMT(5497);
+ for (int i = 0; i < 10; i++) printf("%d: %u\n", i, state[i]);
+ return 0;
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_i32_mul_semiprecise.out b/tests/core/test_i32_mul_semiprecise.out
new file mode 100644
index 00000000..261bf9a9
--- /dev/null
+++ b/tests/core/test_i32_mul_semiprecise.out
@@ -0,0 +1,10 @@
+0: 5497
+1: 2916432318
+2: 2502517762
+3: 3151524867
+4: 2323729668
+5: 2053478917
+6: 2409490438
+7: 848473607
+8: 691103752
+9: 3915535113
diff --git a/tests/test_core.py b/tests/test_core.py
index 351745e2..f30a8669 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -437,45 +437,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
Settings.PRECISE_I32_MUL = 0 # we want semiprecise here
- src = r'''
- #include <stdio.h>
-
- typedef unsigned int uint;
-
- // from cube2, zlib licensed
-
- #define N (624)
- #define M (397)
- #define K (0x9908B0DFU)
-
- static uint state[N];
- static int next = N;
-
- void seedMT(uint seed)
- {
- state[0] = seed;
- for(uint i = 1; i < N; i++) // if we do not do this precisely, at least we should coerce to int immediately, not wait
- state[i] = seed = 1812433253U * (seed ^ (seed >> 30)) + i;
- next = 0;
- }
+ test_path = path_from_root('tests', 'core', 'test_i32_mul_semiprecise')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- seedMT(5497);
- for (int i = 0; i < 10; i++) printf("%d: %u\n", i, state[i]);
- return 0;
- }
- '''
- self.do_run(src, '''0: 5497
-1: 2916432318
-2: 2502517762
-3: 3151524867
-4: 2323729668
-5: 2053478917
-6: 2409490438
-7: 848473607
-8: 691103752
-9: 3915535113
-''')
+ self.do_run_from_file(src, output)
def test_i16_emcc_intrinsic(self):
Settings.CORRECT_SIGNS = 1 # Relevant to this test