diff options
author | markm <markm@FreeBSD.org> | 1998-09-09 07:00:04 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 1998-09-09 07:00:04 +0000 |
commit | 4fcbc3669aa997848e15198cc9fb856287a6788c (patch) | |
tree | 58b20e81687d6d5931f120b50802ed21225bf440 /contrib/perl5/t/cmd/for.t | |
download | FreeBSD-src-4fcbc3669aa997848e15198cc9fb856287a6788c.zip FreeBSD-src-4fcbc3669aa997848e15198cc9fb856287a6788c.tar.gz |
Initial import of Perl5. The king is dead; long live the king!
Diffstat (limited to 'contrib/perl5/t/cmd/for.t')
-rwxr-xr-x | contrib/perl5/t/cmd/for.t | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/contrib/perl5/t/cmd/for.t b/contrib/perl5/t/cmd/for.t new file mode 100755 index 0000000..e45f050 --- /dev/null +++ b/contrib/perl5/t/cmd/for.t @@ -0,0 +1,49 @@ +#!./perl + +# $RCSfile: for.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:09 $ + +print "1..7\n"; + +for ($i = 0; $i <= 10; $i++) { + $x[$i] = $i; +} +$y = $x[10]; +print "#1 :$y: eq :10:\n"; +$y = join(' ', @x); +print "#1 :$y: eq :0 1 2 3 4 5 6 7 8 9 10:\n"; +if (join(' ', @x) eq '0 1 2 3 4 5 6 7 8 9 10') { + print "ok 1\n"; +} else { + print "not ok 1\n"; +} + +$i = $c = 0; +for (;;) { + $c++; + last if $i++ > 10; +} +if ($c == 12) {print "ok 2\n";} else {print "not ok 2\n";} + +$foo = 3210; +@ary = (1,2,3,4,5); +foreach $foo (@ary) { + $foo *= 2; +} +if (join('',@ary) eq '246810') {print "ok 3\n";} else {print "not ok 3\n";} + +for (@ary) { + s/(.*)/ok $1\n/; +} + +print $ary[1]; + +# test for internal scratch array generation +# this also tests that $foo was restored to 3210 after test 3 +for (split(' ','a b c d e')) { + $foo .= $_; +} +if ($foo eq '3210abcde') {print "ok 5\n";} else {print "not ok 5 $foo\n";} + +foreach $foo (("ok 6\n","ok 7\n")) { + print $foo; +} |