diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 11:49:49 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:54 +0200 |
commit | 5b3a08da267f4b8bbdf66574dff5dc8066f99691 (patch) | |
tree | 80e0fa1d5b1a2e5f76ec445ad386766357d32a30 /tests | |
parent | 2bc50ae56c8c1c39fb1362cf02dd263c1f495b35 (diff) |
Use do_run_from_file() for test_dynamic_cast_b
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_dynamic_cast_b.in | 28 | ||||
-rw-r--r-- | tests/core/test_dynamic_cast_b.out | 9 | ||||
-rw-r--r-- | tests/test_core.py | 31 |
3 files changed, 40 insertions, 28 deletions
diff --git a/tests/core/test_dynamic_cast_b.in b/tests/core/test_dynamic_cast_b.in new file mode 100644 index 00000000..f5931fef --- /dev/null +++ b/tests/core/test_dynamic_cast_b.in @@ -0,0 +1,28 @@ + + #include <stdio.h> + + class CBase { virtual void dummy() {} }; + class CDerived : public CBase { int a; }; + class CDerivedest : public CDerived { float b; }; + + int main () + { + CBase *pa = new CBase; + CBase *pb = new CDerived; + CBase *pc = new CDerivedest; + + printf("a1: %d\n", dynamic_cast<CDerivedest*>(pa) != NULL); + printf("a2: %d\n", dynamic_cast<CDerived*>(pa) != NULL); + printf("a3: %d\n", dynamic_cast<CBase*>(pa) != NULL); + + printf("b1: %d\n", dynamic_cast<CDerivedest*>(pb) != NULL); + printf("b2: %d\n", dynamic_cast<CDerived*>(pb) != NULL); + printf("b3: %d\n", dynamic_cast<CBase*>(pb) != NULL); + + printf("c1: %d\n", dynamic_cast<CDerivedest*>(pc) != NULL); + printf("c2: %d\n", dynamic_cast<CDerived*>(pc) != NULL); + printf("c3: %d\n", dynamic_cast<CBase*>(pc) != NULL); + + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_dynamic_cast_b.out b/tests/core/test_dynamic_cast_b.out new file mode 100644 index 00000000..090390e8 --- /dev/null +++ b/tests/core/test_dynamic_cast_b.out @@ -0,0 +1,9 @@ +a1: 0 +a2: 0 +a3: 1 +b1: 0 +b2: 1 +b3: 1 +c1: 1 +c2: 1 +c3: 1 diff --git a/tests/test_core.py b/tests/test_core.py index 162d8525..75706525 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1506,35 +1506,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co def test_dynamic_cast_b(self): if self.emcc_args is None: return self.skip('need libcxxabi') - src = ''' - #include <stdio.h> - - class CBase { virtual void dummy() {} }; - class CDerived : public CBase { int a; }; - class CDerivedest : public CDerived { float b; }; - - int main () - { - CBase *pa = new CBase; - CBase *pb = new CDerived; - CBase *pc = new CDerivedest; - - printf("a1: %d\\n", dynamic_cast<CDerivedest*>(pa) != NULL); - printf("a2: %d\\n", dynamic_cast<CDerived*>(pa) != NULL); - printf("a3: %d\\n", dynamic_cast<CBase*>(pa) != NULL); - - printf("b1: %d\\n", dynamic_cast<CDerivedest*>(pb) != NULL); - printf("b2: %d\\n", dynamic_cast<CDerived*>(pb) != NULL); - printf("b3: %d\\n", dynamic_cast<CBase*>(pb) != NULL); - - printf("c1: %d\\n", dynamic_cast<CDerivedest*>(pc) != NULL); - printf("c2: %d\\n", dynamic_cast<CDerived*>(pc) != NULL); - printf("c3: %d\\n", dynamic_cast<CBase*>(pc) != NULL); + test_path = path_from_root('tests', 'core', 'test_dynamic_cast_b') + src, output = (test_path + s for s in ('.in', '.out')) - return 0; - } - ''' - self.do_run(src, 'a1: 0\na2: 0\na3: 1\nb1: 0\nb2: 1\nb3: 1\nc1: 1\nc2: 1\nc3: 1\n') + self.do_run_from_file(src, output) def test_dynamic_cast_2(self): if self.emcc_args is None: return self.skip('need libcxxabi') |