diff options
author | Jez Ng <me@jezng.com> | 2013-06-06 10:27:17 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-06-07 10:09:12 -0700 |
commit | 32dc04d8d17fb7cc4122d692c8fa1ba661a33803 (patch) | |
tree | c464228c745912654e3ce24ebacd74a6641bfd81 /tests | |
parent | 5f2ccad0a399276de4e8426fcd1449e256499815 (diff) |
Make lrint more correct. Closes #1265.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runner.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 53eb56fe..5e8cbeea 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -1957,6 +1957,39 @@ Succeeded! 1.000000=1.000000*2^0 -1.000000=-1.000000*2^0''') + def test_rounding(self): + src = ''' + #include <stdio.h> + #include <math.h> + + int main() + { + printf("%.1f ", round(1.4)); + printf("%.1f ", round(1.6)); + printf("%.1f ", round(-1.4)); + printf("%.1f ", round(-1.6)); + + printf("%.1f ", round(1.5)); + printf("%.1f ", round(2.5)); + printf("%.1f ", round(-1.5)); + printf("%.1f ", round(-2.5)); + + printf("%ld ", lrint(1.4)); + printf("%ld ", lrint(1.6)); + printf("%ld ", lrint(-1.4)); + printf("%ld ", lrint(-1.6)); + + printf("%ld ", lrint(1.5)); + printf("%ld ", lrint(2.5)); + printf("%ld ", lrint(-1.5)); + printf("%ld ", lrint(-2.5)); + + return 0; + } + ''' + self.do_run(src, "1.0 2.0 -1.0 -2.0 2.0 3.0 -2.0 -3.0 " + "1 2 -1 -2 2 2 -2 -2") + def test_getgep(self): # Generated code includes getelementptr (getelementptr, 0, 1), i.e., GEP as the first param to GEP src = ''' |