1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 09:15:01 +03:00

Tidy up the sourceLineRanges tests using prop.

Co-Authored-By: Patrick Thomson <patrickt@users.noreply.github.com>
This commit is contained in:
Rob Rix 2019-08-06 16:22:38 -04:00
parent fc2233feea
commit 698497b1a0
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -25,13 +25,11 @@ prop desc f
testTree :: Tasty.TestTree testTree :: Tasty.TestTree
testTree = Tasty.testGroup "Data.Source" testTree = Tasty.testGroup "Data.Source"
[ Tasty.testGroup "sourceLineRanges" [ Tasty.testGroup "sourceLineRanges"
[ testProperty "produces 1 more range than there are newlines" $ property $ do [ prop "produces 1 more range than there are newlines" $ \ source -> do
source <- forAll (Gen.source (Hedgehog.Range.linear 0 100))
label (summarize source) label (summarize source)
(length (sourceLineRanges source) === length (Text.splitOn "\r\n" (toText source) >>= Text.splitOn "\r" >>= Text.splitOn "\n")) length (sourceLineRanges source) === length (Text.splitOn "\r\n" (toText source) >>= Text.splitOn "\r" >>= Text.splitOn "\n")
, testProperty "produces exhaustive ranges" $ property $ do , prop "produces exhaustive ranges" $ \ source -> do
source <- forAll (Gen.source (Hedgehog.Range.linear 0 100))
label (summarize source) label (summarize source)
foldMap (`slice` source) (sourceLineRanges source) === source foldMap (`slice` source) (sourceLineRanges source) === source
] ]