[pp] hv box for printing collections

Summary: Long lists will be broken into lines rather than stretch out on a single line.

Reviewed By: jvillard

Differential Revision: D5424323

fbshipit-source-id: 115f16a
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent 2091a529b1
commit e828b0bf8a

@ -35,11 +35,15 @@ module type PPMap = sig
end
let pp_collection ~pp_item fmt c =
let pp_collection fmt c =
let pp_sep fmt () = F.fprintf fmt ", " in
F.pp_print_list ~pp_sep pp_item fmt c
let rec pp_list fmt = function
| []
-> ()
| [item]
-> F.fprintf fmt "@[<h>%a@] " pp_item item
| item :: items
-> F.fprintf fmt "@[<h>%a,@]@ " pp_item item ; pp_list fmt items
in
F.fprintf fmt "{ %a }" pp_collection c
F.fprintf fmt "@[<hv 2>{ %a}@]" pp_list c
module MakePPSet (Ord : PrintableOrderedType) = struct
include Caml.Set.Make (Ord)

@ -137,8 +137,8 @@ let tests =
; read_field_to_id "read_id" "base_id" "f"
; var_assign_id "var" "read_id"
; invariant
"{ base_id$0.f => (SOURCE -> ?), ret_id$0 => (SOURCE -> ?), &var => (SOURCE -> ?) }" ]
)
"{ base_id$0.f => (SOURCE -> ?),\n ret_id$0 => (SOURCE -> ?),\n &var => (SOURCE -> ?) }"
] )
; ( "source flows to var then cleared"
, [ assign_to_source "ret_id"
; var_assign_id "var" "ret_id"
@ -184,7 +184,7 @@ let tests =
; read_field_to_id "read_id" "var_id" "f"
; call_sink "read_id"
; invariant
"{ base_id$0.f => (SOURCE -> ?), ret_id$0 => (SOURCE -> ?), &var.f* => (SOURCE -> SINK) }"
"{ base_id$0.f => (SOURCE -> ?),\n ret_id$0 => (SOURCE -> ?),\n &var.f* => (SOURCE -> SINK) }"
] )
; ( "source -> sink via cast"
, [ assign_to_source "ret_id"

Loading…
Cancel
Save