From 8de825026682ed426429d49bf2dd7516557e415f Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Tue, 23 Dec 2025 14:41:05 +0100 Subject: [PATCH 1/6] Migrate expect tests to dyn syntax --- .headache.dirs | 1 + dune-project | 4 + fpath-base-tests.opam | 2 + test/fpath-base/dune | 7 +- test/fpath-base/test__absolute_path.ml | 231 ++++++++++------- test/fpath-base/test__fpath.ml | 346 +++++++++++++------------ test/fpath-base/test__fsegment.ml | 52 ++-- test/fpath-base/test__hash.ml | 34 +-- test/fpath-base/test__relative_path.ml | 265 +++++++++++-------- test/fpath-sexp0/dune | 6 +- test/stdlib/code_error.ml | 21 ++ test/stdlib/code_error.mli | 18 ++ test/stdlib/dune | 10 + test/stdlib/stdlib_for_test.ml | 26 ++ test/stdlib/stdlib_for_test.mli | 24 ++ 15 files changed, 623 insertions(+), 424 deletions(-) create mode 100644 test/stdlib/code_error.ml create mode 100644 test/stdlib/code_error.mli create mode 100644 test/stdlib/dune create mode 100644 test/stdlib/stdlib_for_test.ml create mode 100644 test/stdlib/stdlib_for_test.mli diff --git a/.headache.dirs b/.headache.dirs index 1d6b981..90b2536 100644 --- a/.headache.dirs +++ b/.headache.dirs @@ -4,3 +4,4 @@ src/fpath-base src/fpath-sexp0 test/fpath-base test/fpath-sexp0 +test/stdlib diff --git a/dune-project b/dune-project index eceb882..90a317e 100644 --- a/dune-project +++ b/dune-project @@ -62,6 +62,8 @@ (>= 5.2)) (base (>= v0.17)) + (dyn + (>= 3.17)) (expect_test_helpers_core (>= v0.17)) (fpath @@ -70,6 +72,8 @@ (= :version)) (fpath-sexp0 (= :version)) + (pp + (>= 2.0.0)) (ppx_compare (>= v0.17)) (ppx_expect diff --git a/fpath-base-tests.opam b/fpath-base-tests.opam index 86f93d1..ef3d505 100644 --- a/fpath-base-tests.opam +++ b/fpath-base-tests.opam @@ -11,10 +11,12 @@ depends: [ "dune" {>= "3.17"} "ocaml" {>= "5.2"} "base" {>= "v0.17"} + "dyn" {>= "3.17"} "expect_test_helpers_core" {>= "v0.17"} "fpath" {>= "0.7.3"} "fpath-base" {= version} "fpath-sexp0" {= version} + "pp" {>= "2.0.0"} "ppx_compare" {>= "v0.17"} "ppx_expect" {>= "v0.17"} "ppx_hash" {>= "v0.17"} diff --git a/test/fpath-base/dune b/test/fpath-base/dune index 883f897..70ad3ad 100644 --- a/test/fpath-base/dune +++ b/test/fpath-base/dune @@ -12,13 +12,16 @@ -open Fpath_base -open - Expect_test_helpers_base) + Expect_test_helpers_base + -open + Stdlib_for_test) (libraries base expect_test_helpers_core.expect_test_helpers_base fpath fpath_base - fpath_sexp0) + fpath_sexp0 + stdlib_for_test) (inline_tests) (instrumentation (backend bisect_ppx)) diff --git a/test/fpath-base/test__absolute_path.ml b/test/fpath-base/test__absolute_path.ml index 6dc996a..b54d97d 100644 --- a/test/fpath-base/test__absolute_path.ml +++ b/test/fpath-base/test__absolute_path.ml @@ -4,20 +4,29 @@ (* SPDX-License-Identifier: MIT *) (*********************************************************************************) +let%expect_test "sexp_of_t" = + print_endline + (Sexplib0.Sexp.to_string_hum + (Absolute_path.sexp_of_t (Absolute_path.v "/hello/path/to/sexp"))); + [%expect {| /hello/path/to/sexp |}]; + () +;; + let%expect_test "of_string" = let test str = - print_s - [%sexp - (Absolute_path.of_string str : (Absolute_path.t, [ `Msg of string ]) Result.t)] + print_dyn + (or_msg_to_dyn + (fun p -> Dyn.string (Absolute_path.to_string p)) + (Absolute_path.of_string str)) in test ""; - [%expect {| (Error (Msg "\"\": invalid path")) |}]; + [%expect {| Error (Msg "\"\": invalid path") |}]; test "/"; - [%expect {| (Ok /) |}]; + [%expect {| Ok "/" |}]; test "a"; - [%expect {| (Error (Msg "\"a\" is not an absolute path")) |}]; + [%expect {| Error (Msg "\"a\" is not an absolute path") |}]; test "/a/b/../.."; - [%expect {| (Ok /) |}]; + [%expect {| Ok "/" |}]; () ;; @@ -30,38 +39,51 @@ let%expect_test "v" = let%expect_test "of_fpath" = let test_fpath f = let t = Absolute_path.of_fpath f in - if Option.is_none t then print_s [%sexp "not an absolute path"]; + if Option.is_none t then print_endline "Not an absolute path."; Option.iter t ~f:(fun t -> print_endline (Absolute_path.to_string t); let f' = Absolute_path.to_fpath t in if Fpath.equal f f' - then print_s [%sexp "does roundtrip", { f : Fpath.t }] - else print_s [%sexp "does not roundtrip", { f : Fpath.t; f' : Fpath.t }]) + then + print_dyn + (Dyn.Tuple + [ String "Does roundtrip."; Record [ "f", String (f |> Fpath.to_string) ] ]) + else + print_dyn + (Dyn.Tuple + [ String "Does not roundtrip." + ; Record + [ "f", String (f |> Fpath.to_string) + ; "f'", String (f' |> Fpath.to_string) + ] + ])) in test_fpath (Fpath.v "/foo/bar"); [%expect {| /foo/bar - ("does roundtrip" ((f /foo/bar))) |}]; + ("Does roundtrip.", { f = "/foo/bar" }) + |}]; test_fpath (Fpath.v "/foo/bar/"); [%expect {| - /foo/bar/ - ("does roundtrip" ((f /foo/bar/))) |}]; + /foo/bar/ + ("Does roundtrip.", { f = "/foo/bar/" }) + |}]; test_fpath (Fpath.v "/"); [%expect {| / - ("does roundtrip" ((f /))) |}]; + ("Does roundtrip.", { f = "/" }) + |}]; test_fpath (Fpath.v "/."); [%expect {| - / - ("does not roundtrip" ( - (f /.) - (f' /))) |}]; + / + ("Does not roundtrip.", { f = "/."; f' = "/" }) + |}]; test_fpath (Fpath.v "a/relative/path"); - [%expect {| "not an absolute path" |}]; + [%expect {| Not an absolute path. |}]; require_does_raise [%here] (fun () -> Fpath.v ""); [%expect {| (Invalid_argument "\"\": invalid path") |}]; () @@ -70,7 +92,7 @@ let%expect_test "of_fpath" = let%expect_test "append" = let abs = Absolute_path.v in let rel = Relative_path.v in - let test a b = print_s [%sexp (Absolute_path.append a b : Absolute_path.t)] in + let test a b = print_endline (Absolute_path.append a b |> Absolute_path.to_string) in test (abs "/a") (rel "b"); [%expect {| /a/b |}]; test (abs "/a") (rel "b/"); @@ -116,7 +138,7 @@ let%expect_test "append - cannot escape base path" = This test demonstrates that append cannot escape the base path. *) let abs = Absolute_path.v in let rel = Relative_path.v in - let test a b = print_s [%sexp (Absolute_path.append a b : Absolute_path.t)] in + let test a b = print_endline (Absolute_path.append a b |> Absolute_path.to_string) in (* Appending a simple path stays below base. *) test (abs "/foo/bar") (rel "baz"); [%expect {| /foo/bar/baz |}]; @@ -171,7 +193,7 @@ let%expect_test "append - v0.4.0 improvement" = let%expect_test "extend" = let abs = Absolute_path.v in let file str = str |> Fsegment.v in - let test a b = print_s [%sexp (Absolute_path.extend a b : Absolute_path.t)] in + let test a b = print_endline (Absolute_path.extend a b |> Absolute_path.to_string) in require_does_raise [%here] (fun () : Fsegment.t -> file "a/b"); [%expect {| (Invalid_argument "Fsegment.v: invalid file segment \"a/b\"") |}]; require_does_not_raise [%here] (fun () -> ignore (file ".." : Fsegment.t)); @@ -203,20 +225,20 @@ let%expect_test "parent" = let abs = Absolute_path.v in let test path = let result = Absolute_path.parent path in - print_s [%sexp (result : Absolute_path.t option)] + print_dyn (Dyn.option (fun s -> Dyn.string (s |> Absolute_path.to_string)) result) in test (abs "/foo/bar"); - [%expect {| (/foo/) |}]; + [%expect {| Some "/foo/" |}]; test (abs "/foo/bar/"); - [%expect {| (/foo/) |}]; + [%expect {| Some "/foo/" |}]; test (abs "/foo/bar/../baz/../foo/"); - [%expect {| (/foo/) |}]; + [%expect {| Some "/foo/" |}]; test (abs "/foo"); - [%expect {| (/) |}]; + [%expect {| Some "/" |}]; test (abs "/"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/."); - [%expect {| () |}]; + [%expect {| None |}]; () ;; @@ -224,62 +246,62 @@ let%expect_test "chop_prefix" = let abs = Absolute_path.v in let test prefix path = let result = Absolute_path.chop_prefix path ~prefix in - print_s [%sexp (result : Relative_path.t option)] + print_dyn (Dyn.option (fun s -> Dyn.string (s |> Relative_path.to_string)) result) in test (abs "/foo") (abs "/foo/bar"); - [%expect {| (bar) |}]; + [%expect {| Some "bar" |}]; test (abs "/foo/") (abs "/foo/bar"); - [%expect {| (bar) |}]; + [%expect {| Some "bar" |}]; test (abs "/foo") (abs "/foo/bar/"); - [%expect {| (bar/) |}]; + [%expect {| Some "bar/" |}]; test (abs "/foo/") (abs "/foo/bar/"); - [%expect {| (bar/) |}]; + [%expect {| Some "bar/" |}]; test (abs "/foo/") (abs "/foo/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (abs "/foo") (abs "/foo/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (abs "/foo") (abs "/foo"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (abs "/foo/") (abs "/foo"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/.") (abs "/foo/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (abs "/foo/.") (abs "/foo"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/") (abs "/foo/."); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (abs "/foo") (abs "/foo/."); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (abs "/foo/bar/") (abs "/foo/bar/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (abs "/foo/bar") (abs "/foo/bar/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (abs "/foo/bar") (abs "/foo/bar"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (abs "/foo/bar/") (abs "/foo/bar"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo") (abs "/foo/bar/baz"); - [%expect {| (bar/baz) |}]; + [%expect {| Some "bar/baz" |}]; test (abs "/foo") (abs "/bar/baz"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/bar") (abs "/foo"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/bar") (abs "/foo/bar/baz"); - [%expect {| (baz) |}]; + [%expect {| Some "baz" |}]; test (abs "/foo/bar") (abs "/foo/bar/baz/qux"); - [%expect {| (baz/qux) |}]; + [%expect {| Some "baz/qux" |}]; (* Paths are normalized before the function call. *) test (abs "/foo/bar") (abs "/foo/bar/../baz"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/bar") (abs "/foo/sna/../bar/baz"); - [%expect {| (baz) |}]; + [%expect {| Some "baz" |}]; (* Beware of string prefix vs path prefix. *) test (abs "/foo/bar") (abs "/foo/bar-baz"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/") (abs "/foo/bar/baz"); - [%expect {| (foo/bar/baz) |}]; + [%expect {| Some "foo/bar/baz" |}]; test (abs "/") (abs "/foo/bar/baz/"); - [%expect {| (foo/bar/baz/) |}]; + [%expect {| Some "foo/bar/baz/" |}]; () ;; @@ -288,57 +310,57 @@ let%expect_test "chop_suffix" = let rel = Relative_path.v in let test path suffix = let result = Absolute_path.chop_suffix path ~suffix in - print_s [%sexp (result : Absolute_path.t option)] + print_dyn (Dyn.option (fun s -> Dyn.string (s |> Absolute_path.to_string)) result) in test (abs "/foo/bar") (rel "bar"); - [%expect {| (/foo/) |}]; + [%expect {| Some "/foo/" |}]; test (abs "/foo/bar") (rel "bar/"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/bar/") (rel "bar"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/bar/") (rel "bar/"); - [%expect {| (/foo/) |}]; + [%expect {| Some "/foo/" |}]; test (abs "/foo/bar") (rel "."); - [%expect {| (/foo/bar) |}]; + [%expect {| Some "/foo/bar" |}]; test (abs "/foo/bar/") (rel "."); - [%expect {| (/foo/bar/) |}]; + [%expect {| Some "/foo/bar/" |}]; test (abs "/foo/bar/.") (rel "."); - [%expect {| (/foo/bar/) |}]; + [%expect {| Some "/foo/bar/" |}]; test (abs "/bar") (rel "foo/bar"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/bar") (rel "foo/bar"); - [%expect {| (/) |}]; + [%expect {| Some "/" |}]; test (abs "/foo/bar") (rel "bar/"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/bar/") (rel "bar"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/bar/") (rel "bar/"); - [%expect {| (/foo/) |}]; + [%expect {| Some "/foo/" |}]; test (abs "/foo/bar") (rel "baz"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/bar/baz") (rel "bar/baz"); - [%expect {| (/foo/) |}]; + [%expect {| Some "/foo/" |}]; test (abs "/foo/bar/baz") (rel "baz/qux"); - [%expect {| () |}]; + [%expect {| None |}]; test (abs "/foo/bar/baz") (rel "."); - [%expect {| (/foo/bar/baz) |}]; + [%expect {| Some "/foo/bar/baz" |}]; test (abs "/foo/bar/baz/") (rel "."); - [%expect {| (/foo/bar/baz/) |}]; + [%expect {| Some "/foo/bar/baz/" |}]; test (abs "/foo/bar/baz") (rel "./"); - [%expect {| (/foo/bar/baz) |}]; + [%expect {| Some "/foo/bar/baz" |}]; test (abs "/foo/bar/baz/") (rel "./"); - [%expect {| (/foo/bar/baz/) |}]; + [%expect {| Some "/foo/bar/baz/" |}]; test (abs "/foo/bar/baz") (rel "foo/../baz"); - [%expect {| (/foo/bar/) |}]; + [%expect {| Some "/foo/bar/" |}]; (* Beware of string suffix vs path suffix. *) test (abs "/foo/bar-baz") (rel "-baz"); - [%expect {| () |}]; + [%expect {| None |}]; () ;; let%expect_test "is_dir_path" = let abs = Absolute_path.v in - let test path = print_s [%sexp (Absolute_path.is_dir_path (abs path) : bool)] in + let test path = print_dyn (Absolute_path.is_dir_path (abs path) |> Dyn.bool) in test "/foo/bar"; [%expect {| false |}]; test "/foo/bar/"; @@ -357,7 +379,7 @@ let%expect_test "is_dir_path" = let%expect_test "to_dir_path" = let abs = Absolute_path.v in let test path = - print_s [%sexp (Absolute_path.to_dir_path (abs path) : Absolute_path.t)] + print_endline (Absolute_path.to_dir_path (abs path) |> Absolute_path.to_string) in test "/foo/bar"; [%expect {| /foo/bar/ |}]; @@ -379,22 +401,29 @@ let%expect_test "rem_empty_seg" = let is_dir_path = Absolute_path.is_dir_path path in let path2 = Absolute_path.rem_empty_seg path in let is_dir_path2 = Absolute_path.is_dir_path path2 in - print_s - [%sexp - { path : Absolute_path.t; is_dir_path : bool } - , { path2 : Absolute_path.t; is_dir_path2 : bool }] + print_dyn + (Dyn.Tuple + [ Record + [ "path", path |> Absolute_path.to_string |> Dyn.string + ; "is_dir_path", is_dir_path |> Dyn.bool + ] + ; Record + [ "path2", path2 |> Absolute_path.to_string |> Dyn.string + ; "is_dir_path2", is_dir_path2 |> Dyn.bool + ] + ]) in test (Absolute_path.v "/tmp/my-dir/"); [%expect {| - (((path /tmp/my-dir/) (is_dir_path true)) - ((path2 /tmp/my-dir) (is_dir_path2 false))) + ({ path = "/tmp/my-dir/"; is_dir_path = true }, + { path2 = "/tmp/my-dir"; is_dir_path2 = false }) |}]; test (Absolute_path.v "/tmp/my-file"); [%expect {| - (((path /tmp/my-file) (is_dir_path false)) - ((path2 /tmp/my-file) (is_dir_path2 false))) + ({ path = "/tmp/my-file"; is_dir_path = false }, + { path2 = "/tmp/my-file"; is_dir_path2 = false }) |}]; () ;; @@ -418,11 +447,16 @@ let%expect_test "relativize" = () ;; +let hashtbl_to_dyn key value table = + let data = Hashtbl.to_alist table in + Dyn.Map (List.map data ~f:(fun (k, v) -> key k, value v)) +;; + let%expect_test "hashtbl" = let t = Hashtbl.create (module Absolute_path) in Hashtbl.set t ~key:(Absolute_path.v "/tmp/my-file") ~data:42; - print_s [%sexp (t : int Hashtbl.M(Absolute_path).t)]; - [%expect {| ((/tmp/my-file 42)) |}] + print_dyn (hashtbl_to_dyn (fun p -> Dyn.string (Absolute_path.to_string p)) Dyn.int t); + [%expect {| map { "/tmp/my-file" : 42 } |}] ;; module Pair = struct @@ -433,6 +467,13 @@ module Pair = struct ; b : Absolute_path.t } [@@deriving compare, hash, sexp_of] + + let to_dyn { a; b } = + Dyn.Record + [ "a", a |> Absolute_path.to_string |> Dyn.string + ; "b", b |> Absolute_path.to_string |> Dyn.string + ] + ;; end let%expect_test "hash-fold-t" = @@ -441,12 +482,6 @@ let%expect_test "hash-fold-t" = t ~key:{ a = Absolute_path.v "/tmp/a"; b = Absolute_path.v "/tmp/a" } ~data:42; - print_s [%sexp (t : int Hashtbl.M(Pair).t)]; - [%expect - {| - (( - ((a /tmp/a) - (b /tmp/a)) - 42)) - |}] + print_dyn (hashtbl_to_dyn Pair.to_dyn Dyn.int t); + [%expect {| map { { a = "/tmp/a"; b = "/tmp/a" } : 42 } |}] ;; diff --git a/test/fpath-base/test__fpath.ml b/test/fpath-base/test__fpath.ml index 5b6e978..6830435 100644 --- a/test/fpath-base/test__fpath.ml +++ b/test/fpath-base/test__fpath.ml @@ -4,11 +4,23 @@ (* SPDX-License-Identifier: MIT *) (*********************************************************************************) +let%expect_test "sexp_of_t" = + print_endline + (Sexplib0.Sexp.to_string_hum (Fpath.sexp_of_t (Fpath.v "hello/path/to/sexp"))); + [%expect {| hello/path/to/sexp |}]; + () +;; + +let hashtbl_to_dyn key value table = + let data = Hashtbl.to_alist table in + Dyn.Map (List.map data ~f:(fun (k, v) -> key k, value v)) +;; + let%expect_test "hashtbl" = let t = Hashtbl.create (module Fpath) in Hashtbl.set t ~key:(Fpath.v "my-file") ~data:42; - print_s [%sexp (t : int Hashtbl.M(Fpath).t)]; - [%expect {| ((my-file 42)) |}] + print_dyn (hashtbl_to_dyn (fun p -> Dyn.string (Fpath.to_string p)) Dyn.int t); + [%expect {| map { "my-file" : 42 } |}] ;; module Fpath_pair : sig @@ -17,113 +29,97 @@ module Fpath_pair : sig ; b : Fpath.t } [@@deriving compare, hash, sexp_of] + + val to_dyn : t -> Dyn.t end = struct - type t = - { a : Fpath.t - ; b : Fpath.t - } - [@@deriving compare, hash, sexp_of] + include struct + [@@@coverage off] + + type t = + { a : Fpath.t + ; b : Fpath.t + } + [@@deriving compare, hash, sexp_of] + end + + let to_dyn { a; b } = + Dyn.Record + [ "a", a |> Fpath.to_string |> Dyn.string; "b", b |> Fpath.to_string |> Dyn.string ] + ;; end let%expect_test "compare" = let test a b = - print_s - [%sexp - (a : Fpath_pair.t) - , (Fpath_pair.compare a b |> Ordering.of_int : Ordering.t) - , (b : Fpath_pair.t)] + print_dyn + (Dyn.Tuple + [ a |> Fpath_pair.to_dyn + ; Fpath_pair.compare a b |> Ordering.of_int |> Ordering.to_dyn + ; b |> Fpath_pair.to_dyn + ]) in test { a = Fpath.v "file-a"; b = Fpath.v "file-b" } { a = Fpath.v "file-a"; b = Fpath.v "file-b" }; - [%expect - {| - (((a file-a) - (b file-b)) - Equal - ((a file-a) - (b file-b))) |}]; + [%expect {| ({ a = "file-a"; b = "file-b" }, Eq, { a = "file-a"; b = "file-b" }) |}]; let t = { Fpath_pair.a = Fpath.v "file-a"; b = Fpath.v "file-b" } in test t t; - [%expect - {| - (((a file-a) - (b file-b)) - Equal - ((a file-a) - (b file-b))) |}]; + [%expect {| ({ a = "file-a"; b = "file-b" }, Eq, { a = "file-a"; b = "file-b" }) |}]; test { a = Fpath.v "file-a"; b = Fpath.v "file-a" } { a = Fpath.v "file-a"; b = Fpath.v "file-b" }; - [%expect - {| - (((a file-a) - (b file-a)) - Less - ((a file-a) - (b file-b))) |}]; + [%expect {| ({ a = "file-a"; b = "file-a" }, Lt, { a = "file-a"; b = "file-b" }) |}]; test { a = Fpath.v "file-b"; b = Fpath.v "file-a" } { a = Fpath.v "file-a"; b = Fpath.v "file-b" }; - [%expect - {| - (((a file-b) - (b file-a)) - Greater - ((a file-a) - (b file-b))) |}]; + [%expect {| ({ a = "file-b"; b = "file-a" }, Gt, { a = "file-a"; b = "file-b" }) |}]; () ;; let%expect_test "hashtbl2" = let t = Hashtbl.create (module Fpath_pair) in Hashtbl.set t ~key:{ Fpath_pair.a = Fpath.v "file-a"; b = Fpath.v "file-b" } ~data:42; - print_s [%sexp (t : int Hashtbl.M(Fpath_pair).t)]; - [%expect - {| - (( - ((a file-a) - (b file-b)) - 42)) |}] + print_dyn (hashtbl_to_dyn Fpath_pair.to_dyn Dyn.int t); + [%expect {| map { { a = "file-a"; b = "file-b" } : 42 } |}] ;; let%expect_test "classify" = let test str = - print_s - [%sexp - (Fpath.classify (Fpath.v str) - : [ `Absolute of Absolute_path.t | `Relative of Relative_path.t ])] + match Fpath.classify (Fpath.v str) with + | `Absolute path -> + print_dyn (Dyn.Variant ("Absolute", [ Dyn.String (Absolute_path.to_string path) ])) + | `Relative path -> + print_dyn (Dyn.Variant ("Relative", [ Dyn.String (Relative_path.to_string path) ])) in test "foo/bar"; - [%expect {| (Relative foo/bar) |}]; + [%expect {| Relative "foo/bar" |}]; test "foo/bar/"; - [%expect {| (Relative foo/bar/) |}]; + [%expect {| Relative "foo/bar/" |}]; test "foo/bar/../baz/../foo/"; - [%expect {| (Relative foo/foo/) |}]; + [%expect {| Relative "foo/foo/" |}]; test "foo"; - [%expect {| (Relative foo) |}]; + [%expect {| Relative "foo" |}]; test "./"; - [%expect {| (Relative ./) |}]; + [%expect {| Relative "./" |}]; test "/foo/bar"; - [%expect {| (Absolute /foo/bar) |}]; + [%expect {| Absolute "/foo/bar" |}]; test "/foo/bar/"; - [%expect {| (Absolute /foo/bar/) |}]; + [%expect {| Absolute "/foo/bar/" |}]; test "/foo/bar/../baz/../foo/"; - [%expect {| (Absolute /foo/foo/) |}]; + [%expect {| Absolute "/foo/foo/" |}]; test "/foo"; - [%expect {| (Absolute /foo) |}]; + [%expect {| Absolute "/foo" |}]; test "/"; - [%expect {| (Absolute /) |}]; + [%expect {| Absolute "/" |}]; test "/."; - [%expect {| (Absolute /) |}]; + [%expect {| Absolute "/" |}]; test "."; - [%expect {| (Relative ./) |}]; + [%expect {| Relative "./" |}]; test "./"; - [%expect {| (Relative ./) |}]; + [%expect {| Relative "./" |}]; test "/a/b/../../../.."; - [%expect {| (Absolute /) |}]; + [%expect {| Absolute "/" |}]; test "/a/b/../../../../foo/"; - [%expect {| (Absolute /foo/) |}]; + [%expect {| Absolute "/foo/" |}]; require_does_raise [%here] (fun () -> test "a/b/../../../.."); [%expect {| @@ -146,27 +142,33 @@ let%expect_test "chop_prefix and chop_suffix" = ~f:(fun (a, b) -> match Fpath.classify a, Fpath.classify b with | `Absolute a, `Absolute b -> - print_s - [%sexp - (a : Absolute_path.t) - , (b : Absolute_path.t) - , "==> chop_prefix" - , (Absolute_path.chop_prefix b ~prefix:a : Relative_path.t option)] + print_dyn + (Dyn.Tuple + [ a |> Absolute_path.to_string |> Dyn.string + ; b |> Absolute_path.to_string |> Dyn.string + ; String "==> chop_prefix" + ; Absolute_path.chop_prefix b ~prefix:a + |> Dyn.option (fun s -> Dyn.string (Relative_path.to_string s)) + ]) | `Relative _, `Absolute _ -> assert false | `Absolute a, `Relative b -> - print_s - [%sexp - (a : Absolute_path.t) - , (b : Relative_path.t) - , "==> chop_suffix" - , (Absolute_path.chop_suffix a ~suffix:b : Absolute_path.t option)] + print_dyn + (Dyn.Tuple + [ a |> Absolute_path.to_string |> Dyn.string + ; b |> Relative_path.to_string |> Dyn.string + ; String "==> chop_suffix" + ; Absolute_path.chop_suffix a ~suffix:b + |> Dyn.option (fun s -> Dyn.string (Absolute_path.to_string s)) + ]) | `Relative a, `Relative b -> - print_s - [%sexp - (a : Relative_path.t) - , (b : Relative_path.t) - , "==> chop_prefix" - , (Relative_path.chop_prefix b ~prefix:a : Relative_path.t option)])) + print_dyn + (Dyn.Tuple + [ a |> Relative_path.to_string |> Dyn.string + ; b |> Relative_path.to_string |> Dyn.string + ; String "==> chop_prefix" + ; Relative_path.chop_prefix b ~prefix:a + |> Dyn.option (fun s -> Dyn.string (Relative_path.to_string s)) + ]))) [ "/", "." ; "/", "a" ; "/a", "a" @@ -192,94 +194,94 @@ let%expect_test "chop_prefix and chop_suffix" = ]; [%expect {| - (/ ./ "==> chop_suffix" (/)) - (/ ./ "==> chop_suffix" (/)) - (/ ./ "==> chop_suffix" (/)) - (/ ./ "==> chop_suffix" (/)) - (/ a "==> chop_suffix" ()) - (/ a "==> chop_suffix" ()) - (/ a/ "==> chop_suffix" ()) - (/ a/ "==> chop_suffix" ()) - (/a a "==> chop_suffix" (/)) - (/a/ a "==> chop_suffix" ()) - (/a a/ "==> chop_suffix" ()) - (/a/ a/ "==> chop_suffix" (/)) - (/a b "==> chop_suffix" ()) - (/a/ b "==> chop_suffix" ()) - (/a b/ "==> chop_suffix" ()) - (/a/ b/ "==> chop_suffix" ()) - (/a/b b "==> chop_suffix" (/a/)) - (/a/b/ b "==> chop_suffix" ()) - (/a/b b/ "==> chop_suffix" ()) - (/a/b/ b/ "==> chop_suffix" (/a/)) - (/a/b a/b "==> chop_suffix" (/)) - (/a/b/ a/b "==> chop_suffix" ()) - (/a/b a/b/ "==> chop_suffix" ()) - (/a/b/ a/b/ "==> chop_suffix" (/)) - (/ / "==> chop_prefix" (./)) - (/ / "==> chop_prefix" (./)) - (/ / "==> chop_prefix" (./)) - (/ / "==> chop_prefix" (./)) - (/ /a "==> chop_prefix" (a)) - (/ /a "==> chop_prefix" (a)) - (/ /a/ "==> chop_prefix" (a/)) - (/ /a/ "==> chop_prefix" (a/)) - (/a / "==> chop_prefix" ()) - (/a/ / "==> chop_prefix" ()) - (/a / "==> chop_prefix" ()) - (/a/ / "==> chop_prefix" ()) - (/a/b /a/b/c "==> chop_prefix" (c)) - (/a/b/ /a/b/c "==> chop_prefix" (c)) - (/a/b /a/b/c/ "==> chop_prefix" (c/)) - (/a/b/ /a/b/c/ "==> chop_prefix" (c/)) - (/a/b /a/bc "==> chop_prefix" ()) - (/a/b/ /a/bc "==> chop_prefix" ()) - (/a/b /a/bc/ "==> chop_prefix" ()) - (/a/b/ /a/bc/ "==> chop_prefix" ()) - (/a/b /a/b/c/d "==> chop_prefix" (c/d)) - (/a/b/ /a/b/c/d "==> chop_prefix" (c/d)) - (/a/b /a/b/c/d/ "==> chop_prefix" (c/d/)) - (/a/b/ /a/b/c/d/ "==> chop_prefix" (c/d/)) - (/a/b/c /a/b/c "==> chop_prefix" (./)) - (/a/b/c/ /a/b/c "==> chop_prefix" ()) - (/a/b/c /a/b/c/ "==> chop_prefix" (./)) - (/a/b/c/ /a/b/c/ "==> chop_prefix" (./)) - (/a/b/c /a/b "==> chop_prefix" ()) - (/a/b/c/ /a/b "==> chop_prefix" ()) - (/a/b/c /a/b/ "==> chop_prefix" ()) - (/a/b/c/ /a/b/ "==> chop_prefix" ()) - (./ ./ "==> chop_prefix" (./)) - (./ ./ "==> chop_prefix" (./)) - (./ ./ "==> chop_prefix" (./)) - (./ ./ "==> chop_prefix" (./)) - (./ a "==> chop_prefix" (a)) - (./ a "==> chop_prefix" (a)) - (./ a/ "==> chop_prefix" (a/)) - (./ a/ "==> chop_prefix" (a/)) - (a ./ "==> chop_prefix" ()) - (a/ ./ "==> chop_prefix" ()) - (a ./ "==> chop_prefix" ()) - (a/ ./ "==> chop_prefix" ()) - (a/b a/b/c "==> chop_prefix" (c)) - (a/b/ a/b/c "==> chop_prefix" (c)) - (a/b a/b/c/ "==> chop_prefix" (c/)) - (a/b/ a/b/c/ "==> chop_prefix" (c/)) - (a/b a/bc "==> chop_prefix" ()) - (a/b/ a/bc "==> chop_prefix" ()) - (a/b a/bc/ "==> chop_prefix" ()) - (a/b/ a/bc/ "==> chop_prefix" ()) - (a/b a/b/c/d "==> chop_prefix" (c/d)) - (a/b/ a/b/c/d "==> chop_prefix" (c/d)) - (a/b a/b/c/d/ "==> chop_prefix" (c/d/)) - (a/b/ a/b/c/d/ "==> chop_prefix" (c/d/)) - (a/b/c a/b/c "==> chop_prefix" (./)) - (a/b/c/ a/b/c "==> chop_prefix" ()) - (a/b/c a/b/c/ "==> chop_prefix" (./)) - (a/b/c/ a/b/c/ "==> chop_prefix" (./)) - (a/b/c a/b "==> chop_prefix" ()) - (a/b/c/ a/b "==> chop_prefix" ()) - (a/b/c a/b/ "==> chop_prefix" ()) - (a/b/c/ a/b/ "==> chop_prefix" ()) + ("/", "./", "==> chop_suffix", Some "/") + ("/", "./", "==> chop_suffix", Some "/") + ("/", "./", "==> chop_suffix", Some "/") + ("/", "./", "==> chop_suffix", Some "/") + ("/", "a", "==> chop_suffix", None) + ("/", "a", "==> chop_suffix", None) + ("/", "a/", "==> chop_suffix", None) + ("/", "a/", "==> chop_suffix", None) + ("/a", "a", "==> chop_suffix", Some "/") + ("/a/", "a", "==> chop_suffix", None) + ("/a", "a/", "==> chop_suffix", None) + ("/a/", "a/", "==> chop_suffix", Some "/") + ("/a", "b", "==> chop_suffix", None) + ("/a/", "b", "==> chop_suffix", None) + ("/a", "b/", "==> chop_suffix", None) + ("/a/", "b/", "==> chop_suffix", None) + ("/a/b", "b", "==> chop_suffix", Some "/a/") + ("/a/b/", "b", "==> chop_suffix", None) + ("/a/b", "b/", "==> chop_suffix", None) + ("/a/b/", "b/", "==> chop_suffix", Some "/a/") + ("/a/b", "a/b", "==> chop_suffix", Some "/") + ("/a/b/", "a/b", "==> chop_suffix", None) + ("/a/b", "a/b/", "==> chop_suffix", None) + ("/a/b/", "a/b/", "==> chop_suffix", Some "/") + ("/", "/", "==> chop_prefix", Some "./") + ("/", "/", "==> chop_prefix", Some "./") + ("/", "/", "==> chop_prefix", Some "./") + ("/", "/", "==> chop_prefix", Some "./") + ("/", "/a", "==> chop_prefix", Some "a") + ("/", "/a", "==> chop_prefix", Some "a") + ("/", "/a/", "==> chop_prefix", Some "a/") + ("/", "/a/", "==> chop_prefix", Some "a/") + ("/a", "/", "==> chop_prefix", None) + ("/a/", "/", "==> chop_prefix", None) + ("/a", "/", "==> chop_prefix", None) + ("/a/", "/", "==> chop_prefix", None) + ("/a/b", "/a/b/c", "==> chop_prefix", Some "c") + ("/a/b/", "/a/b/c", "==> chop_prefix", Some "c") + ("/a/b", "/a/b/c/", "==> chop_prefix", Some "c/") + ("/a/b/", "/a/b/c/", "==> chop_prefix", Some "c/") + ("/a/b", "/a/bc", "==> chop_prefix", None) + ("/a/b/", "/a/bc", "==> chop_prefix", None) + ("/a/b", "/a/bc/", "==> chop_prefix", None) + ("/a/b/", "/a/bc/", "==> chop_prefix", None) + ("/a/b", "/a/b/c/d", "==> chop_prefix", Some "c/d") + ("/a/b/", "/a/b/c/d", "==> chop_prefix", Some "c/d") + ("/a/b", "/a/b/c/d/", "==> chop_prefix", Some "c/d/") + ("/a/b/", "/a/b/c/d/", "==> chop_prefix", Some "c/d/") + ("/a/b/c", "/a/b/c", "==> chop_prefix", Some "./") + ("/a/b/c/", "/a/b/c", "==> chop_prefix", None) + ("/a/b/c", "/a/b/c/", "==> chop_prefix", Some "./") + ("/a/b/c/", "/a/b/c/", "==> chop_prefix", Some "./") + ("/a/b/c", "/a/b", "==> chop_prefix", None) + ("/a/b/c/", "/a/b", "==> chop_prefix", None) + ("/a/b/c", "/a/b/", "==> chop_prefix", None) + ("/a/b/c/", "/a/b/", "==> chop_prefix", None) + ("./", "./", "==> chop_prefix", Some "./") + ("./", "./", "==> chop_prefix", Some "./") + ("./", "./", "==> chop_prefix", Some "./") + ("./", "./", "==> chop_prefix", Some "./") + ("./", "a", "==> chop_prefix", Some "a") + ("./", "a", "==> chop_prefix", Some "a") + ("./", "a/", "==> chop_prefix", Some "a/") + ("./", "a/", "==> chop_prefix", Some "a/") + ("a", "./", "==> chop_prefix", None) + ("a/", "./", "==> chop_prefix", None) + ("a", "./", "==> chop_prefix", None) + ("a/", "./", "==> chop_prefix", None) + ("a/b", "a/b/c", "==> chop_prefix", Some "c") + ("a/b/", "a/b/c", "==> chop_prefix", Some "c") + ("a/b", "a/b/c/", "==> chop_prefix", Some "c/") + ("a/b/", "a/b/c/", "==> chop_prefix", Some "c/") + ("a/b", "a/bc", "==> chop_prefix", None) + ("a/b/", "a/bc", "==> chop_prefix", None) + ("a/b", "a/bc/", "==> chop_prefix", None) + ("a/b/", "a/bc/", "==> chop_prefix", None) + ("a/b", "a/b/c/d", "==> chop_prefix", Some "c/d") + ("a/b/", "a/b/c/d", "==> chop_prefix", Some "c/d") + ("a/b", "a/b/c/d/", "==> chop_prefix", Some "c/d/") + ("a/b/", "a/b/c/d/", "==> chop_prefix", Some "c/d/") + ("a/b/c", "a/b/c", "==> chop_prefix", Some "./") + ("a/b/c/", "a/b/c", "==> chop_prefix", None) + ("a/b/c", "a/b/c/", "==> chop_prefix", Some "./") + ("a/b/c/", "a/b/c/", "==> chop_prefix", Some "./") + ("a/b/c", "a/b", "==> chop_prefix", None) + ("a/b/c/", "a/b", "==> chop_prefix", None) + ("a/b/c", "a/b/", "==> chop_prefix", None) + ("a/b/c/", "a/b/", "==> chop_prefix", None) |}]; () ;; diff --git a/test/fpath-base/test__fsegment.ml b/test/fpath-base/test__fsegment.ml index 1e54588..15bcf88 100644 --- a/test/fpath-base/test__fsegment.ml +++ b/test/fpath-base/test__fsegment.ml @@ -4,24 +4,34 @@ (* SPDX-License-Identifier: MIT *) (*********************************************************************************) +let%expect_test "sexp_of_t" = + print_endline + (Sexplib0.Sexp.to_string_hum (Fsegment.sexp_of_t (Fsegment.v "hello-segment"))); + [%expect {| hello-segment |}]; + () +;; + let%expect_test "of_string" = let test str = - print_s [%sexp (Fsegment.of_string str : (Fsegment.t, [ `Msg of string ]) Result.t)] + print_dyn + (or_msg_to_dyn + (fun p -> Dyn.string (Fsegment.to_string p)) + (Fsegment.of_string str)) in test ""; - [%expect {| (Error (Msg "invalid file segment \"\"")) |}]; + [%expect {| Error (Msg "invalid file segment \"\"") |}]; test "a"; - [%expect {| (Ok a) |}]; + [%expect {| Ok "a" |}]; test ".a"; - [%expect {| (Ok .a) |}]; + [%expect {| Ok ".a" |}]; test ".."; - [%expect {| (Ok ..) |}]; + [%expect {| Ok ".." |}]; test "/"; - [%expect {| (Error (Msg "invalid file segment \"/\"")) |}]; + [%expect {| Error (Msg "invalid file segment \"/\"") |}]; test "a/b"; - [%expect {| (Error (Msg "invalid file segment \"a/b\"")) |}]; + [%expect {| Error (Msg "invalid file segment \"a/b\"") |}]; test "a\000b"; - [%expect {| (Error (Msg "invalid file segment \"a\\000b\"")) |}]; + [%expect {| Error (Msg "invalid file segment \"a\\000b\"") |}]; () ;; @@ -39,11 +49,16 @@ let%expect_test "hard coded" = () ;; +let hashtbl_to_dyn key value table = + let data = Hashtbl.to_alist table in + Dyn.Map (List.map data ~f:(fun (k, v) -> key k, value v)) +;; + let%expect_test "hashtbl" = let t = Hashtbl.create (module Fsegment) in Hashtbl.set t ~key:(Fsegment.v "my-file") ~data:42; - print_s [%sexp (t : int Hashtbl.M(Fsegment).t)]; - [%expect {| ((my-file 42)) |}] + print_dyn (hashtbl_to_dyn (fun p -> Dyn.string (Fsegment.to_string p)) Dyn.int t); + [%expect {| map { "my-file" : 42 } |}] ;; module Pair = struct @@ -54,17 +69,18 @@ module Pair = struct ; b : Fsegment.t } [@@deriving compare, hash, sexp_of] + + let to_dyn { a; b } = + Dyn.Record + [ "a", a |> Fsegment.to_string |> Dyn.string + ; "b", b |> Fsegment.to_string |> Dyn.string + ] + ;; end let%expect_test "hash-fold-t" = let t = Hashtbl.create (module Pair) in Hashtbl.set t ~key:{ a = Fsegment.v "a"; b = Fsegment.v "b" } ~data:42; - print_s [%sexp (t : int Hashtbl.M(Pair).t)]; - [%expect - {| - (( - ((a a) - (b b)) - 42)) - |}] + print_dyn (hashtbl_to_dyn Pair.to_dyn Dyn.int t); + [%expect {| map { { a = "a"; b = "b" } : 42 } |}] ;; diff --git a/test/fpath-base/test__hash.ml b/test/fpath-base/test__hash.ml index 31b463d..da8f033 100644 --- a/test/fpath-base/test__hash.ml +++ b/test/fpath-base/test__hash.ml @@ -31,7 +31,7 @@ let%expect_test "hash" = let seg = Fsegment.v "file" in let h1 = Fpath_base.Fsegment.hash seg in let h2 = Fpath_sexp0.Fsegment.hash seg in - print_s [%sexp (h1 : int)]; + print_dyn (h1 |> Dyn.int); [%expect {| 437367475 |}]; require_equal [%here] (module Int) h1 h2; [%expect {||}]; @@ -42,15 +42,15 @@ let%expect_test "Fsegment.seeded_hash" = let seg = Fsegment.v "file" in let s0 = Fsegment.seeded_hash 0 seg in let s42 = Fsegment.seeded_hash 42 seg in - print_s [%sexp (s0 : int)]; + print_dyn (s0 |> Dyn.int); [%expect {| 437367475 |}]; - print_s [%sexp (s42 : int)]; + print_dyn (s42 |> Dyn.int); [%expect {| 202913284 |}]; let f0 = Fsegment.hash_fold_t (Hash.create ()) seg |> Hash.get_hash_value in let f42 = Fsegment.hash_fold_t (Hash.create ~seed:42 ()) seg |> Hash.get_hash_value in - print_s [%sexp (f0 : int)]; + print_dyn (f0 |> Dyn.int); [%expect {| 437367475 |}]; - print_s [%sexp (f42 : int)]; + print_dyn (f42 |> Dyn.int); [%expect {| 202913284 |}]; require_equal [%here] (module Int) s0 f0; require_equal [%here] (module Int) s42 f42; @@ -62,15 +62,15 @@ let%expect_test "Fpath.seeded_hash" = let path = Fpath.v "file" in let s0 = Fpath.seeded_hash 0 path in let s42 = Fpath.seeded_hash 42 path in - print_s [%sexp (s0 : int)]; + print_dyn (s0 |> Dyn.int); [%expect {| 437367475 |}]; - print_s [%sexp (s42 : int)]; + print_dyn (s42 |> Dyn.int); [%expect {| 202913284 |}]; let f0 = Fpath.hash_fold_t (Hash.create ()) path |> Hash.get_hash_value in let f42 = Fpath.hash_fold_t (Hash.create ~seed:42 ()) path |> Hash.get_hash_value in - print_s [%sexp (f0 : int)]; + print_dyn (f0 |> Dyn.int); [%expect {| 437367475 |}]; - print_s [%sexp (f42 : int)]; + print_dyn (f42 |> Dyn.int); [%expect {| 202913284 |}]; require_equal [%here] (module Int) s0 f0; require_equal [%here] (module Int) s42 f42; @@ -82,17 +82,17 @@ let%expect_test "Relative_path.seeded_hash" = let path = Relative_path.v "file" in let s0 = Relative_path.seeded_hash 0 path in let s42 = Relative_path.seeded_hash 42 path in - print_s [%sexp (s0 : int)]; + print_dyn (s0 |> Dyn.int); [%expect {| 437367475 |}]; - print_s [%sexp (s42 : int)]; + print_dyn (s42 |> Dyn.int); [%expect {| 202913284 |}]; let f0 = Relative_path.hash_fold_t (Hash.create ()) path |> Hash.get_hash_value in let f42 = Relative_path.hash_fold_t (Hash.create ~seed:42 ()) path |> Hash.get_hash_value in - print_s [%sexp (f0 : int)]; + print_dyn (f0 |> Dyn.int); [%expect {| 437367475 |}]; - print_s [%sexp (f42 : int)]; + print_dyn (f42 |> Dyn.int); [%expect {| 202913284 |}]; require_equal [%here] (module Int) s0 f0; require_equal [%here] (module Int) s42 f42; @@ -104,17 +104,17 @@ let%expect_test "Absolute_path.seeded_hash" = let path = Absolute_path.v "/tmp/my-file" in let s0 = Absolute_path.seeded_hash 0 path in let s42 = Absolute_path.seeded_hash 42 path in - print_s [%sexp (s0 : int)]; + print_dyn (s0 |> Dyn.int); [%expect {| 152999615 |}]; - print_s [%sexp (s42 : int)]; + print_dyn (s42 |> Dyn.int); [%expect {| 524647462 |}]; let f0 = Absolute_path.hash_fold_t (Hash.create ()) path |> Hash.get_hash_value in let f42 = Absolute_path.hash_fold_t (Hash.create ~seed:42 ()) path |> Hash.get_hash_value in - print_s [%sexp (f0 : int)]; + print_dyn (f0 |> Dyn.int); [%expect {| 152999615 |}]; - print_s [%sexp (f42 : int)]; + print_dyn (f42 |> Dyn.int); [%expect {| 524647462 |}]; require_equal [%here] (module Int) s0 f0; require_equal [%here] (module Int) s42 f42; diff --git a/test/fpath-base/test__relative_path.ml b/test/fpath-base/test__relative_path.ml index 7efd9d8..94b54c9 100644 --- a/test/fpath-base/test__relative_path.ml +++ b/test/fpath-base/test__relative_path.ml @@ -4,29 +4,38 @@ (* SPDX-License-Identifier: MIT *) (*********************************************************************************) +let%expect_test "sexp_of_t" = + print_endline + (Sexplib0.Sexp.to_string_hum + (Relative_path.sexp_of_t (Relative_path.v "hello/path/to/sexp"))); + [%expect {| hello/path/to/sexp |}]; + () +;; + let%expect_test "of_string" = let test str = - print_s - [%sexp - (Relative_path.of_string str : (Relative_path.t, [ `Msg of string ]) Result.t)] + print_dyn + (or_msg_to_dyn + (fun p -> Dyn.string (Relative_path.to_string p)) + (Relative_path.of_string str)) in test ""; - [%expect {| (Error (Msg "\"\": invalid path")) |}]; + [%expect {| Error (Msg "\"\": invalid path") |}]; test "."; - [%expect {| (Ok ./) |}]; + [%expect {| Ok "./" |}]; test "/a"; - [%expect {| (Error (Msg "\"/a\" is not a relative path")) |}]; + [%expect {| Error (Msg "\"/a\" is not a relative path") |}]; test "/a/../.."; - [%expect {| (Error (Msg "\"/a/../..\" is not a relative path")) |}]; + [%expect {| Error (Msg "\"/a/../..\" is not a relative path") |}]; test "a/b/../.."; - [%expect {| (Ok ./) |}]; + [%expect {| Ok "./" |}]; (* Paths that escape upward are rejected. *) test ".."; - [%expect {| (Error (Msg "path \"..\" escapes above starting point")) |}]; + [%expect {| Error (Msg "path \"..\" escapes above starting point") |}]; test "../a"; - [%expect {| (Error (Msg "path \"../a\" escapes above starting point")) |}]; + [%expect {| Error (Msg "path \"../a\" escapes above starting point") |}]; test "a/../.."; - [%expect {| (Error (Msg "path \"a/../..\" escapes above starting point")) |}]; + [%expect {| Error (Msg "path \"a/../..\" escapes above starting point") |}]; () ;; @@ -48,40 +57,53 @@ let%expect_test "v" = let%expect_test "of_fpath" = let test_fpath f = let t = Relative_path.of_fpath f in - if Option.is_none t then print_s [%sexp "not a relative path"]; + if Option.is_none t then print_endline "Not a relative path."; Option.iter t ~f:(fun t -> print_endline (Relative_path.to_string t); let f' = Relative_path.to_fpath t in if Fpath.equal f f' - then print_s [%sexp "does roundtrip", { f : Fpath.t }] - else print_s [%sexp "does not roundtrip", { f : Fpath.t; f' : Fpath.t }]) + then + print_dyn + (Dyn.Tuple + [ String "Does roundtrip."; Record [ "f", String (f |> Fpath.to_string) ] ]) + else + print_dyn + (Dyn.Tuple + [ String "Does not roundtrip." + ; Record + [ "f", String (f |> Fpath.to_string) + ; "f'", String (f' |> Fpath.to_string) + ] + ])) in test_fpath (Fpath.v "foo/bar"); [%expect {| foo/bar - ("does roundtrip" ((f foo/bar))) |}]; + ("Does roundtrip.", { f = "foo/bar" }) + |}]; test_fpath (Fpath.v "foo/bar/"); [%expect {| - foo/bar/ - ("does roundtrip" ((f foo/bar/))) |}]; + foo/bar/ + ("Does roundtrip.", { f = "foo/bar/" }) + |}]; test_fpath (Fpath.v "."); [%expect {| ./ - ("does not roundtrip" ( - (f .) - (f' ./))) |}]; + ("Does not roundtrip.", { f = "."; f' = "./" }) + |}]; test_fpath (Fpath.v "./"); [%expect {| - ./ - ("does roundtrip" ((f ./))) |}]; + ./ + ("Does roundtrip.", { f = "./" }) + |}]; test_fpath (Fpath.v "/an/absolute/path"); - [%expect {| "not a relative path" |}]; + [%expect {| Not a relative path. |}]; test_fpath (Fpath.v "/an/escaping/absolute/path/../../../../../.."); - [%expect {| "not a relative path" |}]; + [%expect {| Not a relative path. |}]; require_does_raise [%here] (fun () -> test_fpath (Fpath.v "an/../../escaping/path")); [%expect {| @@ -93,7 +115,7 @@ let%expect_test "of_fpath" = let%expect_test "append" = let rel = Relative_path.v in - let test a b = print_s [%sexp (Relative_path.append a b : Relative_path.t)] in + let test a b = print_endline (Relative_path.append a b |> Relative_path.to_string) in test Relative_path.empty Relative_path.empty; [%expect {| ./ |}]; test Relative_path.empty Relative_path.empty; @@ -130,7 +152,7 @@ let%expect_test "append" = let%expect_test "extend" = let rel = Relative_path.v in let file str = str |> Fsegment.v in - let test a b = print_s [%sexp (Relative_path.extend a b : Relative_path.t)] in + let test a b = print_endline (Relative_path.extend a b |> Relative_path.to_string) in require_does_raise [%here] (fun () : Fsegment.t -> file "a/b"); [%expect {| (Invalid_argument "Fsegment.v: invalid file segment \"a/b\"") |}]; require_does_not_raise [%here] (fun () -> ignore (file ".." : Fsegment.t)); @@ -176,17 +198,17 @@ let%expect_test "parent" = let rel = Relative_path.v in let test path = let result = Relative_path.parent path in - print_s [%sexp (result : Relative_path.t option)] + print_dyn (Dyn.option (fun s -> Dyn.string (s |> Relative_path.to_string)) result) in test (rel "foo/bar"); - [%expect {| (foo/) |}]; + [%expect {| Some "foo/" |}]; test (rel "foo/bar/"); - [%expect {| (foo/) |}]; + [%expect {| Some "foo/" |}]; test (rel "foo"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; (* Verify that parent of empty returns [None]. *) test Relative_path.empty; - [%expect {| () |}]; + [%expect {| None |}]; (* Be specific about the expectations here. *) require [%here] (Option.is_none (Relative_path.parent Relative_path.empty)); [%expect {||}]; @@ -196,7 +218,7 @@ let%expect_test "parent" = let%expect_test "of_list" = let test files = let result = Relative_path.of_list (List.map files ~f:Fsegment.v) in - print_s [%sexp (result : Relative_path.t)] + print_endline (result |> Relative_path.to_string) in test []; [%expect {| ./ |}]; @@ -238,83 +260,83 @@ let%expect_test "chop_prefix" = let rel = Relative_path.v in let test prefix path = let result = Relative_path.chop_prefix path ~prefix in - print_s [%sexp (result : Relative_path.t option)] + print_dyn (Dyn.option (fun s -> Dyn.string (s |> Relative_path.to_string)) result) in test (rel "foo") (rel "foo/bar"); - [%expect {| (bar) |}]; + [%expect {| Some "bar" |}]; test (rel "foo") (rel "foo/bar/"); - [%expect {| (bar/) |}]; + [%expect {| Some "bar/" |}]; test (rel "foo/") (rel "foo/bar"); - [%expect {| (bar) |}]; + [%expect {| Some "bar" |}]; test (rel "foo/") (rel "foo/bar/"); - [%expect {| (bar/) |}]; + [%expect {| Some "bar/" |}]; test (rel "foo/") (rel "foo/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (rel "foo") (rel "foo/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (rel "foo") (rel "foo"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (rel "foo/") (rel "foo"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/.") (rel "foo/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (rel "foo/.") (rel "foo"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/") (rel "foo/."); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (rel "foo") (rel "foo/."); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (rel "foo/bar/") (rel "foo/bar/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (rel "foo/bar") (rel "foo/bar/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (rel "foo/bar") (rel "foo/bar"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (rel "foo/bar/") (rel "foo/bar"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo") (rel "foo/bar/baz"); - [%expect {| (bar/baz) |}]; + [%expect {| Some "bar/baz" |}]; test (rel "foo") (rel "bar/baz"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar") (rel "foo"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar") (rel "foo"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar") (rel "foo/bar/baz"); - [%expect {| (baz) |}]; + [%expect {| Some "baz" |}]; test (rel "foo/bar") (rel "foo/bar/baz/qux"); - [%expect {| (baz/qux) |}]; + [%expect {| Some "baz/qux" |}]; (* Paths are normalized before the function call. *) test (rel "foo/bar") (rel "foo/bar/../baz"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar") (rel "foo/sna/../bar/baz"); - [%expect {| (baz) |}]; + [%expect {| Some "baz" |}]; (* Beware of string prefix vs path prefix. *) test (rel "foo/bar") (rel "foo/bar-baz"); - [%expect {| () |}]; + [%expect {| None |}]; (* Test that empty prefix returns the input unchanged *) test Relative_path.empty (rel "foo/bar"); - [%expect {| (foo/bar) |}]; + [%expect {| Some "foo/bar" |}]; test Relative_path.empty Relative_path.empty; - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; (* Test directory path behavior: trailing '/' matters for matching. *) test (rel "foo/bar/") (rel "foo/bar/baz"); - [%expect {| (baz) |}]; + [%expect {| Some "baz" |}]; test (rel "foo/bar") (rel "foo/bar/baz"); - [%expect {| (baz) |}]; + [%expect {| Some "baz" |}]; test (rel "foo/bar/") (rel "foo/bar"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar") (rel "foo/bar/"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; (* More complex directory prefix scenarios. *) test (rel "a/b/c/") (rel "a/b/c/d/e"); - [%expect {| (d/e) |}]; + [%expect {| Some "d/e" |}]; test (rel "a/b/c") (rel "a/b/c/d/e"); - [%expect {| (d/e) |}]; + [%expect {| Some "d/e" |}]; test (rel "a/b/c/") (rel "a/b/c/d/"); - [%expect {| (d/) |}]; + [%expect {| Some "d/" |}]; test (rel "a/b/c") (rel "a/b/c/d/"); - [%expect {| (d/) |}]; + [%expect {| Some "d/" |}]; () ;; @@ -322,70 +344,70 @@ let%expect_test "chop_suffix" = let rel = Relative_path.v in let test path suffix = let result = Relative_path.chop_suffix path ~suffix in - print_s [%sexp (result : Relative_path.t option)] + print_dyn (Dyn.option (fun s -> Dyn.string (s |> Relative_path.to_string)) result) in test (rel "foo/bar") (rel "bar"); - [%expect {| (foo/) |}]; + [%expect {| Some "foo/" |}]; test (rel "foo/bar") (rel "bar/"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar/") (rel "bar"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar/") (rel "bar/"); - [%expect {| (foo/) |}]; + [%expect {| Some "foo/" |}]; (* Verify that empty suffix returns the input unchanged. *) test (rel "foo/bar") Relative_path.empty; - [%expect {| (foo/bar) |}]; + [%expect {| Some "foo/bar" |}]; test (rel "foo/bar/") Relative_path.empty; - [%expect {| (foo/bar/) |}]; + [%expect {| Some "foo/bar/" |}]; test (rel "foo/bar/.") Relative_path.empty; - [%expect {| (foo/bar/) |}]; + [%expect {| Some "foo/bar/" |}]; test (rel "bar") (rel "foo/bar"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar") (rel "foo/bar"); - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; test (rel "foo/bar") (rel "baz"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar/baz") (rel "bar/baz"); - [%expect {| (foo/) |}]; + [%expect {| Some "foo/" |}]; test (rel "foo/bar/baz") (rel "baz/qux"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar/baz") Relative_path.empty; - [%expect {| (foo/bar/baz) |}]; + [%expect {| Some "foo/bar/baz" |}]; test (rel "foo/bar/baz") (rel "foo/../baz"); - [%expect {| (foo/bar/) |}]; + [%expect {| Some "foo/bar/" |}]; (* Beware of string suffix vs path suffix. *) test (rel "foo/bar-baz") (rel "-baz"); - [%expect {| () |}]; + [%expect {| None |}]; test Relative_path.empty Relative_path.empty; - [%expect {| (./) |}]; + [%expect {| Some "./" |}]; (* Test directory path behavior: trailing '/' matters for matching. *) test (rel "foo/bar") (rel "bar"); - [%expect {| (foo/) |}]; + [%expect {| Some "foo/" |}]; test (rel "foo/bar/") (rel "bar/"); - [%expect {| (foo/) |}]; + [%expect {| Some "foo/" |}]; test (rel "foo/bar/") (rel "bar"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "foo/bar") (rel "bar/"); - [%expect {| () |}]; + [%expect {| None |}]; (* More complex directory suffix scenarios. *) test (rel "a/b/c/d/e") (rel "d/e"); - [%expect {| (a/b/c/) |}]; + [%expect {| Some "a/b/c/" |}]; test (rel "a/b/c/d/e/") (rel "d/e/"); - [%expect {| (a/b/c/) |}]; + [%expect {| Some "a/b/c/" |}]; test (rel "a/b/c/d/e") (rel "d/e/"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "a/b/c/d/e/") (rel "d/e"); - [%expect {| () |}]; + [%expect {| None |}]; test (rel "x/y/z/") (rel "z/"); - [%expect {| (x/y/) |}]; + [%expect {| Some "x/y/" |}]; test (rel "x/y/z") (rel "z"); - [%expect {| (x/y/) |}]; + [%expect {| Some "x/y/" |}]; () ;; let%expect_test "is_dir_path" = let rel = Relative_path.v in - let test path = print_s [%sexp (Relative_path.is_dir_path (rel path) : bool)] in + let test path = print_dyn (Relative_path.is_dir_path (rel path) |> Dyn.bool) in test "foo/bar"; [%expect {| false |}]; test "foo/bar/"; @@ -402,7 +424,7 @@ let%expect_test "is_dir_path" = let%expect_test "to_dir_path" = let rel = Relative_path.v in let test path = - print_s [%sexp (Relative_path.to_dir_path (rel path) : Relative_path.t)] + print_endline (Relative_path.to_dir_path (rel path) |> Relative_path.to_string) in test "foo/bar"; [%expect {| foo/bar/ |}]; @@ -422,31 +444,43 @@ let%expect_test "rem_empty_seg" = let is_dir_path = Relative_path.is_dir_path path in let path2 = Relative_path.rem_empty_seg path in let is_dir_path2 = Relative_path.is_dir_path path2 in - print_s - [%sexp - { path : Relative_path.t; is_dir_path : bool } - , { path2 : Relative_path.t; is_dir_path2 : bool }] + print_dyn + (Dyn.Tuple + [ Record + [ "path", path |> Relative_path.to_string |> Dyn.string + ; "is_dir_path", is_dir_path |> Dyn.bool + ] + ; Record + [ "path2", path2 |> Relative_path.to_string |> Dyn.string + ; "is_dir_path2", is_dir_path2 |> Dyn.bool + ] + ]) in test (Relative_path.v "tmp/my-dir/"); [%expect {| - (((path tmp/my-dir/) (is_dir_path true)) - ((path2 tmp/my-dir) (is_dir_path2 false))) + ({ path = "tmp/my-dir/"; is_dir_path = true }, + { path2 = "tmp/my-dir"; is_dir_path2 = false }) |}]; test (Relative_path.v "tmp/my-file"); [%expect {| - (((path tmp/my-file) (is_dir_path false)) - ((path2 tmp/my-file) (is_dir_path2 false))) + ({ path = "tmp/my-file"; is_dir_path = false }, + { path2 = "tmp/my-file"; is_dir_path2 = false }) |}]; () ;; +let hashtbl_to_dyn key value table = + let data = Hashtbl.to_alist table in + Dyn.Map (List.map data ~f:(fun (k, v) -> key k, value v)) +;; + let%expect_test "hashtbl" = let t = Hashtbl.create (module Relative_path) in Hashtbl.set t ~key:(Relative_path.v "path/to/my-file") ~data:42; - print_s [%sexp (t : int Hashtbl.M(Relative_path).t)]; - [%expect {| ((path/to/my-file 42)) |}] + print_dyn (hashtbl_to_dyn (fun p -> Dyn.string (Relative_path.to_string p)) Dyn.int t); + [%expect {| map { "path/to/my-file" : 42 } |}] ;; module Pair = struct @@ -457,6 +491,13 @@ module Pair = struct ; b : Relative_path.t } [@@deriving compare, hash, sexp_of] + + let to_dyn { a; b } = + Dyn.Record + [ "a", a |> Relative_path.to_string |> Dyn.string + ; "b", b |> Relative_path.to_string |> Dyn.string + ] + ;; end let%expect_test "hash-fold-t" = @@ -465,12 +506,6 @@ let%expect_test "hash-fold-t" = t ~key:{ a = Relative_path.v "path/to/a"; b = Relative_path.v "path/to/b" } ~data:42; - print_s [%sexp (t : int Hashtbl.M(Pair).t)]; - [%expect - {| - (( - ((a path/to/a) - (b path/to/b)) - 42)) - |}] + print_dyn (hashtbl_to_dyn Pair.to_dyn Dyn.int t); + [%expect {| map { { a = "path/to/a"; b = "path/to/b" } : 42 } |}] ;; diff --git a/test/fpath-sexp0/dune b/test/fpath-sexp0/dune index 56d930c..a77240c 100644 --- a/test/fpath-sexp0/dune +++ b/test/fpath-sexp0/dune @@ -8,8 +8,10 @@ -warn-error +a -open - Fpath_sexp0) - (libraries fpath fpath_sexp0) + Fpath_sexp0 + -open + Stdlib_for_test) + (libraries fpath fpath_sexp0 stdlib_for_test) (inline_tests) (instrumentation (backend bisect_ppx)) diff --git a/test/stdlib/code_error.ml b/test/stdlib/code_error.ml new file mode 100644 index 0000000..4366b55 --- /dev/null +++ b/test/stdlib/code_error.ml @@ -0,0 +1,21 @@ +(*********************************************************************************) +(* fpath-base: Extending [Fpath] to use alongside [Sexplib0] and/or [Base] *) +(* SPDX-FileCopyrightText: 2023-2025 Mathieu Barbin *) +(* SPDX-License-Identifier: MIT *) +(*********************************************************************************) + +type t = + { message : string + ; data : (string * Dyn.t) list + } + +exception E of t + +let raise message data = raise (E { message; data }) +let to_dyn { message; data } = Dyn.Tuple [ Dyn.String message; Record data ] + +let () = + Printexc.register_printer (function + | E t -> Some (Dyn.to_string (to_dyn t)) + | _ -> None [@coverage off]) +;; diff --git a/test/stdlib/code_error.mli b/test/stdlib/code_error.mli new file mode 100644 index 0000000..82098a9 --- /dev/null +++ b/test/stdlib/code_error.mli @@ -0,0 +1,18 @@ +(*_********************************************************************************) +(*_ fpath-base: Extending [Fpath] to use alongside [Sexplib0] and/or [Base] *) +(*_ SPDX-FileCopyrightText: 2023-2025 Mathieu Barbin *) +(*_ SPDX-License-Identifier: MIT *) +(*_********************************************************************************) + +(*_ Inspired by a similar module in stdune. *) + +(** A programming error that should be reported upstream *) + +type t = + { message : string + ; data : (string * Dyn.t) list + } + +exception E of t + +val raise : string -> (string * Dyn.t) list -> _ diff --git a/test/stdlib/dune b/test/stdlib/dune new file mode 100644 index 0000000..ea7e444 --- /dev/null +++ b/test/stdlib/dune @@ -0,0 +1,10 @@ +(library + (name stdlib_for_test) + (package fpath-base-tests) + (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a) + (libraries dyn ordering pp) + (instrumentation + (backend bisect_ppx)) + (lint + (pps ppx_js_style -allow-let-operators -check-doc-comments)) + (preprocess no_preprocessing)) diff --git a/test/stdlib/stdlib_for_test.ml b/test/stdlib/stdlib_for_test.ml new file mode 100644 index 0000000..13face3 --- /dev/null +++ b/test/stdlib/stdlib_for_test.ml @@ -0,0 +1,26 @@ +(*********************************************************************************) +(* fpath-base: Extending [Fpath] to use alongside [Sexplib0] and/or [Base] *) +(* SPDX-FileCopyrightText: 2023-2025 Mathieu Barbin *) +(* SPDX-License-Identifier: MIT *) +(*********************************************************************************) + +module Code_error = Code_error +module Dyn = Dyn + +module Ordering = struct + include Ordering + + let to_dyn = function + | Lt -> Dyn.Variant ("Lt", []) + | Eq -> Dyn.Variant ("Eq", []) + | Gt -> Dyn.Variant ("Gt", []) + ;; +end + +let print pp = Format.printf "%a@." Pp.to_fmt pp +let print_dyn dyn = print (Dyn.pp dyn) + +let or_msg_to_dyn a_to_dyn = function + | Ok a -> Dyn.Variant ("Ok", [ a_to_dyn a ]) + | Error (`Msg err) -> Dyn.Variant ("Error", [ Dyn.Variant ("Msg", [ Dyn.string err ]) ]) +;; diff --git a/test/stdlib/stdlib_for_test.mli b/test/stdlib/stdlib_for_test.mli new file mode 100644 index 0000000..d5a5b31 --- /dev/null +++ b/test/stdlib/stdlib_for_test.mli @@ -0,0 +1,24 @@ +(*_********************************************************************************) +(*_ fpath-base: Extending [Fpath] to use alongside [Sexplib0] and/or [Base] *) +(*_ SPDX-FileCopyrightText: 2023-2025 Mathieu Barbin *) +(*_ SPDX-License-Identifier: MIT *) +(*_********************************************************************************) + +(** Extending [Stdlib] for use in the tests in this project. *) + +module Code_error = Code_error +module Dyn = Dyn + +module Ordering : sig + include module type of struct + include Ordering + end + + val to_dyn : t -> Dyn.t +end + +val print_dyn : Dyn.t -> unit + +(** Additional dyn helpers. *) + +val or_msg_to_dyn : ('a -> Dyn.t) -> ('a, [ `Msg of string ]) Result.t -> Dyn.t From 8ef21b23c9057e07664089bc08f9931e8efe12e0 Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Tue, 23 Dec 2025 14:45:29 +0100 Subject: [PATCH 2/6] Use local expect test helpers --- test/fpath-base/test__absolute_path.ml | 46 ++++++++------------ test/fpath-base/test__fpath.ml | 7 +--- test/fpath-base/test__hash.ml | 18 ++++---- test/fpath-base/test__relative_path.ml | 58 +++++++++----------------- test/stdlib/stdlib_for_test.ml | 36 ++++++++++++++++ test/stdlib/stdlib_for_test.mli | 24 +++++++++++ 6 files changed, 108 insertions(+), 81 deletions(-) diff --git a/test/fpath-base/test__absolute_path.ml b/test/fpath-base/test__absolute_path.ml index b54d97d..f75045c 100644 --- a/test/fpath-base/test__absolute_path.ml +++ b/test/fpath-base/test__absolute_path.ml @@ -31,8 +31,8 @@ let%expect_test "of_string" = ;; let%expect_test "v" = - require_does_raise [%here] (fun () -> Absolute_path.v ""); - [%expect {| (Invalid_argument "Absolute_path.v: \"\": invalid path") |}]; + require_does_raise (fun () -> Absolute_path.v ""); + [%expect {| Invalid_argument("Absolute_path.v: \"\": invalid path") |}]; () ;; @@ -84,8 +84,8 @@ let%expect_test "of_fpath" = |}]; test_fpath (Fpath.v "a/relative/path"); [%expect {| Not an absolute path. |}]; - require_does_raise [%here] (fun () -> Fpath.v ""); - [%expect {| (Invalid_argument "\"\": invalid path") |}]; + require_does_raise (fun () -> Fpath.v ""); + [%expect {| Invalid_argument("\"\": invalid path") |}]; () ;; @@ -112,20 +112,14 @@ let%expect_test "append" = test (abs "/") (rel "./a/b/../c/."); [%expect {| /a/c/ |}]; (* Escaping relative paths cannot be created. *) - require_does_raise [%here] (fun () -> + require_does_raise (fun () -> (test (abs "/a/c") (rel "./../b/d/../c/.") [@coverage off])); [%expect - {| - (Invalid_argument - "Relative_path.v: path \"./../b/d/../c/.\" escapes above starting point") - |}]; - require_does_raise [%here] (fun () -> + {| Invalid_argument("Relative_path.v: path \"./../b/d/../c/.\" escapes above starting point") |}]; + require_does_raise (fun () -> (test (abs "/a/c") (rel "./../../../b/d/../c/.") [@coverage off])); [%expect - {| - (Invalid_argument - "Relative_path.v: path \"./../../../b/d/../c/.\" escapes above starting point") - |}]; + {| Invalid_argument("Relative_path.v: path \"./../../../b/d/../c/.\" escapes above starting point") |}]; () ;; @@ -165,21 +159,15 @@ let%expect_test "append - v0.4.0 improvement" = This test verifies that attempts to create escaping relative paths fail before they can be used with append. *) (* These attempts to create escaping relative paths now fail. *) - require_does_raise [%here] (fun () -> Relative_path.v ".."); + require_does_raise (fun () -> Relative_path.v ".."); [%expect - {| (Invalid_argument "Relative_path.v: path \"..\" escapes above starting point") |}]; - require_does_raise [%here] (fun () -> Relative_path.v "../foo"); + {| Invalid_argument("Relative_path.v: path \"..\" escapes above starting point") |}]; + require_does_raise (fun () -> Relative_path.v "../foo"); [%expect - {| - (Invalid_argument - "Relative_path.v: path \"../foo\" escapes above starting point") - |}]; - require_does_raise [%here] (fun () -> Relative_path.v "a/../.."); + {| Invalid_argument("Relative_path.v: path \"../foo\" escapes above starting point") |}]; + require_does_raise (fun () -> Relative_path.v "a/../.."); [%expect - {| - (Invalid_argument - "Relative_path.v: path \"a/../..\" escapes above starting point") - |}]; + {| Invalid_argument("Relative_path.v: path \"a/../..\" escapes above starting point") |}]; (* Therefore, append can never receive an escaping path. Before v0.4.0, if you could construct [Relative_path.v "../foo"], then: @@ -194,9 +182,9 @@ let%expect_test "extend" = let abs = Absolute_path.v in let file str = str |> Fsegment.v in let test a b = print_endline (Absolute_path.extend a b |> Absolute_path.to_string) in - require_does_raise [%here] (fun () : Fsegment.t -> file "a/b"); - [%expect {| (Invalid_argument "Fsegment.v: invalid file segment \"a/b\"") |}]; - require_does_not_raise [%here] (fun () -> ignore (file ".." : Fsegment.t)); + require_does_raise (fun () : Fsegment.t -> file "a/b"); + [%expect {| Invalid_argument("Fsegment.v: invalid file segment \"a/b\"") |}]; + ignore (file ".." : Fsegment.t); [%expect {||}]; test (abs "/") (file "a"); [%expect {| /a |}]; diff --git a/test/fpath-base/test__fpath.ml b/test/fpath-base/test__fpath.ml index 6830435..e2cb58e 100644 --- a/test/fpath-base/test__fpath.ml +++ b/test/fpath-base/test__fpath.ml @@ -120,12 +120,9 @@ let%expect_test "classify" = [%expect {| Absolute "/" |}]; test "/a/b/../../../../foo/"; [%expect {| Absolute "/foo/" |}]; - require_does_raise [%here] (fun () -> test "a/b/../../../.."); + require_does_raise (fun () -> test "a/b/../../../.."); [%expect - {| - (Invalid_argument - "Fpath.classify: path \"a/b/../../../..\" escapes above starting point") - |}]; + {| Invalid_argument("Fpath.classify: path \"a/b/../../../..\" escapes above starting point") |}]; () ;; diff --git a/test/fpath-base/test__hash.ml b/test/fpath-base/test__hash.ml index da8f033..4ea1e81 100644 --- a/test/fpath-base/test__hash.ml +++ b/test/fpath-base/test__hash.ml @@ -33,7 +33,7 @@ let%expect_test "hash" = let h2 = Fpath_sexp0.Fsegment.hash seg in print_dyn (h1 |> Dyn.int); [%expect {| 437367475 |}]; - require_equal [%here] (module Int) h1 h2; + require_equal (module Int) h1 h2; [%expect {||}]; () ;; @@ -52,8 +52,8 @@ let%expect_test "Fsegment.seeded_hash" = [%expect {| 437367475 |}]; print_dyn (f42 |> Dyn.int); [%expect {| 202913284 |}]; - require_equal [%here] (module Int) s0 f0; - require_equal [%here] (module Int) s42 f42; + require_equal (module Int) s0 f0; + require_equal (module Int) s42 f42; [%expect {||}]; () ;; @@ -72,8 +72,8 @@ let%expect_test "Fpath.seeded_hash" = [%expect {| 437367475 |}]; print_dyn (f42 |> Dyn.int); [%expect {| 202913284 |}]; - require_equal [%here] (module Int) s0 f0; - require_equal [%here] (module Int) s42 f42; + require_equal (module Int) s0 f0; + require_equal (module Int) s42 f42; [%expect {||}]; () ;; @@ -94,8 +94,8 @@ let%expect_test "Relative_path.seeded_hash" = [%expect {| 437367475 |}]; print_dyn (f42 |> Dyn.int); [%expect {| 202913284 |}]; - require_equal [%here] (module Int) s0 f0; - require_equal [%here] (module Int) s42 f42; + require_equal (module Int) s0 f0; + require_equal (module Int) s42 f42; [%expect {||}]; () ;; @@ -116,8 +116,8 @@ let%expect_test "Absolute_path.seeded_hash" = [%expect {| 152999615 |}]; print_dyn (f42 |> Dyn.int); [%expect {| 524647462 |}]; - require_equal [%here] (module Int) s0 f0; - require_equal [%here] (module Int) s42 f42; + require_equal (module Int) s0 f0; + require_equal (module Int) s42 f42; [%expect {||}]; () ;; diff --git a/test/fpath-base/test__relative_path.ml b/test/fpath-base/test__relative_path.ml index 94b54c9..61a0cab 100644 --- a/test/fpath-base/test__relative_path.ml +++ b/test/fpath-base/test__relative_path.ml @@ -40,17 +40,14 @@ let%expect_test "of_string" = ;; let%expect_test "v" = - require_does_raise [%here] (fun () -> Relative_path.v ""); - [%expect {| (Invalid_argument "Relative_path.v: \"\": invalid path") |}]; - require_does_raise [%here] (fun () -> Relative_path.v ".."); + require_does_raise (fun () -> Relative_path.v ""); + [%expect {| Invalid_argument("Relative_path.v: \"\": invalid path") |}]; + require_does_raise (fun () -> Relative_path.v ".."); [%expect - {| (Invalid_argument "Relative_path.v: path \"..\" escapes above starting point") |}]; - require_does_raise [%here] (fun () -> Relative_path.v "../a"); + {| Invalid_argument("Relative_path.v: path \"..\" escapes above starting point") |}]; + require_does_raise (fun () -> Relative_path.v "../a"); [%expect - {| - (Invalid_argument - "Relative_path.v: path \"../a\" escapes above starting point") - |}]; + {| Invalid_argument("Relative_path.v: path \"../a\" escapes above starting point") |}]; () ;; @@ -104,12 +101,9 @@ let%expect_test "of_fpath" = [%expect {| Not a relative path. |}]; test_fpath (Fpath.v "/an/escaping/absolute/path/../../../../../.."); [%expect {| Not a relative path. |}]; - require_does_raise [%here] (fun () -> test_fpath (Fpath.v "an/../../escaping/path")); + require_does_raise (fun () -> test_fpath (Fpath.v "an/../../escaping/path")); [%expect - {| - (Invalid_argument - "Relative_path.of_fpath: path \"an/../../escaping/path\" escapes above starting point") - |}]; + {| Invalid_argument("Relative_path.of_fpath: path \"an/../../escaping/path\" escapes above starting point") |}]; () ;; @@ -153,9 +147,9 @@ let%expect_test "extend" = let rel = Relative_path.v in let file str = str |> Fsegment.v in let test a b = print_endline (Relative_path.extend a b |> Relative_path.to_string) in - require_does_raise [%here] (fun () : Fsegment.t -> file "a/b"); - [%expect {| (Invalid_argument "Fsegment.v: invalid file segment \"a/b\"") |}]; - require_does_not_raise [%here] (fun () -> ignore (file ".." : Fsegment.t)); + require_does_raise (fun () : Fsegment.t -> file "a/b"); + [%expect {| Invalid_argument("Fsegment.v: invalid file segment \"a/b\"") |}]; + ignore (file ".." : Fsegment.t); [%expect {| |}]; test Relative_path.empty (file "a"); [%expect {| a |}]; @@ -185,12 +179,9 @@ let%expect_test "extend" = [%expect {| ./ |}]; test (rel "a") (file ".."); [%expect {| ./ |}]; - require_does_raise [%here] (fun () -> test (rel "./") (file "..")); + require_does_raise (fun () -> test (rel "./") (file "..")); [%expect - {| - (Invalid_argument - "Relative_path.extend: path \"./..\" escapes above starting point") - |}]; + {| Invalid_argument("Relative_path.extend: path \"./..\" escapes above starting point") |}]; () ;; @@ -210,7 +201,7 @@ let%expect_test "parent" = test Relative_path.empty; [%expect {| None |}]; (* Be specific about the expectations here. *) - require [%here] (Option.is_none (Relative_path.parent Relative_path.empty)); + require (Option.is_none (Relative_path.parent Relative_path.empty)); [%expect {||}]; () ;; @@ -226,18 +217,12 @@ let%expect_test "of_list" = [%expect {| a |}]; test [ "." ]; [%expect {| ./ |}]; - require_does_raise [%here] (fun () -> test [ ".." ]); + require_does_raise (fun () -> test [ ".." ]); [%expect - {| - (Invalid_argument - "Relative_path.extend: path \"./..\" escapes above starting point") - |}]; - require_does_raise [%here] (fun () -> test [ "a"; ".."; ".." ]); + {| Invalid_argument("Relative_path.extend: path \"./..\" escapes above starting point") |}]; + require_does_raise (fun () -> test [ "a"; ".."; ".." ]); [%expect - {| - (Invalid_argument - "Relative_path.extend: path \"./..\" escapes above starting point") - |}]; + {| Invalid_argument("Relative_path.extend: path \"./..\" escapes above starting point") |}]; test [ "a"; ".." ]; [%expect {| ./ |}]; test [ "a"; "." ]; @@ -247,12 +232,9 @@ let%expect_test "of_list" = test [ "a"; "b"; "c"; "d" ]; [%expect {| a/b/c/d |}]; (* Even if we would "come back" later, we fail at the intermediate escaping step. *) - require_does_raise [%here] (fun () -> test [ "a"; ".."; ".."; "b"; "c" ]); + require_does_raise (fun () -> test [ "a"; ".."; ".."; "b"; "c" ]); [%expect - {| - (Invalid_argument - "Relative_path.extend: path \"./..\" escapes above starting point") - |}]; + {| Invalid_argument("Relative_path.extend: path \"./..\" escapes above starting point") |}]; () ;; diff --git a/test/stdlib/stdlib_for_test.ml b/test/stdlib/stdlib_for_test.ml index 13face3..dc5abcb 100644 --- a/test/stdlib/stdlib_for_test.ml +++ b/test/stdlib/stdlib_for_test.ml @@ -24,3 +24,39 @@ let or_msg_to_dyn a_to_dyn = function | Ok a -> Dyn.Variant ("Ok", [ a_to_dyn a ]) | Error (`Msg err) -> Dyn.Variant ("Error", [ Dyn.Variant ("Msg", [ Dyn.string err ]) ]) ;; + +module Int = struct + include Int + + let to_dyn = Dyn.int +end + +let require cond = if not cond then failwith "Required condition does not hold" + +let require_does_raise f = + match f () with + | _ -> Code_error.raise "Did not raise." [] + | exception e -> print_endline (Printexc.to_string e) +;; + +module With_equal_and_dyn = struct + module type S = sig + type t + + val equal : t -> t -> bool + val to_dyn : t -> Dyn.t + end +end + +let require_equal + (type a) + (module M : With_equal_and_dyn.S with type t = a) + (v1 : a) + (v2 : a) + = + if not (M.equal v1 v2) + then + Code_error.raise + "Values are not equal." + [ "v1", v1 |> M.to_dyn; "v2", v2 |> M.to_dyn ] +;; diff --git a/test/stdlib/stdlib_for_test.mli b/test/stdlib/stdlib_for_test.mli index d5a5b31..d903ef6 100644 --- a/test/stdlib/stdlib_for_test.mli +++ b/test/stdlib/stdlib_for_test.mli @@ -19,6 +19,30 @@ end val print_dyn : Dyn.t -> unit +module Int : sig + include module type of struct + include Stdlib.Int + end + + val to_dyn : t -> Dyn.t +end + (** Additional dyn helpers. *) val or_msg_to_dyn : ('a -> Dyn.t) -> ('a, [ `Msg of string ]) Result.t -> Dyn.t + +(** Expect test helpers. *) + +val require : bool -> unit +val require_does_raise : (unit -> 'a) -> unit + +module With_equal_and_dyn : sig + module type S = sig + type t + + val equal : t -> t -> bool + val to_dyn : t -> Dyn.t + end +end + +val require_equal : (module With_equal_and_dyn.S with type t = 'a) -> 'a -> 'a -> unit From bcb0360babb77c0937a5473b9c480da664166c90 Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Tue, 23 Dec 2025 14:47:04 +0100 Subject: [PATCH 3/6] Fix coverage tests --- test/fpath-sexp0/test__stdlib.ml | 27 +++++++++++++++++++++++++++ test/fpath-sexp0/test__stdlib.mli | 5 +++++ 2 files changed, 32 insertions(+) create mode 100644 test/fpath-sexp0/test__stdlib.ml create mode 100644 test/fpath-sexp0/test__stdlib.mli diff --git a/test/fpath-sexp0/test__stdlib.ml b/test/fpath-sexp0/test__stdlib.ml new file mode 100644 index 0000000..47af44e --- /dev/null +++ b/test/fpath-sexp0/test__stdlib.ml @@ -0,0 +1,27 @@ +(*********************************************************************************) +(* fpath-base: Extending [Fpath] to use alongside [Sexplib0] and/or [Base] *) +(* SPDX-FileCopyrightText: 2023-2025 Mathieu Barbin *) +(* SPDX-License-Identifier: MIT *) +(*********************************************************************************) + +let%expect_test "require" = + require_does_raise (fun () -> require false); + [%expect {| Failure("Required condition does not hold") |}]; + () +;; + +let%expect_test "require_does_raise did not raise" = + (match require_does_raise ignore with + | () -> assert false + | exception exn -> print_string (Printexc.to_string exn)); + [%expect {| ("Did not raise.", {}) |}]; + () +;; + +let%expect_test "require_equal not equal" = + (match require_equal (module Int) 0 42 with + | () -> assert false + | exception exn -> print_string (Printexc.to_string exn)); + [%expect {| ("Values are not equal.", { v1 = 0; v2 = 42 }) |}]; + () +;; diff --git a/test/fpath-sexp0/test__stdlib.mli b/test/fpath-sexp0/test__stdlib.mli new file mode 100644 index 0000000..9b18179 --- /dev/null +++ b/test/fpath-sexp0/test__stdlib.mli @@ -0,0 +1,5 @@ +(*_********************************************************************************) +(*_ fpath-base: Extending [Fpath] to use alongside [Sexplib0] and/or [Base] *) +(*_ SPDX-FileCopyrightText: 2023-2025 Mathieu Barbin *) +(*_ SPDX-License-Identifier: MIT *) +(*_********************************************************************************) From fdc8457839e6d57d7f091e462eca616a096338ef Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Tue, 23 Dec 2025 14:50:27 +0100 Subject: [PATCH 4/6] Simplify dependencies --- dune-project | 14 ++------------ fpath-base-dev.opam | 3 --- fpath-base-tests.opam | 4 +--- test/fpath-base/dune | 14 ++------------ test/stdlib/stdlib_for_test.ml | 1 + test/stdlib/stdlib_for_test.mli | 1 + 6 files changed, 7 insertions(+), 30 deletions(-) diff --git a/dune-project b/dune-project index 90a317e..f5e880d 100644 --- a/dune-project +++ b/dune-project @@ -64,14 +64,14 @@ (>= v0.17)) (dyn (>= 3.17)) - (expect_test_helpers_core - (>= v0.17)) (fpath (>= 0.7.3)) (fpath-base (= :version)) (fpath-sexp0 (= :version)) + (ordering + (>= 3.17)) (pp (>= 2.0.0)) (ppx_compare @@ -80,12 +80,8 @@ (>= v0.17)) (ppx_hash (>= v0.17)) - (ppx_here - (>= v0.17)) (ppx_sexp_conv (>= v0.17)) - (ppx_sexp_value - (>= v0.17)) (ppxlib (>= 0.33)))) @@ -102,8 +98,6 @@ (>= v0.17)) (bisect_ppx (>= 2.8.3)) - (expect_test_helpers_core - (>= v0.17)) (fpath (>= 0.7.3)) (fpath-base @@ -120,14 +114,10 @@ (>= v0.17)) (ppx_hash (>= v0.17)) - (ppx_here - (>= v0.17)) (ppx_js_style (>= v0.17)) (ppx_sexp_conv (>= v0.17)) - (ppx_sexp_value - (>= v0.17)) (ppxlib (>= 0.33)) (sherlodoc diff --git a/fpath-base-dev.opam b/fpath-base-dev.opam index 2579f24..73347d9 100644 --- a/fpath-base-dev.opam +++ b/fpath-base-dev.opam @@ -13,7 +13,6 @@ depends: [ "ocamlformat" {= "0.28.1"} "base" {>= "v0.17"} "bisect_ppx" {>= "2.8.3"} - "expect_test_helpers_core" {>= "v0.17"} "fpath" {>= "0.7.3"} "fpath-base" {= version} "fpath-base-tests" {= version} @@ -22,10 +21,8 @@ depends: [ "ppx_compare" {>= "v0.17"} "ppx_expect" {>= "v0.17"} "ppx_hash" {>= "v0.17"} - "ppx_here" {>= "v0.17"} "ppx_js_style" {>= "v0.17"} "ppx_sexp_conv" {>= "v0.17"} - "ppx_sexp_value" {>= "v0.17"} "ppxlib" {>= "0.33"} "sherlodoc" {with-doc & >= "0.2"} "odoc" {with-doc} diff --git a/fpath-base-tests.opam b/fpath-base-tests.opam index ef3d505..608a2d5 100644 --- a/fpath-base-tests.opam +++ b/fpath-base-tests.opam @@ -12,17 +12,15 @@ depends: [ "ocaml" {>= "5.2"} "base" {>= "v0.17"} "dyn" {>= "3.17"} - "expect_test_helpers_core" {>= "v0.17"} "fpath" {>= "0.7.3"} "fpath-base" {= version} "fpath-sexp0" {= version} + "ordering" {>= "3.17"} "pp" {>= "2.0.0"} "ppx_compare" {>= "v0.17"} "ppx_expect" {>= "v0.17"} "ppx_hash" {>= "v0.17"} - "ppx_here" {>= "v0.17"} "ppx_sexp_conv" {>= "v0.17"} - "ppx_sexp_value" {>= "v0.17"} "ppxlib" {>= "0.33"} "odoc" {with-doc} ] diff --git a/test/fpath-base/dune b/test/fpath-base/dune index 70ad3ad..cf365d5 100644 --- a/test/fpath-base/dune +++ b/test/fpath-base/dune @@ -12,16 +12,8 @@ -open Fpath_base -open - Expect_test_helpers_base - -open Stdlib_for_test) - (libraries - base - expect_test_helpers_core.expect_test_helpers_base - fpath - fpath_base - fpath_sexp0 - stdlib_for_test) + (libraries base fpath fpath_base fpath_sexp0 stdlib_for_test) (inline_tests) (instrumentation (backend bisect_ppx)) @@ -33,6 +25,4 @@ ppx_compare ppx_expect ppx_hash - ppx_here - ppx_sexp_conv - ppx_sexp_value))) + ppx_sexp_conv))) diff --git a/test/stdlib/stdlib_for_test.ml b/test/stdlib/stdlib_for_test.ml index dc5abcb..a9745ad 100644 --- a/test/stdlib/stdlib_for_test.ml +++ b/test/stdlib/stdlib_for_test.ml @@ -31,6 +31,7 @@ module Int = struct let to_dyn = Dyn.int end +let print_endline = Stdlib.print_endline let require cond = if not cond then failwith "Required condition does not hold" let require_does_raise f = diff --git a/test/stdlib/stdlib_for_test.mli b/test/stdlib/stdlib_for_test.mli index d903ef6..9b43d74 100644 --- a/test/stdlib/stdlib_for_test.mli +++ b/test/stdlib/stdlib_for_test.mli @@ -33,6 +33,7 @@ val or_msg_to_dyn : ('a -> Dyn.t) -> ('a, [ `Msg of string ]) Result.t -> Dyn.t (** Expect test helpers. *) +val print_endline : string -> unit val require : bool -> unit val require_does_raise : (unit -> 'a) -> unit From 3211ecdaf1fb9b9f52e72b754e81547884bc818c Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Tue, 23 Dec 2025 14:52:24 +0100 Subject: [PATCH 5/6] Simplify direct dev dependencies --- dune-project | 12 +----------- fpath-base-dev.opam | 6 +----- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/dune-project b/dune-project index f5e880d..f69daf1 100644 --- a/dune-project +++ b/dune-project @@ -108,19 +108,9 @@ (= :version)) (mdx (>= 2.4)) - (ppx_compare - (>= v0.17)) - (ppx_expect - (>= v0.17)) - (ppx_hash - (>= v0.17)) (ppx_js_style (>= v0.17)) - (ppx_sexp_conv - (>= v0.17)) (ppxlib (>= 0.33)) (sherlodoc - (and - :with-doc - (>= 0.2))))) + (>= 0.2)))) diff --git a/fpath-base-dev.opam b/fpath-base-dev.opam index 73347d9..583dda0 100644 --- a/fpath-base-dev.opam +++ b/fpath-base-dev.opam @@ -18,13 +18,9 @@ depends: [ "fpath-base-tests" {= version} "fpath-sexp0" {= version} "mdx" {>= "2.4"} - "ppx_compare" {>= "v0.17"} - "ppx_expect" {>= "v0.17"} - "ppx_hash" {>= "v0.17"} "ppx_js_style" {>= "v0.17"} - "ppx_sexp_conv" {>= "v0.17"} "ppxlib" {>= "0.33"} - "sherlodoc" {with-doc & >= "0.2"} + "sherlodoc" {>= "0.2"} "odoc" {with-doc} ] build: [ From a198e574dabecdb3aab85ec9d982b915dd85ad23 Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Tue, 23 Dec 2025 14:53:25 +0100 Subject: [PATCH 6/6] Lower deps in doc/ --- doc/explanation/dune | 2 +- doc/explanation/prelude.txt | 4 ++-- doc/guides/dune | 2 +- doc/guides/prelude.txt | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/explanation/dune b/doc/explanation/dune index 12d60e2..5403375 100644 --- a/doc/explanation/dune +++ b/doc/explanation/dune @@ -6,5 +6,5 @@ (mdx (package fpath-base-dev) (deps - (package fpath-base)) + (package fpath-sexp0)) (preludes prelude.txt)) diff --git a/doc/explanation/prelude.txt b/doc/explanation/prelude.txt index 1ff2380..b0e1657 100644 --- a/doc/explanation/prelude.txt +++ b/doc/explanation/prelude.txt @@ -1,2 +1,2 @@ -#require "fpath-base" ;; -open Fpath_base ;; +#require "fpath-sexp0" ;; +open Fpath_sexp0 ;; diff --git a/doc/guides/dune b/doc/guides/dune index 12d60e2..5403375 100644 --- a/doc/guides/dune +++ b/doc/guides/dune @@ -6,5 +6,5 @@ (mdx (package fpath-base-dev) (deps - (package fpath-base)) + (package fpath-sexp0)) (preludes prelude.txt)) diff --git a/doc/guides/prelude.txt b/doc/guides/prelude.txt index 1ff2380..b0e1657 100644 --- a/doc/guides/prelude.txt +++ b/doc/guides/prelude.txt @@ -1,2 +1,2 @@ -#require "fpath-base" ;; -open Fpath_base ;; +#require "fpath-sexp0" ;; +open Fpath_sexp0 ;;