From 7c4a3a436ae9b65f051f509872ad6a16a41241fe Mon Sep 17 00:00:00 2001 From: AlDanial Date: Thu, 15 Dec 2022 18:51:44 -0800 Subject: [PATCH] test case for comments in OCaml strings, #701 --- Unix/cloc | 1 + Unix/t/01_opts.t | 7 +++++++ tests/inputs/issues/701/demo.ml | 8 ++++++++ tests/outputs/issues/701/results.yaml | 21 +++++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 tests/inputs/issues/701/demo.ml create mode 100644 tests/outputs/issues/701/results.yaml diff --git a/Unix/cloc b/Unix/cloc index cfed6abd..b6eba617 100755 --- a/Unix/cloc +++ b/Unix/cloc @@ -9512,6 +9512,7 @@ sub set_constants { # {{{1 [ 'call_regexp_common' , 'C++' ], ], 'OCaml' => [ + [ 'rm_comments_in_strings', '"', '(*', '*)', 1 ], [ 'remove_OCaml_comments', ], ], 'OpenCL' => [ diff --git a/Unix/t/01_opts.t b/Unix/t/01_opts.t index de82f0b5..d31a117a 100755 --- a/Unix/t/01_opts.t +++ b/Unix/t/01_opts.t @@ -683,6 +683,13 @@ my @Tests = ( 'ref' => '../tests/outputs/issues/692/results.yaml', }, + { + 'name' => 'comments in OCaml strings, #701', + 'cd' => '../tests/inputs/issues/701', + 'args' => '--strip-str-comments demo.ml', + 'ref' => '../tests/outputs/issues/701/results.yaml', + }, + ); # Special cases: diff --git a/tests/inputs/issues/701/demo.ml b/tests/inputs/issues/701/demo.ml new file mode 100644 index 00000000..f6726288 --- /dev/null +++ b/tests/inputs/issues/701/demo.ml @@ -0,0 +1,8 @@ +let just_a_string = " + (* +" +let x = 0 +let also_a_string = " + *) +" +let y = x diff --git a/tests/outputs/issues/701/results.yaml b/tests/outputs/issues/701/results.yaml new file mode 100644 index 00000000..7918886d --- /dev/null +++ b/tests/outputs/issues/701/results.yaml @@ -0,0 +1,21 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 1.95 + elapsed_seconds : 0.00726699829101562 + n_files : 1 + n_lines : 8 + files_per_second : 137.608398950131 + lines_per_second : 1100.86719160105 + report_file : ../../../outputs/issues/701/results.yaml +'OCaml' : + nFiles: 1 + blank: 0 + comment: 0 + code: 8 +SUM: + blank: 0 + comment: 0 + code: 8 + nFiles: 1