module Main where import Test.Tasty import Test.Tasty.QuickCheck as QC import Test.Tasty.HUnit import Graphics.Gloss import Lib import Examples main :: IO () main = do defaultMain (testGroup "L-systems tests" [unitTests, propertyChecks]) unitTests :: TestTree unitTests = testGroup "Unit tests" [ testCase "iterate gosper once" $ axiom (iterateLSystem 1 gosper) @?= "A-B--B+A++AA+B-" , testCase "iterate sierpinski once" $ axiom (iterateLSystem 1 sierpinski) @?= "A-B+A+B-A-BB-BB" , testCase "instructions of one iteration of gosper" $ instructions (iterateLSystem 1 gosper) @?= [Forward,TurnLeft,Forward,TurnLeft,TurnLeft,Forward,TurnRight,Forward,TurnRight,TurnRight,Forward,Forward,TurnRight,Forward,TurnLeft] , testCase "instructions of one iteration of sierpinski" $ instructions (iterateLSystem 1 sierpinski) @?= [Forward,TurnLeft,Forward,TurnRight,Forward,TurnRight,Forward,TurnLeft,Forward,TurnLeft,Forward,Forward,TurnLeft,Forward,Forward] , testCase "draw axiom of gosper" $ drawLSystem gosper @?= Line [(10.0,0.0),(0.0,0.0)] , testCase "draw one iteration of gosper" $ drawLSystem (iterateLSystem 1 gosper) @?= Line [(25.0,-8.660253),(20.0,-17.320507),(10.0,-17.320507),(-4.7683716e-7,-17.320507),(5.0,-8.660254),(15.0,-8.6602545),(10.0,0.0),(0.0,0.0)] ] propertyChecks :: TestTree propertyChecks = testGroup "Property tests (QuickCheck)" [ ]