Loading tests/Copar/Functors/GroupValuedSpec.hs +19 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import Test.Hspec.Megaparsec import TestHelpers import Data.Complex import Data.Ratio import Copar.Functors.GroupValued import Copar.Coalgebra.Parser Loading @@ -18,6 +19,7 @@ spec = do parseMorphismPointIntSpec parseMorphismPointDoubleSpec parseMorphismPointComplexSpec parseMorphismPointRationalSpec parseMorphismPointIntSpec :: Spec Loading Loading @@ -97,3 +99,20 @@ parseMorphismPointComplexSpec = describe "parseMorphismPoint (Complex)" $ do [(0, Sorted 1 (c (-2.3) 0), 0)] where c a b = OrderedComplex (a :+ b) parseMorphismPointRationalSpec :: Spec parseMorphismPointRationalSpec = describe "parseMorphismPoint (Rational)" $ do let p = fmap snd . parseMorphisms (Functor 1 (GroupValued @(Ratio Int) Variable)) EnableSanityChecks "" it "parses a simple example" $ p "x: {x: 1/5, y: 3/7}\ny: {}" `shouldParse` encoding [(Sorted 1 (22%35)), (Sorted 1 0)] [(0, (Sorted 1 (1%5)), 0), (0, (Sorted 1 (3%7)), 1)] it "parses negative values" $ p "x: {x: -1/5, y: -3/7}\ny: {}" `shouldParse` encoding [(Sorted 1 (-22%35)), (Sorted 1 0)] [(0, (Sorted 1 (-1%5)), 0), (0, (Sorted 1 (-3%7)), 1)] Loading
tests/Copar/Functors/GroupValuedSpec.hs +19 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ import Test.Hspec.Megaparsec import TestHelpers import Data.Complex import Data.Ratio import Copar.Functors.GroupValued import Copar.Coalgebra.Parser Loading @@ -18,6 +19,7 @@ spec = do parseMorphismPointIntSpec parseMorphismPointDoubleSpec parseMorphismPointComplexSpec parseMorphismPointRationalSpec parseMorphismPointIntSpec :: Spec Loading Loading @@ -97,3 +99,20 @@ parseMorphismPointComplexSpec = describe "parseMorphismPoint (Complex)" $ do [(0, Sorted 1 (c (-2.3) 0), 0)] where c a b = OrderedComplex (a :+ b) parseMorphismPointRationalSpec :: Spec parseMorphismPointRationalSpec = describe "parseMorphismPoint (Rational)" $ do let p = fmap snd . parseMorphisms (Functor 1 (GroupValued @(Ratio Int) Variable)) EnableSanityChecks "" it "parses a simple example" $ p "x: {x: 1/5, y: 3/7}\ny: {}" `shouldParse` encoding [(Sorted 1 (22%35)), (Sorted 1 0)] [(0, (Sorted 1 (1%5)), 0), (0, (Sorted 1 (3%7)), 1)] it "parses negative values" $ p "x: {x: -1/5, y: -3/7}\ny: {}" `shouldParse` encoding [(Sorted 1 (-22%35)), (Sorted 1 0)] [(0, (Sorted 1 (-1%5)), 0), (0, (Sorted 1 (-3%7)), 1)]