13 is ($c . $_, 'cab', 'optimized');
17 is ($c . $_ , 'cab', 'unoptimized');
23 @foo = ("hi \n","there\n","!\n");
26 is (join('',@bar), 'hi there!');
30 is (join('',$foo,@foo), 'hi there!');
34 ok ($got == 1) or print "# got $got\n";
39 ok ($got == 1) or print "# got $got\n";
44 ok ($got == 0) or print "# got $got\n";
50 ok ($got == 2) or print "# got $got\n";
56 ok ($got == 0) or print "# got $got\n";
62 ok ($got == 5) or print "# got $got\n";
68 ok ($got == 2) or print "# got $got\n";
74 ok ($got == 1) or print "# got $got\n";
80 ok ($got == 0) or print "# got $got\n";
86 ok ($got == 2) or print "# got $got\n";
92 ok ($got == 2) or print "# got $got\n";
98 ok ($got == 0) or print "# got $got\n";
101 # This case once mistakenly behaved like paragraph mode.
105 ok ($got == 0) or print "# got $got\n";
112 is ($_, "abc", "Go Unicode");
116 is ($_, "abc\x{1234}");
118 $_ = "\x{1234}\x{2345}";
122 my @stuff = qw(this that);
123 is (chop(@stuff[0,1]), 't');
125 # bug id 20010305.012
126 @stuff = qw(ab cd ef);
127 is (chop(@stuff = @stuff), 'f');
129 @stuff = qw(ab cd ef);
130 is (chop(@stuff[0, 2]), 'f');
133 is (chop(@stuff{1, 3}), '4');
135 # chomp should not stringify references unless it decides to modify them
139 ok ($got == 0) or print "# got $got\n";
140 is (ref($_), "ARRAY", "chomp ref (modify)");
142 $/ = ")"; # the last char of something like "ARRAY(0x80ff6e4)"
144 ok ($got == 1) or print "# got $got\n";
145 ok (!ref($_), "chomp ref (no modify)");
149 %chomp = ("One" => "One", "Two\n" => "Two", "" => "");
150 %chop = ("One" => "On", "Two\n" => "Two", "" => "");
152 foreach (keys %chomp) {
158 fail ("\$\@ = \"$err\"");
160 is ($_, $chomp{$key}, "chomp hash key");
164 foreach (keys %chop) {
170 fail ("\$\@ = \"$err\"");
172 is ($_, $chop{$key}, "chop hash key");
176 # chop and chomp can't be lvalues
177 eval 'chop($x) = 1;';
178 ok($@ =~ /Can\'t modify.*chop.*in.*assignment/);
179 eval 'chomp($x) = 1;';
180 ok($@ =~ /Can\'t modify.*chom?p.*in.*assignment/);
181 eval 'chop($x, $y) = (1, 2);';
182 ok($@ =~ /Can\'t modify.*chop.*in.*assignment/);
183 eval 'chomp($x, $y) = (1, 2);';
184 ok($@ =~ /Can\'t modify.*chom?p.*in.*assignment/);
186 my @chars = ("N", "\xd3", substr ("\xd4\x{100}", 0, 1), chr 1296);
187 foreach my $start (@chars) {
188 foreach my $end (@chars) {
190 my $message = "start=" . ord ($start) . " end=" . ord $end;
191 my $string = $start . $end;
193 is ($string, $start, $message);
196 utf8::encode ($end_utf8);
197 next if $end_utf8 eq $end;
199 # $end ne $end_utf8, so these should not chomp.
200 $string = $start . $end_utf8;
201 my $chomped = $string;
203 is ($chomped, $string, "$message (end as bytes)");
206 $string = $start . $end;
209 is ($chomped, $string, "$message (\$/ as bytes)");
214 # returns length in characters, but not in bytes.
220 $/ = "\x{100}\x{101}";