-
Notifications
You must be signed in to change notification settings - Fork 461
Remove orphan ByteString Listable instance. #152
Conversation
This was created with a whole mess of Leancheck combinators. A Hedgehog approach makes things easier.
| prop "covers multiple lines" $ | ||
| \ n -> totalSpan (fromText (Text.intersperse '\n' (Text.replicate n "*"))) `shouldBe` Span (Pos 1 1) (Pos (max 1 n) (if n > 0 then 2 else 1)) | ||
|
|
||
| describe "newlineIndices" $ do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In keeping with my philosophy of “do as little as possible so I don’t end up rewriting the whole test suite in an act of Pyrrhic futility”, I’ve left the tests that didn’t use LeanCheck as specs with describe.
| import qualified Data.Source | ||
| import Data.Functor.Identity | ||
|
|
||
| source :: (GenBase m ~ Identity, MonadGen m) => Hedgehog.Range Int -> m Data.Source.Source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GenBase constraint is a weird artifact of the Hedgehog API.
| import qualified Test.Tasty as Tasty | ||
| import Test.Tasty.Hedgehog (testProperty) | ||
|
|
||
| prop :: HasCallStack => String -> (Source -> PropertyT IO ()) -> Tasty.TestTree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrote this little helper to save keystrokes and modify as few of the specs as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice ✨
| @@ -0,0 +1,12 @@ | |||
| {-# LANGUAGE TypeFamilies #-} | |||
| module Generators | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figure we’re gonna have a lot of generators, many of which may depend on each other.
| import qualified Test.Tasty as Tasty | ||
| import Test.Tasty.Hedgehog (testProperty) | ||
|
|
||
| prop :: HasCallStack => String -> (Source -> PropertyT IO ()) -> Tasty.TestTree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice ✨
As we begin to transition to Hedgehog (#122), this instance stood out as one we could absolutely delete: it’s a roundabout way of expressing what we mean in the Data.Source tests, namely that we want to generate random UTF-8 ByteStrings and run our computations over them.