mirror of
https://github.com/zoriya/HAL.git
synced 2026-06-01 13:25:26 +00:00
Adding more tests
This commit is contained in:
+4
-3
@@ -3,9 +3,10 @@ import Expressions
|
||||
|
||||
eval :: Statement -> LispEnv -> Either String (String, LispEnv)
|
||||
eval (Expr expr) env = evalS expr env
|
||||
eval (Atom (ASymbol symb)) env = case getSymbolValue symb env of
|
||||
Just v -> Right (show v, env)
|
||||
Nothing -> Left $ "**Error: Variable not bound " ++ symb ++ "**"
|
||||
eval (Atom (ASymbol symb)) env =
|
||||
case getSymbolValue symb env of
|
||||
Just v -> Right (show v, env)
|
||||
Nothing -> Left $ "**Error: Variable not bound " ++ symb ++ "**"
|
||||
eval (Atom atom) env = Right (show atom, env)
|
||||
|
||||
getSymbolValue :: String -> LispEnv -> Maybe Atom
|
||||
|
||||
+11
-2
@@ -1,12 +1,21 @@
|
||||
import Test.HUnit
|
||||
import System.Exit ( exitFailure, exitSuccess )
|
||||
import BasicParser
|
||||
import Data.Char
|
||||
|
||||
charTest :: Test
|
||||
charTest = TestCase (assertEqual "char '123'," (Just '1', "23") (parse char "123"))
|
||||
charTest = "char '123'," ~: (Just '1', "23") ~=? parse pChar "123"
|
||||
|
||||
charIfTest :: Test
|
||||
charIfTest = "charIf isSpace ' 1 23'," ~: (Just ' ', "1 23") ~=? parse (pCharIf isSpace) " 1 23"
|
||||
|
||||
charIfFailureTest :: Test
|
||||
charIfFailureTest = "charIf isSpace '1 23'," ~: (Nothing, "1 23") ~=? parse (pCharIf isSpace) "1 23"
|
||||
|
||||
tests :: Test
|
||||
tests = TestList [TestLabel "Basic parser char" charTest]
|
||||
tests = TestList [
|
||||
TestLabel "Basic parser" charTest, charIfTest, charIfFailureTest
|
||||
]
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
|
||||
Reference in New Issue
Block a user