Skip to content

Commit ee0ea6f

Browse files
author
kamoii
committed
Add test for Array instances
1 parent 01de34f commit ee0ea6f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/Test/Main.purs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ main = do
1414
testIntDivMod
1515
testIntDegree
1616
testRecordInstances
17+
testArrayInstances
1718
testGenericRep
1819

1920
foreign import testNumberShow :: (Number -> String) -> AlmostEff
@@ -151,3 +152,17 @@ testRecordInstances = do
151152
assert "Record top" $
152153
(top :: { a :: Boolean }).a
153154
== top
155+
156+
testArrayInstances :: AlmostEff
157+
testArrayInstances = do
158+
assert "Functor" $ map (_ + 1) [1, 2, 3] == [2, 3, 4]
159+
assert "Functor empty" $ map (_ + 1) [] == []
160+
assert "Semigroup" $ append [1, 2] [3, 4] == [1, 2, 3, 4]
161+
assert "Semigroup empty left" $ append [] [3, 4] == [3, 4]
162+
assert "Semigroup emtpy right" $ append [1, 2] [] == [1, 2]
163+
assert "Apply" $ apply [(_ + 1), (_ * 2)] [1, 2, 3] == [2, 3, 4, 2, 4, 6]
164+
assert "Apply empty left" $ apply ([] :: Array (Int -> Int)) [1, 2, 3] == []
165+
assert "Apply empty right" $ apply [(_ + 1), (_ * 2)] [] == []
166+
assert "Bind instance" $ bind [1, 2, 3] (\a -> [a, a]) == [1, 1, 2, 2, 3, 3]
167+
assert "Bind instance empty left" $ bind ([] :: Array Int) (\a -> [a, a]) == []
168+
assert "Bind instance empty right" $ bind [1, 2, 3] (\_ -> ([] :: Array Int)) == []

0 commit comments

Comments
 (0)