Commit 3ca7bfd8 authored by Julien Lopez's avatar Julien Lopez
Browse files

[TESTS][EVAL] Add parse error messages; new test added

parent 3322367e
......@@ -54,7 +54,7 @@ let parse_to_lambda expr =
let cbegin = Loc.start_off loc - Loc.start_bol loc in
let cend = Loc.stop_off loc - Loc.start_bol loc in
eprintf "File %s, line %d, characters %d-%d:\nUnbound identifier\n"
Sys.argv.(1) l cbegin cend; raise Error)
(Loc.file_name loc) l cbegin cend; raise Error)
| Int(_, i) -> Const(Value.Integer(Intervals.V.from_int i))
| String(loc, s) ->
let s = Ident.U.mk s in
......
open Printf
open Parse
open Value
open Camlp4.PreCast
let load_file f =
let ic = open_in f in
......@@ -32,12 +33,20 @@ let str, file =
if Array.length Sys.argv > 1 then load_file Sys.argv.(1), Sys.argv.(1)
else (eprintf "Fatal error: No input file\n"; exit 1)
in
let expr = ExprParser.of_string str file in
(*printf "Original: %s\nExpr: " str;
print_expr expr;
printf "\nResult: %s\n" (expr_to_string expr);*)
try
let expr = ExprParser.of_string str file in
(*printf "Original: %s\nExpr: " str;
print_expr expr;
printf "\nResult: %s\n" (expr_to_string expr);*)
let lambdaexpr = Compile.parse_to_lambda expr in
let evalexpr = Eval.expr lambdaexpr 100 in
print_value evalexpr; printf "\n"
with Compile.Error -> exit 3
with
| Compile.Error -> exit 3
| Loc.Exc_located (loc, exn) ->
let l = Loc.start_line loc in
let cbegin = Loc.start_off loc - Loc.start_bol loc in
let cend = Loc.stop_off loc - Loc.start_bol loc in
eprintf "File %s, line %d, characters %d-%d:\n" (Loc.file_name loc) l
cbegin cend; raise exn
| _ -> exit 4
File ./tests/eval/tests/match_error_simple.test, line 1, characters 8-12:
Fatal error: exception Stream.Error("[branch] expected after "with" (in [expression])")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment