Commit | Line | Data |
---|---|---|
4592e6ca NIS |
1 | #!./perl |
2 | ||
3 | BEGIN { | |
4 | chdir 't' if -d 't'; | |
20822f61 | 5 | @INC = '../lib'; |
4592e6ca NIS |
6 | } |
7 | ||
00db94a9 DM |
8 | use Test::More tests => 19; |
9 | ||
10 | use_ok('Tie::StdHandle'); | |
11 | ||
4592e6ca NIS |
12 | tie *tst,Tie::StdHandle; |
13 | ||
14 | $f = 'tst'; | |
15 | ||
00db94a9 | 16 | unlink("afile.new") if -f "afile"; |
4592e6ca | 17 | |
00db94a9 DM |
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"); | |
4592e6ca | 29 | |
4592e6ca | 30 | $b = <$f>; |
00db94a9 DM |
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 | ||
4592e6ca | 38 | $b = <$f>; |
00db94a9 DM |
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 | ||
052b629e | 46 | unlink("afile"); |