Idris2/tests/refc/strings/TestStrings.idr
Robert Wright c34c6e0959 Complete RefC standard String support
- Fix off-by-one error in String reverse
- Correct order of arguments in strSubstr
- Actually use start index of strSubstr
- Reduce memory usage of strSubstr in case of overrunning string end
- Add fastPack/fastUnpack/fastConcat
- Use unsigned chars for character comparisons
- Fix generated C character encodings
2021-05-20 14:25:16 +01:00

33 lines
908 B
Idris

module TestStrings
import Data.String
main : IO ()
main = do
let helloWorld = "Hello, " ++ "world"
putStrLn helloWorld
putStrLn $ show $ length helloWorld
putStrLn $ reverse helloWorld
putStrLn $ substr 1 2 helloWorld
putStrLn $ show $ assert_total $ strIndex helloWorld 1
putStrLn $ strCons 'a' "bc"
putStrLn $ show $ strUncons "abc"
putStrLn $ fastPack ['p', 'a', 'c', 'k']
putStrLn $ show $ fastUnpack "unpack"
putStrLn $ fastConcat ["con", "cat", "en", "ate"]
let chars = ['a', 'A', '~', '0', ' ', '\n', '\x9f']
putStrLn $ show $ map isUpper chars
putStrLn $ show $ map isLower chars
putStrLn $ show $ map isDigit chars
putStrLn $ show $ map isSpace chars
putStrLn $ show $ map isNL chars
putStrLn $ show $ map isControl chars
putStrLn $ show $ map chr [97, 65, 126, 48, 32, 10, 159]
putStrLn $ show $ map ord chars