From c5fed4ac25a51234157b636dfba11bcc77078fbf Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 13 Sep 2016 12:37:59 -0400 Subject: [PATCH] Test sourceSpanToRange across arbitrary sources. --- test/Source/Spec.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/Source/Spec.hs b/test/Source/Spec.hs index 4fd95857f..28118d201 100644 --- a/test/Source/Spec.hs +++ b/test/Source/Spec.hs @@ -18,6 +18,8 @@ spec = parallel $ do foldMap (`slice` source) (actualLineRanges (totalRange s) source) `shouldBe` source describe "sourceSpanToRange" $ do - it "computes the range covering a span in a source" $ - let source = fromList "a\nb" in - sourceSpanToRange source (SourceSpan "" (SourcePos 0 0) (SourcePos 1 1)) `shouldBe` totalRange source + prop "computes the range covering a span in some source" $ + \ s -> let source = fromList s + spans = zipWith (\ i Range {..} -> SourceSpan "" (SourcePos i 0) (SourcePos i (end - start))) [0..] ranges + ranges = actualLineRanges (totalRange source) source in + sourceSpanToRange source <$> spans `shouldBe` ranges