@@ -1,6 +1,7 @@
1module Regression.T1 (test1) where
1module Regression.T1 (test1) where
3import Ether
3import Ether
4+import Data.List (group)
5import Test.Tasty
6import Test.Tasty
6import Test.Tasty.QuickCheck
7import Test.Tasty.QuickCheck
@@ -23,6 +24,10 @@ testEther = do
24runner1 s1 s2 = flip (runReader @Tag1) s1 . flip (runReaderT @Tag2) s2
25runner1 s1 s2 = flip (runReader @Tag1) s1 . flip (runReaderT @Tag2) s2
25runner2 s1 s2 = flip (runReader @Tag2) s2 . flip (runReaderT @Tag1) s1
26runner2 s1 s2 = flip (runReader @Tag2) s2 . flip (runReaderT @Tag1) s1
27+runner3 s1 s2 = flip runReaders (Tagged @Tag1 s1, Tagged @Tag2 s2)
29+same :: Eq a => [a] -> Bool
30+same = (<=1) . length . group
27test1 :: TestTree
32test1 :: TestTree
28test1 = testGroup "T1: Reader local environment"
33test1 = testGroup "T1: Reader local environment"
@@ -32,7 +37,13 @@ test1 = testGroup "T1: Reader local environment"
32 , testProperty "runner₂ works"
37 , testProperty "runner₂ works"
33 $ \s1 s2 -> property
38 $ \s1 s2 -> property
34 $ runner2 s1 s2 testEther == ((s1, s2), (s1, map succ s2))
39 $ runner2 s1 s2 testEther == ((s1, s2), (s1, map succ s2))
40+ , testProperty "runner₃ works"
42+ $ runner3 s1 s2 testEther == ((s1, s2), (s1, map succ s2))
35− , testProperty "runner₁ == runner₂"
43+ , testProperty "runner₁ == runner₂ == runner₃"
36 $ \s1 s2 -> property
44 $ \s1 s2 -> property
37− $ runner1 s1 s2 testEther == runner2 s1 s2 testEther
46+ [ runner1 s1 s2 testEther
47+ , runner2 s1 s2 testEther
48+ , runner3 s1 s2 testEther ]