summaryrefslogtreecommitdiff
path: root/tests/test_core.py
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-06 19:58:10 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:35:49 +0200
commit0453ade06eec5d1e39c4efdbfe9f000c7510bd4e (patch)
treed2863cb265287673fbae144f77dd0b5b0f60c571 /tests/test_core.py
parent3d2406f47c732f9d0693f7ca27ff992432027705 (diff)
Use do_run_from_file() for test_intvars
Diffstat (limited to 'tests/test_core.py')
-rw-r--r--tests/test_core.py53
1 files changed, 3 insertions, 50 deletions
diff --git a/tests/test_core.py b/tests/test_core.py
index fde5c8ca..9f5f5a4c 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -20,57 +20,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_intvars(self):
if self.emcc_args == None: return self.skip('needs ta2')
- src = '''
- #include <stdio.h>
- int global = 20;
- int *far;
- int main()
- {
- int x = 5;
- int y = x+17;
- int z = (y-1)/2; // Should stay an integer after division!
- y += 1;
- int w = x*3+4;
- int k = w < 15 ? 99 : 101;
- far = &k;
- *far += global;
- int i = k > 100; // Should be an int, not a bool!
- int j = i << 6;
- j >>= 1;
- j = j ^ 5;
- int h = 1;
- h |= 0;
- int p = h;
- p &= 0;
- printf("*%d,%d,%d,%d,%d,%d,%d,%d,%d*\\n", x, y, z, w, k, i, j, h, p);
-
- long hash = -1;
- size_t perturb;
- int ii = 0;
- for (perturb = hash; ; perturb >>= 5) {
- printf("%d:%d", ii, perturb);
- ii++;
- if (ii == 9) break;
- printf(",");
- }
- printf("*\\n");
- printf("*%.1d,%.2d*\\n", 56, 9);
-
- // Fixed-point math on 64-bit ints. Tricky to support since we have no 64-bit shifts in JS
- {
- struct Fixed {
- static int Mult(int a, int b) {
- return ((long long)a * (long long)b) >> 16;
- }
- };
- printf("fixed:%d\\n", Fixed::Mult(150000, 140000));
- }
+ test_path = path_from_root('tests', 'core', 'test_intvars')
+ src, output = (test_path + s for s in ('.in', '.out'))
- printf("*%ld*%p\\n", (long)21, &hash); // The %p should not enter an infinite loop!
- return 0;
- }
- '''
- self.do_run(src, '*5,23,10,19,121,1,37,1,0*\n0:-1,1:134217727,2:4194303,3:131071,4:4095,5:127,6:3,7:0,8:0*\n*56,09*\nfixed:320434\n*21*')
+ self.do_run_from_file(src, output)
def test_sintvars(self):
Settings.CORRECT_SIGNS = 1 # Relevant to this test