(lexer "x := 3;")                                                   === ("x" @= int 3, [])
                 , parserTestOK pStatement (lexer "while (x > 0) x := x - 1;")                                 === (While (Var "x" .> int 0) $ "x" @= Var "x" .- int 1, [])
                 , parserTestOK pStatement (lexer "r := 1; i := 0; while (i < n) { i := i + 1; r := r * i; }") === (fac, [])
                 ]
  where
    fac = Compound
        [ "r" @= int 1
        , "i" @= int 0
        , While (Var "i" .< Var "n") $ Compound
            [ "i" @= Var "i" .+ int 1
            , "r" @= Var "r" .* Var "i"
            ]
        ]

(===) = id

main = fmap (const ()) $ runT
testsStatement = [ parserTestOK pStatement (lexer "x := 3;")                                                   === ("x" @= int 3, [])
                 , parserTestOK pStatement (lexer "while (x > 0) x := x - 1;")                                 === (While (Var "x" .> int 0) $ "x" @= Var "x" .- int 1, [])
                 , parserTestOK pStatement (lexer "r := 1; i := 0; while (i < n) { i := i + 1; r := r * i; }") === (fac, [])
                 ]
  where
    fac = Compound
        [ "r" @= int 1
        , "i" @= int 0
        , While (Var "i" .< Var "n") $ Compound
            [ "i" @= Var "i" .+ int 1
            , "r" @= Var "r" .* Var "i"
            ]
        ]
testsStatement = [ parserTestOK pStatement (lexer "x := 3;")                                                   === ("x" @= int 3, [])
                 , parserTestOK pStatement (lexer "while (x > 0) x := x - 1;")                                 === (While (Var "x" .> int 0) $ "x" @= Var "x" .- int 1, [])
                 , parserTestOK pStatement (lexer "r := 1; i := 0; while (i < n) { i := i + 1; r := r * i; }") === (fac, [])
                 ]
  where
    fac = Compound
        [ "r" @= int 1
        , "i" @= int 0
        , While (Var "i" .< Var "n") $ Compound
            [ "i" @= Var "i" .+ int 1
            , "r" @= Var "r" .* Var "i"
            ]
        ]