Commit 903c3200 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢

Add some tests for rational-valued functor

parent 89885be0
......@@ -5,6 +5,7 @@ import Test.Hspec.Megaparsec
import TestHelpers
import Data.Complex
import Data.Ratio
import Copar.Functors.GroupValued
import Copar.Coalgebra.Parser
......@@ -18,6 +19,7 @@ spec = do
parseMorphismPointIntSpec
parseMorphismPointDoubleSpec
parseMorphismPointComplexSpec
parseMorphismPointRationalSpec
parseMorphismPointIntSpec :: Spec
......@@ -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)]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment