5 if (($Config::Config{'extensions'} !~ /\bre\b/) ){
6 print "1..0 # Skip -- Perl configured without re module\n";
13 my $re_taint_bit = 0x00100000;
14 my $re_eval_bit = 0x00200000;
16 use Test::More tests => 16;
20 $INC{ 'Term/Cap.pm' } = 1;
21 local $ENV{PERL_RE_TC};
23 is( $ENV{PERL_RE_COLORS}, "md\tme\tso\tse\tus\tue",
24 'setcolor() should provide default colors' );
25 $ENV{PERL_RE_TC} = 'su,n,ny';
27 is( $ENV{PERL_RE_COLORS}, "su\tn\tny", '... or use $ENV{PERL_RE_COLORS}' );
32 local $SIG{__WARN__} = sub {
35 #eval { re::bits(1) };
36 #like( $warn, qr/Useless use/, 'bits() should warn with no args' );
38 delete $ENV{PERL_RE_COLORS};
40 is( $ENV{PERL_RE_COLORS}, undef,
41 "... should not set regex colors given 'debug'" );
42 re::bits(0, 'debugcolor');
43 isnt( $ENV{PERL_RE_COLORS}, '',
44 "... should set regex colors given 'debugcolor'" );
45 re::bits(0, 'nosuchsubpragma');
46 like( $warn, qr/Unknown "re" subpragma/,
47 '... should warn about unknown subpragma' );
48 ok( re::bits(0, 'taint') & $re_taint_bit, '... should set taint bits' );
49 ok( re::bits(0, 'eval') & $re_eval_bit, '... should set eval bits' );
52 eval "use re qw(debug ALL)";
53 like( $warn, qr/"Debug" not "debug"/, 'debug with debugging type should warn');
58 re->import('taint', 'eval');
59 ok( $^H & $re_taint_bit, 'import should set taint bits in $^H when requested' );
60 ok( $^H & $re_eval_bit, 'import should set eval bits in $^H when requested' );
62 re->unimport('taint');
63 ok( !( $^H & $re_taint_bit ), 'unimport should clear bits in $^H when requested' );
65 ok( !( $^H & $re_eval_bit ), '... and again' );
66 my $reg=qr/(foo|bar|baz|blah)/;
68 eval"use re Debug=>'ALL'";
70 eval"no re Debug=>'ALL'";
71 ok( $ok, 'No segv!' );
73 my $message = "Don't tread on me";
76 is($_, $message, "re doesn't clobber \$_");
92 local $SIG{__WARN__} = sub { warn shift; ++$w };
94 is $w, undef, 'no warning for "use re;" (which is not useless)';