@@ -10,12 +10,11 @@ import Test.Hspec
1010
1111import qualified Generators as Gen
1212import qualified Hedgehog.Gen as Gen
13- import Hedgehog ((===) )
13+ import Hedgehog ((===) , label )
1414import qualified Hedgehog.Range
1515import Hedgehog hiding (Range )
1616import qualified Test.Tasty as Tasty
1717import Test.Tasty.Hedgehog (testProperty )
18- import qualified Test.Tasty.QuickCheck as QC
1918
2019prop :: HasCallStack => String -> (Source -> PropertyT IO () ) -> Tasty. TestTree
2120prop desc f
@@ -27,13 +26,15 @@ prop desc f
2726testTree :: Tasty. TestTree
2827testTree = Tasty. testGroup " Data.Source"
2928 [ Tasty. testGroup " sourceLineRanges"
30- [ QC. testProperty " produces 1 more range than there are newlines" $
31- \ source -> QC. label (summarize source) $
32- length (sourceLineRanges source) QC. === length (Text. splitOn " \r\n " (toText source) >>= Text. splitOn " \r " >>= Text. splitOn " \n " )
33-
34- , QC. testProperty " produces exhaustive ranges" $
35- \ source -> QC. label (summarize source) $
36- foldMap (`slice` source) (sourceLineRanges source) QC. === source
29+ [ testProperty " produces 1 more range than there are newlines" $ property $ do
30+ source <- forAll (Gen. source (Hedgehog.Range. linear 0 100 ))
31+ label (summarize source)
32+ (length (sourceLineRanges source) === length (Text. splitOn " \r\n " (toText source) >>= Text. splitOn " \r " >>= Text. splitOn " \n " ))
33+
34+ , testProperty " produces exhaustive ranges" $ property $ do
35+ source <- forAll (Gen. source (Hedgehog.Range. linear 0 100 ))
36+ label (summarize source)
37+ foldMap (`slice` source) (sourceLineRanges source) === source
3738 ]
3839
3940 , Tasty. testGroup " spanToRange"
@@ -99,8 +100,3 @@ insetSpan sourceSpan = sourceSpan { spanStart = (spanStart sourceSpan) { posColu
99100
100101insetRange :: Range -> Range
101102insetRange Range {.. } = Range (succ start) (pred end)
102-
103-
104- instance QC. Arbitrary Source where
105- arbitrary = fromText . Text. pack <$> QC. listOf (QC. frequency [ (1 , pure ' \r ' ), (1 , pure ' \n ' ), (20 , QC. arbitraryUnicodeChar) ])
106- shrink src = fromText . Text. pack <$> QC. shrinkList QC. shrinkNothing (Text. unpack (toText src))
0 commit comments