expectEval : List Token -> Rational -> Expectation
expectEval tokens expectedRational =
case E.eval tokens of
Ok actualRational ->
Expect.equal expectedRational actualRational
Err _ ->
Expect.fail "eval failed"
int : Int -> Rational
int =
Rational.fromInt
rational : Int -> Int -> Rational
rational n d =
Rational.new n d
|> Maybe.withDefault Rational.zero
intT : Int -> Token
intT =
Token.Number << int
operatorT : Operator -> Token
operatorT =
Token.Operator