This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
f293a0ae12833e3d7e5e0012084943f10162703c
[perl5.git] / t / op.chop
1 #!./perl
2
3 # $Header: op.chop,v 3.0 89/10/18 15:28:19 lwall Locked $
4
5 print "1..4\n";
6
7 # optimized
8
9 $_ = 'abc';
10 $c = do foo();
11 if ($c . $_ eq 'cab') {print "ok 1\n";} else {print "not ok 1 $c$_\n";}
12
13 # unoptimized
14
15 $_ = 'abc';
16 $c = chop($_);
17 if ($c . $_ eq 'cab') {print "ok 2\n";} else {print "not ok 2\n";}
18
19 sub foo {
20     chop;
21 }
22
23 @foo = ("hi \n","there\n","!\n");
24 @bar = @foo;
25 chop(@bar);
26 print join('',@bar) eq 'hi there!' ? "ok 3\n" : "not ok 3\n";
27
28 $foo = "\n";
29 chop($foo,@foo);
30 print join('',$foo,@foo) eq 'hi there!' ? "ok 4\n" : "not ok 4\n";