diff options
author | John Peacock <jpeacock@rowman.com> | 2000-05-18 07:55:27 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-10-25 21:03:50 +0000 |
commit | 784707d55e15908335a8276d5ed4548baa321d1f (patch) | |
tree | f6d0c3be03e31678960cc7b9769a90f4a8fe1ef4 /t/op | |
parent | ae21d580cc4565c4ab54286c723cd431c96dedeb (diff) | |
download | perl-784707d55e15908335a8276d5ed4548baa321d1f.tar.gz |
Zero-padded Numerics in Perl Format
Message-ID: <3924126F.A58BE57A@UnivPress.com>
p4raw-id: //depot/perl@7444
Diffstat (limited to 't/op')
-rwxr-xr-x | t/op/write.t | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/t/op/write.t b/t/op/write.t index 5b01eb78b7..fc155a88c7 100755 --- a/t/op/write.t +++ b/t/op/write.t @@ -1,6 +1,6 @@ #!./perl -print "1..9\n"; +print "1..11\n"; my $CAT = ($^O eq 'MSWin32') ? 'type' : 'cat'; @@ -43,7 +43,7 @@ of huma... now is the time for all good men to come to\n"; if (`$CAT Op_write.tmp` eq $right) - { print "ok 1\n"; unlink 'Op_write.tmp'; } + { print "ok 1\n"; 1 while unlink 'Op_write.tmp'; } else { print "not ok 1\n"; } @@ -85,7 +85,7 @@ necessary now is the time for all good men to come to\n"; if (`$CAT Op_write.tmp` eq $right) - { print "ok 2\n"; unlink 'Op_write.tmp'; } + { print "ok 2\n"; 1 while unlink 'Op_write.tmp'; } else { print "not ok 2\n"; } @@ -129,7 +129,7 @@ necessary now is the time for all good men to come to\n"; if (`$CAT Op_write.tmp` eq $right) - { print "ok 3\n"; unlink 'Op_write.tmp'; } + { print "ok 3\n"; 1 while unlink 'Op_write.tmp'; } else { print "not ok 3\n"; } @@ -184,7 +184,7 @@ $right = "fit\n"; if (`$CAT Op_write.tmp` eq $right) - { print "ok 6\n"; unlink 'Op_write.tmp'; } + { print "ok 6\n"; 1 while unlink 'Op_write.tmp'; } else { print "not ok 6\n"; } @@ -213,8 +213,53 @@ write (OUT4); close OUT4; if (`$CAT Op_write.tmp` eq "1\n") { print "ok 9\n"; - unlink "Op_write.tmp"; + 1 while unlink "Op_write.tmp"; } else { print "not ok 9\n"; } + +eval <<'EOFORMAT'; +format OUT10 = +@####.## @0###.## +$test1, $test1 +. +EOFORMAT + +open(OUT10, '>Op_write.tmp') || die "Can't create Op_write.tmp"; + +$test1 = 12.95; +write(OUT10); +close OUT10; + +$right = " 12.95 00012.95\n"; +if (`$CAT Op_write.tmp` eq $right) + { print "ok 10\n"; 1 while unlink 'Op_write.tmp'; } +else + { print "not ok 10\n"; } + +eval <<'EOFORMAT'; +format OUT11 = +@0###.## +$test1 +@ 0# +$test1 +@0 # +$test1 +. +EOFORMAT + +open(OUT11, '>Op_write.tmp') || die "Can't create Op_write.tmp"; + +$test1 = 12.95; +write(OUT11); +close OUT11; + +$right = +"00012.95 +1 0# +10 #\n"; +if (`$CAT Op_write.tmp` eq $right) + { print "ok 11\n"; 1 while unlink 'Op_write.tmp'; } +else + { print "not ok 11\n"; } |