diff options
author | Mark Murray <markm@FreeBSD.org> | 1998-09-09 07:00:04 +0000 |
---|---|---|
committer | Mark Murray <markm@FreeBSD.org> | 1998-09-09 07:00:04 +0000 |
commit | ff6b7ba98e8d4aab04cbe2bfdffdfc9171c1812b (patch) | |
tree | 58b20e81687d6d5931f120b50802ed21225bf440 /contrib/perl5/t/op/sprintf.t |
Initial import of Perl5. The king is dead; long live the king!vendor/perl5/5.005.02
Notes
Notes:
svn path=/vendor/perl5/dist/; revision=38980
svn path=/vendor/perl5/5.005.02/; revision=38982; tag=vendor/perl5/5.005.02
Diffstat (limited to 'contrib/perl5/t/op/sprintf.t')
-rwxr-xr-x | contrib/perl5/t/op/sprintf.t | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/contrib/perl5/t/op/sprintf.t b/contrib/perl5/t/op/sprintf.t new file mode 100755 index 000000000000..b9b4751c791d --- /dev/null +++ b/contrib/perl5/t/op/sprintf.t @@ -0,0 +1,33 @@ +#!./perl + +# $RCSfile: sprintf.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:27 $ + +print "1..4\n"; + +$^W = 1; +$SIG{__WARN__} = sub { + if ($_[0] =~ /^Invalid conversion/) { + $w++; + } else { + warn @_; + } +}; + +$w = 0; +$x = sprintf("%3s %-4s%%foo %.0d%5d %#x%c%3.1f","hi",123,0,456,0,ord('A'),3.0999); +if ($x eq ' hi 123 %foo 456 0A3.1' && $w == 0) { + print "ok 1\n"; +} else { + print "not ok 1 '$x'\n"; +} + +for $i (2 .. 4) { + $f = ('%6 .6s', '%6. 6s', '%6.6 s')[$i - 2]; + $w = 0; + $x = sprintf($f, ''); + if ($x eq $f && $w == 1) { + print "ok $i\n"; + } else { + print "not ok $i '$x' '$f' '$w'\n"; + } +} |