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
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6 }
7
8 use Test::More tests => 19;
9
10 use_ok('Tie::StdHandle');
11
12 tie *tst,Tie::StdHandle;
13
14 $f = 'tst';
15
16 unlink("afile.new") if -f "afile";
17
18 ok(open($f,"+>afile"), "open +>afile");
19 ok(open($f, "+<", "afile"), "open +<, afile");
20 ok(binmode($f), "binmode")
21     or diag("binmode: $!\n");
22
23 ok(-f "afile", "-f afile");
24
25 ok(print($f "SomeData\n"), "print");
26 is(tell($f), 9, "tell");
27 ok(printf($f "Some %d value\n",1234), "printf");
28 ok(seek($f,0,0), "seek");
29
30 $b = <$f>;
31 is($b, "SomeData\n", "b eq SomeData");
32 ok(!eof($f), "!eof");
33
34 is(read($f,($b=''),4), 4, "read(4)");
35 is($b, 'Some', "b eq Some");
36 is(getc($f), ' ', "getc");
37
38 $b = <$f>;
39 ok(eof($f), "eof");
40 ok(seek($f,0,0), "seek");
41 is(read($f,($b='scrinches'),4,4), 4, "read(4,4)"); # with offset
42 is($b, 'scriSome', "b eq scriSome");
43
44 ok(close($f), "close");
45
46 unlink("afile");