Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/waddlaw/testable-io
https://github.com/waddlaw/testable-io
haskell
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/waddlaw/testable-io
- Owner: waddlaw
- License: bsd-3-clause
- Created: 2018-03-07T02:16:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-11T12:57:20.000Z (almost 7 years ago)
- Last Synced: 2024-11-06T23:42:23.239Z (about 2 months ago)
- Topics: haskell
- Language: Haskell
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/waddlaw/testable-io.svg?branch=master)](https://travis-ci.org/waddlaw/testable-io)
# testable-io
Inspired: [imperative-edsl](https://hackage.haskell.org/package/imperative-edsl)
## Example
```haskell
module Main (main) whereimport Test.FakeIO
import Test.Hspecmain :: IO ()
main = hspec $ do
describe "execFakeIO" $
it "use getChar" $ do
execFakeIO act "Haskell" `shouldReturn` "'H'\n"
execFakeIO act "GHC" `shouldReturn` "'G'\n"
execFakeIO act "guchi" `shouldReturn` "'g'\n"
execFakeIO act "BIGMOON" `shouldReturn` "'B'\n"
describe "evalFakeIO" $
it "use getChar" $ do
evalFakeIO act "Haskell" `shouldReturn` ('H', 's')
evalFakeIO act "GHC" `shouldReturn` ('G','C')
evalFakeIO act "guchi" `shouldReturn` ('g','c')
evalFakeIO act "BIGMOON" `shouldReturn` ('B','G')
describe "runFakeIO" $
it "use getChar" $ do
runFakeIO act "Haskell" `shouldReturn` (('H', 's'), "'H'\n")
runFakeIO act "GHC" `shouldReturn` (('G','C'), "'G'\n")
runFakeIO act "guchi" `shouldReturn` (('g','c'), "'g'\n")
runFakeIO act "BIGMOON" `shouldReturn` (('B','G'), "'B'\n")act :: IO (Char, Char)
act = do
x <- getChar
print x
_ <- getChar
y <- getChar
return (x, y)
```## Restriction
This library is only work on [hspec](http://hspec.github.io/).