{- -----------------------------------------------------------------------------
Copyright 2020 Kevin P. Barry

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
----------------------------------------------------------------------------- -}

-- Author: Kevin P. Barry [ta0kira@gmail.com]

{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE Safe #-}

module Parser.IntegrationTest (
) where

import Text.Parsec

import Parser.Common
import Parser.DefinedCategory ()
import Parser.Procedure ()
import Parser.TypeCategory ()
import Types.IntegrationTest


instance ParseFromSource (IntegrationTestHeader SourcePos) where
  sourceParser :: ParserE m (IntegrationTestHeader SourcePos)
sourceParser = String
-> ParserE m (IntegrationTestHeader SourcePos)
-> ParserE m (IntegrationTestHeader SourcePos)
forall (m :: * -> *) a.
Monad m =>
String -> ParserE m a -> ParserE m a
labeled String
"testcase" (ParserE m (IntegrationTestHeader SourcePos)
 -> ParserE m (IntegrationTestHeader SourcePos))
-> ParserE m (IntegrationTestHeader SourcePos)
-> ParserE m (IntegrationTestHeader SourcePos)
forall a b. (a -> b) -> a -> b
$ do
    SourcePos
c <- ParsecT String () m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
    ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter ParserE m ()
forall (m :: * -> *). Monad m => ParserE m ()
kwTestcase
    String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
string_ String
"\""
    String
name <- ParsecT String () m Char
-> ParserE m () -> ParsecT String () m String
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT String () m Char
forall (m :: * -> *). Monad m => ParserE m Char
stringChar (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
string_ String
"\"")
    ParserE m ()
forall (m :: * -> *). Monad m => ParserE m ()
optionalSpace
    ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
string_ String
"{")
    ExpectedResult SourcePos
result <- ParserE m (ExpectedResult SourcePos)
resultCompiles ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserE m (ExpectedResult SourcePos)
resultError ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserE m (ExpectedResult SourcePos)
resultCrash ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserE m (ExpectedResult SourcePos)
resultSuccess
    [String]
args <- ParserE m [String]
parseArgs ParserE m [String] -> ParserE m [String] -> ParserE m [String]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> [String] -> ParserE m [String]
forall (m :: * -> *) a. Monad m => a -> m a
return []
    ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
string_ String
"}")
    IntegrationTestHeader SourcePos
-> ParserE m (IntegrationTestHeader SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (IntegrationTestHeader SourcePos
 -> ParserE m (IntegrationTestHeader SourcePos))
-> IntegrationTestHeader SourcePos
-> ParserE m (IntegrationTestHeader SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos]
-> String
-> [String]
-> ExpectedResult SourcePos
-> IntegrationTestHeader SourcePos
forall c.
[c]
-> String
-> [String]
-> ExpectedResult c
-> IntegrationTestHeader c
IntegrationTestHeader [SourcePos
c] String
name [String]
args ExpectedResult SourcePos
result where
      resultCompiles :: ParserE m (ExpectedResult SourcePos)
resultCompiles = String
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall (m :: * -> *) a.
Monad m =>
String -> ParserE m a -> ParserE m a
labeled String
"compiles expectation" (ParserE m (ExpectedResult SourcePos)
 -> ParserE m (ExpectedResult SourcePos))
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall a b. (a -> b) -> a -> b
$ do
        SourcePos
c <- ParsecT String () m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
        ParserE m () -> ParserE m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserE m () -> ParserE m ()) -> ParserE m () -> ParserE m ()
forall a b. (a -> b) -> a -> b
$ ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"compiles")
        ([OutputPattern]
req,[OutputPattern]
exc) <- ParsecT String () m ([OutputPattern], [OutputPattern])
requireOrExclude
        ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos))
-> ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos]
-> [OutputPattern] -> [OutputPattern] -> ExpectedResult SourcePos
forall c.
[c] -> [OutputPattern] -> [OutputPattern] -> ExpectedResult c
ExpectCompiles [SourcePos
c] [OutputPattern]
req [OutputPattern]
exc
      resultError :: ParserE m (ExpectedResult SourcePos)
resultError = String
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall (m :: * -> *) a.
Monad m =>
String -> ParserE m a -> ParserE m a
labeled String
"error expectation" (ParserE m (ExpectedResult SourcePos)
 -> ParserE m (ExpectedResult SourcePos))
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall a b. (a -> b) -> a -> b
$ do
        SourcePos
