Commit | Line | Data |
---|---|---|
4592e6ca NIS |
1 | #!./perl |
2 | ||
3 | BEGIN { | |
4 | chdir 't' if -d 't'; | |
20822f61 | 5 | @INC = '../lib'; |
4592e6ca NIS |
6 | } |
7 | ||
6269bcb3 | 8 | use Tie::StdHandle; |
4592e6ca NIS |
9 | tie *tst,Tie::StdHandle; |
10 | ||
11 | $f = 'tst'; | |
12 | ||
7762c374 | 13 | print "1..14\n"; |
4592e6ca NIS |
14 | |
15 | # my $file tests | |
16 | ||
052b629e GA |
17 | unlink("afile.new") if -f "afile"; |
18 | print "$!\nnot " unless open($f,"+>afile") && open($f, "+<", "afile"); | |
4592e6ca NIS |
19 | print "ok 1\n"; |
20 | print "$!\nnot " unless binmode($f); | |
21 | print "ok 2\n"; | |
052b629e | 22 | print "not " unless -f "afile"; |
4592e6ca NIS |
23 | print "ok 3\n"; |
24 | print "not " unless print $f "SomeData\n"; | |
25 | print "ok 4\n"; | |
26 | print "not " unless tell($f) == 9; | |
27 | print "ok 5\n"; | |
28 | print "not " unless printf $f "Some %d value\n",1234; | |
29 | print "ok 6\n"; | |
30 | print "not " unless seek($f,0,0); | |
31 | print "ok 7\n"; | |
32 | $b = <$f>; | |
33 | print "not " unless $b eq "SomeData\n"; | |
34 | print "ok 8\n"; | |
35 | print "not " if eof($f); | |
36 | print "ok 9\n"; | |
37 | read($f,($b=''),4); | |
38 | print "'$b' not " unless $b eq 'Some'; | |
39 | print "ok 10\n"; | |
40 | print "not " unless getc($f) eq ' '; | |
41 | print "ok 11\n"; | |
42 | $b = <$f>; | |
43 | print "not " unless eof($f); | |
44 | print "ok 12\n"; | |
7762c374 FC |
45 | seek($f,0,0); |
46 | read($f,($b='scrinches'),4,4); # with offset | |
47 | print "'$b' not " unless $b eq 'scriSome'; | |
4592e6ca | 48 | print "ok 13\n"; |
7762c374 FC |
49 | print "not " unless close($f); |
50 | print "ok 14\n"; | |
052b629e | 51 | unlink("afile"); |