OldAndNewExprTests.fs 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. module OldAndNewExprTests
  2. open Fuchu
  3. let testf input =
  4. testCase input <| fun _ ->
  5. let f input =
  6. let exp =
  7. Qsp.Parser.Generic.runStateEither Qsp.Parser.Expr.pExprOld Qsp.Parser.Generic.emptyState input
  8. |> snd
  9. let act =
  10. Qsp.Parser.Generic.runStateEither Qsp.Parser.Expr.pExprNew Qsp.Parser.Generic.emptyState input
  11. |> snd
  12. exp, act
  13. let exp, act = f input
  14. Assert.Equal("", exp, act)
  15. [<Tests>]
  16. let tests =
  17. testList "expr test" [
  18. testf "1 + 2 * 3"
  19. testf "1 + 2 mod 3 * 4"
  20. testf "-1 - -1"
  21. testf "-(a + b)"
  22. testf "var1 and var2 and no var3 and obj var4"
  23. testf "var1[var1 + var2] and func(arg1, arg2[expr], x + y)"
  24. testf "a = 10 or b = 20 and c = 30"
  25. testf "a = pstam> (pmaxstam/4)*2 and pstam <= (pmaxstam/4)*3"
  26. testf "no obj 'apple'"
  27. testf "a = no -a > b"
  28. testf "a and b = c and d"
  29. testf "obj 'яблоко' = 0"
  30. ]
  31. let start () = run tests