c <- ParsecT String () m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
        ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"error")
        ([OutputPattern]
req,[OutputPattern]
exc) <- ParsecT String () m ([OutputPattern], [OutputPattern])
requireOrExclude
        ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos))
-> ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos]
-> [OutputPattern] -> [OutputPattern] -> ExpectedResult SourcePos
forall c.
[c] -> [OutputPattern] -> [OutputPattern] -> ExpectedResult c
ExpectCompileError [SourcePos
c] [OutputPattern]
req [OutputPattern]
exc
      resultCrash :: ParserE m (ExpectedResult SourcePos)
resultCrash = String
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall (m :: * -> *) a.
Monad m =>
String -> ParserE m a -> ParserE m a
labeled String
"crash expectation" (ParserE m (ExpectedResult SourcePos)
 -> ParserE m (ExpectedResult SourcePos))
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall a b. (a -> b) -> a -> b
$ do
        SourcePos
c <- ParsecT String () m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
        ParserE m () -> ParserE m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserE m () -> ParserE m ()) -> ParserE m () -> ParserE m ()
forall a b. (a -> b) -> a -> b
$ ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"crash")
        ([OutputPattern]
req,[OutputPattern]
exc) <- ParsecT String () m ([OutputPattern], [OutputPattern])
requireOrExclude
        ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos))
-> ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos]
-> [OutputPattern] -> [OutputPattern] -> ExpectedResult SourcePos
forall c.
[c] -> [OutputPattern] -> [OutputPattern] -> ExpectedResult c
ExpectRuntimeError [SourcePos
c] [OutputPattern]
req [OutputPattern]
exc
      resultSuccess :: ParserE m (ExpectedResult SourcePos)
resultSuccess = String
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall (m :: * -> *) a.
Monad m =>
String -> ParserE m a -> ParserE m a
labeled String
"success expectation" (ParserE m (ExpectedResult SourcePos)
 -> ParserE m (ExpectedResult SourcePos))
-> ParserE m (ExpectedResult SourcePos)
-> ParserE m (ExpectedResult SourcePos)
forall a b. (a -> b) -> a -> b
$ do
        SourcePos
c <- ParsecT String () m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
        ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"success")
        ([OutputPattern]
req,[OutputPattern]
exc) <- ParsecT String () m ([OutputPattern], [OutputPattern])
requireOrExclude
        ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos))
-> ExpectedResult SourcePos -> ParserE m (ExpectedResult SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos]
-> [OutputPattern] -> [OutputPattern] -> ExpectedResult SourcePos
forall c.
[c] -> [OutputPattern] -> [OutputPattern] -> ExpectedResult c
ExpectRuntimeSuccess [SourcePos
c] [OutputPattern]
req [OutputPattern]
exc
      parseArgs :: ParserE m [String]
parseArgs = String -> ParserE m [String] -> ParserE m [String]
forall (m :: * -> *) a.
Monad m =>
String -> ParserE m a -> ParserE m a
labeled String
"testcase args" (ParserE m [String] -> ParserE m [String])
-> ParserE m [String] -> ParserE m [String]
forall a b. (a -> b) -> a -> b
$ do
        ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"args")
        ParsecT String () m String -> ParserE m [String]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT String () m String -> ParsecT String () m String
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter ParsecT String () m String
forall (m :: * -> *). Monad m => ParserE m String
quotedString)
      requireOrExclude :: ParsecT String () m ([OutputPattern], [OutputPattern])
requireOrExclude = ParsecT String () m [([OutputPattern], [OutputPattern])]
parsed ParsecT String () m [([OutputPattern], [OutputPattern])]
-> ([([OutputPattern], [OutputPattern])]
    -> ParsecT String () m ([OutputPattern], [OutputPattern]))
-> ParsecT String () m ([OutputPattern], [OutputPattern])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ([OutputPattern], [OutputPattern])
-> ParsecT String () m ([OutputPattern], [OutputPattern])
forall (m :: * -> *) a. Monad m => a -> m a
return (([OutputPattern], [OutputPattern])
 -> ParsecT String () m ([OutputPattern], [OutputPattern]))
-> ([([OutputPattern], [OutputPattern])]
    -> ([OutputPattern], [OutputPattern]))
-> [([OutputPattern], [OutputPattern])]
-> ParsecT String () m ([OutputPattern], [OutputPattern])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (([OutputPattern], [OutputPattern])
 -> ([OutputPattern], [OutputPattern])
 -> ([OutputPattern], [OutputPattern]))
