~alcinnz/CatTrap

484ba2c1fc86388a5e8e17aebc5d5409998768bb — Adrian Cochrane 5 months ago 972a138
Test flexbox positioning!
1 files changed, 33 insertions(+), 0 deletions(-)

M test/Test.hs
M test/Test.hs => test/Test.hs +33 -0
@@ 771,6 771,39 @@ spec = do
                Flex.children = [[(child 40 AlStretch) { shrink = 2}]],
                pageWidth = 40
              })
        it "positions correctly" $ do
            let child l align = FlexChild {
                grow = 0,
                shrink = 0,
                basis = l,
                Flex.alignment = align,
                flexInner = l
              }
            let child' l align pos = FlexChild {
                grow = 0, shrink = 0, basis = l,
                Flex.alignment = align, flexInner = (pos, l)
              }
            let flex childs = FlexParent {
                direction = Row,
                reverseRows = False,
                wrap = Wrap,
                justify = JStart,
                alignLines = Just JStart,
                baseGap = 2,
                crossGap = 2,
                Flex.children = childs,
                pageWidth = 80
              }
            let baseFlex = flex [[(child 10 AlStart) { grow = 1 },
                    (child 20 AlCenter) { shrink = 1 },
                    (child 30 AlEnd) { grow = 2 },
                    (child 40 AlStretch) { shrink = 2 }]] :: FlexParent Double Double
            flexPosition (,) (\a -> Size a a) (10, 10) (Size 50 50) baseFlex `shouldBe` flex [[
                (child' 10 AlStart (10, 10)) { grow = 1 },
                (child' 20 AlCenter (22, 20)) { shrink = 1 },
                (child' 30 AlEnd (44, 20)) { grow = 2 },
                (child' 40 AlStretch (76, 10)) { shrink = 2 }
              ]]


runMath = flip evalCalc [] . mapCalc fst . flip parseCalc [] . filter (/= Whitespace) . tokenize