22module Main (main ) where
33
44import LispVal
5- import Parser
65import Eval
76
87import qualified Data.Text as T
98
109import Test.Tasty
1110import Test.Tasty.Golden
1211import qualified Data.ByteString.Lazy.Char8 as C
12+ import Data.Functor ((<&>) )
1313
1414main :: IO ()
1515main = defaultMain tests
@@ -30,7 +30,7 @@ tests = testGroup "Golden Tests"
3030 , tastyGoldenRun " greater than" " test/test_gt.scm" " test/ans/test_gt.txt"
3131 , tastyGoldenRun " lexical scope 1" " test/test_scope1.scm" " test/ans/test_scope1.txt"
3232 , tastyGoldenRun " lexical scope 2" " test/test_scope2.scm" " test/ans/test_scope2.txt"
33- , tastyGoldenRun " issue #23" " test/test_scope3.scm" " test/ans/test_scope3.txt"
33+ , tastyGoldenFail " issue #23" " test/test_scope3.scm" " test/ans/test_scope3.txt"
3434 , tastyGoldenRun " issue #25" " test/test_scope4.scm" " test/ans/test_scope4.txt"
3535 , tastyGoldenRun " Recursion 1" " test/test_fix.scm" " test/ans/test_fix.txt"
3636 , tastyGoldenRun " Recursion 2" " test/test_fix2.scm" " test/ans/test_fix2.txt"
@@ -40,13 +40,18 @@ tests = testGroup "Golden Tests"
4040 ]
4141
4242tastyGoldenRun :: TestName -> T. Text -> FilePath -> TestTree
43- tastyGoldenRun testName testFile correct = goldenVsString testName correct (evalTextTest (Just " lib/stdlib.scm" ) (testFile) >>= (return . C. pack . show ))
44-
45- evalTextTest :: Maybe T. Text -> T. Text -> IO LispVal -- REPL
46- evalTextTest (Just stdlib) file= do
47- stdlib <- getFileContents $ T. unpack stdlib
48- f <- getFileContents $ T. unpack file
49- runASTinEnv basicEnv $ textToEvalForm stdlib f
50- evalTextTest Nothing file = do
43+ tastyGoldenRun testName testFile correct =
44+ goldenVsString testName correct $
45+ evalTextTest " lib/stdlib.scm" testFile <&> C. pack . show
46+
47+ tastyGoldenFail :: TestName -> T. Text -> FilePath -> TestTree
48+ tastyGoldenFail testName testFile correct =
49+ goldenVsString testName correct $
50+ (safeExec $ evalTextTest " lib/stdlib.scm" testFile) <&>
51+ either C. pack (C. pack . show )
52+
53+ evalTextTest :: T. Text -> T. Text -> IO LispVal -- REPL
54+ evalTextTest stdlib file= do
55+ stdlib' <- getFileContents $ T. unpack stdlib
5156 f <- getFileContents $ T. unpack file
52- runASTinEnv basicEnv $ fileToEvalForm ( T. unpack file) f
57+ runASTinEnv basicEnv $ textToEvalForm stdlib' f
0 commit comments