1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Extract alignment from the property test.

This commit is contained in:
Rob Rix 2016-05-25 10:59:16 -04:00
parent 5c1b0809ec
commit 6caf9d3930

View File

@ -54,10 +54,7 @@ spec = parallel $ do
pendingWith "TBD"
prop "covers every input child" $
\ elements ->
let (_, ranges) = toSourcesAndRanges elements
children = toAlignedChildren elements in
sort (nub (keysOfAlignedChildren (alignBranch id children ranges))) `shouldBe` sort (catMaybes (branchElementKey <$> elements))
\ elements -> sort (nub (keysOfAlignedChildren (alignmentFromBranchElements elements))) `shouldBe` sort (catMaybes (branchElementKey <$> elements))
prop "covers every line of every input child" $
pendingWith "TBD"
@ -192,6 +189,11 @@ data BranchElement
| Margin (Join These String)
deriving Show
alignmentFromBranchElements :: [BranchElement] -> [Join These (Range, [(String, Range)])]
alignmentFromBranchElements elements = alignBranch id children ranges
where (_, ranges) = toSourcesAndRanges elements
children = toAlignedChildren elements
branchElementContents :: BranchElement -> Join These String
branchElementContents (Child _ contents) = contents
branchElementContents (Margin contents) = contents