aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 11:45:19 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:35:54 +0200
commita79233eb34e9060d09b342522ffa1c26fe69ad7c (patch)
tree98ff8cc5a86b4693779dfd4cc17c469519d7011b /tests
parent7b0834231923fe37add5a4230ecd94da5b77bc06 (diff)
Use do_run_from_file() for test_polymorph
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_polymorph.in34
-rw-r--r--tests/core/test_polymorph.out3
-rw-r--r--tests/test_core.py36
3 files changed, 40 insertions, 33 deletions
diff --git a/tests/core/test_polymorph.in b/tests/core/test_polymorph.in
new file mode 100644
index 00000000..2faa1935
--- /dev/null
+++ b/tests/core/test_polymorph.in
@@ -0,0 +1,34 @@
+
+ #include <stdio.h>
+ struct Pure {
+ virtual int implme() = 0;
+ };
+ struct Parent : Pure {
+ virtual int getit() { return 11; };
+ int implme() { return 32; }
+ };
+ struct Child : Parent {
+ int getit() { return 74; }
+ int implme() { return 1012; }
+ };
+
+ struct Other {
+ int one() { return 11; }
+ int two() { return 22; }
+ };
+
+ int main()
+ {
+ Parent *x = new Parent();
+ Parent *y = new Child();
+ printf("*%d,%d,%d,%d*\n", x->getit(), y->getit(), x->implme(), y->implme());
+
+ Other *o = new Other;
+ int (Other::*Ls)() = &Other::one;
+ printf("*%d*\n", (o->*(Ls))());
+ Ls = &Other::two;
+ printf("*%d*\n", (o->*(Ls))());
+
+ return 0;
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_polymorph.out b/tests/core/test_polymorph.out
new file mode 100644
index 00000000..0d036bf0
--- /dev/null
+++ b/tests/core/test_polymorph.out
@@ -0,0 +1,3 @@
+*11,74,32,1012*
+*11*
+*22* \ No newline at end of file
diff --git a/tests/test_core.py b/tests/test_core.py
index 8b96a6d6..50e4baa0 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1424,41 +1424,11 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_polymorph(self):
if self.emcc_args is None: return self.skip('requires emcc')
- src = '''
- #include <stdio.h>
- struct Pure {
- virtual int implme() = 0;
- };
- struct Parent : Pure {
- virtual int getit() { return 11; };
- int implme() { return 32; }
- };
- struct Child : Parent {
- int getit() { return 74; }
- int implme() { return 1012; }
- };
-
- struct Other {
- int one() { return 11; }
- int two() { return 22; }
- };
- int main()
- {
- Parent *x = new Parent();
- Parent *y = new Child();
- printf("*%d,%d,%d,%d*\\n", x->getit(), y->getit(), x->implme(), y->implme());
-
- Other *o = new Other;
- int (Other::*Ls)() = &Other::one;
- printf("*%d*\\n", (o->*(Ls))());
- Ls = &Other::two;
- printf("*%d*\\n", (o->*(Ls))());
+ test_path = path_from_root('tests', 'core', 'test_polymorph')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, '*11,74,32,1012*\n*11*\n*22*')
+ self.do_run_from_file(src, output)
def test_segfault(self):
if self.emcc_args is None: return self.skip('SAFE_HEAP without ta2 means we check types too, which hide segfaults')