diff options
| author | Ian Lynagh <igloo@earth.li> | 2011-11-19 22:07:24 +0000 |
|---|---|---|
| committer | Ian Lynagh <igloo@earth.li> | 2011-11-19 22:07:24 +0000 |
| commit | 7e260784729260a1049731211173a90c55fad797 (patch) | |
| tree | 50dba7f2ae97beac5c2dfeb57b6de828a3de3b5f /libraries/base/tests/unicode002.hs | |
| parent | 2b0adbd247fc84bfee92fd8949be71f7d907012c (diff) | |
| download | haskell-7e260784729260a1049731211173a90c55fad797.tar.gz | |
Move lib/Char tests from testsuite to base
Diffstat (limited to 'libraries/base/tests/unicode002.hs')
| -rw-r--r-- | libraries/base/tests/unicode002.hs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libraries/base/tests/unicode002.hs b/libraries/base/tests/unicode002.hs new file mode 100644 index 0000000000..50ed5ddf44 --- /dev/null +++ b/libraries/base/tests/unicode002.hs @@ -0,0 +1,44 @@ +module Main where + + +import Data.Char +import Numeric + +header = "Code C P S U L A D" + +preds = [ + isControl, + isPrint, + isSpace, + isUpper, + isLower, + isAlpha, + isDigit] + +prtBool :: Bool -> String + +prtBool True = "T " +prtBool False = "F " + +showCode :: Char -> Int -> String + +showCode c w = code ++ pad + where + code = show (ord c) + l = length code + spaces = map anytospace [1..] + anytospace _ = ' ' + pad | l >= w = "" + | otherwise = take (w - l) spaces + +charCode :: Char -> String + +rapply a b = b a + +charCode c = (showCode c 5) ++ (foldr1 (++) $ map prtBool $ map (rapply c) preds) + +main = do + putStrLn header + mapM (putStrLn . charCode) [ (chr 0) .. (chr 6553) ] + + |
