3-way merge with Myers diff
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

merge3: rename test_ functions in interop test (merlint E330)

+55 -55
+55 -55
test/interop/git/test.ml
··· 77 77 78 78 (** {1 Section 1: Trivial clean merges} *) 79 79 80 - let test_identical () = 80 + let identical () = 81 81 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"line1\nline2\n" 82 82 ~ours:"line1\nline2\n" ~theirs:"line1\nline2\n" () 83 83 84 - let test_only_ours_changed () = 84 + let only_ours_changed () = 85 85 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"line1\nline2\n" 86 86 ~ours:"changed\nline2\n" ~theirs:"line1\nline2\n" () 87 87 88 - let test_only_theirs_changed () = 88 + let only_theirs_changed () = 89 89 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"line1\nline2\n" 90 90 ~ours:"line1\nline2\n" ~theirs:"changed\nline2\n" () 91 91 92 - let test_both_same_change () = 92 + let both_same_change () = 93 93 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"line1\nline2\n" 94 94 ~ours:"line1\nchanged\n" ~theirs:"line1\nchanged\n" () 95 95 96 96 (** {1 Section 2: Non-overlapping changes (the core of useful merging)} *) 97 97 98 - let test_non_overlapping_modifies () = 98 + let non_overlapping_modifies () = 99 99 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"a\nb\nc\nd\ne\n" 100 100 ~ours:"X\nb\nc\nd\ne\n" ~theirs:"a\nb\nc\nd\nY\n" () 101 101 102 - let test_non_overlapping_inserts () = 102 + let non_overlapping_inserts () = 103 103 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"line1\nline5\n" 104 104 ~ours:"line1\nline2\nline3\nline5\n" ~theirs:"line1\nline5\nline6\nline7\n" 105 105 () 106 106 107 - let test_non_overlapping_deletes () = 107 + let non_overlapping_deletes () = 108 108 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"a\nb\nc\nd\ne\n" 109 109 ~ours:"a\nc\nd\ne\n" ~theirs:"a\nb\nc\nd\n" () 110 110 111 - let test_modify_unrelated_blocks () = 111 + let modify_unrelated_blocks () = 112 112 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" 113 113 ~base:"function f1() {}\n\nfunction f2() {}\n\nfunction f3() {}\n" 114 114 ~ours: ··· 119 119 120 120 (** {1 Section 3: Add/insert combinations} *) 121 121 122 - let test_ours_inserts_theirs_unchanged () = 122 + let ours_inserts_theirs_unchanged () = 123 123 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"a\nb\nc\n" 124 124 ~ours:"a\nNEW\nb\nc\n" ~theirs:"a\nb\nc\n" () 125 125 126 - let test_theirs_inserts_ours_unchanged () = 126 + let theirs_inserts_ours_unchanged () = 127 127 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"a\nb\nc\n" 128 128 ~ours:"a\nb\nc\n" ~theirs:"a\nb\nNEW\nc\n" () 129 129 130 - let test_both_insert_at_start () = 130 + let both_insert_at_start () = 131 131 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"common\n" 132 132 ~ours:"prefix_ours\ncommon\n" ~theirs:"prefix_theirs\ncommon\n" () 133 133 134 - let test_both_insert_at_end () = 134 + let both_insert_at_end () = 135 135 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"common\n" 136 136 ~ours:"common\nsuffix_ours\n" ~theirs:"common\nsuffix_theirs\n" () 137 137 138 138 (** {1 Section 4: Conflict cases} *) 139 139 140 - let test_both_modify_same_line () = 140 + let both_modify_same_line () = 141 141 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"let x = 1\n" 142 142 ~ours:"let x = 2\n" ~theirs:"let x = 3\n" () 143 143 144 - let test_both_modify_same_block_differently () = 144 + let both_modify_same_block_differently () = 145 145 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"a\nb\nc\n" 146 146 ~ours:"a\nB1\nB2\nc\n" ~theirs:"a\nX\nY\nZ\nc\n" () 147 147 148 - let test_overlapping_inserts () = 148 + let overlapping_inserts () = 149 149 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"line1\nline2\n" 150 150 ~ours:"line1\nINSERT_O\nline2\n" ~theirs:"line1\nINSERT_T\nline2\n" () 151 151 152 152 (** {1 Section 5: Edge cases} *) 153 153 154 - let test_empty_base () = 154 + let empty_base () = 155 155 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"" 156 156 ~ours:"hello\n" ~theirs:"world\n" () 157 157 158 - let test_no_trailing_newline () = 158 + let no_trailing_newline () = 159 159 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"a\nb" 160 160 ~ours:"a\nB" ~theirs:"a\nb" () 161 161 162 - let test_only_whitespace_changes () = 162 + let only_whitespace_changes () = 163 163 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:" let x = 1\n" 164 164 ~ours:"\tlet x = 1\n" ~theirs:" let x = 1\n" () 165 165 166 - let test_single_line_files () = 166 + let single_line_files () = 167 167 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base:"original\n" 168 168 ~ours:"original\n" ~theirs:"changed\n" () 169 169 170 - let test_completely_different () = 170 + let completely_different () = 171 171 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" 172 172 ~base:"orig1\norig2\norig3\n" ~ours:"alice1\nalice2\nalice3\n" 173 173 ~theirs:"bob1\nbob2\nbob3\n" () 174 174 175 175 (** {1 Section 6: Realistic scenarios} *) 176 176 177 - let test_ocaml_function_edits () = 177 + let ocaml_function_edits () = 178 178 let base = 179 179 "let add x y = x + y\nlet sub x y = x - y\nlet mul x y = x * y\n" 180 180 in ··· 194 194 in 195 195 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base ~ours ~theirs () 196 196 197 - let test_imports_added_both_sides () = 197 + let imports_added_both_sides () = 198 198 let base = "open Lwt.Syntax\n\nlet f () = ()\n" in 199 199 let ours = "open Lwt.Syntax\nopen My_module\n\nlet f () = ()\n" in 200 200 let theirs = "open Lwt.Syntax\nopen Other_module\n\nlet f () = ()\n" in 201 201 check_vs_git ~ours_label:"ours" ~theirs_label:"theirs" ~base ~ours ~theirs () 202 202 203 - let test_changelog_entries () = 203 + let changelog_entries () = 204 204 let base = "## v1.0\n- initial release\n" in 205 205 let ours = "## v1.1\n- bug fix A\n## v1.0\n- initial release\n" in 206 206 let theirs = "## v1.1\n- bug fix B\n## v1.0\n- initial release\n" in ··· 284 284 done; 285 285 Array.of_list !lines 286 286 287 - let test_random_seed seed = 287 + let random_seed seed = 288 288 let base_lines = random_lines ~seed 20 in 289 289 let base = join base_lines in 290 290 let ours = join (edit ~seed:(seed + 1000) ~ops:5 base_lines) in ··· 296 296 Generates a large random base, then does single-line edits on each side. The 297 297 merge should be fast (Myers O(ND) is near-linear when D is small). *) 298 298 299 - let test_large_file_seeded () = 299 + let large_file_seeded () = 300 300 let seed = 42 in 301 301 let n = 5000 in 302 302 let base_lines = random_lines ~seed n in ··· 316 316 [ 317 317 ( "trivial-clean", 318 318 [ 319 - Alcotest.test_case "identical" `Quick test_identical; 320 - Alcotest.test_case "only ours" `Quick test_only_ours_changed; 321 - Alcotest.test_case "only theirs" `Quick test_only_theirs_changed; 322 - Alcotest.test_case "both same" `Quick test_both_same_change; 319 + Alcotest.test_case "identical" `Quick identical; 320 + Alcotest.test_case "only ours" `Quick only_ours_changed; 321 + Alcotest.test_case "only theirs" `Quick only_theirs_changed; 322 + Alcotest.test_case "both same" `Quick both_same_change; 323 323 ] ); 324 324 ( "non-overlapping", 325 325 [ 326 - Alcotest.test_case "modifies" `Quick test_non_overlapping_modifies; 327 - Alcotest.test_case "inserts" `Quick test_non_overlapping_inserts; 328 - Alcotest.test_case "deletes" `Quick test_non_overlapping_deletes; 326 + Alcotest.test_case "modifies" `Quick non_overlapping_modifies; 327 + Alcotest.test_case "inserts" `Quick non_overlapping_inserts; 328 + Alcotest.test_case "deletes" `Quick non_overlapping_deletes; 329 329 Alcotest.test_case "unrelated blocks" `Quick 330 - test_modify_unrelated_blocks; 330 + modify_unrelated_blocks; 331 331 ] ); 332 332 ( "inserts", 333 333 [ 334 334 Alcotest.test_case "ours inserts" `Quick 335 - test_ours_inserts_theirs_unchanged; 335 + ours_inserts_theirs_unchanged; 336 336 Alcotest.test_case "theirs inserts" `Quick 337 - test_theirs_inserts_ours_unchanged; 338 - Alcotest.test_case "both at start" `Quick test_both_insert_at_start; 339 - Alcotest.test_case "both at end" `Quick test_both_insert_at_end; 337 + theirs_inserts_ours_unchanged; 338 + Alcotest.test_case "both at start" `Quick both_insert_at_start; 339 + Alcotest.test_case "both at end" `Quick both_insert_at_end; 340 340 ] ); 341 341 ( "conflicts", 342 342 [ 343 - Alcotest.test_case "same line" `Quick test_both_modify_same_line; 343 + Alcotest.test_case "same line" `Quick both_modify_same_line; 344 344 Alcotest.test_case "same block diff" `Quick 345 - test_both_modify_same_block_differently; 345 + both_modify_same_block_differently; 346 346 Alcotest.test_case "overlapping inserts" `Quick 347 - test_overlapping_inserts; 347 + overlapping_inserts; 348 348 Alcotest.test_case "completely different" `Quick 349 - test_completely_different; 349 + completely_different; 350 350 ] ); 351 351 ( "edge-cases", 352 352 [ 353 - Alcotest.test_case "empty base" `Quick test_empty_base; 353 + Alcotest.test_case "empty base" `Quick empty_base; 354 354 Alcotest.test_case "no trailing newline" `Quick 355 - test_no_trailing_newline; 355 + no_trailing_newline; 356 356 Alcotest.test_case "whitespace only" `Quick 357 - test_only_whitespace_changes; 358 - Alcotest.test_case "single line" `Quick test_single_line_files; 357 + only_whitespace_changes; 358 + Alcotest.test_case "single line" `Quick single_line_files; 359 359 ] ); 360 360 ( "realistic", 361 361 [ 362 362 Alcotest.test_case "ocaml function edits" `Quick 363 - test_ocaml_function_edits; 363 + ocaml_function_edits; 364 364 Alcotest.test_case "imports both sides" `Quick 365 - test_imports_added_both_sides; 366 - Alcotest.test_case "changelog" `Quick test_changelog_entries; 365 + imports_added_both_sides; 366 + Alcotest.test_case "changelog" `Quick changelog_entries; 367 367 ] ); 368 368 ( "random", 369 369 [ 370 - Alcotest.test_case "seed 1" `Quick (fun () -> test_random_seed 1); 371 - Alcotest.test_case "seed 2" `Quick (fun () -> test_random_seed 2); 372 - Alcotest.test_case "seed 7" `Quick (fun () -> test_random_seed 7); 373 - Alcotest.test_case "seed 42" `Quick (fun () -> test_random_seed 42); 374 - Alcotest.test_case "seed 100" `Quick (fun () -> test_random_seed 100); 375 - Alcotest.test_case "seed 999" `Quick (fun () -> test_random_seed 999); 370 + Alcotest.test_case "seed 1" `Quick (fun () -> random_seed 1); 371 + Alcotest.test_case "seed 2" `Quick (fun () -> random_seed 2); 372 + Alcotest.test_case "seed 7" `Quick (fun () -> random_seed 7); 373 + Alcotest.test_case "seed 42" `Quick (fun () -> random_seed 42); 374 + Alcotest.test_case "seed 100" `Quick (fun () -> random_seed 100); 375 + Alcotest.test_case "seed 999" `Quick (fun () -> random_seed 999); 376 376 ] ); 377 - ("large", [ Alcotest.test_case "5000 lines" `Slow test_large_file_seeded ]); 377 + ("large", [ Alcotest.test_case "5000 lines" `Slow large_file_seeded ]); 378 378 ]