diff options
-rw-r--r-- | tests/core/test_llvmswitch.in | 24 | ||||
-rw-r--r-- | tests/core/test_llvmswitch.out | 1 | ||||
-rw-r--r-- | tests/test_core.py | 27 |
3 files changed, 28 insertions, 24 deletions
diff --git a/tests/core/test_llvmswitch.in b/tests/core/test_llvmswitch.in new file mode 100644 index 00000000..64cfa652 --- /dev/null +++ b/tests/core/test_llvmswitch.in @@ -0,0 +1,24 @@ + + #include <stdio.h> + #include <string.h> + + int switcher(int p) + { + switch(p) { + case 'a': + case 'b': + case 'c': + return p-1; + case -15: + return p+1; + } + return p; + } + + int main( int argc, const char *argv[] ) { + unsigned int x = 0xfffffff1; + x >>= (argc-1); // force it to be unsigned for purpose of checking our switch comparison in signed/unsigned + printf("*%d,%d,%d,%d,%d,%d*\n", switcher('a'), switcher('b'), switcher('c'), switcher(x), switcher(-15), switcher('e')); + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_llvmswitch.out b/tests/core/test_llvmswitch.out new file mode 100644 index 00000000..4647c7e1 --- /dev/null +++ b/tests/core/test_llvmswitch.out @@ -0,0 +1 @@ +*96,97,98,-14,-14,101*
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index 25daae15..f85858e5 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2008,31 +2008,10 @@ def process(filename): def test_llvmswitch(self): Settings.CORRECT_SIGNS = 1 - src = ''' - #include <stdio.h> - #include <string.h> - - int switcher(int p) - { - switch(p) { - case 'a': - case 'b': - case 'c': - return p-1; - case -15: - return p+1; - } - return p; - } + test_path = path_from_root('tests', 'core', 'test_llvmswitch') + src, output = (test_path + s for s in ('.in', '.out')) - int main( int argc, const char *argv[] ) { - unsigned int x = 0xfffffff1; - x >>= (argc-1); // force it to be unsigned for purpose of checking our switch comparison in signed/unsigned - printf("*%d,%d,%d,%d,%d,%d*\\n", switcher('a'), switcher('b'), switcher('c'), switcher(x), switcher(-15), switcher('e')); - return 0; - } - ''' - self.do_run(src, '*96,97,98,-14,-14,101*') + self.do_run_from_file(src, output) # By default, when user has not specified a -std flag, Emscripten should always build .cpp files using the C++03 standard, # i.e. as if "-std=c++03" had been passed on the command line. On Linux with Clang 3.2 this is the case, but on Windows |