more FromParser

This commit is contained in:
rhiannon morris 2023-03-13 19:33:09 +01:00
parent 90232dd1f8
commit 765c62866a
6 changed files with 110 additions and 40 deletions

View file

@ -3,9 +3,11 @@ module Tests.FromPTerm
import Quox.Parser.Syntax
import Quox.Parser
import TermImpls
import TypingImpls
import Tests.Parser as TParser
import TAP
import System.File
import Derive.Prelude
%language ElabReflection
@ -15,16 +17,18 @@ import Derive.Prelude
public export
data Failure =
ParseError (Parser.Error)
| FromParserError FromParserError
| FromParser FromParserError
| WrongResult String
| ExpectedFail String
%runElab derive "FromParser.FromParserError" [Show]
%runElab derive "FileError" [Show]
%runElab derive "Parser.Error" [Show]
%runElab derive "FromParserError" [Show]
export
ToInfo Failure where
toInfo (ParseError err) = toInfo err
toInfo (FromParserError err) =
toInfo (FromParser err) =
[("type", "FromParserError"),
("got", show err)]
toInfo (WrongResult got) =
@ -40,7 +44,7 @@ parameters {c : Bool} {auto _ : Show b}
parsesWith : (b -> Bool) -> Test
parsesWith p = test label $ do
pres <- mapFst ParseError $ lexParseWith grm inp
res <- mapFst FromParserError $ fromP pres
res <- mapFst FromParser $ fromP pres
unless (p res) $ Left $ WrongResult $ show res
parses : Test