File: 10use_fnmatch.t

package info (click to toggle)
libfile-fnmatch-perl 0.02-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 188 kB
  • ctags: 422
  • sloc: perl: 12; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use Test;
BEGIN { plan tests => 9 };
use File::FnMatch ':fnmatch';
ok(1); # If we made it this far, we are ok.

ok(defined &fnmatch, 1, "fnmatch imported");
my @const = grep { /^FNM_/ } keys %{__PACKAGE__ . '::'};
ok(@const > 0, 1, "FNM_* constants imported");

ok(fnmatch("*log", "/var/log"));
unless (defined &FNM_PATHNAME) {
  skip("No FNM_PATHNAME", !fnmatch("*log", "/var/log", FNM_PATHNAME));
  skip("No FNM_PATHNAME", fnmatch("/*/*log", "/var/log", FNM_PATHNAME));
} else {
  ok(!fnmatch("*log", "/var/log", FNM_PATHNAME));
  ok(fnmatch("/*/*log", "/var/log", FNM_PATHNAME));
}

unless (defined &FNM_PATHNAME and defined &FNM_PERIOD) {
  skip("No FNM_PATHNAME|FNM_PERIOD", fnmatch("/a/*", "/a/bc", $flags));
  skip("No FNM_PATHNAME|FNM_PERIOD", !fnmatch("/a/*", "/a/.bc", $flags));
  skip("No FNM_PATHNAME|FNM_PERIOD", !fnmatch("/a/*", "/a/b/c", $flags));
} else {
  my $flags = FNM_PATHNAME|FNM_PERIOD;
  ok(fnmatch("/a/*", "/a/bc", $flags));
  ok(!fnmatch("/a/*", "/a/.bc", $flags));
  ok(!fnmatch("/a/*", "/a/b/c", $flags));
}