Merge branch 'feature/hex-printing' into 'dev'
Fix one hex printing bug See merge request ligolang/ligo!274
This commit is contained in:
commit
40411c39ea
@ -188,10 +188,14 @@ let literal ppf (l:literal) = match l with
|
||||
| Literal_timestamp n -> fprintf ppf "+%d" n
|
||||
| Literal_mutez n -> fprintf ppf "%dmutez" n
|
||||
| Literal_string s -> fprintf ppf "%S" s
|
||||
| Literal_bytes b -> fprintf ppf "0x%s" @@ Bytes.to_string @@ Bytes.escaped b
|
||||
| Literal_bytes b -> fprintf ppf "0x%a" Hex.pp (Hex.of_bytes b)
|
||||
| Literal_address s -> fprintf ppf "@%S" s
|
||||
| Literal_operation _ -> fprintf ppf "Operation(...bytes)"
|
||||
| Literal_key s -> fprintf ppf "key %s" s
|
||||
| Literal_key_hash s -> fprintf ppf "key_hash %s" s
|
||||
| Literal_signature s -> fprintf ppf "Signature %s" s
|
||||
| Literal_chain_id s -> fprintf ppf "Chain_id %s" s
|
||||
|
||||
let%expect_test _ =
|
||||
Format.printf "%a" literal (Literal_bytes (Bytes.of_string "foo")) ;
|
||||
[%expect{| 0x666f6f |}]
|
||||
|
@ -5,8 +5,9 @@
|
||||
simple-utils
|
||||
tezos-utils
|
||||
)
|
||||
(inline_tests)
|
||||
(preprocess
|
||||
(pps ppx_let)
|
||||
(pps ppx_let ppx_expect)
|
||||
)
|
||||
(flags (:standard -open Simple_utils))
|
||||
)
|
||||
|
@ -58,8 +58,7 @@ let rec value ppf : value -> unit = function
|
||||
| D_unit -> fprintf ppf "unit"
|
||||
| D_string s -> fprintf ppf "\"%s\"" s
|
||||
| D_bytes x ->
|
||||
let (`Hex hex) = Hex.of_bytes x in
|
||||
fprintf ppf "0x%s" hex
|
||||
fprintf ppf "0x%a" Hex.pp @@ Hex.of_bytes x
|
||||
| D_pair (a, b) -> fprintf ppf "(%a), (%a)" value a value b
|
||||
| D_left a -> fprintf ppf "L(%a)" value a
|
||||
| D_right b -> fprintf ppf "R(%a)" value b
|
||||
@ -124,6 +123,10 @@ let tl_statement ppf (ass, _) = assignment ppf ass
|
||||
let program ppf (p:program) =
|
||||
fprintf ppf "Program:\n---\n%a" (pp_print_list ~pp_sep:pp_print_newline tl_statement) p
|
||||
|
||||
let%expect_test _ =
|
||||
Format.printf "%a" value (D_bytes (Bytes.of_string "foo")) ;
|
||||
[%expect{| 0x666f6f |}]
|
||||
|
||||
let%expect_test _ =
|
||||
let pp = expression' Format.std_formatter in
|
||||
let dummy_type = T_base Base_unit in
|
||||
|
Loading…
Reference in New Issue
Block a user