From 919f32a650a99ec4b4d47e9496f65c706c0921d0 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Fri, 20 May 2016 21:59:46 -0400 Subject: [PATCH] Spike out an Arbitrary instance for BranchElement. --- test/AlignmentSpec.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/AlignmentSpec.hs b/test/AlignmentSpec.hs index 1fe8b0e19..a696f3c21 100644 --- a/test/AlignmentSpec.hs +++ b/test/AlignmentSpec.hs @@ -211,6 +211,18 @@ instance Arbitrary Child where shrink Child {..} | null childContents, null childMargin = [] | otherwise = Child childKey <$> "" : shrinkList (const []) childContents <*> "" : shrinkList (const []) childMargin +instance Arbitrary BranchElement where + arbitrary = oneof [ Child' <$> key <*> joinTheseOf contents + , Margin <$> joinTheseOf margin ] + where key = listOf1 (elements (['a'..'z'] ++ ['A'..'Z'] ++ ['0'..'9'])) + contents = listOf (padding '*') + margin = listOf (padding '-') + padding char = frequency [ (10, pure char) + , (1, pure '\n') ] + joinTheseOf g = oneof [ Join . This <$> g + , Join . That <$> g + , (Join .) . These <$> g <*> g ] + instance Show Child where show Child {..} = childMargin ++ "(" ++ childKey ++ childContents ++ ")"