Because of #16550 these tests would now spew
[p5sagit/p5-mst-13.2.git] / lib / filetest.t
CommitLineData
03309359 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
8use Test::More tests => 11;
9
10# these two should be kept in sync with the pragma itself
11# if hint bits are changed there, other things *will* break
12my $hint_bits = 0x00400000;
13my $error = "filetest: the only implemented subpragma is 'access'.\n";
14
15# can't use it yet, because of the import death
16ok( require filetest, 'required pragma successfully' );
17
18# and here's one culprit, right here
19eval { filetest->import('bad subpragma') };
20is( $@, $error, 'filetest dies with bad subpragma on import' );
21
22is( $^H & $hint_bits, 0, 'hint bits not set without pragma in place' );
23
24# now try the normal usage
25# can't check $^H here; it's lexically magic (see perlvar)
26# the test harness unintentionally hoards the goodies for itself
27use_ok( 'filetest', 'access' );
28
29# and import again, to see it here
30filetest->import('access');
31ok( $^H & $hint_bits, 'hint bits set with pragma loaded' );
32
33# and now get rid of it
34filetest->unimport('access');
35is( $^H & $hint_bits, 0, 'hint bits not set with pragma unimported' );
36
37eval { filetest->unimport() };
38is( $@, $error, 'filetest dies without subpragma on unimport' );
39
40# there'll be a compilation aborted failure here, with the eval string
41eval "no filetest 'fake pragma'";
42like( $@, qr/^$error/, 'filetest dies with bad subpragma on unuse' );
43
44eval "use filetest 'bad subpragma'";
45like( $@, qr/^$error/, 'filetest dies with bad subpragma on use' );
46
47eval "use filetest";
48like( $@, qr/^$error/, 'filetest dies with missing subpragma on use' );
49
50eval "no filetest";
51like( $@, qr/^$error/, 'filetest dies with missing subpragma on unuse' );