Drop all the unnecessary "use utf8" clauses and some of
[p5sagit/p5-mst-13.2.git] / t / op / study.t
old mode 100644 (file)
new mode 100755 (executable)
index 01e33fa..0c111ea
@@ -1,8 +1,11 @@
 #!./perl
 
-# $Header: study.t,v 4.0 91/03/20 01:54:59 lwall Locked $
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+}
 
-print "1..24\n";
+print "1..26\n";
 
 $x = "abc\ndef\n";
 study($x);
@@ -67,3 +70,34 @@ if (/^$_$/) {print "ok 23\n";} else {print "not ok 23\n";}
 
 $* = 1;                # test 3 only tested the optimized version--this one is for real
 if ("ab\ncd\n" =~ /^cd/) {print "ok 24\n";} else {print "not ok 24\n";}
+
+if ($^O eq 'os390') {
+    # Even with the alarm() OS/390 can't manage these tests
+    # (Perl just goes into a busy loop, luckily an interruptable one)
+    for (25..26) { print "not ok $_ # compiler bug?\n" }
+} else {
+    # [ID 20010618.006] tests 25..26 may loop
+    use Config;
+    my $have_alarm = $Config{d_alarm};
+    local $SIG{ALRM} = sub { die "timeout\n" };
+
+    $_ = 'FGF';
+    study;
+    my $ok = $have_alarm
+       ? eval { alarm(2); my $match = /G.F$/; alarm(0); !$match }
+       : eval { !/G.F$/ };
+    if ($ok && !$@) {
+       print "ok 25\n";
+    } else {
+       print "not ok 25\t# " . $@ || "should not match\n";
+    }
+    $ok = $have_alarm
+       ? eval { alarm(2); my $match = /[F]F$/; alarm(0); !$match }
+       : eval { !/[F]F$/ };
+    if ($ok && !$@) {
+       print "ok 26\n";
+    } else {
+       print "not ok 26\t# " . $@ || "should not match\n";
+    }
+}
+