This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
14
unikernel/duniverse/dune_/otherlibs/dune-glob/test/dune
Normal file
14
unikernel/duniverse/dune_/otherlibs/dune-glob/test/dune
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(library
|
||||
(name dune_glob_unit_tests)
|
||||
(inline_tests)
|
||||
(libraries
|
||||
stdune
|
||||
dune_glob
|
||||
;; This is because of the (implicit_transitive_deps false)
|
||||
;; in dune-project
|
||||
ppx_expect.config
|
||||
ppx_expect.config_types
|
||||
base
|
||||
ppx_inline_test.config)
|
||||
(preprocess
|
||||
(pps ppx_expect)))
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
open! Stdune
|
||||
module Glob = Dune_glob.V1
|
||||
|
||||
let printf = Printf.printf
|
||||
|
||||
let test glob s ~expect =
|
||||
let res = Glob.test glob s in
|
||||
let status = if res = expect then "pass" else "fail" in
|
||||
printf "[%s] %S matches %S == %b" status (Glob.to_string glob) s res
|
||||
;;
|
||||
|
||||
let%expect_test _ =
|
||||
let glob = Glob.of_string "test" in
|
||||
printf "%S" (Glob.to_string glob);
|
||||
[%expect {| "test" |}]
|
||||
;;
|
||||
|
||||
let%expect_test _ =
|
||||
let glob = Glob.of_string "te*" in
|
||||
test glob "test" ~expect:true;
|
||||
[%expect {| [pass] "te*" matches "test" == true |}];
|
||||
test glob "t" ~expect:false;
|
||||
[%expect {| [pass] "te*" matches "t" == false |}];
|
||||
test glob "te" ~expect:true;
|
||||
[%expect {| [pass] "te*" matches "te" == true |}]
|
||||
;;
|
||||
|
||||
let%expect_test _ =
|
||||
let glob = Glob.of_string "*st" in
|
||||
test glob "test" ~expect:true;
|
||||
[%expect {| [pass] "*st" matches "test" == true |}];
|
||||
test glob "t" ~expect:false;
|
||||
[%expect {| [pass] "*st" matches "t" == false |}];
|
||||
(* This is surprising, but documented *)
|
||||
test glob "st" ~expect:false;
|
||||
[%expect {| [pass] "*st" matches "st" == false |}];
|
||||
test glob ".st" ~expect:false;
|
||||
[%expect {| [pass] "*st" matches ".st" == false |}]
|
||||
;;
|
||||
|
||||
let%expect_test _ =
|
||||
let glob = Glob.of_string "foo.{ml,mli}" in
|
||||
test glob "foo.ml" ~expect:true;
|
||||
[%expect {| [pass] "foo.{ml,mli}" matches "foo.ml" == true |}];
|
||||
test glob "foo.mli" ~expect:true;
|
||||
[%expect {| [pass] "foo.{ml,mli}" matches "foo.mli" == true |}];
|
||||
test glob "foo." ~expect:false;
|
||||
[%expect {| [pass] "foo.{ml,mli}" matches "foo." == false |}]
|
||||
;;
|
||||
|
||||
let%expect_test _ =
|
||||
let glob = Glob.of_string "foo**" in
|
||||
test glob "foo.ml" ~expect:false;
|
||||
[%expect {| [pass] "foo**" matches "foo.ml" == false |}];
|
||||
test glob "fooml" ~expect:true;
|
||||
[%expect {| [pass] "foo**" matches "fooml" == true |}]
|
||||
;;
|
||||
|
||||
let%expect_test _ =
|
||||
let glob = Glob.of_string "**" in
|
||||
test glob "foo/bar" ~expect:true;
|
||||
[%expect {| [pass] "**" matches "foo/bar" == true |}];
|
||||
test glob "" ~expect:true;
|
||||
[%expect {| [pass] "**" matches "" == true |}];
|
||||
test glob "foo.bar" ~expect:true;
|
||||
[%expect {| [pass] "**" matches "foo.bar" == true |}]
|
||||
;;
|
||||
|
||||
let%expect_test _ =
|
||||
let glob = Glob.of_string "*" in
|
||||
test glob ".foo" ~expect:false;
|
||||
[%expect {| [pass] "*" matches ".foo" == false |}];
|
||||
test glob "foo.ml" ~expect:true;
|
||||
[%expect {| [pass] "*" matches "foo.ml" == true |}];
|
||||
test glob "foo/" ~expect:false;
|
||||
[%expect {| [pass] "*" matches "foo/" == false |}]
|
||||
;;
|
||||
|
||||
let%expect_test _ =
|
||||
let glob = Glob.of_string "[!._]*" in
|
||||
test glob ".foo" ~expect:false;
|
||||
[%expect {| [pass] "[!._]*" matches ".foo" == false |}];
|
||||
test glob "foo.ml" ~expect:true;
|
||||
[%expect {| [pass] "[!._]*" matches "foo.ml" == true |}];
|
||||
test glob "a" ~expect:true;
|
||||
[%expect {| [pass] "[!._]*" matches "a" == true |}]
|
||||
;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue