@@ -9,7 +9,7 @@ import Test.Hspec
99
1010import qualified Generators as Gen
1111import qualified Hedgehog.Gen as Gen
12- import Hedgehog ((===) )
12+ import Hedgehog ((===) , label )
1313import qualified Hedgehog.Range
1414import Hedgehog hiding (Range )
1515import qualified Test.Tasty as Tasty
@@ -25,11 +25,15 @@ prop desc f
2525testTree :: Tasty. TestTree
2626testTree = Tasty. testGroup " Data.Source"
2727 [ Tasty. testGroup " sourceLineRanges"
28- [ prop " produces 1 more range than there are newlines" $
29- \ source -> length (sourceLineRanges source) === succ (Text. count " \n " (toText source))
30-
31- , prop " produces exhaustive ranges" $
32- \ source -> foldMap (`slice` source) (sourceLineRanges source) === source
28+ [ testProperty " produces 1 more range than there are newlines" $ property $ do
29+ source <- forAll (Gen. source (Hedgehog.Range. linear 0 100 ))
30+ label (summarize source)
31+ (length (sourceLineRanges source) === length (Text. splitOn " \r\n " (toText source) >>= Text. splitOn " \r " >>= Text. splitOn " \n " ))
32+
33+ , testProperty " produces exhaustive ranges" $ property $ do
34+ source <- forAll (Gen. source (Hedgehog.Range. linear 0 100 ))
35+ label (summarize source)
36+ foldMap (`slice` source) (sourceLineRanges source) === source
3337 ]
3438
3539 , Tasty. testGroup " spanToRange"
@@ -68,6 +72,10 @@ testTree = Tasty.testGroup "Data.Source"
6872 ]
6973
7074 ]
75+ where summarize src = case sourceLines src of
76+ [] -> " empty"
77+ [x] -> if nullSource x then " empty" else " single-line"
78+ _ -> " multiple lines"
7179
7280spec :: Spec
7381spec = do
0 commit comments