This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
stdhandle.t: convert to use Test::More
[perl5.git] / lib / Tie / Handle / stdhandle.t
CommitLineData
4592e6ca
NIS
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
20822f61 5 @INC = '../lib';
4592e6ca
NIS
6}
7
00db94a9
DM
8use Test::More tests => 19;
9
10use_ok('Tie::StdHandle');
11
4592e6ca
NIS
12tie *tst,Tie::StdHandle;
13
14$f = 'tst';
15
00db94a9 16unlink("afile.new") if -f "afile";
4592e6ca 17
00db94a9
DM
18ok(open($f,"+>afile"), "open +>afile");
19ok(open($f, "+<", "afile"), "open +<, afile");
20ok(binmode($f), "binmode")
21 or diag("binmode: $!\n");
22
23ok(-f "afile", "-f afile");
24
25ok(print($f "SomeData\n"), "print");
26is(tell($f), 9, "tell");
27ok(printf($f "Some %d value\n",1234), "printf");
28ok(seek($f,0,0), "seek");
4592e6ca 29
4592e6ca 30$b = <$f>;
00db94a9
DM
31is($b, "SomeData\n", "b eq SomeData");
32ok(!eof($f), "!eof");
33
34is(read($f,($b=''),4), 4, "read(4)");
35is($b, 'Some', "b eq Some");
36is(getc($f), ' ', "getc");
37
4592e6ca 38$b = <$f>;
00db94a9
DM
39ok(eof($f), "eof");
40ok(seek($f,0,0), "seek");
41is(read($f,($b='scrinches'),4,4), 4, "read(4,4)"); # with offset
42is($b, 'scriSome', "b eq scriSome");
43
44ok(close($f), "close");
45
052b629e 46unlink("afile");