packages feed

sifflet-2.3.0: tests/Testing/Common/ExprTreeTests.hs

module Testing.Common.ExprTreeTests 
    (testStyle, aDemoExpr, demoEnv)

where


import Graphics.Rendering.Cairo hiding (translate, x, y)

import Data.Number.Sifflet
import Data.Sifflet.Geometry
import Data.Sifflet.TreeLayout
import Language.Sifflet.Expr

import Testing.Common.TestStyles


testStyle :: Style
testStyle = 
    let normal = ColorRGB 0.3 0.6 0.5
        active = ColorRGB 0.15 0.3 0.25
        auxColor = ColorRGBA 1.0 1.0 0.5 0.75
    in styleTest4 {textMargin = 18,
                   hpad = 27, vpad = 36,
                   vtinypad = (0, 0),
                   styleAuxOffset = Position 4 (-12),
                   styleNormalTextColor = normal,
                   styleNormalEdgeColor = normal,
                   styleActiveTextColor = active,
                   styleActiveEdgeColor = active,
                   styleAuxColor = auxColor,
                   styleAuxFont = 
                       VFont "serif" FontSlantItalic FontWeightNormal 14,
                   styleShowNodeBoxes = False,
                   styleShowNodePorts = False
                  }


aDemoExpr :: Expr
aDemoExpr = let a = eSymbol "ant"
                b = eSymbol "butterfly"
                c = eSymbol "cheetah"
            in eIf (eGt a (ePlus b (eInt 5)))
                   (ePlus a (ePlus b c))
                   (eTimes (ePlus a (eInt 7))
                           (eMinus b (eInt 12)))

demoEnv :: Env
demoEnv = extendEnv ["ant", "butterfly", "cheetah"]
                    [VNumber (Exact x) | x <- [5, 10, 18]] 
                    baseEnv