add regmust() to re.pm/re.xs
[p5sagit/p5-mst-13.2.git] / ext / re / t / re_funcs.t
1 #!./perl
2
3 BEGIN {
4         chdir 't' if -d 't';
5         @INC = '../lib';
6         require Config;
7         if (($Config::Config{'extensions'} !~ /\bre\b/) ){
8                 print "1..0 # Skip -- Perl configured without re module\n";
9                 exit 0;
10         }
11 }
12
13 use strict;
14
15 use Test::More; # test count at bottom of file
16 use re qw(is_regexp regexp_pattern regmust);
17 my $qr=qr/foo/i;
18
19 ok(is_regexp($qr),'is_regexp($qr)');
20 ok(!is_regexp(''),'is_regexp("")');
21 is((regexp_pattern($qr))[0],'foo','regexp_pattern[0]');
22 is((regexp_pattern($qr))[1],'i','regexp_pattern[1]');
23 is(regexp_pattern($qr),'(?i-xsm:foo)','scalar regexp_pattern');
24 ok(!regexp_pattern(''),'!regexp_pattern("")');
25 {
26     my $qr=qr/here .* there/x;
27     my ($anchored,$floating)=regmust($qr);
28     is($anchored,'here',"Regmust anchored - qr//");
29     is($floating,'there',"Regmust floating - qr//");
30     my $foo='blah';
31     ($anchored,$floating)=regmust($foo);
32     is($anchored,undef,"Regmust anchored - non ref");
33     is($floating,undef,"Regmust anchored - non ref");
34     my $bar=['blah'];
35     ($anchored,$floating)=regmust($foo);
36     is($anchored,undef,"Regmust anchored - ref");
37     is($floating,undef,"Regmust anchored - ref");
38 }
39
40 # New tests above this line, don't forget to update the test count below!
41 use Test::More tests => 12;
42 # No tests here!