home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl560.zip / t / lib / textfill.t < prev    next >
Text File  |  1999-07-20  |  3KB  |  99 lines

  1. #!./perl -w
  2.  
  3. BEGIN {
  4.     chdir 't' if -d 't';
  5.     unshift @INC, '../lib';
  6. }
  7.  
  8. use Text::Wrap qw(&fill);
  9.  
  10. @tests = (split(/\nEND\n/s, <<DONE));
  11. TEST1
  12. Cyberdog Information
  13.  
  14. Cyberdog & Netscape in the news
  15. Important Press Release regarding Cyberdog and Netscape. Check it out! 
  16.  
  17. Cyberdog Plug-in Support!
  18. Cyberdog support for Netscape Plug-ins is now available to download! Go
  19. to the Cyberdog Beta Download page and download it now! 
  20.  
  21. Cyberdog Book
  22. Check out Jesse Feiler's way-cool book about Cyberdog. You can find
  23. details out about the book as well as ordering information at Philmont
  24. Software Mill site. 
  25.  
  26. Java!
  27. Looking to view Java applets in Cyberdog 1.1 Beta 3? Download and install
  28. the Mac OS Runtime for Java and try it out! 
  29.  
  30. Cyberdog 1.1 Beta 3
  31. We hope that Cyberdog and OpenDoc 1.1 will be available within the next
  32. two weeks. In the meantime, we have released another version of
  33. Cyberdog, Cyberdog 1.1 Beta 3. This version fixes several bugs that were
  34. reported to us during out public beta period. You can check out our release
  35. notes to see what we fixed! 
  36. END
  37.     Cyberdog Information
  38.     Cyberdog & Netscape in the news Important Press Release regarding
  39.  Cyberdog and Netscape. Check it out! 
  40.     Cyberdog Plug-in Support! Cyberdog support for Netscape Plug-ins is now
  41.  available to download! Go to the Cyberdog Beta Download page and download
  42.  it now! 
  43.     Cyberdog Book Check out Jesse Feiler's way-cool book about Cyberdog.
  44.  You can find details out about the book as well as ordering information at
  45.  Philmont Software Mill site. 
  46.     Java! Looking to view Java applets in Cyberdog 1.1 Beta 3? Download and
  47.  install the Mac OS Runtime for Java and try it out! 
  48.     Cyberdog 1.1 Beta 3 We hope that Cyberdog and OpenDoc 1.1 will be
  49.  available within the next two weeks. In the meantime, we have released
  50.  another version of Cyberdog, Cyberdog 1.1 Beta 3. This version fixes
  51.  several bugs that were reported to us during out public beta period. You
  52.  can check out our release notes to see what we fixed! 
  53. END
  54. DONE
  55.  
  56.  
  57. $| = 1;
  58.  
  59. print "1..", @tests/2, "\n";
  60.  
  61. use Text::Wrap;
  62.  
  63. $rerun = $ENV{'PERL_DL_NONLAZY'} ? 0 : 1;
  64.  
  65. $tn = 1;
  66. while (@tests) {
  67.     my $in = shift(@tests);
  68.     my $out = shift(@tests);
  69.  
  70.     $in =~ s/^TEST(\d+)?\n//;
  71.  
  72.     my $back = fill('    ', ' ', $in);
  73.  
  74.     if ($back eq $out) {
  75.         print "ok $tn\n";
  76.     } elsif ($rerun) {
  77.         my $oi = $in;
  78.         open(F,">#o") and do { print F $back; close(F) };
  79.         open(F,">#e") and do { print F $out;  close(F) };
  80.         foreach ($in, $back, $out) {
  81.             s/\t/^I\t/gs;
  82.             s/\n/\$\n/gs;
  83.         }
  84.         print "------------ input ------------\n";
  85.         print $in;
  86.         print "\n------------ output -----------\n";
  87.         print $back;
  88.         print "\n------------ expected ---------\n";
  89.         print $out;
  90.         print "\n-------------------------------\n";
  91.         $Text::Wrap::debug = 1;
  92.         fill('    ', ' ', $oi);
  93.         exit(1);
  94.     } else {
  95.         print "not ok $tn\n";
  96.     }
  97.     $tn++;
  98. }
  99.