module Data.Text.ParagraphLayout.RectSpec (spec) where import Data.Int (Int32) import Test.Hspec import Data.Text.ParagraphLayout.Internal.Rect positiveRect :: Rect Int32 positiveRect = Rect 50 (-70) 10 10 negativeRect :: Rect Int32 negativeRect = Rect 80 (-75) (-15) (-15) spec :: Spec spec = do describe "union of two rects (low X, low Y)" $ llSpec $ union LL positiveRect negativeRect describe "union of two rects (low X, high Y)" $ lhSpec $ union LH positiveRect negativeRect describe "union of two rects (high X, low Y)" $ hlSpec $ union HL positiveRect negativeRect describe "union of two rects (high X, high Y)" $ hhSpec $ union HH positiveRect negativeRect llSpec :: Rect Int32 -> SpecWith () llSpec r = do commonSpec r it "has origin at 50,-90" $ (x_origin r, y_origin r) `shouldBe` (50, -90) it "has terminus at 80,-60" $ (x_terminus r, y_terminus r) `shouldBe` (80, -60) it "has size 30,30" $ (x_size r, y_size r) `shouldBe` (30, 30) lhSpec :: Rect Int32 -> SpecWith () lhSpec r = do commonSpec r it "has origin at 50,-60" $ (x_origin r, y_origin r) `shouldBe` (50, -60) it "has terminus at 80,-90" $ (x_terminus r, y_terminus r) `shouldBe` (80, -90) it "has size 30,-30" $ (x_size r, y_size r) `shouldBe` (30, -30) hlSpec :: Rect Int32 -> SpecWith () hlSpec r = do commonSpec r it "has origin at 80,-90" $ (x_origin r, y_origin r) `shouldBe` (80, -90) it "has terminus at 50,-60" $ (x_terminus r, y_terminus r) `shouldBe` (50, -60) it "has size -30,30" $ (x_size r, y_size r) `shouldBe` (-30, 30) hhSpec :: Rect Int32 -> SpecWith () hhSpec r = do commonSpec r it "has origin at 80,-60" $ (x_origin r, y_origin r) `shouldBe` (80, -60) it "has terminus at 50,-90" $ (x_terminus r, y_terminus r) `shouldBe` (50, -90) it "has size -30,-30" $ (x_size r, y_size r) `shouldBe` (-30, -30) commonSpec :: Rect Int32 -> SpecWith () commonSpec r = do it "has minimum coordinates at at 50,-90" $ (x_min r, y_min r) `shouldBe` (50, -90) it "has maximum coordinates at 80,-60" $ (x_max r, y_max r) `shouldBe` (80, -60) it "has absolute size 30,30" $ (width r, height r) `shouldBe` (30, 30)