home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl560.zip / t / lib / tie-stdhandle.t < prev    next >
Text File  |  2000-03-12  |  970b  |  48 lines

  1. #!./perl
  2.  
  3. BEGIN {
  4.     chdir 't' if -d 't';
  5.     unshift @INC, '../lib';
  6. }
  7.  
  8. use Tie::Handle;
  9. tie *tst,Tie::StdHandle;
  10.  
  11. $f = 'tst';
  12.  
  13. print "1..13\n";   
  14.  
  15. # my $file tests
  16.  
  17. unlink("afile.new") if -f "afile";     
  18. print "$!\nnot " unless open($f,"+>afile");
  19. print "ok 1\n";
  20. print "$!\nnot " unless binmode($f);
  21. print "ok 2\n";
  22. print "not " unless -f "afile";     
  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";
  45. print "not " unless close($f);
  46. print "ok 13\n";
  47. unlink("afile");     
  48.