2015-12-03 19:44:28 +03:00
|
|
|
module Main where
|
2015-12-03 19:38:49 +03:00
|
|
|
|
2015-12-04 17:16:23 +03:00
|
|
|
import Diff
|
|
|
|
import Range
|
2015-12-03 19:44:42 +03:00
|
|
|
import Split
|
2015-12-04 17:16:23 +03:00
|
|
|
import Syntax
|
|
|
|
import qualified Data.Set as Set
|
2015-12-03 19:38:49 +03:00
|
|
|
import Test.Hspec
|
|
|
|
|
2015-11-18 01:44:16 +03:00
|
|
|
main :: IO ()
|
2015-12-03 19:44:42 +03:00
|
|
|
main = hspec $ do
|
2015-12-04 17:00:40 +03:00
|
|
|
describe "adjoinRows" $ do
|
2015-12-03 19:47:51 +03:00
|
|
|
it "empty lines are the left unit" $
|
2015-12-04 00:24:35 +03:00
|
|
|
adjoinRows [ Row [] [] ] [ Row [ Text "a" ] [ Text "b" ] ] `shouldBe` [ Row [ Text "a" ] [ Text "b" ] ]
|
2015-12-03 19:47:51 +03:00
|
|
|
|
2015-12-03 19:58:34 +03:00
|
|
|
it "empty lines are the left unit for multiple lines" $
|
2015-12-04 00:24:35 +03:00
|
|
|
adjoinRows [ Row [] [] ] [ Row [ Text "a" ] [ Text "b" ], Row [ Text "a" ] [ Text "b" ] ] `shouldBe` [ Row [ Text "a" ] [ Text "b" ], Row [ Text "a" ] [ Text "b" ] ]
|
2015-12-03 19:58:34 +03:00
|
|
|
|
2015-12-03 19:44:42 +03:00
|
|
|
it "two single line elements should concatenate into a single line" $
|
2015-12-04 00:24:35 +03:00
|
|
|
adjoinRows [ Row [ Text "a" ] [ Text "b" ] ] [ Row [ Text "a" ] [ Text "b" ] ] `shouldBe` [ Row [ Text "a", Text "a" ] [ Text "b", Text "b" ] ]
|
2015-12-03 20:07:03 +03:00
|
|
|
|
|
|
|
it "single line elements on the left concatenate onto the first of multiple lines on the right" $
|
2015-12-04 00:24:35 +03:00
|
|
|
adjoinRows [ Row [ Text "a1" ] [ Text "b1" ] ] [ Row [ Text "a2" ] [ Text "b2" ], Row [ Text "a3" ] [ Text "b3" ] ] `shouldBe` [ Row [ Text "a1", Text "a2" ] [ Text "b1", Text "b2" ], Row [ Text "a3" ] [ Text "b3" ] ]
|
2015-12-03 20:07:03 +03:00
|
|
|
|
|
|
|
it "the last of multiple line elements on the left concatenate onto the first of multiple lines on the right" $
|
2015-12-04 00:24:35 +03:00
|
|
|
adjoinRows [ Row [ Text "a1" ] [ Text "b1" ], Row [ Text "a2" ] [ Text "b2" ] ] [ Row [ Text "a3" ] [ Text "b3" ], Row [ Text "a4" ] [ Text "b4" ] ] `shouldBe` [ Row [ Text "a1" ] [ Text "b1" ], Row [ Text "a2", Text "a3" ] [ Text "b2", Text "b3" ], Row [ Text "a4" ] [ Text "b4" ] ]
|
2015-12-04 17:16:23 +03:00
|
|
|
|
|
|
|
describe "annotatedToRows" $ do
|
|
|
|
it "outputs one row for single-line unchanged leaves" $
|
2015-12-04 17:40:38 +03:00
|
|
|
annotatedToRows (Annotated (Info (Range 0 1) lineRange $ Set.fromList [ "leaf" ], Info (Range 0 1) lineRange $ Set.fromList [ "leaf" ]) (Leaf "")) "a" "a" `shouldBe` ([ Row [ Span (Just "leaf") "a" ] [ Span (Just "leaf") "a" ] ], Range 0 1, Range 0 1)
|
2015-12-04 17:16:23 +03:00
|
|
|
where
|
2015-12-04 17:41:11 +03:00
|
|
|
oneLineUnchangedIndexedSource = "[ a, b, c ]"
|
|
|
|
oneLineUnchangedIndexedRange = totalRange oneLineUnchangedIndexedSource
|
2015-12-04 17:40:38 +03:00
|
|
|
lineRange = Range 0 0
|