Permalink
Browse files

Added a few QuickCheck checks

  • Loading branch information...
1 parent 13104d3 commit e5837eb66a9d565be4d2c2c10ef4d4b8fbe9ddcb @michaelfeathers committed Aug 14, 2009
Showing with 17 additions and 1 deletion.
  1. +16 −0 eb_checks.hs
  2. +1 −1 editbuffer.hs
View
@@ -0,0 +1,16 @@
+
+
+import Test.QuickCheck
+import EditBuffer
+
+instance Arbitrary Char where
+ arbitrary = elements printableRange
+ where printableRange = [' '..'~']
+
+prop_insert_delete_inverse ch =
+ emptyBuffer == (deleteChar . moveLeft .insertChar ch) emptyBuffer
+
+prop_insert_char_advances n =
+ n >= 0 ==> n == x
+ where (EditBuffer(x,_) contents) = (iterate (insertChar 'a') emptyBuffer) !! n
+
View
@@ -17,7 +17,7 @@ module EditBuffer
where
type Location = (Int, Int)
-data EditBuffer = EditBuffer Location String deriving Show
+data EditBuffer = EditBuffer Location String deriving (Eq,Show)
emptyBuffer = EditBuffer (0,0) ""

0 comments on commit e5837eb

Please sign in to comment.