-> ([OutputPattern], [OutputPattern])
-> [([OutputPattern], [OutputPattern])]
-> ([OutputPattern], [OutputPattern])
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr ([OutputPattern], [OutputPattern])
-> ([OutputPattern], [OutputPattern])
-> ([OutputPattern], [OutputPattern])
forall a a. ([a], [a]) -> ([a], [a]) -> ([a], [a])
merge ([OutputPattern], [OutputPattern])
forall a a. ([a], [a])
empty where
        empty :: ([a], [a])
empty = ([],[])
        merge :: ([a], [a]) -> ([a], [a]) -> ([a], [a])
merge ([a]
cs1,[a]
ds1) ([a]
cs2,[a]
ds2) = ([a]
cs1[a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++[a]
cs2,[a]
ds1[a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
++[a]
ds2)
        parsed :: ParsecT String () m [([OutputPattern], [OutputPattern])]
parsed = ParsecT String () m ([OutputPattern], [OutputPattern])
-> ParserE m ()
-> ParsecT String () m [([OutputPattern], [OutputPattern])]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy ParsecT String () m ([OutputPattern], [OutputPattern])
anyType ParserE m ()
forall (m :: * -> *). Monad m => ParserE m ()
optionalSpace
        anyType :: ParsecT String () m ([OutputPattern], [OutputPattern])
anyType = ParsecT String () m ([OutputPattern], [OutputPattern])
forall a. ParsecT String () m ([OutputPattern], [a])
require ParsecT String () m ([OutputPattern], [OutputPattern])
-> ParsecT String () m ([OutputPattern], [OutputPattern])
-> ParsecT String () m ([OutputPattern], [OutputPattern])
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT String () m ([OutputPattern], [OutputPattern])
forall a. ParsecT String () m ([a], [OutputPattern])
exclude where
          require :: ParsecT String () m ([OutputPattern], [a])
require = do
            ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"require")
            OutputScope
s <- ParsecT String () m OutputScope
outputScope
            String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
string_ String
"\""
            String
r <- ([String] -> String)
-> ParserE m [String] -> ParsecT String () m String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (ParserE m [String] -> ParsecT String () m String)
-> ParserE m [String] -> ParsecT String () m String
forall a b. (a -> b) -> a -> b
$ ParsecT String () m String -> ParserE m () -> ParserE m [String]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT String () m String
forall (m :: * -> *). Monad m => ParserE m String
regexChar (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
string_ String
"\"")
            ParserE m ()
forall (m :: * -> *). Monad m => ParserE m ()
optionalSpace
            ([OutputPattern], [a])
-> ParsecT String () m ([OutputPattern], [a])
forall (m :: * -> *) a. Monad m => a -> m a
return ([OutputScope -> String -> OutputPattern
OutputPattern OutputScope
s String
r],[])
          exclude :: ParsecT String () m ([a], [OutputPattern])
exclude = do
            ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"exclude")
            OutputScope
s <- ParsecT String () m OutputScope
outputScope
            String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
string_ String
"\""
            String
e <- ([String] -> String)
-> ParserE m [String] -> ParsecT String () m String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (ParserE m [String] -> ParsecT String () m String)
-> ParserE m [String] -> ParsecT String () m String
forall a b. (a -> b) -> a -> b
$ ParsecT String () m String -> ParserE m () -> ParserE m [String]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT String () m String
forall (m :: * -> *). Monad m => ParserE m String
regexChar (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
string_ String
"\"")
            ParserE m ()
forall (m :: * -> *). Monad m => ParserE m ()
optionalSpace
            ([a], [OutputPattern])
-> ParsecT String () m ([a], [OutputPattern])
forall (m :: * -> *) a. Monad m => a -> m a
return ([],[OutputScope -> String -> OutputPattern
OutputPattern OutputScope
s String
e])
      outputScope :: ParsecT String () m OutputScope
outputScope = ParsecT String () m OutputScope -> ParsecT String () m OutputScope
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT String () m OutputScope
anyScope ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
                    ParsecT String () m OutputScope -> ParsecT String () m OutputScope
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT String () m OutputScope
compilerScope ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
                    ParsecT String () m OutputScope -> ParsecT String () m OutputScope
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT String () m OutputScope
stderrScope ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
                    ParsecT String () m OutputScope -> ParsecT String () m OutputScope
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT String () m OutputScope
stdoutScope ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
                    OutputScope -> ParsecT String () m OutputScope
