xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Fatal.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl -w
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate   chdir 't' if -d 't';
5*0Sstevel@tonic-gate   @INC = '../lib';
6*0Sstevel@tonic-gate   print "1..15\n";
7*0Sstevel@tonic-gate}
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gateuse strict;
10*0Sstevel@tonic-gateuse Fatal qw(open close :void opendir);
11*0Sstevel@tonic-gate
12*0Sstevel@tonic-gatemy $i = 1;
13*0Sstevel@tonic-gateeval { open FOO, '<lkjqweriuapofukndajsdlfjnvcvn' };
14*0Sstevel@tonic-gateprint "not " unless $@ =~ /^Can't open/;
15*0Sstevel@tonic-gateprint "ok $i\n"; ++$i;
16*0Sstevel@tonic-gate
17*0Sstevel@tonic-gatemy $foo = 'FOO';
18*0Sstevel@tonic-gatefor ('$foo', "'$foo'", "*$foo", "\\*$foo") {
19*0Sstevel@tonic-gate    eval qq{ open $_, '<$0' };
20*0Sstevel@tonic-gate    print "not " if $@;
21*0Sstevel@tonic-gate    print "ok $i\n"; ++$i;
22*0Sstevel@tonic-gate
23*0Sstevel@tonic-gate    print "not " if $@ or scalar(<$foo>) !~ m|^#!./perl|;
24*0Sstevel@tonic-gate    print "ok $i\n"; ++$i;
25*0Sstevel@tonic-gate    eval qq{ close FOO };
26*0Sstevel@tonic-gate    print "not " if $@;
27*0Sstevel@tonic-gate    print "ok $i\n"; ++$i;
28*0Sstevel@tonic-gate}
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gateeval { opendir FOO, 'lkjqweriuapofukndajsdlfjnvcvn' };
31*0Sstevel@tonic-gateprint "not " unless $@ =~ /^Can't open/;
32*0Sstevel@tonic-gateprint "ok $i\n"; ++$i;
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gateeval { my $a = opendir FOO, 'lkjqweriuapofukndajsdlfjnvcvn' };
35*0Sstevel@tonic-gateprint "not " if $@ =~ /^Can't open/;
36*0Sstevel@tonic-gateprint "ok $i\n"; ++$i;
37