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