xref: /openbsd-src/gnu/usr.bin/perl/ext/File-Glob/t/case.t (revision 256a93a44f36679bee503f12e49566c2183f6181)
143003dfeSmillert#!./perl
243003dfeSmillert
343003dfeSmillertBEGIN {
443003dfeSmillert    chdir 't' if -d 't';
5898184e3Ssthen    @INC = '../lib';
643003dfeSmillert    require Config; import Config;
743003dfeSmillert    if ($Config{'extensions'} !~ /\bFile\/Glob\b/i) {
843003dfeSmillert        print "1..0\n";
943003dfeSmillert        exit 0;
1043003dfeSmillert    }
1143003dfeSmillert}
12898184e3Ssthen
13898184e3Ssthenuse Test::More tests => 7;
14898184e3Ssthen
15898184e3SsthenBEGIN {
16898184e3Ssthen    use_ok('File::Glob', qw(:glob csh_glob));
1743003dfeSmillert}
1843003dfeSmillert
19898184e3Ssthenmy $pat = "op/G*.t";
2043003dfeSmillert
2143003dfeSmillertimport File::Glob ':nocase';
2243003dfeSmillert@a = csh_glob($pat);
23898184e3Ssthencmp_ok(scalar @a, '>=', 8, 'use of the case sensitivity tags, via csh_glob()');
2443003dfeSmillert
2543003dfeSmillert# This may fail on systems which are not case-PRESERVING
2643003dfeSmillertimport File::Glob ':case';
27898184e3Ssthen@a = csh_glob($pat);
28898184e3Ssthenis(scalar @a, 0, 'None should be uppercase');
2943003dfeSmillert
3043003dfeSmillert@a = bsd_glob($pat, GLOB_NOCASE);
31898184e3Ssthencmp_ok(scalar @a, '>=', 3, 'explicit use of the GLOB_NOCASE flag');
3243003dfeSmillert
3343003dfeSmillert# Test Win32 backslash nastiness...
34898184e3SsthenSKIP: {
35*256a93a4Safresh1    skip 'Not Win32', 3 unless $^O eq 'MSWin32';
36898184e3Ssthen
37f3efcd01Safresh1    @a = File::Glob::bsd_glob("op\\g*.t");
38898184e3Ssthen    cmp_ok(scalar @a, '>=', 8);
3943003dfeSmillert    mkdir "[]", 0;
40f3efcd01Safresh1    @a = File::Glob::bsd_glob("\\[\\]", GLOB_QUOTE);
4143003dfeSmillert    rmdir "[]";
42898184e3Ssthen    is(scalar @a, 1);
4343003dfeSmillert    @a = bsd_glob("op\\*", GLOB_QUOTE);
44898184e3Ssthen    isnt(scalar @a, 0);
4543003dfeSmillert}
46