PL_scopestack_name needs to be present, -DDEBUGGING or not.
[p5sagit/p5-mst-13.2.git] / ext / re / t / re.t
CommitLineData
93c8c1bf 1#!./perl
2
93c8c1bf 3BEGIN {
2628e9ce 4 require Config;
5 if (($Config::Config{'extensions'} !~ /\bre\b/) ){
6 print "1..0 # Skip -- Perl configured without re module\n";
7 exit 0;
8 }
93c8c1bf 9}
10
4940c443 11use strict;
12
f9f4320a 13use Test::More tests => 13;
93c8c1bf 14require_ok( 're' );
15
16# setcolor
17$INC{ 'Term/Cap.pm' } = 1;
18local $ENV{PERL_RE_TC};
19re::setcolor();
20is( $ENV{PERL_RE_COLORS}, "md\tme\tso\tse\tus\tue",
21 'setcolor() should provide default colors' );
22$ENV{PERL_RE_TC} = 'su,n,ny';
23re::setcolor();
24is( $ENV{PERL_RE_COLORS}, "su\tn\tny", '... or use $ENV{PERL_RE_COLORS}' );
25
26# bits
27# get on
28my $warn;
29local $SIG{__WARN__} = sub {
30 $warn = shift;
31};
f9f4320a 32#eval { re::bits(1) };
33#like( $warn, qr/Useless use/, 'bits() should warn with no args' );
93c8c1bf 34
35delete $ENV{PERL_RE_COLORS};
36re::bits(0, 'debug');
4940c443 37is( $ENV{PERL_RE_COLORS}, undef,
93c8c1bf 38 "... should not set regex colors given 'debug'" );
39re::bits(0, 'debugcolor');
40isnt( $ENV{PERL_RE_COLORS}, '',
41 "... should set regex colors given 'debugcolor'" );
42re::bits(0, 'nosuchsubpragma');
43like( $warn, qr/Unknown "re" subpragma/,
44 '... should warn about unknown subpragma' );
45ok( re::bits(0, 'taint') & 0x00100000, '... should set taint bits' );
46ok( re::bits(0, 'eval') & 0x00200000, '... should set eval bits' );
47
48local $^H;
49
50# import
51re->import('taint', 'eval');
52ok( $^H & 0x00100000, 'import should set taint bits in $^H when requested' );
53ok( $^H & 0x00200000, 'import should set eval bits in $^H when requested' );
54
55re->unimport('taint');
56ok( !( $^H & 0x00100000 ), 'unimport should clear bits in $^H when requested' );
57re->unimport('eval');
58ok( !( $^H & 0x00200000 ), '... and again' );
07be1b83 59my $reg=qr/(foo|bar|baz|blah)/;
60close STDERR;
61eval"use re Debug=>'ALL'";
62my $ok='foo'=~/$reg/;
63eval"no re Debug=>'ALL'";
64ok( $ok, 'No segv!' );
65
93c8c1bf 66package Term::Cap;
67
68sub Tgetent {
69 bless({}, $_[0]);
70}
71
72sub Tputs {
73 return $_[1];
74}