From 5a4adfa76bfab84a5168b1041a3fb50b7d308554 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sat, 19 Mar 2022 14:13:15 -0400 Subject: [PATCH] fixes, do not run Format tests on < 4.08 --- qtest/make.ml | 1 + src/core/CCFormat.ml | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/qtest/make.ml b/qtest/make.ml index 5c63c9d3..390400e5 100644 --- a/qtest/make.ml +++ b/qtest/make.ml @@ -19,6 +19,7 @@ let do_not_test file = assert (not (is_suffix ~sub:"make.ml" file)); str_sub ~sub:"Labels.ml" file || is_suffix ~sub:".pp.ml" file || + (if Sys.ocaml_version < "4.08" then Filename.basename file = "CCFormat.ml" else false) || is_suffix ~sub:".pp.mli" file || is_suffix ~sub:"containers.ml" file || is_suffix ~sub:"_top.ml" file || diff --git a/src/core/CCFormat.ml b/src/core/CCFormat.ml index 4d38beb0..f0547d92 100644 --- a/src/core/CCFormat.ml +++ b/src/core/CCFormat.ml @@ -407,6 +407,19 @@ let set_color_tag_handling ppf = in pp_set_formatter_stag_functions ppf funs' +(*$R + set_color_default true; + let s = sprintf + "what is your %a? %a! No, %a! Ahhhhhhh@." + (styling [`FG `White; `Bold] string) "favorite color" + (styling [`FG `Blue] string) "blue" + (styling [`FG `Red] string) "red" + in + assert_equal ~printer:CCFun.id + "what is your \027[37;1mfavorite color\027[0m? \027[34mblue\027[0m! No, \027[31mred\027[0m! Ahhhhhhh\n" + s +*) + [@@@else_] (* either prints the tag of [s] or delegate to [or_else] *) @@ -435,9 +448,9 @@ let set_color_tag_handling ppf = let functions = { funs with mark_open_tag = mark_open_tag st ~or_else:funs.mark_open_tag; - mark_close_stag = mark_close_tag st ~or_else:funs.mark_close_tag; + mark_close_tag = mark_close_tag st ~or_else:funs.mark_close_tag; } in - pp_set_formatter_stag_functions ppf functions + pp_set_formatter_tag_functions ppf functions [@@@endif] @@ -463,19 +476,6 @@ let set_color_default = s *) -(*$R - set_color_default true; - let s = sprintf - "what is your %a? %a! No, %a! Ahhhhhhh@." - (styling [`FG `White; `Bold] string) "favorite color" - (styling [`FG `Blue] string) "blue" - (styling [`FG `Red] string) "red" - in - assert_equal ~printer:CCFun.id - "what is your \027[37;1mfavorite color\027[0m? \027[34mblue\027[0m! No, \027[31mred\027[0m! Ahhhhhhh\n" - s -*) - let with_color s pp out x = pp_open_tag out s; pp out x;