forall (m :: * -> *) a. Monad m => a -> m a
return OutputScope
OutputAny
      anyScope :: ParsecT String () m OutputScope
anyScope      = ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"any")      ParserE m ()
-> ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> OutputScope -> ParsecT String () m OutputScope
forall (m :: * -> *) a. Monad m => a -> m a
return OutputScope
OutputAny
      compilerScope :: ParsecT String () m OutputScope
compilerScope = ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"compiler") ParserE m ()
-> ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> OutputScope -> ParsecT String () m OutputScope
forall (m :: * -> *) a. Monad m => a -> m a
return OutputScope
OutputCompiler
      stderrScope :: ParsecT String () m OutputScope
stderrScope   = ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"stderr")   ParserE m ()
-> ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> OutputScope -> ParsecT String () m OutputScope
forall (m :: * -> *) a. Monad m => a -> m a
return OutputScope
OutputStderr
      stdoutScope :: ParsecT String () m OutputScope
stdoutScope   = ParserE m () -> ParserE m ()
forall (m :: * -> *) a. Monad m => ParserE m a -> ParserE m a
sepAfter (String -> ParserE m ()
forall (m :: * -> *). Monad m => String -> ParserE m ()
keyword String
"stdout")   ParserE m ()
-> ParsecT String () m OutputScope
-> ParsecT String () m OutputScope
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> OutputScope -> ParsecT String () m OutputScope
forall (m :: * -> *) a. Monad m => a -> m a
return OutputScope
OutputStdout

instance ParseFromSource (IntegrationTest SourcePos) where
  sourceParser :: ParserE m (IntegrationTest SourcePos)
sourceParser = String
-> ParserE m (IntegrationTest SourcePos)
-> ParserE m (IntegrationTest SourcePos)
forall (m :: * -> *) a.
Monad m =>
String -> ParserE m a -> ParserE m a
labeled String
"integration test" (ParserE m (IntegrationTest SourcePos)
 -> ParserE m (IntegrationTest SourcePos))
-> ParserE m (IntegrationTest SourcePos)
-> ParserE m (IntegrationTest SourcePos)
forall a b. (a -> b) -> a -> b
$ do
    IntegrationTestHeader SourcePos
h <- ParserE m (IntegrationTestHeader SourcePos)
forall a (m :: * -> *).
(ParseFromSource a, CompileErrorM m) =>
ParserE m a
sourceParser
    ([AnyCategory SourcePos]
cs,[DefinedCategory SourcePos]
ds,[TestProcedure SourcePos]
ts) <- ParserE m (AnyCategory SourcePos)
-> ParserE m (DefinedCategory SourcePos)
-> ParserE m (TestProcedure SourcePos)
-> ParserE
     m
     ([AnyCategory SourcePos], [DefinedCategory SourcePos],
      [TestProcedure SourcePos])
forall (m :: * -> *) a b c.
Monad m =>
ParserE m a
-> ParserE m b -> ParserE m c -> ParserE m ([a], [b], [c])
parseAny3 ParserE m (AnyCategory SourcePos)
forall a (m :: * -> *).
(ParseFromSource a, CompileErrorM m) =>
ParserE m a
sourceParser ParserE m (DefinedCategory SourcePos)
forall a (m :: * -> *).
(ParseFromSource a, CompileErrorM m) =>
ParserE m a
sourceParser ParserE m (TestProcedure SourcePos)
forall a (m :: * -> *).
(ParseFromSource a, CompileErrorM m) =>
ParserE m a
sourceParser
    IntegrationTest SourcePos -> ParserE m (IntegrationTest SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (IntegrationTest SourcePos
 -> ParserE m (IntegrationTest SourcePos))
-> IntegrationTest SourcePos
-> ParserE m (IntegrationTest SourcePos)
forall a b. (a -> b) -> a -> b
$ IntegrationTestHeader SourcePos
-> [AnyCategory SourcePos]
-> [DefinedCategory SourcePos]
-> [TestProcedure SourcePos]
-> IntegrationTest SourcePos
forall c.
IntegrationTestHeader c
-> [AnyCategory c]
-> [DefinedCategory c]
-> [TestProcedure c]
-> IntegrationTest c
IntegrationTest IntegrationTestHeader SourcePos
h [AnyCategory SourcePos]
cs [DefinedCategory SourcePos]
ds [TestProcedure SourcePos]
ts