@@ -9,11 +9,9 @@ import Node.Buffer (BufferValueType(..), toArray, concat', fromArray, fill, copy
99import Node.Encoding (Encoding (..))
1010import Test.Assert (assert' )
1111
12- type Test = Effect Unit
13-
14- main :: Test
12+ main :: Effect Unit
1513main = do
16- log " Testing ..."
14+ log " Effect Uniting ..."
1715
1816 log " Reading and writing"
1917 testReadWrite
@@ -45,7 +43,7 @@ main = do
4543 log " getAtOffset"
4644 testGetAtOffset
4745
48- testReadWrite :: Test
46+ testReadWrite :: Effect Unit
4947testReadWrite = do
5048 buf <- create 1
5149 let val = 42
@@ -54,14 +52,14 @@ testReadWrite = do
5452
5553 assertEq val readVal
5654
57- testFromArray :: Test
55+ testFromArray :: Effect Unit
5856testFromArray = do
5957 buf <- fromArray [1 ,2 ,3 ,4 ,5 ]
6058 readVal <- read UInt8 2 buf
6159
6260 assertEq 3 readVal
6361
64- testToArray :: Test
62+ testToArray :: Effect Unit
6563testToArray = do
6664 let val = [1 ,2 ,67 ,3 ,3 ,7 ,8 ,3 ,4 ,237 ]
6765
@@ -70,7 +68,7 @@ testToArray = do
7068
7169 assertEq val valOut
7270
73- testFromString :: Test
71+ testFromString :: Effect Unit
7472testFromString = do
7573 let str = " hello, world"
7674
@@ -79,7 +77,7 @@ testFromString = do
7977
8078 assertEq val 32 -- ASCII space
8179
82- testToString :: Test
80+ testToString :: Effect Unit
8381testToString = do
8482 let str = " hello, world"
8583
@@ -88,7 +86,7 @@ testToString = do
8886
8987 assertEq str strOut
9088
91- testReadString :: Test
89+ testReadString :: Effect Unit
9290testReadString = do
9391 let str = " hello, world"
9492
@@ -97,7 +95,7 @@ testReadString = do
9795
9896 assertEq " world" strOut
9997
100- testCopy :: Test
98+ testCopy :: Effect Unit
10199testCopy = do
102100 buf1 <- fromArray [1 ,2 ,3 ,4 ,5 ]
103101 buf2 <- fromArray [10 ,9 ,8 ,7 ,6 ]
@@ -108,30 +106,30 @@ testCopy = do
108106 assertEq copied 3
109107 assertEq out [10 ,9 ,1 ,2 ,3 ]
110108
111- testFill :: Test
109+ testFill :: Effect Unit
112110testFill = do
113111 buf <- fromArray [1 ,1 ,1 ,1 ,1 ]
114112 fill 42 2 4 buf
115113 out <- toArray buf
116114
117115 assertEq [1 ,1 ,42 ,42 ,1 ] out
118116
119- testConcat' :: Test
117+ testConcat' :: Effect Unit
120118testConcat' = do
121119 bufs <- traverse fromArray $ map (\x -> [x, x+1 , x+2 ]) [0 ,3 ,6 ,9 ,12 ]
122120 buf <- concat' bufs 15
123121 out <- toArray buf
124122
125123 assertEq [0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ] out
126124
127- testGetAtOffset :: Test
125+ testGetAtOffset :: Effect Unit
128126testGetAtOffset = do
129127 buf <- fromArray [1 , 2 , 3 , 4 ]
130128 assertEq (Just 2 ) =<< getAtOffset 1 buf
131129 assertEq Nothing =<< getAtOffset 4 buf
132130 assertEq Nothing =<< getAtOffset (-1 ) buf
133131
134- assertEq :: forall a . Eq a => Show a => a -> a -> Test
132+ assertEq :: forall a . Eq a => Show a => a -> a -> Effect Unit
135133assertEq x y =
136134 if x == y
137135 then pure unit
0 commit comments