import Text.ParserCombinators.Parsec

import Decimal

operTestValues :: [(String, Decimal -> Decimal -> Decimal, String, String)]
operTestValues =
    [ ("12",(+),"7.00","19.00")
    , ("1E+2",(+),"1E+4","1.01E+4")
    , ("1.3",(-), "1.07","0.23")
    , ("1.3",(-), "1.30","0.00")
    , ("1.3",(-), "2.07", "-0.77")
    , ("1.20",(*),"3","3.60")
    , ("7",(*),"3","21")
    , ("0.9",(*),"0.8", "0.72")
    , ("0.9",(*),"-0", "-0.0")
    , ("654321",(*),"654321","4.28135971E+11") -- needs rounding
    , ("1",(/),"3","0.333333333")
    , ("2",(/),"3","0.666666667")
    , ("5",(/),"2","2.5")
    , ("1",(/),"10","0.1")
    , ("12",(/),"12","1")
    , ("8.00",(/),"2","4.00")
    , ("2.400",(/),"2.0","1.20")
    , ("1000",(/),"100","10")
    , ("1000",(/),"1","1000")
    , ("2.40E+6",(/),"2","1.20E+6")
    ]

operCheckValue :: (String, Decimal -> Decimal -> Decimal, String, String) -> Bool
operCheckValue (a,op,b,c) =
    let a' = read a
	b' = read b
	in 
	(showScientific (a' `op` b')) == c

compareTestValues :: [(String,String,Ordering)]
compareTestValues =
    [ ("2.1","3",LT)
    , ("2.1","2.1",EQ)
    , ("2.1","2.10",EQ)
    , ("3","2.1",GT)
    , ("2.1","-3",GT)
    , ("-3","2.1",LT)
    ]

compareCheckValue :: (String,String,Ordering) -> Bool
compareCheckValue (a,b,o) =
    let a' = (read a) :: Decimal
	b' = read b
	in
	(compare a' b') == o
