-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMain4.purs
44 lines (39 loc) · 1.15 KB
/
Main4.purs
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
33
34
35
36
37
38
39
40
41
42
43
44
-- | How to test:
-- |
-- | ```
-- | pulp test --main Test.Main4
-- | ```
-- |
-- | This is a test that `readSome` will prevent the Node.js event
-- | loop from exiting.
module Test.Main4 where
import Prelude
import Control.Alt (alt)
import Data.Either (Either(..))
import Effect (Effect)
import Effect.Aff (Error, Milliseconds(..), delay, parallel, runAff_, sequential)
import Effect.Class.Console as Console
import Node.Stream (Readable)
import Node.Stream.Aff (readSome)
import Partial.Unsafe (unsafePartial)
import Test.Spec (describe, it)
import Test.Spec.Reporter (consoleReporter)
import Test.Spec.Runner (runSpec)
import Unsafe.Coerce (unsafeCoerce)
foreign import stdin :: Readable ()
completion :: Either Error (Effect Unit) -> Effect Unit
completion = case _ of
Left e -> Console.error (unsafeCoerce e)
Right f -> f
main :: Effect Unit
main = unsafePartial $ do
runAff_ completion do
runSpec [ consoleReporter ] do
describe "Node.Stream.Aff" do
it "reads 1" do
sequential $ alt
do
parallel $ void $ readSome stdin
do
parallel $ delay (Milliseconds 500.0)
pure (pure unit)