1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 01:52:11 +03:00
juvix/test/Base.hs

44 lines
1.5 KiB
Haskell
Raw Normal View History

2022-02-15 16:12:53 +03:00
module Base (
module Test.Tasty,
module Test.Tasty.HUnit,
module MiniJuvix.Prelude,
module Base
) where
import Test.Tasty
import Test.Tasty.HUnit
import MiniJuvix.Prelude
import qualified MiniJuvix.Syntax.Concrete.Language as M
import qualified MiniJuvix.Syntax.Abstract.Language as A
2022-02-15 16:12:53 +03:00
import qualified MiniJuvix.Syntax.Concrete.Parser as M
import qualified MiniJuvix.Syntax.Concrete.Scoped.Scoper as M
import qualified MiniJuvix.Translation.ScopedToAbstract as A
2022-02-15 16:12:53 +03:00
parseModuleIO :: FilePath -> IO (M.Module 'M.Parsed 'M.ModuleTop)
parseModuleIO = fromRightIO id . M.runModuleParserIO
2022-02-18 15:01:42 +03:00
parseTextModuleIO :: Text -> IO (M.Module 'M.Parsed 'M.ModuleTop)
parseTextModuleIO = fromRightIO id . return . M.runModuleParser "literal string"
2022-02-15 16:12:53 +03:00
scopeModuleIO :: M.Module 'M.Parsed 'M.ModuleTop -> IO (M.Module 'M.Scoped 'M.ModuleTop)
2022-03-25 19:44:32 +03:00
scopeModuleIO = fmap snd . fromRightIO' printErrorAnsi . M.scopeCheck1IO "."
2022-02-15 16:12:53 +03:00
translateModuleIO :: M.Module 'M.Scoped 'M.ModuleTop -> IO A.TopModule
translateModuleIO = fmap snd . fromRightIO id . return . A.translateModule
2022-02-18 15:01:42 +03:00
data AssertionDescr =
Single Assertion
| Steps ((String -> IO ()) -> Assertion)
2022-02-15 16:12:53 +03:00
data TestDescr = TestDescr {
testName :: String,
testRoot :: FilePath,
-- | relative to root
2022-02-18 15:01:42 +03:00
testAssertion :: AssertionDescr
2022-02-15 16:12:53 +03:00
}
mkTest :: TestDescr -> TestTree
2022-02-18 15:01:42 +03:00
mkTest TestDescr {..} = case testAssertion of
Single assertion -> testCase testName $ withCurrentDirectory testRoot assertion
Steps steps -> testCaseSteps testName (withCurrentDirectory testRoot . steps)