1*0Sstevel@tonic-gate#!./perl -i.inplace 2*0Sstevel@tonic-gate# note the extra switch, for the test below 3*0Sstevel@tonic-gate 4*0Sstevel@tonic-gateBEGIN { 5*0Sstevel@tonic-gate chdir 't' if -d 't'; 6*0Sstevel@tonic-gate @INC = '../lib'; 7*0Sstevel@tonic-gate} 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gateuse Test::More tests => 55; 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gateuse English qw( -no_match_vars ) ; 12*0Sstevel@tonic-gateuse Config; 13*0Sstevel@tonic-gateuse Errno; 14*0Sstevel@tonic-gate 15*0Sstevel@tonic-gateis( $PID, $$, '$PID' ); 16*0Sstevel@tonic-gate 17*0Sstevel@tonic-gate$_ = 1; 18*0Sstevel@tonic-gateis( $ARG, $_, '$ARG' ); 19*0Sstevel@tonic-gate 20*0Sstevel@tonic-gatesub foo { 21*0Sstevel@tonic-gate is($ARG[0], $_[0], '@ARG' ); 22*0Sstevel@tonic-gate} 23*0Sstevel@tonic-gatefoo(1); 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate"abc" =~ /b/; 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gateok( !$PREMATCH, '$PREMATCH undefined' ); 28*0Sstevel@tonic-gateok( !$MATCH, '$MATCH undefined' ); 29*0Sstevel@tonic-gateok( !$POSTMATCH, '$POSTMATCH undefined' ); 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate$OFS = " "; 32*0Sstevel@tonic-gate$ORS = "\n"; 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate{ 35*0Sstevel@tonic-gate local(*IN, *OUT); 36*0Sstevel@tonic-gate if ($^O ne 'dos') { 37*0Sstevel@tonic-gate pipe(IN, OUT); 38*0Sstevel@tonic-gate } else { 39*0Sstevel@tonic-gate open(OUT, ">en.tmp"); 40*0Sstevel@tonic-gate } 41*0Sstevel@tonic-gate select(OUT); 42*0Sstevel@tonic-gate $| = 1; 43*0Sstevel@tonic-gate print 'ok', '7'; 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate # since $| is 1, this should be true 46*0Sstevel@tonic-gate ok( $OUTPUT_AUTOFLUSH, '$OUTPUT_AUTOFLUSH should be true' ); 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate my $close = close OUT; 49*0Sstevel@tonic-gate ok( !($close) == $CHILD_ERROR, '$CHILD_ERROR should be false' ); 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate open(IN, "<en.tmp") if ($^O eq 'dos'); 52*0Sstevel@tonic-gate my $foo = <IN>; 53*0Sstevel@tonic-gate like( $foo, qr/ok 7/, '$OFS' ); 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate # chomp is true because $ORS is "\n" 56*0Sstevel@tonic-gate ok( chomp($foo), '$ORS should be \n' ); 57*0Sstevel@tonic-gate} 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gateis( $FORMAT_NAME, 'OUT', '$FORMAT_NAME' ); 60*0Sstevel@tonic-gateis( $FORMAT_TOP_NAME, 'OUT_TOP', '$FORMAT_TOP_NAME' ); 61*0Sstevel@tonic-gateis( $FORMAT_FORMFEED, "\f", '$FORMAT_FORMFEED' ); 62*0Sstevel@tonic-gateis( $FORMAT_LINES_LEFT, 0, '$FORMAT_LINES_LEFT' ); 63*0Sstevel@tonic-gateis( $FORMAT_LINES_PER_PAGE, 60, '$FORMAT_LINES_PER_PAGE' ); 64*0Sstevel@tonic-gateis( $FORMAT_LINE_BREAK_CHARACTERS, " \n-", '$FORMAT_LINE_BREAK_CHARACTERS'); 65*0Sstevel@tonic-gateis( $FORMAT_PAGE_NUMBER, 0, '$FORMAT_PAGE_NUMBER' ); 66*0Sstevel@tonic-gateis( $ACCUMULATOR, $^A, '$ACCUMULATOR' ); 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gateundef $OUTPUT_FIELD_SEPARATOR; 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gateif ($threads) { $" = "\n" } else { $LIST_SEPARATOR = "\n" }; 71*0Sstevel@tonic-gate@foo = (8, 9); 72*0Sstevel@tonic-gate@foo = split(/\n/, "@foo"); 73*0Sstevel@tonic-gateis( $foo[0], 8, '$"' ); 74*0Sstevel@tonic-gateis( $foo[1], 9, '$LIST_SEPARATOR' ); 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gateundef $OUTPUT_RECORD_SEPARATOR; 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gateeval 'NO SUCH FUNCTION'; 79*0Sstevel@tonic-gatelike( $EVAL_ERROR, qr/method/, '$EVAL_ERROR' ); 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gateis( $UID, $<, '$UID' ); 82*0Sstevel@tonic-gateis( $GID, $(, '$GID' ); 83*0Sstevel@tonic-gateis( $EUID, $>, '$EUID' ); 84*0Sstevel@tonic-gateis( $EGID, $), '$EGID' ); 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gateis( $PROGRAM_NAME, $0, '$PROGRAM_NAME' ); 87*0Sstevel@tonic-gateis( $BASETIME, $^T, '$BASETIME' ); 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gateis( $PERL_VERSION, $^V, '$PERL_VERSION' ); 90*0Sstevel@tonic-gateis( $DEBUGGING, $^D, '$DEBUGGING' ); 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gateis( $WARNING, 0, '$WARNING' ); 93*0Sstevel@tonic-gatelike( $EXECUTABLE_NAME, qr/perl/i, '$EXECUTABLE_NAME' ); 94*0Sstevel@tonic-gateis( $OSNAME, $Config{osname}, '$OSNAME' ); 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate# may be non-portable 97*0Sstevel@tonic-gateok( $SYSTEM_FD_MAX >= 2, '$SYSTEM_FD_MAX should be at least 2' ); 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gateis( $INPLACE_EDIT, '.inplace', '$INPLACE_EDIT' ); 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate'aabbcc' =~ /(.{2}).+(.{2})(?{ 9 })/; 102*0Sstevel@tonic-gateis( $LAST_PAREN_MATCH, 'cc', '$LAST_PARENT_MATCH' ); 103*0Sstevel@tonic-gateis( $LAST_REGEXP_CODE_RESULT, 9, '$LAST_REGEXP_CODE_RESULT' ); 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gateis( $LAST_MATCH_START[1], 0, '@LAST_MATCH_START' ); 106*0Sstevel@tonic-gateis( $LAST_MATCH_END[1], 2, '@LAST_MATCH_END' ); 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gateok( !$PERLDB, '$PERLDB should be false' ); 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate{ 111*0Sstevel@tonic-gate local $INPUT_RECORD_SEPARATOR = "\n\n"; 112*0Sstevel@tonic-gate like( <DATA>, qr/a paragraph./, '$INPUT_RECORD_SEPARATOR' ); 113*0Sstevel@tonic-gate} 114*0Sstevel@tonic-gatelike( <DATA>, qr/second paragraph..\z/s, '$INPUT_RECORD_SEPARATOR' ); 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gateis( $INPUT_LINE_NUMBER, 2, '$INPUT_LINE_NUMBER' ); 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gatemy %hash; 119*0Sstevel@tonic-gate$SUBSCRIPT_SEPARATOR = '|'; 120*0Sstevel@tonic-gate$hash{d,e,f} = 1; 121*0Sstevel@tonic-gate$SUBSEP = ','; 122*0Sstevel@tonic-gate$hash{'a', 'b', 'c'} = 1; 123*0Sstevel@tonic-gatemy @keys = sort keys %hash; 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gateis( $keys[0], 'a,b,c', '$SUBSCRIPT_SEPARATOR' ); 126*0Sstevel@tonic-gateis( $keys[1], 'd|e|f', '$SUBSCRIPT_SEPARATOR' ); 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gateeval { is( $EXCEPTIONS_BEING_CAUGHT, 1, '$EXCEPTIONS_BEING_CAUGHT' ) }; 129*0Sstevel@tonic-gateok( !$EXCEPTIONS_BEING_CAUGHT, '$EXCEPTIONS_BEING_CAUGHT should be false' ); 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gateeval { local *F; my $f = 'asdasdasd'; ++$f while -e $f; open(F, $f); }; 132*0Sstevel@tonic-gateis( $OS_ERROR, $ERRNO, '$OS_ERROR' ); 133*0Sstevel@tonic-gateok( $OS_ERROR{ENOENT}, '%OS_ERROR (ENOENT should be set)' ); 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gatepackage B; 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gateuse English; 138*0Sstevel@tonic-gate 139*0Sstevel@tonic-gate"abc" =~ /b/; 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gatemain::is( $PREMATCH, 'a', '$PREMATCH defined' ); 142*0Sstevel@tonic-gatemain::is( $MATCH, 'b', '$MATCH defined' ); 143*0Sstevel@tonic-gatemain::is( $POSTMATCH, 'c', '$POSTMATCH defined' ); 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate{ 146*0Sstevel@tonic-gate my $s = "xyz"; 147*0Sstevel@tonic-gate $s =~ s/y/t$MATCH/; 148*0Sstevel@tonic-gate main::is( $s, "xtyz", '$MATCH defined in right side of s///' ); 149*0Sstevel@tonic-gate} 150*0Sstevel@tonic-gate 151*0Sstevel@tonic-gatepackage C; 152*0Sstevel@tonic-gate 153*0Sstevel@tonic-gateuse English qw( -no_match_vars ) ; 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate"abc" =~ /b/; 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gatemain::ok( !$PREMATCH, '$PREMATCH disabled' ); 158*0Sstevel@tonic-gatemain::ok( !$MATCH, '$MATCH disabled' ); 159*0Sstevel@tonic-gatemain::ok( !$POSTMATCH, '$POSTMATCH disabled' ); 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate__END__ 162*0Sstevel@tonic-gateThis is a line. 163*0Sstevel@tonic-gateThis is a paragraph. 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gateThis is a second paragraph. 166*0Sstevel@tonic-gateIt has several lines. 167