aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-03-15 15:05:36 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-03-17 17:56:17 -0700
commitb0794537c311ff38bd6e9e87e173861c88303b24 (patch)
tree464ea51d2286e94eda70fcab56466d38c33d22f4
parente4462dc1b20ce152bf71546927d401844124df02 (diff)
add test_simplify_ifs
-rw-r--r--tests/test_other.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_other.py b/tests/test_other.py
index a9880cf3..263bc376 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -2577,3 +2577,24 @@ int main()
assert 'warning' in err, err
assert 'incorrect target triple' in err, err
+ def test_simplify_ifs(self):
+ open('src.c', 'w').write(r'''
+ #include <stdio.h>
+ #include <string.h>
+ int main(int argc, char **argv) {
+ if (argc > 5 && strlen(argv[0]) > 1 && strlen(argv[1]) > 2) printf("halp");
+ return 0;
+ }
+ ''')
+ for opts, ifs in [
+ [['-g2'], 3],
+ [['-profiling'], 1],
+ [['-profiling', '-g2'], 1]
+ ]:
+ print opts, ifs
+ Popen([PYTHON, EMCC, 'src.c', '-O2'] + opts, stdout=PIPE, stderr=PIPE).communicate()
+ src = open('a.out.js').read()
+ main = src[src.find('function _main'):src.find('\n}', src.find('function _main'))]
+ actual_ifs = main.count('if (')
+ assert ifs == actual_ifs, main
+