From 192c1e277b50bfcbfdd3717ce2ae7c1a42fa9601 Mon Sep 17 00:00:00 2001 From: "Jerry D. Hedden" Date: Tue, 8 Jan 2008 10:01:02 -0500 Subject: Move re::regexp_pattern to universal.c From: "Jerry D. Hedden" Message-ID: <1ff86f510801081201q5c36f055re6165ebfe8876c2e@mail.gmail.com> p4raw-id: //depot/perl@32911 --- t/op/re.t | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 t/op/re.t (limited to 't/op') diff --git a/t/op/re.t b/t/op/re.t new file mode 100644 index 0000000000..d098bdc7da --- /dev/null +++ b/t/op/re.t @@ -0,0 +1,46 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +use strict; +use warnings; + +use Test::More; # test count at bottom of file +use re qw(is_regexp regexp_pattern + regname regnames regnames_count); +{ + my $qr=qr/foo/pi; + ok(is_regexp($qr),'is_regexp($qr)'); + ok(!is_regexp(''),'is_regexp("")'); + is((regexp_pattern($qr))[0],'foo','regexp_pattern[0]'); + is((regexp_pattern($qr))[1],'ip','regexp_pattern[1]'); + is(regexp_pattern($qr),'(?pi-xsm:foo)','scalar regexp_pattern'); + ok(!regexp_pattern(''),'!regexp_pattern("")'); +} + +if ('1234'=~/(?:(?\d)|(?!))(?\d)(?\d)(?\d)/){ + my @names = sort +regnames(); + is("@names","A B","regnames"); + @names = sort +regnames(0); + is("@names","A B","regnames"); + my $names = regnames(); + is($names, "B", "regnames in scalar context"); + @names = sort +regnames(1); + is("@names","A B C","regnames"); + is(join("", @{regname("A",1)}),"13"); + is(join("", @{regname("B",1)}),"24"); + { + if ('foobar'=~/(?foo)(?bar)/) { + is(regnames_count(),2); + } else { + ok(0); ok(0); + } + } + is(regnames_count(),3); +} +# New tests above this line, don't forget to update the test count below! +use Test::More tests => 14; +# No tests here! -- cgit v1.2.1