-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
81 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
{-# OPTIONS_GHC -Wno-type-defaults #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
{-# OPTIONS_GHC -Wno-type-defaults #-} | ||
|
||
module Language.Lambda.ImplSpec where | ||
|
||
import Data.Either (isRight) | ||
import Control.Monad (forM_) | ||
import Test.Hspec | ||
import Data.Either (isRight) | ||
import qualified Data.Text as Text | ||
import qualified Toml | ||
import System.Exit (exitFailure) | ||
import Test.Hspec | ||
import qualified Toml | ||
|
||
import Language.Lambda.Impl as Impl | ||
|
||
handleErr :: (Show e) => Either e a -> IO a | ||
handleErr = either (\err -> print err >> exitFailure) pure | ||
|
||
spec :: Spec | ||
spec = do | ||
Impl.Config{..} <- runIO $ do | ||
configResult <- Toml.decodeFileEither configCodec "config.toml" | ||
case configResult of | ||
Left err -> do | ||
print err | ||
exitFailure | ||
Right config -> return config | ||
|
||
configResult <- Toml.decodeFileEither configCodec "config.toml" >>= handleErr | ||
handleErr (Impl.parseRawConfig configResult) | ||
|
||
let title = Text.unpack (configLanguage <> " (fragment: " <> configFragment <> ")") | ||
describe title $ | ||
forM_ (zip [1..] configProblems) $ \(i, Impl.Problem{..}) -> do | ||
forM_ (zip [1 ..] configProblems) $ \(i, Impl.Problem{..}) -> do | ||
describe ("problem #" <> show i) $ do | ||
forM_ problemSolutions $ \solution@Impl.Solution{..} -> do | ||
it (Text.unpack solutionName) $ do | ||
Impl.validateSolution problemConstraints solution `shouldSatisfy` isRight | ||
Impl.validateSolution problemConstraints solution `shouldSatisfy` isRight |