2022-09-07 14:59:41 +03:00
|
|
|
module Parsing.Negative where
|
|
|
|
|
|
|
|
import Base
|
2022-11-07 16:47:56 +03:00
|
|
|
import Juvix.Compiler.Builtins (iniState)
|
2022-09-07 14:59:41 +03:00
|
|
|
import Juvix.Compiler.Pipeline
|
|
|
|
import Juvix.Parser.Error
|
|
|
|
|
2022-12-20 15:05:40 +03:00
|
|
|
root :: Path Abs Dir
|
|
|
|
root = relToProject $(mkRelDir "tests/negative")
|
2022-09-07 14:59:41 +03:00
|
|
|
|
|
|
|
data NegTest = NegTest
|
|
|
|
{ _name :: String,
|
2022-12-20 15:05:40 +03:00
|
|
|
_relDir :: Path Rel Dir,
|
|
|
|
_file :: Path Rel File
|
2022-09-07 14:59:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
testDescr :: NegTest -> TestDescr
|
|
|
|
testDescr NegTest {..} =
|
2022-12-20 15:05:40 +03:00
|
|
|
let tRoot = root <//> _relDir
|
|
|
|
file' = tRoot <//> _file
|
2022-09-07 14:59:41 +03:00
|
|
|
in TestDescr
|
|
|
|
{ _testName = _name,
|
|
|
|
_testRoot = tRoot,
|
|
|
|
_testAssertion = Single $ do
|
2022-12-20 15:05:40 +03:00
|
|
|
let entryPoint = defaultEntryPoint tRoot file'
|
2022-11-07 16:47:56 +03:00
|
|
|
res <- runIOEither iniState entryPoint upToParsing
|
2022-09-07 14:59:41 +03:00
|
|
|
case mapLeft fromJuvixError res of
|
|
|
|
Left (Just (_ :: ParserError)) -> return ()
|
|
|
|
Left Nothing -> assertFailure "The parser did not find an error."
|
|
|
|
Right _ -> assertFailure "An error ocurred but it was not in the parser."
|
|
|
|
}
|
|
|
|
|
|
|
|
allTests :: TestTree
|
|
|
|
allTests =
|
|
|
|
testGroup
|
|
|
|
"Parsing negative tests"
|
|
|
|
( map (mkTest . testDescr) scoperErrorTests
|
|
|
|
)
|
|
|
|
|
|
|
|
scoperErrorTests :: [NegTest]
|
|
|
|
scoperErrorTests =
|
|
|
|
[ NegTest
|
|
|
|
"Tab character"
|
2022-12-20 15:05:40 +03:00
|
|
|
$(mkRelDir ".")
|
|
|
|
$(mkRelFile "Tab.juvix")
|
2022-09-07 14:59:41 +03:00
|
|
|
]
|