diff options
author | Artem Pelenitsyn <a.pelenitsyn@gmail.com> | 2020-12-14 17:48:39 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-01-02 07:32:50 -0500 |
commit | 77c4a15f5a4aea95080059af90bae2767f162a4f (patch) | |
tree | de06beac475968cd34943df6dc284955eadd1bdf /libraries/base/tests | |
parent | 85d899c8d319a4bf4c386df9b7964b29ac0fbd38 (diff) | |
download | haskell-77c4a15f5a4aea95080059af90bae2767f162a4f.tar.gz |
base: add Numeric.{readBin, showBin} (fix #19036)
Diffstat (limited to 'libraries/base/tests')
-rw-r--r-- | libraries/base/tests/Numeric/num006.hs | 13 | ||||
-rw-r--r-- | libraries/base/tests/Numeric/num006.stdout | 2 | ||||
-rw-r--r-- | libraries/base/tests/Numeric/num007.hs | 3 | ||||
-rw-r--r-- | libraries/base/tests/Numeric/num007.stdout | 3 |
4 files changed, 10 insertions, 11 deletions
diff --git a/libraries/base/tests/Numeric/num006.hs b/libraries/base/tests/Numeric/num006.hs index 65347dd8aa..56b8a568f7 100644 --- a/libraries/base/tests/Numeric/num006.hs +++ b/libraries/base/tests/Numeric/num006.hs @@ -7,22 +7,13 @@ import Data.Char --showDec :: Integral a => a -> ShowS showDec = showInt - -{- ---showBinary :: Integral a => a -> ShowS -showBinary n r = - showString "0b" $ - showIntAtBase 2 (toChr) n r - where toChr d = chr (ord '0' + fromIntegral d) --} - main = do print (map (\ x -> showOct x []) [1..32]) print (map (\ x -> showDec x []) [1..32]) print (map (\ x -> showHex x []) [1..32]) --- print (map (\ x -> showBinary x []) [1..32]) + print (map (\ x -> showBin x []) [1..32]) putStrLn (showOct (241324784::Int) []) putStrLn (showDec (241324784::Int) []) putStrLn (showHex (241324784::Int) []) ---- putStrLn (showBinary (241324784::Int) []) + putStrLn (showBin (241324784::Int) []) diff --git a/libraries/base/tests/Numeric/num006.stdout b/libraries/base/tests/Numeric/num006.stdout index e0c45403ec..39b435351e 100644 --- a/libraries/base/tests/Numeric/num006.stdout +++ b/libraries/base/tests/Numeric/num006.stdout @@ -1,6 +1,8 @@ ["1","2","3","4","5","6","7","10","11","12","13","14","15","16","17","20","21","22","23","24","25","26","27","30","31","32","33","34","35","36","37","40"] ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"] ["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20"] +["1","10","11","100","101","110","111","1000","1001","1010","1011","1100","1101","1110","1111","10000","10001","10010","10011","10100","10101","10110","10111","11000","11001","11010","11011","11100","11101","11110","11111","100000"] 1630451360 241324784 e6252f0 +1110011000100101001011110000 diff --git a/libraries/base/tests/Numeric/num007.hs b/libraries/base/tests/Numeric/num007.hs index e02bd41d64..d248d3a08c 100644 --- a/libraries/base/tests/Numeric/num007.hs +++ b/libraries/base/tests/Numeric/num007.hs @@ -6,12 +6,15 @@ import Numeric main = do + putStrLn (show (readBin "00000111")) putStrLn (show (readOct "00000111")) putStrLn (show (readDec "00000111")) putStrLn (show (readHex "00000111")) + putStrLn (show (readBin "-24")) putStrLn (show (readOct "-24")) putStrLn (show (readDec "-24")) putStrLn (show (readHex "-24")) + putStrLn (show ((readBin ::ReadS Integer) "1011784372843778438743")) putStrLn (show ((readOct ::ReadS Integer) "3248784372843778438743")) putStrLn (show ((readDec ::ReadS Integer) "3248784372843778438743")) putStrLn (show ((readHex ::ReadS Integer) "3248784372843778438743")) diff --git a/libraries/base/tests/Numeric/num007.stdout b/libraries/base/tests/Numeric/num007.stdout index ef60021827..b26c636f2c 100644 --- a/libraries/base/tests/Numeric/num007.stdout +++ b/libraries/base/tests/Numeric/num007.stdout @@ -1,9 +1,12 @@ +[(7,"")] [(73,"")] [(111,"")] [(273,"")] [] [] [] +[] +[(11,"784372843778438743")] [(212,"8784372843778438743")] [(3248784372843778438743,"")] [(60788519836879239998834499,"")] |