File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 22
33#### Yocaml
44
5+ - Fix ` Path.relocate ` (by [ mspwn] ( https://github.com/mspwn ) )
56- Add ` Data.Validation.req ` and ` Data.Validation.opt ` for compact validation and alternative name (by [ xhtmlboi] ( https://github.com/xhtmlboi ) )
67- Add ` Data.Validation.where_opt ` (and ` String ` , ` Int ` and ` Float ` version) (by [ xvw] ( https://xvw.lol ) )
78- Improve pretty-printing of validation errors (by [ Linda-Njau] ( https://github.com/Linda-Njau ) )
Original file line number Diff line number Diff line change @@ -148,8 +148,8 @@ let move ~into source =
148148 match basename source with None -> into | Some x -> append into [ x ]
149149
150150let remove_common_prefix into source =
151- let rec aux acc into source =
152- match (into, source ) with
151+ let rec aux acc s_into s_source =
152+ match (s_into, s_source ) with
153153 | [ x ], y :: xs when String. equal x y -> List. rev_append acc (x :: xs)
154154 | x :: xs , y :: ys when String. equal x y -> aux (x :: acc) xs ys
155155 | _ -> into @ source
Original file line number Diff line number Diff line change @@ -332,7 +332,7 @@ let test_relocate4 =
332332
333333let test_relocate5 =
334334 let open Alcotest in
335- test_case " relocate when common suffixes 1" `Quick (fun () ->
335+ test_case " relocate when common prefixes 1" `Quick (fun () ->
336336 let open Yocaml.Path in
337337 let expected = rel [ " foo" ; " bar" ; " index.html" ]
338338 and computed =
@@ -344,7 +344,7 @@ let test_relocate5 =
344344
345345let test_relocate6 =
346346 let open Alcotest in
347- test_case " relocate when common suffixes 2" `Quick (fun () ->
347+ test_case " relocate when common prefixes 2" `Quick (fun () ->
348348 let open Yocaml.Path in
349349 let expected = rel [ " foo" ; " bar" ; " baz" ; " index.html" ]
350350 and computed =
@@ -354,6 +354,18 @@ let test_relocate6 =
354354 in
355355 check Testable. path " should be equal" expected computed)
356356
357+ let test_relocate7 =
358+ let open Alcotest in
359+ test_case " relocate when partial common prefixes" `Quick (fun () ->
360+ let open Yocaml.Path in
361+ let expected = rel [ " foo" ; " bar" ; " foo" ; " baz" ; " index.html" ]
362+ and computed =
363+ relocate
364+ ~into: (rel [ " foo" ; " bar" ])
365+ (rel [ " foo" ; " baz" ; " index.html" ])
366+ in
367+ check Testable. path " should be equal" expected computed)
368+
357369let test_from_string1 =
358370 let open Alcotest in
359371 test_case " from_string 1" `Quick (fun () ->
@@ -435,6 +447,7 @@ let cases =
435447 ; test_relocate4
436448 ; test_relocate5
437449 ; test_relocate6
450+ ; test_relocate7
438451 ; test_from_string1
439452 ; test_from_string2
440453 ; test_from_string3
You can’t perform that action at this time.
0 commit comments