mirror of
https://github.com/google/ormolu.git
synced 2025-01-06 06:33:37 +03:00
Avoid comparing ‘SourceText’ when comparing ASTs
This commit is contained in:
parent
5f5f9227aa
commit
2dfd181c2f
@ -1,8 +1,3 @@
|
||||
-- Test should have tested different whitespaces inside pragma. However, the
|
||||
-- pragmas contain a "SourceText" which compares as equal only if the whitespace
|
||||
-- inside the pragma is printed exactly identically (i.e. including newlines and
|
||||
-- all.) In practice, removing this whitespace is desirable, so whitespace is
|
||||
-- not varied to avoid spurious and difficult-to-avoid test case errors.
|
||||
instance {-# OVERLAPPABLE #-} Eq Int where
|
||||
(==) _ _ = False
|
||||
|
||||
|
@ -1,17 +1,11 @@
|
||||
-- Test should have tested different whitespaces inside pragma. However, the
|
||||
-- pragmas contain a "SourceText" which compares as equal only if the whitespace
|
||||
-- inside the pragma is printed exactly identically (i.e. including newlines and
|
||||
-- all.) In practice, removing this whitespace is desirable, so whitespace is
|
||||
-- not varied to avoid spurious and difficult-to-avoid test case errors.
|
||||
|
||||
instance {-# OVERLAPPABLE #-} Eq Int where (==) _ _ = False
|
||||
instance {-# OVERLAPPABLE #-} Eq Int where (==) _ _ = False
|
||||
|
||||
instance
|
||||
{-# OVERLAPPING #-} Ord Int where compare _ _ = GT
|
||||
{-# OVERLAPPING #-} Ord Int where compare _ _ = GT
|
||||
|
||||
instance {-# OVERLAPS #-} Eq Double where
|
||||
instance {-# OVERLAPS #-} Eq Double where
|
||||
(==) _ _ = False
|
||||
|
||||
instance
|
||||
{-# INCOHERENT #-} Ord Double where
|
||||
{-# INCOHERENT #-} Ord Double where
|
||||
compare _ _ = GT
|
||||
|
@ -9,6 +9,7 @@ module Ormolu.Diff
|
||||
)
|
||||
where
|
||||
|
||||
import BasicTypes (SourceText)
|
||||
import Data.Generics
|
||||
import GHC
|
||||
import Ormolu.CommentStream
|
||||
@ -33,7 +34,10 @@ matchIgnoringSrcSpans = genericQuery
|
||||
where
|
||||
genericQuery :: GenericQ (GenericQ Bool)
|
||||
genericQuery x y = (toConstr x == toConstr y)
|
||||
&& and (gzipWithQ (genericQuery `extQ` srcSpanEq `extQ` hsModuleEq) x y)
|
||||
&& and (gzipWithQ (genericQuery
|
||||
`extQ` srcSpanEq
|
||||
`extQ` hsModuleEq
|
||||
`extQ` sourceTextEq) x y)
|
||||
|
||||
srcSpanEq :: SrcSpan -> GenericQ Bool
|
||||
srcSpanEq _ _ = True
|
||||
@ -46,3 +50,6 @@ matchIgnoringSrcSpans = genericQuery
|
||||
matchIgnoringSrcSpans
|
||||
hs0 { hsmodImports = sortImports (hsmodImports hs0) }
|
||||
hs1 { hsmodImports = sortImports (hsmodImports hs1) }
|
||||
|
||||
sourceTextEq :: SourceText -> GenericQ Bool
|
||||
sourceTextEq _ _ = True
|
||||
|
Loading…
Reference in New Issue
Block a user