review request (more regular output)

This commit is contained in:
Lesenechal Remi 2020-01-17 17:02:54 +01:00
parent 4ca9a0243b
commit a30d59121f
2 changed files with 7 additions and 8 deletions

View File

@ -966,12 +966,12 @@ let%expect_test _ =
let%expect_test _ =
run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ] ;
[%expect {|
failed with string some_string |}]
failwith("some_string") |}]
let%expect_test _ =
run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ; "--format=json" ] ;
[%expect {|
{"status":"ok","content":"failed with string some_string"} |}]
{"status":"ok","content":"failwith(\"some_string\")"} |}]
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; contract "bad_address_format.religo" ; "main" ] ;
@ -1022,5 +1022,5 @@ let%expect_test _ =
(* TODO should not be bad? *)
run_ligo_good [ "dry-run" ; contract "subtle_nontail_fail.mligo" ; "main" ; "()" ; "()" ] ;
[%expect {|
failed with string This contract always fails |}]
failwith("This contract always fails") |}]

View File

@ -38,11 +38,10 @@ type dry_run_options =
let failwith_to_string (f:run_failwith_res) : string result =
let%bind str = match f with
| Failwith_int i -> ok @@ string_of_int i
| Failwith_string s -> ok @@ s
| Failwith_string s -> ok @@ Format.asprintf "\"%s\"" (String.escaped s)
| Failwith_bytes b ->
generic_try (simple_error "Could not convert failwith bytes to string") @@
(fun () -> Bytes.to_string b) in
ok @@ Format.asprintf "failed with value '%s'" str
ok @@ Format.asprintf "0X%a" Hex.pp (Hex.of_bytes b) in
ok @@ Format.asprintf "failwith(%s)" str
let make_dry_run_options (opts : dry_run_options) : options result =
let open Proto_alpha_utils.Trace in
@ -169,4 +168,4 @@ let evaluate_expression ?options exp exp_type =
| Success etv' -> ex_value_ty_to_michelson etv'
| Fail res ->
let%bind str = failwith_to_string res in
fail @@ Errors.failwith str ()
fail @@ Errors.failwith str ()