#!/usr/bin/perl =pod =head1 NAME test.pl - a set of basic tests for Display.pm =head1 SYNOPSIS Given a working installation and configuration file: ./test.pl ./test.pl -v # to dump config values, etc. =head1 SEE ALSO =cut use strict; use warnings; use lib 'lib'; use lib 'wala'; use Test::Simple tests => 6; use Display qw(%WalaConf %DISPLAY_CONF &handle); sub section; # cheap options: my $VERBOSE; for (@ARGV) { $VERBOSE = 1 if m/-v|--verbose/; } my $testlines = <h1. Hello Some stuff. Dogs frolic in moonlight. one two LINES my $expectedlines = <Hello

Some stuff.

Dogs
frolic in

moonlight.

LINES # Tests section 'configuration'; ok (do("conf.pl"), "ran conf file"); ok (defined %WalaConf, '%WalaConf defined'); hash_print(%WalaConf) if $VERBOSE; ok (defined %DISPLAY_CONF, '%DISPLAY_CONF defined'); hash_print(%DISPLAY_CONF) if $VERBOSE; section 'individual subroutine tests'; ok (Display::recent_month() =~ m/\d{4}\/\d{1,2}/, 'recent_month returns a month'); section 'markup'; ok (Display::line_parse($testlines, undef) eq $expectedlines, 'line_parse works'); print "\nline_parse result:\n" . Display::line_parse('', $testlines) . "\n" if $VERBOSE; ok (Display::line_parse("IS return 'TRUE';", '') eq 'IS TRUE', 'eval_perl in line_parse'); # Utility routines. sub hash_print { my %hash = @_; my $string; for my $key (sort keys %hash) { $string .= "\n\t$key: $hash{$key}"; } print $string . "\n\n"; return; } sub pause { my $time = shift; #print " pausing $time seconds\n"; sleep $time; } sub section { my $msg = shift; print "\n-- $msg --\n\n"; }