~alcinnz/CatTrap

ref: 272852e8b518fb81dcd92d785f8284a713df0e2b CatTrap/test/Test.hs -rw-r--r-- 815 bytes
272852e8 — Adrian Cochrane Draft new CatTrap API which hopefully is easier to implement. 1 year, 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{-# LANGUAGE OverloadedStrings #-}
module Main where

import Test.Hspec

import Graphics.Layout.Arithmetic
import Data.CSS.Syntax.Tokens (tokenize, Token(..))
import Debug.Trace (traceShowId)

main :: IO ()
main = hspec spec

spec :: Spec
spec = do
    describe "canary" $ do
        it "test framework works" $ do
            True `shouldBe` True
    describe "calc()" $ do
        it "Can perform basic arithmatic" $ do
            runMath "42" `shouldBe` 42
            runMath "6 * 9" `shouldBe` 54
--            runMath "6 * 9 - 42" `shouldBe` 12
--            runMath "6 * (9 - 42)" `shouldBe` -198
--            runMath "6 * calc(9 - 42)" `shouldBe` -198
--            runMath "6 * abs(9 - 42)" `shouldBe` 198

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