use strict; use lib "t/lib"; use Data::Dumper; use Digest::MD5 qw(md5_hex); use LWP::UserAgent; use Test::Google::Chart::Samples; my $ua = LWP::UserAgent->new(); my @samples = Test::Google::Chart::Samples->samples; print < Google::Chart Samples

Google::Chart Sample

(generated on @{[scalar localtime]})
These samples were taken from the Google Chart API Developer's Manual
EOHTML my ($g_count, $skip_count) = (0, 0); while (@samples) { my ($uri, $code) = splice(@samples, 0, 2); my $g = $code->(); (++$skip_count and next) unless $g; $g_count++; my $generated_uri = $g->as_uri; my $o_res = $ua->get($uri); my $g_res = $ua->get($generated_uri); my $bg_color = 'fff'; if (md5_hex($o_res->content) != md5_hex($g_res->content)) { $bg_color = 'f00'; } local $Data::Dumper::Indent = 1; local $Data::Dumper::Deparse = 1; my $code_str = Dumper($code); $code_str =~ s/\$VAR1 = //; $code_str =~ s/ use strict 'refs';\n//; $code_str =~ s/ package Test::Google::Chart::Samples;\n//; $code_str =~ s/'Google::Chart'/Google::Chart/g; print <
From the Manual Generated
$code_str
EOHTML } print < EOHTML print STDERR "Generated $g_count charts\n"; print STDERR "Skipped $skip_count charts\n";