Commit 851ed06f authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢

Fix test and benchmark compilation

parent 29866152
......@@ -55,7 +55,7 @@ benchParser ::
-> Benchmark
benchParser benchmarkName fexpr input = bench benchmarkName (nf parse input)
where
parse = parseMorphisms fexpr EnableSanityChecks ""
parse = parseMorphisms fexpr Nothing EnableSanityChecks ""
mkPoly :: [[Factor a]] -> Polynomial a
mkPoly =
......
......@@ -99,7 +99,7 @@ parseMorphismsSpec = describe "parseMorphisms" $ do
Right [ (Sorted 1 (SomeF1 ("a" :: Text))), (Sorted 2 (SomeF1 ("a" :: Text))) ]
context "the symbol table" $ do
let p x = fromSymbolTable . fst <$> parseMorphisms (Functor 1 (P Variable)) EnableSanityChecks "" x
let p x = fromSymbolTable . fst <$> parseMorphisms (Functor 1 (P Variable)) Nothing EnableSanityChecks "" x
it "contains the defined symbols" $ do
(HM.elems <$> p "a: []\nb: []\nc: []") `shouldParse` ["a", "b", "c"]
......@@ -199,4 +199,4 @@ instance ParseMorphism SomeFunctor where
parsing :: (Functor f, ParseMorphism f) => FunctorExpression f Sort
-> Text
-> Either (ParseErrorBundle Text Void) (Encoding (Label (Desorted f)) (F1 (Desorted f)))
parsing expr = fmap snd . parseMorphisms expr EnableSanityChecks ""
parsing expr = fmap snd . parseMorphisms expr Nothing EnableSanityChecks ""
......@@ -72,7 +72,7 @@ removeSomeFunctor = bimap
parseMorphismPointSpec :: Spec
parseMorphismPointSpec = describe "parseMorphismPoint" $ do
let morphp fexpr input =
(removeSomeFunctor . snd) <$> parseMorphisms (Functor 1 fexpr) EnableSanityChecks "" input
(removeSomeFunctor . snd) <$> parseMorphisms (Functor 1 fexpr) Nothing EnableSanityChecks "" input
it "parses a constant" $ do
morphp (mkPoly [[c ["a", "b", "c"]]]) "x: inj 0 (a)"
......@@ -235,7 +235,7 @@ parseMorphismPointSpec = describe "parseMorphismPoint" $ do
refineSpec :: Spec
refineSpec = describe "refining" $ do
let morphp fexpr input = snd <$> parseMorphisms (Functor 1 fexpr) EnableSanityChecks "" input
let morphp fexpr input = snd <$> parseMorphisms (Functor 1 fexpr) Nothing EnableSanityChecks "" input
it "distinguishes constants" $ do
let Right enc =
......
......@@ -34,7 +34,7 @@ functorExpressionSpec = describe "functorExpression" $ do
parseMorphismPointSpec :: Spec
parseMorphismPointSpec = describe "parseMorphismPoint" $ do
it "works for a simple example"
$ (snd <$> parseMorphisms (Functor 1 (Bag Variable))
$ (snd <$> parseMorphisms (Functor 1 (Bag Variable)) Nothing
EnableSanityChecks
""
"x: {x,x}"
......@@ -51,6 +51,6 @@ refineSpec = describe "refining" $ do
it "distinguishes points with different successor count"
$ let Right (_, enc) =
parseMorphisms f EnableSanityChecks "" "x: {x, x, y}\ny: {x, y}"
parseMorphisms f Nothing EnableSanityChecks "" "x: {x, x, y}\ny: {x, y}"
in stToIO (refine (Proxy @(Desorted Bag)) enc True)
`shouldReturn` (Part.fromBlocks [[0], [1]])
......@@ -37,7 +37,7 @@ parseMorphismPointSpec = describe "parseMorphismPoint" $ do
it "works for a simple example" $
(snd <$>
parseMorphisms
(Functor 1 (Distribution Variable))
(Functor 1 (Distribution Variable)) Nothing
EnableSanityChecks
""
"x: {x: 0.5, y: 0.5}\ny: {x: 1.0}") `shouldParse`
......@@ -49,22 +49,22 @@ parseMorphismPointSpec = describe "parseMorphismPoint" $ do
]
it "errors if edge weight sum isn't 1" $
parseMorphisms (Functor 1 (Distribution Variable)) EnableSanityChecks ""
parseMorphisms (Functor 1 (Distribution Variable)) Nothing EnableSanityChecks ""
`shouldFailOn`
"x: {x: 0.5}"
it "errors if an edge weight is below zero" $
parseMorphisms (Functor 1 (Distribution Variable)) EnableSanityChecks ""
parseMorphisms (Functor 1 (Distribution Variable)) Nothing EnableSanityChecks ""
`shouldFailOn`
"x: {x: -1}"
it "errors if an edge weight is above one" $
parseMorphisms (Functor 1 (Distribution Variable)) EnableSanityChecks ""
parseMorphisms (Functor 1 (Distribution Variable)) Nothing EnableSanityChecks ""
`shouldFailOn`
"x: {x: 1.3}"
it "uses approximate comparison for doubles" $
parseMorphisms (Functor 1 (Distribution Variable)) EnableSanityChecks "" `shouldSucceedOn`
parseMorphisms (Functor 1 (Distribution Variable)) Nothing EnableSanityChecks "" `shouldSucceedOn`
"s0: {s0: 0.1, s1: 0.1, s2: 0.1, s3: 0.1, s4: 0.1, s5: 0.1, s6: 0.1, s7: 0.1, s8: 0.1, s9: 0.1}\n\
\s1: {s1: 1.0}\n\
\s2: {s2: 1.0}\n\
......@@ -81,7 +81,7 @@ refineSpec = describe "refining" $ do
let f = Functor 1 (Distribution Variable)
it "handles states with incoming edges greater than 1" $ do
let x = parseMorphisms f EnableSanityChecks "" "x: {z: 1.0}\ny: {z: 1.0}\nz: {y: 1.0}"
let x = parseMorphisms f Nothing EnableSanityChecks "" "x: {z: 1.0}\ny: {z: 1.0}\nz: {y: 1.0}"
x `shouldSatisfy` isRight
let Right (_, enc) = x
stToIO (refine (Proxy @(Desorted Distribution)) enc True) `shouldReturn` Part.fromBlocks [[0, 1, 2]]
......@@ -34,7 +34,7 @@ parseIntSpec = describe "Int-valued parser" $ do
parseMorphismPointIntSpec :: Spec
parseMorphismPointIntSpec = describe "parseMorphismPoint (Int)" $ do
let p = fmap snd . parseMorphisms (Functor 1 (GroupValued @Int Variable)) EnableSanityChecks ""
let p = fmap snd . parseMorphisms (Functor 1 (GroupValued @Int Variable)) Nothing EnableSanityChecks ""
it "parses an empty successor list"
$ p "x: {}"
......@@ -56,7 +56,7 @@ parseMorphismPointDoubleSpec :: Spec
parseMorphismPointDoubleSpec = describe "parseMorphismPoint (Double)" $ do
let
p =
fmap snd . parseMorphisms (Functor 1 (GroupValued @EqDouble Variable)) EnableSanityChecks ""
fmap snd . parseMorphisms (Functor 1 (GroupValued @EqDouble Variable)) Nothing EnableSanityChecks ""
it "parses an empty successor list"
$ p "x: {}"
......@@ -77,7 +77,7 @@ parseMorphismPointDoubleSpec = describe "parseMorphismPoint (Double)" $ do
parseMorphismPointComplexSpec :: Spec
parseMorphismPointComplexSpec = describe "parseMorphismPoint (Complex)" $ do
let p = fmap snd . parseMorphisms
(Functor 1 (GroupValued @OrderedComplex Variable))
(Functor 1 (GroupValued @OrderedComplex Variable)) Nothing
EnableSanityChecks
""
......@@ -123,7 +123,7 @@ parseMorphismPointComplexSpec = describe "parseMorphismPoint (Complex)" $ do
parseMorphismPointRationalSpec :: Spec
parseMorphismPointRationalSpec = describe "parseMorphismPoint (Rational)" $ do
let p = fmap snd . parseMorphisms
(Functor 1 (GroupValued @(Ratio Int) Variable))
(Functor 1 (GroupValued @(Ratio Int) Variable)) Nothing
EnableSanityChecks
""
......
......@@ -304,7 +304,7 @@ makeMorphParser
)
)
makeMorphParser = fmap snd . parseMorphisms
(Functor 1 (SlowMonoidValued Variable))
(Functor 1 (SlowMonoidValued Variable)) Nothing
EnableSanityChecks
""
......
......@@ -197,7 +197,7 @@ e inner = Exponential inner . ExplicitExp . V.fromList
morphp :: (Functor f, ParseMorphism f) => f (FunctorExpression f Sort)
-> Text
-> Either (ParseErrorBundle Text Void) (Encoding (Label (Desorted f)) (F1 (Desorted f)))
morphp fexpr input = snd <$> parseMorphisms (Functor 1 fexpr) EnableSanityChecks "" input
morphp fexpr input = snd <$> parseMorphisms (Functor 1 fexpr) Nothing EnableSanityChecks "" input
parseMorphismPointSpec :: Spec
parseMorphismPointSpec = describe "parseMorphismPoint" $ do
......
......@@ -18,7 +18,8 @@ spec = do
parseMorphismPointSpec :: Spec
parseMorphismPointSpec = describe "parseMorphismPoint" $ do
it "works for a simple example" $
(snd <$> parseMorphisms (Functor 1 (Powerset Variable)) EnableSanityChecks "" "x: {x, y}\ny: {}") `shouldParse`
(snd <$> parseMorphisms (Functor 1 (Powerset Variable)) Nothing EnableSanityChecks "" "x: {x, y}\ny: {}")
`shouldParse`
(encoding
[(Sorted 1 True), (Sorted 1 False)]
[ (0, mkDesortedLabel @Powerset (Sorted 1 ()), 0)
......@@ -27,4 +28,5 @@ parseMorphismPointSpec = describe "parseMorphismPoint" $ do
)
it "errors on duplicate edges" $
parseMorphisms (Functor 1 (Powerset Variable)) EnableSanityChecks "" `shouldFailOn` "x: {x, x}"
parseMorphisms (Functor 1 (Powerset Variable)) Nothing EnableSanityChecks ""
`shouldFailOn` "x: {x, x}"
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