summaryrefslogtreecommitdiff
path: root/libraries/base/tests
diff options
context:
space:
mode:
authorHE, Tao <sighingnow@gmail.com>2018-05-16 12:13:16 -0400
committerBen Gamari <ben@smart-cactus.org>2018-05-16 12:58:29 -0400
commit4ffaf4b67773af4c72d92bb8b6c87b1a7d34ac0f (patch)
treec3d42ecb1e5d85363bb5070af2f54299de7551ae /libraries/base/tests
parent99f8cc84a5b23878b3b0732955cb651bc973e9f2 (diff)
downloadhaskell-4ffaf4b67773af4c72d92bb8b6c87b1a7d34ac0f.tar.gz
Improve numeric stability of numericEnumFrom for floating numbers
Fixes #15081. Test Plan: cd libraries/base && make test TEST="enumNumeric" Reviewers: hvr, bgamari Reviewed By: bgamari Subscribers: dfeuer, simonpj, thomie, carter GHC Trac Issues: #15081 Differential Revision: https://phabricator.haskell.org/D4650
Diffstat (limited to 'libraries/base/tests')
-rw-r--r--libraries/base/tests/all.T1
-rw-r--r--libraries/base/tests/enumNumeric.hs7
-rw-r--r--libraries/base/tests/enumNumeric.stdout5
3 files changed, 13 insertions, 0 deletions
diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T
index d530e10266..eb00fc37af 100644
--- a/libraries/base/tests/all.T
+++ b/libraries/base/tests/all.T
@@ -2,6 +2,7 @@
test('readFloat', exit_code(1), compile_and_run, [''])
test('enumDouble', normal, compile_and_run, [''])
test('enumRatio', normal, compile_and_run, [''])
+test('enumNumeric', normal, compile_and_run, [''])
test('tempfiles', normal, compile_and_run, [''])
test('fixed', normal, compile_and_run, [''])
test('quotOverflow', normal, compile_and_run, [''])
diff --git a/libraries/base/tests/enumNumeric.hs b/libraries/base/tests/enumNumeric.hs
new file mode 100644
index 0000000000..36c4846d1f
--- /dev/null
+++ b/libraries/base/tests/enumNumeric.hs
@@ -0,0 +1,7 @@
+main :: IO ()
+main = do
+ print $ map (/2) ([5..6] :: [Double])
+ print $ ([9007199254740990..9007199254740991] :: [Double])
+ print $ map (/2) ([9007199254740990..9007199254740991] :: [Double])
+ print $ ([9007199254740989..9007199254740990] :: [Double])
+ print $ map (/2) ([9007199254740989..9007199254740990] :: [Double])
diff --git a/libraries/base/tests/enumNumeric.stdout b/libraries/base/tests/enumNumeric.stdout
new file mode 100644
index 0000000000..3d7eb74f91
--- /dev/null
+++ b/libraries/base/tests/enumNumeric.stdout
@@ -0,0 +1,5 @@
+[2.5,3.0]
+[9.00719925474099e15,9.007199254740991e15,9.007199254740992e15,9.007199254740992e15]
+[4.503599627370495e15,4.5035996273704955e15,4.503599627370496e15,4.503599627370496e15]
+[9.007199254740989e15,9.00719925474099e15]
+[4.5035996273704945e15,4.503599627370495e15]