This repository has been archived on 2023-06-24. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2022FuncProg-project3-RPGEn.../test/ParserSpec.hs
Tibo De Peuter 83659e69b4 #18 #14 Inital parser commit
Added basic parser functionality & tests for these functionalites.
Split tests in several files
2022-12-17 23:14:04 +01:00

52 lines
1.8 KiB
Haskell

module ParserSpec where
import Test.Hspec
import Parse
import Data.Either
spec :: Spec
spec = do
describe "Basics of entries" $ do
it "can parse integers" $ do
let correct = Right $ Regular $ Integer 1
correct `shouldBe` parseWith regular "1"
it "can parse string" $ do
let input = "dit is een string"
correct = Right $ Regular $ String input
correct `shouldBe` parseWith regular ("\"" ++ input ++ "\"")
it "can parse infinite" $ do
let correct = Right $ Regular Infinite
correct `shouldBe` parseWith regular "infinite"
let wrong = Right $ Regular Infinite
wrong `shouldNotBe` parseWith regular "infinitee"
it "can parse entries" $ do
let input = "id : \"dagger\""
correct = Right $ Entry "id" $ Regular $ String "dagger"
correct `shouldBe` parseWith entry input
let input = "x: 0"
correct = Right $ Entry "x" $ Regular $ Integer 0
correct `shouldBe` parseWith entry input
let input = "useTimes: infinite"
correct = Right $ Entry "useTimes" $ Regular Infinite
correct `shouldBe` parseWith entry input
describe "Special kinds" $ do
it "can parse actions" $ do
let input = "actions: {}"
correct = Right $ Entry "actions" $ Regular Infinite -- TODO Change this
correct `shouldBe` parseWith action input
it "can parse conditions" $ do
pending
it "can parse layouts" $ do
pending
describe "Lists and blocks" $ do
it "can parse entities" $ do
pending