diff options
author | David Mitchell <davem@iabyn.com> | 2013-10-23 16:37:39 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2013-10-23 16:37:39 +0100 |
commit | 00db94a99cf028d8d91eedfbb546d9ebc2b1ae7c (patch) | |
tree | 240fc94c9428d2f47b406c898c90200284ea34d2 /lib/Tie | |
parent | fea7fb25afff9547ae810fad732c75518bb156a3 (diff) | |
download | perl-00db94a99cf028d8d91eedfbb546d9ebc2b1ae7c.tar.gz |
stdhandle.t: convert to use Test::More
print "ok 13\n" is *so* 1990's.
Diffstat (limited to 'lib/Tie')
-rw-r--r-- | lib/Tie/Handle/stdhandle.t | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/lib/Tie/Handle/stdhandle.t b/lib/Tie/Handle/stdhandle.t index b1ae7c455b..861bdab116 100644 --- a/lib/Tie/Handle/stdhandle.t +++ b/lib/Tie/Handle/stdhandle.t @@ -5,47 +5,42 @@ BEGIN { @INC = '../lib'; } -use Tie::StdHandle; +use Test::More tests => 19; + +use_ok('Tie::StdHandle'); + tie *tst,Tie::StdHandle; $f = 'tst'; -print "1..14\n"; +unlink("afile.new") if -f "afile"; -# my $file tests +ok(open($f,"+>afile"), "open +>afile"); +ok(open($f, "+<", "afile"), "open +<, afile"); +ok(binmode($f), "binmode") + or diag("binmode: $!\n"); + +ok(-f "afile", "-f afile"); + +ok(print($f "SomeData\n"), "print"); +is(tell($f), 9, "tell"); +ok(printf($f "Some %d value\n",1234), "printf"); +ok(seek($f,0,0), "seek"); -unlink("afile.new") if -f "afile"; -print "$!\nnot " unless open($f,"+>afile") && open($f, "+<", "afile"); -print "ok 1\n"; -print "$!\nnot " unless binmode($f); -print "ok 2\n"; -print "not " unless -f "afile"; -print "ok 3\n"; -print "not " unless print $f "SomeData\n"; -print "ok 4\n"; -print "not " unless tell($f) == 9; -print "ok 5\n"; -print "not " unless printf $f "Some %d value\n",1234; -print "ok 6\n"; -print "not " unless seek($f,0,0); -print "ok 7\n"; $b = <$f>; -print "not " unless $b eq "SomeData\n"; -print "ok 8\n"; -print "not " if eof($f); -print "ok 9\n"; -read($f,($b=''),4); -print "'$b' not " unless $b eq 'Some'; -print "ok 10\n"; -print "not " unless getc($f) eq ' '; -print "ok 11\n"; +is($b, "SomeData\n", "b eq SomeData"); +ok(!eof($f), "!eof"); + +is(read($f,($b=''),4), 4, "read(4)"); +is($b, 'Some', "b eq Some"); +is(getc($f), ' ', "getc"); + $b = <$f>; -print "not " unless eof($f); -print "ok 12\n"; -seek($f,0,0); -read($f,($b='scrinches'),4,4); # with offset -print "'$b' not " unless $b eq 'scriSome'; -print "ok 13\n"; -print "not " unless close($f); -print "ok 14\n"; +ok(eof($f), "eof"); +ok(seek($f,0,0), "seek"); +is(read($f,($b='scrinches'),4,4), 4, "read(4,4)"); # with offset +is($b, 'scriSome', "b eq scriSome"); + +ok(close($f), "close"); + unlink("afile"); |