From deb5a0f018898c3f7a8bda5b4e905c046198c885 Mon Sep 17 00:00:00 2001 From: joshvera Date: Tue, 11 Oct 2016 15:12:48 -0400 Subject: [PATCH] Fix SourceSpan in tests --- test/DiffSummarySpec.hs | 2 +- test/Source/Spec.hs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/DiffSummarySpec.hs b/test/DiffSummarySpec.hs index 9eeaec446..fa0670ee0 100644 --- a/test/DiffSummarySpec.hs +++ b/test/DiffSummarySpec.hs @@ -23,7 +23,7 @@ import Test.Hspec.QuickCheck import Data.These sourceSpanBetween :: (Int, Int) -> (Int, Int) -> SourceSpan -sourceSpanBetween (s1, e1) (s2, e2) = SourceSpan "" (SourcePos s1 e1) (SourcePos s2 e2) +sourceSpanBetween (s1, e1) (s2, e2) = SourceSpan (SourcePos s1 e1) (SourcePos s2 e2) arrayInfo :: Record '[Category, Range, SourceSpan] arrayInfo = ArrayLiteral .: Range 0 3 .: sourceSpanBetween (1, 1) (1, 5) .: RNil diff --git a/test/Source/Spec.hs b/test/Source/Spec.hs index 810578eb9..e767a3ebc 100644 --- a/test/Source/Spec.hs +++ b/test/Source/Spec.hs @@ -21,7 +21,7 @@ spec = parallel $ do describe "sourceSpanToRange" $ do prop "computes single-line ranges" $ \ s -> let source = fromList s - spans = zipWith (\ i Range {..} -> SourceSpan "" (SourcePos i 0) (SourcePos i (end - start))) [0..] ranges + 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 @@ -35,13 +35,13 @@ spec = parallel $ do describe "totalSpan" $ do prop "covers single lines" $ - \ n -> totalSpan (fromList (replicate n '*')) `shouldBe` SourceSpan "" (SourcePos 0 0) (SourcePos 0 (max 0 n)) + \ n -> totalSpan (fromList (replicate n '*')) `shouldBe` SourceSpan (SourcePos 0 0) (SourcePos 0 (max 0 n)) prop "covers multiple lines" $ - \ n -> totalSpan (fromList (intersperse '\n' (replicate n '*'))) `shouldBe` SourceSpan "" (SourcePos 0 0) (SourcePos (max 0 (pred n)) (if n > 0 then 1 else 0)) + \ n -> totalSpan (fromList (intersperse '\n' (replicate n '*'))) `shouldBe` SourceSpan (SourcePos 0 0) (SourcePos (max 0 (pred n)) (if n > 0 then 1 else 0)) totalSpan :: Source Char -> SourceSpan -totalSpan source = SourceSpan "" (SourcePos 0 0) (SourcePos (pred (length ranges)) (end lastRange - start lastRange)) +totalSpan source = SourceSpan (SourcePos 0 0) (SourcePos (pred (length ranges)) (end lastRange - start lastRange)) where ranges = actualLineRanges (totalRange source) source lastRange = Prelude.last ranges