summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/core/test_inherit.in25
-rw-r--r--tests/core/test_inherit.out1
-rw-r--r--tests/test_core.py30
3 files changed, 30 insertions, 26 deletions
diff --git a/tests/core/test_inherit.in b/tests/core/test_inherit.in
new file mode 100644
index 00000000..e9a152e8
--- /dev/null
+++ b/tests/core/test_inherit.in
@@ -0,0 +1,25 @@
+
+ #include <stdio.h>
+ struct Parent {
+ int x1, x2;
+ };
+ struct Child : Parent {
+ int y;
+ };
+ int main()
+ {
+ Parent a;
+ a.x1 = 50;
+ a.x2 = 87;
+ Child b;
+ b.x1 = 78;
+ b.x2 = 550;
+ b.y = 101;
+ Child* c = (Child*)&a;
+ c->x1 ++;
+ c = &b;
+ c->y --;
+ printf("*%d,%d,%d,%d,%d,%d,%d*\n", a.x1, a.x2, b.x1, b.x2, b.y, c->x1, c->x2);
+ return 0;
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_inherit.out b/tests/core/test_inherit.out
new file mode 100644
index 00000000..34570bd7
--- /dev/null
+++ b/tests/core/test_inherit.out
@@ -0,0 +1 @@
+*51,87,78,550,100,78,550* \ No newline at end of file
diff --git a/tests/test_core.py b/tests/test_core.py
index eba924dc..d2e4909b 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1401,32 +1401,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
self.do_run_from_file(src, output)
def test_inherit(self):
- src = '''
- #include <stdio.h>
- struct Parent {
- int x1, x2;
- };
- struct Child : Parent {
- int y;
- };
- int main()
- {
- Parent a;
- a.x1 = 50;
- a.x2 = 87;
- Child b;
- b.x1 = 78;
- b.x2 = 550;
- b.y = 101;
- Child* c = (Child*)&a;
- c->x1 ++;
- c = &b;
- c->y --;
- printf("*%d,%d,%d,%d,%d,%d,%d*\\n", a.x1, a.x2, b.x1, b.x2, b.y, c->x1, c->x2);
- return 0;
- }
- '''
- self.do_run(src, '*51,87,78,550,100,78,550*')
+ test_path = path_from_root('tests', 'core', 'test_inherit')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_isdigit_l(self):
if self.emcc_args is None: return self.skip('no libcxx inclusion without emcc')