From 9fc64de787009d6980af84d8845624db72aa40d4 Mon Sep 17 00:00:00 2001 From: Shayne Fletcher Date: Mon, 12 Sep 2022 19:37:54 -0700 Subject: [PATCH] print utf8 in ocamlrep_marshal smoke test Summary: use unicode character escape sequences in `print_tree` Differential Revision: D39420801 fbshipit-source-id: 25ce2ef68062b448f1013dfe0f542eb460f40025 --- .../test/ocamlrep_marshal/test_ocamlrep_marshal.ml | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/hphp/hack/test/ocamlrep_marshal/test_ocamlrep_marshal.ml b/hphp/hack/test/ocamlrep_marshal/test_ocamlrep_marshal.ml index 1b83beb4da8..65ec893147f 100644 --- a/hphp/hack/test/ocamlrep_marshal/test_ocamlrep_marshal.ml +++ b/hphp/hack/test/ocamlrep_marshal/test_ocamlrep_marshal.ml @@ -47,10 +47,14 @@ let rec print_tree let n = List.length cs - 1 in Printf.sprintf "%s%s" pd tag :: List.concat (Caml.List.mapi ( fun i c -> - let pad = - (pc ^ (if i = n then "`-- " else "|-- "), - pc ^ (if i = n then " " else "| ")) in - print_tree ~pad c + let pad = let enable_utf8 = true in + if enable_utf8 then + (pc ^ (if i = n then "\u{02517} " else "\u{02523} "), + pc ^ (if i = n then " " else "\u{02503} ")) + else + (pc ^ (if i = n then "`-- " else "|-- "), + pc ^ (if i = n then " " else "| ")) + in print_tree ~pad c ) cs) [@@ocamlformat "disable"] (* [show_tree] produces a string of [t]. *) @@ -59,13 +63,15 @@ let show_tree t = (* An example tree. *) let tree = - `Node ("." + `Node ("life" , [ - `Node ("S", [ - `Node ("T", [ - `Node ("U", [])]); - `Node ("V", [])]) - ; `Node ("W", []) + `Node ("domain", [ + `Node ("kingdom", [ + `Node ("phylum", [])]); + `Node ("class", []); + `Node ("order", []) + ]) + ; `Node ("family", []) ]) [@@ocamlformat "disable"] let test_sharing () = -- 2.11.4.GIT