From f60f2f5c164eeee24666f8556616aa381a54fd8e Mon Sep 17 00:00:00 2001 From: Mateo Date: Thu, 8 Aug 2024 09:59:16 +0200 Subject: [PATCH] feat: slightly change format, replace   with utf8 nbsp --- src/lsp/cobol_lsp/lsp_data_info_printer.ml | 5 +++-- test/lsp/lsp_hover.ml | 22 +++++++++++----------- test/lsp/lsp_picture_interp.ml | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/lsp/cobol_lsp/lsp_data_info_printer.ml b/src/lsp/cobol_lsp/lsp_data_info_printer.ml index e530ad840..1c62761db 100644 --- a/src/lsp/cobol_lsp/lsp_data_info_printer.ml +++ b/src/lsp/cobol_lsp/lsp_data_info_printer.ml @@ -33,7 +33,7 @@ let max_value digits scale = let decimal_part = Str.string_before (Str.string_after s whole) scale in float_of_string (whole_part ^ "." ^ decimal_part) -let nbsp_repl = Str.global_replace (Str.regexp " ") " " +let nbsp_repl = Str.global_replace (Str.regexp " ") " " (* <- utf8 nbsp *) let pp_example_of ppf (picture: Cobol_data.Picture.t) = try @@ -44,11 +44,12 @@ let pp_example_of ppf (picture: Cobol_data.Picture.t) = if Float.is_integer max then string_of_int (int_of_float max) else string_of_float max in - Fmt.pf ppf "\n\nExample display values [%s] (0) [%s] (%s)" + Fmt.pf ppf "\n\n*e.g,* [`%s`] (0), [`%s`] (%s)" (Lsp_picture_interp.example_of ~picture 0. |> nbsp_repl) (Lsp_picture_interp.example_of ~picture max |> nbsp_repl) max_str | _ -> () + with Invalid_argument _ -> () let pp_usage: usage Pretty.printer = diff --git a/test/lsp/lsp_hover.ml b/test/lsp/lsp_hover.ml index d4452f56c..7ee599d0e 100644 --- a/test/lsp/lsp_hover.ml +++ b/test/lsp/lsp_hover.ml @@ -292,7 +292,7 @@ let%expect_test "hover-typedef-vars" = PIC 999 USAGE DISPLAY ``` NUMERIC(digits = 3, scale = 0, with_sign = false) - Example display values [000] (0) [123] (123) + *e.g,* [`000`] (0), [`123`] (123) VALUE 123 (line 8, character 16): __rootdir__/prog.cob:9.13-9.21: @@ -391,7 +391,7 @@ let%expect_test "hover-typedef-vars" = PIC 999 USAGE DISPLAY ``` NUMERIC(digits = 3, scale = 0, with_sign = false) - Example display values [000] (0) [123] (123) + *e.g,* [`000`] (0), [`123`] (123) VALUE 123 (line 12, character 47): __rootdir__/prog.cob:13.44-13.52: @@ -465,7 +465,7 @@ let%expect_test "hover-typedef-vars-usage" = PIC -BZZZ,ZZ9.99 USAGE DISPLAY ``` NUMERIC(digits = 8, scale = 2, with_sign = false) - Example display values [        0.00] (0) [  123,456.78] (123456.78) + *e.g,* [`        0.00`] (0), [`  123,456.78`] (123456.78) (line 6, character 11): __rootdir__/prog.cob:7.11-7.15: 4 DATA DIVISION. @@ -482,7 +482,7 @@ let%expect_test "hover-typedef-vars-usage" = PIC 9 USAGE BINARY ``` NUMERIC(digits = 1, scale = 0, with_sign = false) - Example display values [0] (0) [1] (1) + *e.g,* [`0`] (0), [`1`] (1) (line 7, character 11): __rootdir__/prog.cob:8.11-8.15: 5 WORKING-STORAGE SECTION. @@ -558,7 +558,7 @@ let%expect_test "hover-typedef-vars-usage" = PIC 9 USAGE PACKED-DECIMAL ``` NUMERIC(digits = 1, scale = 0, with_sign = false) - Example display values [0] (0) [1] (1) + *e.g,* [`0`] (0), [`1`] (1) (line 12, character 11): __rootdir__/prog.cob:13.11-13.15: 10 01 VAR6 PIC 111 USAGE BIT. @@ -575,7 +575,7 @@ let%expect_test "hover-typedef-vars-usage" = PIC $++/+.+B+ USAGE DISPLAY ``` NUMERIC(digits = 4, scale = 2, with_sign = false) - Example display values [         ] (0) [$+1/2.3 4] (12.34) |}];; + *e.g,* [`         `] (0), [`$+1/2.3 4`] (12.34) |}];; let%expect_test "hover-typedef-filler-vars" = let { projdir; end_with_postproc }, server = make_lsp_project () in @@ -813,7 +813,7 @@ let%expect_test "hover-typedef-renames" = PIC 9 USAGE DISPLAY ``` NUMERIC(digits = 1, scale = 0, with_sign = false) - Example display values [0] (0) [1] (1) + *e.g,* [`0`] (0), [`1`] (1) (line 8, character 16): __rootdir__/prog.cob:9.10-9.25: 6 01 X. @@ -831,7 +831,7 @@ let%expect_test "hover-typedef-renames" = PIC 9 USAGE DISPLAY ``` NUMERIC(digits = 1, scale = 0, with_sign = false) - Example display values [0] (0) [1] (1) + *e.g,* [`0`] (0), [`1`] (1) (line 8, character 23): __rootdir__/prog.cob:9.23-9.24: 6 01 X. @@ -848,7 +848,7 @@ let%expect_test "hover-typedef-renames" = PIC 9 USAGE DISPLAY ``` NUMERIC(digits = 1, scale = 0, with_sign = false) - Example display values [0] (0) [1] (1) + *e.g,* [`0`] (0), [`1`] (1) (line 9, character 22): __rootdir__/prog.cob:10.13-10.22: 7 05 Y PIC 9. @@ -884,7 +884,7 @@ let%expect_test "hover-typedef-renames" = PIC 9 USAGE DISPLAY ``` NUMERIC(digits = 1, scale = 0, with_sign = false) - Example display values [0] (0) [1] (1) |}];; + *e.g,* [`0`] (0), [`1`] (1) |}];; let%expect_test "hover-typedef-redefines" = let { projdir; end_with_postproc }, server = make_lsp_project () in @@ -939,7 +939,7 @@ let%expect_test "hover-typedef-redefines" = PIC 9 USAGE DISPLAY ``` NUMERIC(digits = 1, scale = 0, with_sign = false) - Example display values [0] (0) [1] (1) + *e.g,* [`0`] (0), [`1`] (1) (line 9, character 20): __rootdir__/prog.cob:10.20-10.21: 7 05 Y PIC 9. diff --git a/test/lsp/lsp_picture_interp.ml b/test/lsp/lsp_picture_interp.ml index 2cdf121fc..94123eec1 100644 --- a/test/lsp/lsp_picture_interp.ml +++ b/test/lsp/lsp_picture_interp.ml @@ -50,7 +50,7 @@ let unit_tests = ("Z,ZZZ.ZZ+", +123.456, " 123.45+"); ("*,***.**+", -123.45, "**123.45-"); ("**,***,***.**", +12345678.9, "12,345,678.90"); - (* ("$Z,ZZZ,ZZZ.ZZCR", +12345.67, "$ 12,345.67"); *) + ("$Z,ZZZ,ZZZ.ZZCR", +12345.67, "$ 12,345.67 "); ("$B*,***.**BBDB", 0., "*******.******"); ("$B*,***,***.**BBDB", -12345.67, "$ ***12,345.67 DB");]