Almost-minimal filesystem based blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
1.8 KiB

17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
  1. #!/usr/bin/perl
  2. =pod
  3. =head1 NAME
  4. test.pl - a set of basic tests for Display.pm
  5. =head1 SYNOPSIS
  6. Given a working installation and configuration file:
  7. ./test.pl
  8. ./test.pl -v # to dump config values, etc.
  9. =head1 SEE ALSO
  10. =cut
  11. use strict;
  12. use warnings;
  13. use lib 'lib';
  14. use lib 'wala';
  15. use Test::Simple tests => 6;
  16. use Display qw(%WalaConf %DISPLAY_CONF &handle);
  17. sub section;
  18. # cheap options:
  19. my $VERBOSE;
  20. for (@ARGV) {
  21. $VERBOSE = 1 if m/-v|--verbose/;
  22. }
  23. my $testlines = <<LINES;
  24. <textile>h1. Hello
  25. Some stuff.
  26. </textile>
  27. <freeverse>
  28. Dogs
  29. frolic in
  30. moonlight.
  31. </freeverse>
  32. <list>
  33. one
  34. two
  35. </list>
  36. LINES
  37. my $expectedlines = <<LINES;
  38. <h3>Hello</h3>
  39. <p>Some stuff.</p>
  40. <p>Dogs<br />
  41. frolic in</p>
  42. <p>moonlight.</p>
  43. <ul>
  44. <li>one</li>
  45. <li>two</li>
  46. </ul>
  47. LINES
  48. # Tests
  49. section 'configuration';
  50. ok (do("conf.pl"), "ran conf file");
  51. ok (defined %WalaConf, '%WalaConf defined');
  52. hash_print(%WalaConf) if $VERBOSE;
  53. ok (defined %DISPLAY_CONF, '%DISPLAY_CONF defined');
  54. hash_print(%DISPLAY_CONF) if $VERBOSE;
  55. section 'individual subroutine tests';
  56. ok (Display::recent_month() =~ m/\d{4}\/\d{1,2}/,
  57. 'recent_month returns a month');
  58. section 'markup';
  59. ok (Display::line_parse($testlines, undef) eq $expectedlines,
  60. 'line_parse works');
  61. print "\nline_parse result:\n" .
  62. Display::line_parse('', $testlines) . "\n" if $VERBOSE;
  63. ok (Display::line_parse("IS <perl>return 'TRUE';</perl>", '') eq 'IS TRUE',
  64. 'eval_perl in line_parse');
  65. # Utility routines.
  66. sub hash_print {
  67. my %hash = @_;
  68. my $string;
  69. for my $key (sort keys %hash) {
  70. $string .= "\n\t$key: $hash{$key}";
  71. }
  72. print $string . "\n\n";
  73. return;
  74. }
  75. sub pause {
  76. my $time = shift;
  77. #print " pausing $time seconds\n";
  78. sleep $time;
  79. }
  80. sub section {
  81. my $msg = shift;
  82. print "\n-- $msg --\n\n";
  83. }