This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Convert t/op/study.t to use test.pl, strict and warnings.
[perl5.git] / t / op / study.t
CommitLineData
a10707d8 1#!./perl -w
378cc40b 2
27c93d93
HS
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
a10707d8 6 require './test.pl';
27c93d93 7}
378cc40b 8
a10707d8
NC
9watchdog(10);
10plan(tests => 29);
11use strict;
12use vars '$x';
856271c8
CB
13
14use Config;
15my $have_alarm = $Config{d_alarm};
378cc40b
LW
16
17$x = "abc\ndef\n";
18study($x);
19
856271c8
CB
20ok($x =~ /^abc/);
21ok($x !~ /^def/);
378cc40b 22
f02c194e
RGS
23# used to be a test for $*
24ok($x =~ /^def/m);
378cc40b
LW
25
26$_ = '123';
27study;
856271c8 28ok(/^([0-9][0-9]*)/);
378cc40b 29
a10707d8
NC
30ok(!($x =~ /^xxx/));
31ok(!($x !~ /^abc/));
378cc40b 32
856271c8 33ok($x =~ /def/);
a10707d8 34ok(!($x !~ /def/));
378cc40b
LW
35
36study($x);
856271c8 37ok($x !~ /.def/);
a10707d8 38ok(!($x =~ /.def/));
378cc40b 39
856271c8 40ok($x =~ /\ndef/);
a10707d8 41ok(!($x !~ /\ndef/));
378cc40b
LW
42
43$_ = 'aaabbbccc';
44study;
a10707d8
NC
45ok(/(a*b*)(c*)/);
46is($1, 'aaabbb');
47is($2,'ccc');
48ok(/(a+b+c+)/);
49is($1, 'aaabbbccc');
378cc40b 50
a10707d8 51ok(!/a+b?c+/);
378cc40b
LW
52
53$_ = 'aaabccc';
54study;
856271c8
CB
55ok(/a+b?c+/);
56ok(/a*b+c*/);
378cc40b
LW
57
58$_ = 'aaaccc';
59study;
856271c8 60ok(/a*b?c*/);
a10707d8 61ok(!/a*b+c*/);
378cc40b
LW
62
63$_ = 'abcdef';
64study;
856271c8
CB
65ok(/bcd|xyz/);
66ok(/xyz|bcd/);
378cc40b 67
856271c8 68ok(m|bc/*d|);
378cc40b 69
856271c8 70ok(/^$_$/);
378cc40b 71
f02c194e
RGS
72# used to be a test for $*
73ok("ab\ncd\n" =~ /^cd/m);
0dec986a 74
a10707d8 75TODO: {
e826edc3 76 # Even with the alarm() OS/390 and BS2000 can't manage these tests
51153910 77 # (Perl just goes into a busy loop, luckily an interruptable one)
a10707d8
NC
78 todo_skip('busy loop - compiler bug?', 2)
79 if $^O eq 'os390' or $^O eq 'posix-bc';
80
81 # [ID ] tests 25..26 may loop
27c93d93
HS
82
83 $_ = 'FGF';
84 study;
a10707d8
NC
85 ok(!/G.F$/, 'bug 20010618.006');
86 ok(!/[F]F$/, 'bug 20010618.006');
0dec986a 87}