Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions check/src/check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ and process_mismatch state exp_lines got_lines =
in
let handle_report_infos alt state =
(* If either is not a valid report line, then it is consumed.
If both are valid report_lines then the first in lexicographical order
is consumed *)
If both are valid report_lines then the first that should appear in
the report order is consumed *)
let exp_ri = Reports.report_info_of_line exp in
let got_ri = Reports.report_info_of_line got in
match exp_ri, got_ri with
| Ok _, Ok _ ->
let comp = String.compare exp got in
| Ok exp_ri, Ok got_ri ->
let comp = Reports.compare exp_ri got_ri in
assert (comp <> 0);
if comp < 0 then consume_exp state
else (* > 0 *) consume_got state
Expand Down
6 changes: 6 additions & 0 deletions check/src/reports.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ type report_info = {
value : string;
}

let compare ri1 ri2 =
let ( |:? ) x f = if x <> 0 then x else f () in
String.compare ri1.filepath ri2.filepath
|:? (fun () -> Int.compare ri1.line_nb ri2.line_nb)
|:? (fun () -> String.compare ri1.value ri2.value)

let line_of_report_info ri =
Printf.sprintf "%s:%d:%s" ri.filepath ri.line_nb ri.value

Expand Down
2 changes: 2 additions & 0 deletions check/src/reports.mli
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ type report_info = {
value : string;
}

val compare : report_info -> report_info -> int

val line_of_report_info : report_info -> string

(* Format of report lines is : '<file_path>:<line_number>:<value>' with :
Expand Down