1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Test that we align insertions into empty branches without losing nodes.

This commit is contained in:
Rob Rix 2016-05-16 12:37:13 -04:00
parent 6f819341ab
commit e40434f476

View File

@ -101,6 +101,12 @@ spec = parallel $ do
align sources (Pure (Insert (info 0 1 :< Leaf "a"))) `shouldBe` PrettyDiff sources
[ Join (That (Pure (SplitInsert (info 0 1 :< Leaf "a")))) ]
it "aligns insertions into empty branches" $
let sources = both (Source.fromList "") (Source.fromList "a") in
align sources (both (info 0 0) (info 0 1) `branch` [ Pure (Insert (info 0 1 :< Leaf "a")) ]) `shouldBe` PrettyDiff sources
[ Join (These (info 0 0 `branch` [])
(info 0 1 `branch` [ Pure (SplitInsert (info 0 1 :< Leaf "a")) ])) ]
it "aligns context following insertions" $
let sources = both (Source.fromList "a\nc") (Source.fromList "a\nb\nc") in
align sources (both (info 0 3) (info 0 5) `branch` [ pure (info 0 1) `leaf` "a", Pure (Insert (info 2 3 :< Leaf "b")), both (info 2 3) (info 4 5) `leaf` "c" ])