summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-03-03 15:49:14 -0500
committerBen Gamari <ben@smart-cactus.org>2017-03-03 15:49:15 -0500
commit10d28d0ababe52a705c10d450869d7a61063c4ae (patch)
treed13a9cb96556b516ced7ca6ac301e54798972dc0
parentc1dacb8a9c18677495bbe7e41391f8ca7a573070 (diff)
downloadhaskell-10d28d0ababe52a705c10d450869d7a61063c4ae.tar.gz
testsuite: Add test for floating-point abs (numrun015)
Test Plan: Validate Reviewers: idontgetoutmuch, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3273
-rw-r--r--testsuite/tests/numeric/should_run/all.T1
-rw-r--r--testsuite/tests/numeric/should_run/numrun015.hs20
-rw-r--r--testsuite/tests/numeric/should_run/numrun015.stdout10
3 files changed, 31 insertions, 0 deletions
diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T
index 6510dc91cd..2d2353bd8a 100644
--- a/testsuite/tests/numeric/should_run/all.T
+++ b/testsuite/tests/numeric/should_run/all.T
@@ -33,6 +33,7 @@ test('numrun011', normal, compile_and_run, [''])
test('numrun012', normal, compile_and_run, [''])
test('numrun013', normal, compile_and_run, [''])
test('numrun014', normal, compile_and_run, [''])
+test('numrun015', normal, compile_and_run, [''])
test('arith016', normal, compile_and_run, [''])
test('arith017', normal, compile_and_run, [''])
test('arith018', normal, compile_and_run, [''])
diff --git a/testsuite/tests/numeric/should_run/numrun015.hs b/testsuite/tests/numeric/should_run/numrun015.hs
new file mode 100644
index 0000000000..070c5ab5bd
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/numrun015.hs
@@ -0,0 +1,20 @@
+-- Test that floating-point abs works correctly
+
+absF :: Float -> Float
+absF = abs
+
+absD :: Double -> Double
+absD = abs
+
+main :: IO ()
+main = do
+ print $ absF (1 / 0)
+ print $ absD (1 / 0)
+ print $ absF 1
+ print $ absD 1
+ print $ absF (-1)
+ print $ absD (-1)
+ print $ absF (-1 / 0)
+ print $ absD (-1 / 0)
+ print $ absF (1 / 0)
+ print $ absD (1 / 0)
diff --git a/testsuite/tests/numeric/should_run/numrun015.stdout b/testsuite/tests/numeric/should_run/numrun015.stdout
new file mode 100644
index 0000000000..33cdeb42bb
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/numrun015.stdout
@@ -0,0 +1,10 @@
+Infinity
+Infinity
+1.0
+1.0
+1.0
+1.0
+Infinity
+Infinity
+Infinity
+Infinity