1
2;;;; test-glob.scm
3
4;; test glob-pattern -> regex translation
5
6(import (chicken irregex))
7
8(assert (irregex-match (glob->sre "foo.bar") "foo.bar"))
9(assert (irregex-match (glob->sre "foo*") "foo.bar"))
10(assert (irregex-match (glob->sre "foo/*") "foo/bar"))
11(assert (not (irregex-match (glob->sre "foo/*") "foo/bar/baz")))
12(assert (irregex-match (glob->sre "foo/*/*") "foo/bar/baz"))
13(assert (not (irregex-match (glob->sre "foo/*") "foo/.bar")))
14(assert (irregex-match (glob->sre "*foo") "xyzfoo"))
15(assert (not (irregex-match (glob->sre "*foo") ".foo")))
16(assert (not (irregex-match (glob->sre "*foo*") "a.fooxxx/yyy")))
17(assert (irregex-match (glob->sre "*foo*") "fooxxx"))
18(assert (irregex-match (glob->sre "main.[ch]") "main.c"))
19(assert (irregex-match (glob->sre "main.[ch]") "main.h"))
20(assert (not (irregex-match (glob->sre "main.[ch]") "main.cpp")))
21(assert (irregex-match (glob->sre "main.[-c]") "main.h"))
22(assert (not (irregex-match (glob->sre "main.[-h]") "main.h")))
23
24;; test file globbing
25
26(import (chicken file))
27
28(assert (pair? (glob "../tests")))
29(assert (pair? (glob "../tests/*")))
30(assert (null? (glob "../nowhere")))
31(assert (null? (glob "../nowhere/*")))
32