Skip to content
Permalink
Browse files

add test for parsing pretty printed contracts

  • Loading branch information...
David Smith
David Smith committed Mar 14, 2019
1 parent e5e24a9 commit de51f65c2362b047ddbb6f019b356436366b9a8f
Showing with 9 additions and 2 deletions.
  1. +9 −2 meadow-client/test/Marlowe/ParserTests.purs
@@ -11,7 +11,8 @@ import Control.Monad.Rec.Class (class MonadRec)
import Data.Either (Either(..))
import Marlowe.Gen (genContract, genObservation, genValue)
import Marlowe.Parser (contract, observation, value)
import Semantics (Contract, Observation, Value)
import Marlowe.Pretty (pretty)
import Marlowe.Types (Contract, Observation, Value)
import Test.QuickCheck (class Testable, Result, (===))
import Test.QuickCheck.Gen (Gen)
import Test.Unit (TestSuite, Test, suite, test)
@@ -24,6 +25,7 @@ all =
test "Value Parser" $ quickCheckGen valueParser
test "Observation Parser" $ quickCheckGen observationParser
test "Contract Parser" $ quickCheckGen contractParser
test "Pretty Contract Parser" $ quickCheckGen prettyParser

quickCheckGen :: forall e prop. Testable prop => Gen prop -> Test ( random RANDOM | e )
quickCheckGen = quickCheck
@@ -41,4 +43,9 @@ observationParser = do
contractParser :: forall m. MonadGen m => MonadRec m => Lazy (m Value) => Lazy (m Observation) => Lazy (m Contract) => m Result
contractParser = do
v <- genContract
pure (parse (parens contract <|> contract) (show v) === Right v)
pure (parse (parens contract <|> contract) (show v) === Right v)

prettyParser :: forall m. MonadGen m => MonadRec m => Lazy (m Value) => Lazy (m Observation) => Lazy (m Contract) => m Result
prettyParser = do
v <- genContract
pure (parse (parens contract <|> contract) (show $ pretty v) === Right v)

0 comments on commit de51f65

Please sign in to comment.
You can’t perform that action at this time.