Permalink
Browse files

Move tests to their own module.

  • Loading branch information...
1 parent 162c453 commit d3be9af99c22b0fa572c21a81da01769ef27d66b @kowey kowey committed Aug 16, 2011
Showing with 37 additions and 31 deletions.
  1. +0 −31 Data/AttoLisp.hs
  2. +37 −0 Data/AttoLisp/Test.hs
View
@@ -579,37 +579,6 @@ instance (FromLisp a, FromLisp b, FromLisp c) => FromLisp (a, b, c) where
parseLisp e = typeMismatch "3-tuple" e
{-# INLINE parseLisp #-}
-{- --- TESTS ----------------------------------------------------
-data Msg = Msg T.Text Integer
- deriving (Eq, Show)
-
-instance ToLisp Msg where
- toLisp (Msg t n) = mkStruct "msg" [toLisp t, toLisp n]
-
-instance FromLisp Msg where
- parseLisp e = struct "msg" Msg e
-
-
-test_sexp1 =
- show (List [Number 42.2, Symbol "foo", "blah"]) == "(42.2 foo \"blah\")"
-
-test_msg1 = toLisp (Msg "foo" 42)
-test_msg2 = List [Symbol "msg"]
-test_msg3 = List [Symbol "msg", "bar", "baz"]
-
-test_parse :: IO ()
-test_parse = do
- mapM_ (\inp ->
- putStrLn $ show inp ++ " => " ++ show (A.parseOnly (lisp <* A.endOfInput) inp))
- inputs
- where
- inputs = ["()", "42", "(4 5 6)", "(3 (4))", "(3(4))",
- "\"foo\"", "foo", "(foo \"bar\" 23)"]
-
-
-
--- -}
-
{-
We are using the standard Common Lisp read table.
View
@@ -0,0 +1,37 @@
+{-# LANGUAGE OverloadedStrings, Rank2Types, DeriveDataTypeable, BangPatterns,
+ MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances,
+ UndecidableInstances #-}
+
+module Data.AttoLisp.Test where
+
+import Control.Applicative
+import Data.AttoLisp
+import qualified Data.Attoparsec as A
+import qualified Data.Text as T
+import qualified Data.Text.Encoding as T
+
+data Msg = Msg T.Text Integer
+ deriving (Eq, Show)
+
+instance ToLisp Msg where
+ toLisp (Msg t n) = mkStruct "msg" [toLisp t, toLisp n]
+
+instance FromLisp Msg where
+ parseLisp e = struct "msg" Msg e
+
+
+test_sexp1 =
+ show (List [Number 42.2, Symbol "foo", "blah"]) == "(42.2 foo \"blah\")"
+
+test_msg1 = toLisp (Msg "foo" 42)
+test_msg2 = List [Symbol "msg"]
+test_msg3 = List [Symbol "msg", "bar", "baz"]
+
+test_parse :: IO ()
+test_parse = do
+ mapM_ (\inp ->
+ putStrLn $ show inp ++ " => " ++ show (A.parseOnly (lisp <* A.endOfInput) inp))
+ inputs
+ where
+ inputs = ["()", "42", "(4 5 6)", "(3 (4))", "(3(4))",
+ "\"foo\"", "foo", "(foo \"bar\" 23)"]

0 comments on commit d3be9af

Please sign in to comment.