diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 11:56:31 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:54 +0200 |
commit | 1985354735e25d1d61a895811a379fa2b1213ae9 (patch) | |
tree | fa14e7f59c509dd1dd67a2d7b3129a8056b5cb90 /tests | |
parent | c704860e22fe37c0e0ae1502d12cb1abbe7992bf (diff) |
Use do_run_from_file() for test_funcptr_namecollide
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_funcptr_namecollide.in | 27 | ||||
-rw-r--r-- | tests/core/test_funcptr_namecollide.out | 1 | ||||
-rw-r--r-- | tests/test_core.py | 30 |
3 files changed, 31 insertions, 27 deletions
diff --git a/tests/core/test_funcptr_namecollide.in b/tests/core/test_funcptr_namecollide.in new file mode 100644 index 00000000..0b27b07c --- /dev/null +++ b/tests/core/test_funcptr_namecollide.in @@ -0,0 +1,27 @@ + + #include <stdio.h> + + void do_call(void (*puts)(const char *), const char *str); + + void do_print(const char *str) { + if (!str) do_call(NULL, "delusion"); + if ((int)str == -1) do_print(str+10); + puts("===="); + puts(str); + puts("===="); + } + + void do_call(void (*puts)(const char *), const char *str) { + if (!str) do_print("confusion"); + if ((int)str == -1) do_call(NULL, str-10); + (*puts)(str); + } + + int main(int argc, char **argv) + { + for (int i = 0; i < argc; i++) { + do_call(i != 10 ? do_print : NULL, i != 15 ? "waka waka" : NULL); + } + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_funcptr_namecollide.out b/tests/core/test_funcptr_namecollide.out new file mode 100644 index 00000000..360b24da --- /dev/null +++ b/tests/core/test_funcptr_namecollide.out @@ -0,0 +1 @@ +waka
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index 7b9cd750..911c7a68 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1538,34 +1538,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_funcptr_namecollide(self): - src = r''' - #include <stdio.h> - - void do_call(void (*puts)(const char *), const char *str); - - void do_print(const char *str) { - if (!str) do_call(NULL, "delusion"); - if ((int)str == -1) do_print(str+10); - puts("===="); - puts(str); - puts("===="); - } - - void do_call(void (*puts)(const char *), const char *str) { - if (!str) do_print("confusion"); - if ((int)str == -1) do_call(NULL, str-10); - (*puts)(str); - } + test_path = path_from_root('tests', 'core', 'test_funcptr_namecollide') + src, output = (test_path + s for s in ('.in', '.out')) - int main(int argc, char **argv) - { - for (int i = 0; i < argc; i++) { - do_call(i != 10 ? do_print : NULL, i != 15 ? "waka waka" : NULL); - } - return 0; - } - ''' - self.do_run(src, 'waka', force_c=True) + self.do_run_from_file(src, output, force_c=True) def test_emptyclass(self): if self.emcc_args is None: return self.skip('requires emcc') |