test suite and fix input_line_number()
[p5sagit/p5-mst-13.2.git] / t / lib / fatal.t
old mode 100644 (file)
new mode 100755 (executable)
index fe2f63d..fb3757f
@@ -1,23 +1,27 @@
-#!./perl
+#!./perl -w
 
 BEGIN {
-    chdir 't' if -d 't';
-    @INC = '../lib';
+   chdir 't' if -d 't';
+   unshift @INC, '../lib';
+   print "1..9\n";
 }
 
-print "1..2\n";
+use strict;
+use Fatal qw(open);
 
-sub false { 0; }
+my $i = 1;
+eval { open FOO, '<lkjqweriuapofukndajsdlfjnvcvn' };
+print "not " unless $@ =~ /^Can't open/;
+print "ok $i\n"; ++$i;
 
-sub true  { 1; }
+my $foo = 'FOO';
+for ('$foo', "'$foo'", "*$foo", "\\*$foo") {
+    eval qq{ open $_, '<$0' };
+    print "not " if $@;
+    print "ok $i\n"; ++$i;
 
-use Fatal qw(true false);
-
-eval { true(); };
-
-print "not " if $@;
-print "ok 1\n";
-
-eval { false(); };
-print "not " unless $@;
-print "ok 2\n";
+    print "not " unless scalar(<FOO>) =~ m|^#!./perl|;
+    print "not " if $@;
+    print "ok $i\n"; ++$i;
+    close FOO;
+}