Permalink
Browse files

- One more test.

  • Loading branch information...
1 parent 87ed838 commit 7e9b5d9a503e7e684c175f8575cf3cf1e64e0bf9 @graninas committed Feb 9, 2014
Showing with 53 additions and 3 deletions.
  1. +1 −0 Amoeba/Test/Data/Raws/World3.adt
  2. +31 −0 Amoeba/Test/Data/Raws/World3.arf
  3. +21 −3 Amoeba/Test/ParsingTest.hs
@@ -0,0 +1 @@
+Right [EmptyToken,Comment " General items",EmptyToken,Item "Karyon" [IntResource "lifebound" (0,5000),IntResource "durability" (100,100),IntResource "energy" (300,2000)],EmptyToken,Comment " Conductor",Item "Conductor" [IntResource "lifebound" (0,1000),IntResource "durability" (100,100),IntResource "energy" (0,100)],EmptyToken,Comment " World definition file",EmptyToken,World "Pandora" [IntProperty "width" 20,IntProperty "height" 20,ObjectProperty "defaultCell" (Object "Empty" "Player0"),CellsProperty "cells" [CellProperty (10,10) (Object "Karyon" "Player1"),CellProperty (9,9) (Object "Plasma" "Player1"),CellProperty (9,10) (Object "Plasma" "Player1"),CellProperty (9,11) (Object "Plasma" "Player1"),CellProperty (10,9) (Object "Plasma" "Player1"),CellProperty (10,11) (Object "Plasma" "Player1"),CellProperty (11,9) (Object "Plasma" "Player1"),CellProperty (11,10) (Object "Plasma" "Player1"),CellProperty (11,11) (Object "Plasma" "Player1"),CellProperty (15,15) (Object "Karyon" "Player2")]]]
@@ -0,0 +1,31 @@
+
+; General items
+
+Item "Karyon"
+ lifebound = (0, 5000)
+ durability = (100, 100)
+ energy = (300, 2000)
+
+; Conductor
+Item "Conductor"
+ lifebound = (0, 1000)
+ durability = (100, 100)
+ energy = (0, 100)
+
+; World definition file
+
+World "Pandora"
+ width = 20
+ height = 20
+ defaultCell = Object "Empty" "Player0"
+ cells =
+ (10, 10): Object "Karyon" "Player1"
+ (9, 9): Object "Plasma" "Player1"
+ (9, 10): Object "Plasma" "Player1"
+ (9, 11): Object "Plasma" "Player1"
+ (10, 9): Object "Plasma" "Player1"
+ (10, 11): Object "Plasma" "Player1"
+ (11, 9): Object "Plasma" "Player1"
+ (11, 10): Object "Plasma" "Player1"
+ (11, 11): Object "Plasma" "Player1"
+ (15, 15): Object "Karyon" "Player2"
View
@@ -26,12 +26,15 @@ world1 = ("World1", "./Data/Raws/World1.arf",
, EmptyToken
, World "Pandora" [ IntProperty "width" 20, IntProperty "height" 20, ObjectProperty "defaultCell" (Object "Empty" "Player0")
, CellsProperty "cells" [ CellProperty (10, 10) (Object "Karyon" "Player1")
- , CellProperty (9, 9) (Object "Plasma" "Player1")]]
- ])
+ , CellProperty (9, 9) (Object "Plasma" "Player1")]] ])
world2 = ( "World2"
, "./Data/Raws/World2.arf"
, parseRawTokens
, undefined )
+world3 = ( "World3"
+ , "./Data/Raws/World3.arf"
+ , parseRawTokens
+ , undefined )
parseExample parser dataFile = liftM parser (readFile dataFile)
@@ -62,6 +65,17 @@ prop_parseWorld2 = monadicIO $ do
where
pred expected _ parsed = expected == parsed
+prop_parseWorld3 = monadicIO $ do
+ r <- run $ readFile "./Data/Raws/World3.adt"
+ res <- run $ examineExample world3 (pred (read r))
+ assert res
+ where
+ pred expected _ parsed = expected == parsed
+
+writeAdt rawFile destFile = do
+ p <- parseExample parseRawTokens rawFile
+ writeFile destFile $ show p
+
tests :: IO Bool
tests = $quickCheckAll
@@ -70,4 +84,8 @@ runTests = tests >>= \passed -> putStrLn $
else "Some tests failed."
main :: IO ()
-main = runTests
+main = do
+ runTests
+ putStr ""
+ --writeAdt "./Data/Raws/World3.arf" "./Data/Raws/World3.adt"
+

0 comments on commit 7e9b5d9

Please sign in to comment.