mirror of
https://github.com/anoma/juvix.git
synced 2024-12-14 17:32:00 +03:00
69594edc7b
This patch dramatically increases the efficiency of `juvix dev root`, which was unnecessarily parsing all dependencies included in the `Package.juvix` file. Other commands that do not require the `Package` will also be faster. It also refactors some functions so that the `TaggedLock` effect is run globally. I've added `singletons-base` as a dependency so we can have `++` on the type level. We've tried to define a type family ourselves but inference was not working properly.
61 lines
1.6 KiB
Haskell
61 lines
1.6 KiB
Haskell
module BackendMarkdown.Negative where
|
|
|
|
import Base
|
|
import Juvix.Compiler.Backend.Markdown.Error
|
|
import Juvix.Parser.Error
|
|
|
|
type FailMsg = String
|
|
|
|
data NegTest = NegTest
|
|
{ _name :: String,
|
|
_relDir :: Path Rel Dir,
|
|
_file :: Path Rel File,
|
|
_checkErr :: ParserError -> Maybe FailMsg
|
|
}
|
|
|
|
testDescr :: NegTest -> TestDescr
|
|
testDescr NegTest {..} =
|
|
let tRoot = root <//> _relDir
|
|
file' = tRoot <//> _file
|
|
in TestDescr
|
|
{ _testName = _name,
|
|
_testRoot = tRoot,
|
|
_testAssertion = Single $ do
|
|
entryPoint <- testDefaultEntryPointIO tRoot file'
|
|
result <- testTaggedLockedToIO (snd <$> runIOEither entryPoint upToParsing)
|
|
case mapLeft fromJuvixError result of
|
|
Left (Just err) -> whenJust (_checkErr err) assertFailure
|
|
Right _ -> assertFailure "Unexpected success."
|
|
Left Nothing -> assertFailure "Unexpected error."
|
|
}
|
|
|
|
allTests :: TestTree
|
|
allTests =
|
|
testGroup
|
|
"Markdown negative tests"
|
|
(map (mkTest . testDescr) tests)
|
|
|
|
root :: Path Abs Dir
|
|
root = relToProject $(mkRelDir "tests/negative")
|
|
|
|
wrongError :: Maybe FailMsg
|
|
wrongError = Just "Incorrect error"
|
|
|
|
tests :: [NegTest]
|
|
tests =
|
|
[ NegTest
|
|
"Empty file"
|
|
$(mkRelDir "Markdown")
|
|
$(mkRelFile "Empty.juvix.md")
|
|
$ \case
|
|
ErrMarkdownBackend (ErrNoJuvixCodeBlocks _) -> Nothing
|
|
_ -> wrongError,
|
|
NegTest
|
|
"No Juvix code blocks"
|
|
$(mkRelDir "Markdown")
|
|
$(mkRelFile "NoJuvixCodeBlocks.juvix.md")
|
|
$ \case
|
|
ErrMarkdownBackend (ErrNoJuvixCodeBlocks _) -> Nothing
|
|
_ -> wrongError
|
|
]
|