Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 6fe2710

Browse files
author
Patrick Thomson
committed
No need to pull in QC; Hedgehog's label can do this.
1 parent bd57500 commit 6fe2710

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

semantic.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,9 @@ test-suite test
397397
, tasty-hedgehog ^>= 1.0.0.1
398398
, tasty-hspec ^>= 1.1.5.1
399399
, tasty-hunit ^>= 0.10.0.2
400-
, tasty-quickcheck ^>= 0.10
401400
, HUnit ^>= 1.6.0.0
402401
, leancheck >= 0.8 && <1
403402
, temporary ^>= 1.3
404-
, QuickCheck ^>= 2.13
405403
if flag(release)
406404
ghc-options: -dynamic
407405

test/Data/Source/Spec.hs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ import Test.Hspec
1010

1111
import qualified Generators as Gen
1212
import qualified Hedgehog.Gen as Gen
13-
import Hedgehog ((===))
13+
import Hedgehog ((===), label)
1414
import qualified Hedgehog.Range
1515
import Hedgehog hiding (Range)
1616
import qualified Test.Tasty as Tasty
1717
import Test.Tasty.Hedgehog (testProperty)
18-
import qualified Test.Tasty.QuickCheck as QC
1918

2019
prop :: HasCallStack => String -> (Source -> PropertyT IO ()) -> Tasty.TestTree
2120
prop desc f
@@ -27,13 +26,15 @@ prop desc f
2726
testTree :: Tasty.TestTree
2827
testTree = 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

100101
insetRange :: Range -> Range
101102
insetRange 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

Comments
 (0)