1*0Sstevel@tonic-gate#!./perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateBEGIN { 4*0Sstevel@tonic-gate chdir 't' if -d 't'; 5*0Sstevel@tonic-gate @INC = '../lib'; 6*0Sstevel@tonic-gate} 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gateuse strict; 9*0Sstevel@tonic-gate 10*0Sstevel@tonic-gateuse Test::More tests => 13; 11*0Sstevel@tonic-gaterequire_ok( 're' ); 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gate# setcolor 14*0Sstevel@tonic-gate$INC{ 'Term/Cap.pm' } = 1; 15*0Sstevel@tonic-gatelocal $ENV{PERL_RE_TC}; 16*0Sstevel@tonic-gatere::setcolor(); 17*0Sstevel@tonic-gateis( $ENV{PERL_RE_COLORS}, "md\tme\tso\tse\tus\tue", 18*0Sstevel@tonic-gate 'setcolor() should provide default colors' ); 19*0Sstevel@tonic-gate$ENV{PERL_RE_TC} = 'su,n,ny'; 20*0Sstevel@tonic-gatere::setcolor(); 21*0Sstevel@tonic-gateis( $ENV{PERL_RE_COLORS}, "su\tn\tny", '... or use $ENV{PERL_RE_COLORS}' ); 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate# bits 24*0Sstevel@tonic-gate# get on 25*0Sstevel@tonic-gatemy $warn; 26*0Sstevel@tonic-gatelocal $SIG{__WARN__} = sub { 27*0Sstevel@tonic-gate $warn = shift; 28*0Sstevel@tonic-gate}; 29*0Sstevel@tonic-gateeval { re::bits(1) }; 30*0Sstevel@tonic-gatelike( $warn, qr/Useless use/, 'bits() should warn with no args' ); 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gatedelete $ENV{PERL_RE_COLORS}; 33*0Sstevel@tonic-gatere::bits(0, 'debug'); 34*0Sstevel@tonic-gateis( $ENV{PERL_RE_COLORS}, undef, 35*0Sstevel@tonic-gate "... should not set regex colors given 'debug'" ); 36*0Sstevel@tonic-gatere::bits(0, 'debugcolor'); 37*0Sstevel@tonic-gateisnt( $ENV{PERL_RE_COLORS}, '', 38*0Sstevel@tonic-gate "... should set regex colors given 'debugcolor'" ); 39*0Sstevel@tonic-gatere::bits(0, 'nosuchsubpragma'); 40*0Sstevel@tonic-gatelike( $warn, qr/Unknown "re" subpragma/, 41*0Sstevel@tonic-gate '... should warn about unknown subpragma' ); 42*0Sstevel@tonic-gateok( re::bits(0, 'taint') & 0x00100000, '... should set taint bits' ); 43*0Sstevel@tonic-gateok( re::bits(0, 'eval') & 0x00200000, '... should set eval bits' ); 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gatelocal $^H; 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate# import 48*0Sstevel@tonic-gatere->import('taint', 'eval'); 49*0Sstevel@tonic-gateok( $^H & 0x00100000, 'import should set taint bits in $^H when requested' ); 50*0Sstevel@tonic-gateok( $^H & 0x00200000, 'import should set eval bits in $^H when requested' ); 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gatere->unimport('taint'); 53*0Sstevel@tonic-gateok( !( $^H & 0x00100000 ), 'unimport should clear bits in $^H when requested' ); 54*0Sstevel@tonic-gatere->unimport('eval'); 55*0Sstevel@tonic-gateok( !( $^H & 0x00200000 ), '... and again' ); 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gatepackage Term::Cap; 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gatesub Tgetent { 60*0Sstevel@tonic-gate bless({}, $_[0]); 61*0Sstevel@tonic-gate} 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gatesub Tputs { 64*0Sstevel@tonic-gate return $_[1]; 65*0Sstevel@tonic-gate} 66