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 _ = let%expect_test _ =
run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ] ; run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ] ;
[%expect {| [%expect {|
failed with string some_string |}] failwith("some_string") |}]
let%expect_test _ = let%expect_test _ =
run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ; "--format=json" ] ; run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ; "--format=json" ] ;
[%expect {| [%expect {|
{"status":"ok","content":"failed with string some_string"} |}] {"status":"ok","content":"failwith(\"some_string\")"} |}]
let%expect_test _ = let%expect_test _ =
run_ligo_bad [ "compile-contract" ; contract "bad_address_format.religo" ; "main" ] ; run_ligo_bad [ "compile-contract" ; contract "bad_address_format.religo" ; "main" ] ;
@ -1022,5 +1022,5 @@ let%expect_test _ =
(* TODO should not be bad? *) (* TODO should not be bad? *)
run_ligo_good [ "dry-run" ; contract "subtle_nontail_fail.mligo" ; "main" ; "()" ; "()" ] ; run_ligo_good [ "dry-run" ; contract "subtle_nontail_fail.mligo" ; "main" ; "()" ; "()" ] ;
[%expect {| [%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 failwith_to_string (f:run_failwith_res) : string result =
let%bind str = match f with let%bind str = match f with
| Failwith_int i -> ok @@ string_of_int i | 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 -> | Failwith_bytes b ->
generic_try (simple_error "Could not convert failwith bytes to string") @@ ok @@ Format.asprintf "0X%a" Hex.pp (Hex.of_bytes b) in
(fun () -> Bytes.to_string b) in ok @@ Format.asprintf "failwith(%s)" str
ok @@ Format.asprintf "failed with value '%s'" str
let make_dry_run_options (opts : dry_run_options) : options result = let make_dry_run_options (opts : dry_run_options) : options result =
let open Proto_alpha_utils.Trace in 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' | Success etv' -> ex_value_ty_to_michelson etv'
| Fail res -> | Fail res ->
let%bind str = failwith_to_string res in let%bind str = failwith_to_string res in
fail @@ Errors.failwith str () fail @@ Errors.failwith str ()