aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 12:36:18 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:35:55 +0200
commit6d66c810e7b3de21a7ddefb28447184c97c638c6 (patch)
tree59d62515a4abcfd59f0ec11790381aac32994b82
parent9858eb7a56cd620e2731a8bb08a12d331d470c92 (diff)
Use do_run_from_file() for test_ptrtoint
-rw-r--r--tests/core/test_ptrtoint.in16
-rw-r--r--tests/core/test_ptrtoint.out1
-rw-r--r--tests/test_core.py21
3 files changed, 22 insertions, 16 deletions
diff --git a/tests/core/test_ptrtoint.in b/tests/core/test_ptrtoint.in
new file mode 100644
index 00000000..be7214e8
--- /dev/null
+++ b/tests/core/test_ptrtoint.in
@@ -0,0 +1,16 @@
+
+ #include <stdio.h>
+
+ int main( int argc, const char *argv[] ) {
+ char *a = new char[10];
+ char *a0 = a+0;
+ char *a5 = a+5;
+ int *b = new int[10];
+ int *b0 = b+0;
+ int *b5 = b+5;
+ int c = (int)b5-(int)b0; // Emscripten should warn!
+ int d = (int)b5-(int)b0; // Emscripten should warn!
+ printf("*%d*\n", (int)a5-(int)a0);
+ return 0;
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_ptrtoint.out b/tests/core/test_ptrtoint.out
new file mode 100644
index 00000000..770e08e0
--- /dev/null
+++ b/tests/core/test_ptrtoint.out
@@ -0,0 +1 @@
+*5* \ No newline at end of file
diff --git a/tests/test_core.py b/tests/test_core.py
index b4bdbe1c..9a2448fa 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1822,26 +1822,15 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_ptrtoint(self):
if self.emcc_args is None: return self.skip('requires emcc')
- src = '''
- #include <stdio.h>
- int main( int argc, const char *argv[] ) {
- char *a = new char[10];
- char *a0 = a+0;
- char *a5 = a+5;
- int *b = new int[10];
- int *b0 = b+0;
- int *b5 = b+5;
- int c = (int)b5-(int)b0; // Emscripten should warn!
- int d = (int)b5-(int)b0; // Emscripten should warn!
- printf("*%d*\\n", (int)a5-(int)a0);
- return 0;
- }
- '''
runner = self
def check_warnings(output):
runner.assertEquals(filter(lambda line: 'Warning' in line, output.split('\n')).__len__(), 4)
- self.do_run(src, '*5*', output_processor=check_warnings)
+
+ test_path = path_from_root('tests', 'core', 'test_ptrtoint')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output, output_processor=check_warnings)
def test_sizeof(self):
if self.emcc_args is None: return self.skip('requires emcc')