Pod-Advent

 view release on metacpan or  search on metacpan

t/spellcheck.t  view on Meta::CPAN

#!perl

use strict;
use warnings;
use Test::More;
use Pod::Advent;
use Test::Differences;

eval "use Text::Aspell";
plan skip_all => "Text::Aspell required for testing spellcheck" if $@;

# for the case of an empty package, which is useful for testing with.
eval { Text::Aspell->can('new') } or
  plan skip_all => "Text::Aspell required for testing spellcheck";

plan tests => 26;

my $advent = Pod::Advent->new;

ok( $Pod::Advent::speller, "got speller" )
  or exit;
isa_ok( $Pod::Advent::speller, 'Text::Aspell', "got Text::Aspell" );
is( $advent->spellcheck_enabled, 1, "spellcheck enabled" );
is( $Pod::Advent::speller->get_option('lang'), 'en_US', "en_US dictionary" );

my $s;
$advent->output_string( \$s );
$advent->parse_file( \*DATA );

is( $advent->num_spelling_errors, 20, "misspelled word ct" );
eq_or_diff( [ $advent->spelling_errors ], [qw/
	z1
	z2
	z3
	z4
	z5
	z6
	z3
	z9
	z15
	z16
	z20
	z21
	z22
	z23
	z24
	z25
	z26
	z27
	z28
	z29
/], "misspelled words" );

$advent->__reset();
is( $advent->num_spelling_errors, 0, "<reset> misspelled word ct" );
is_deeply( [ $advent->spelling_errors ], [qw/ /], "<reset> misspelled words" );

my $text;

$text = "";
is( $advent->__spellcheck($text), 0, "[$text] spellcheck return val" );
is( $advent->num_spelling_errors, 0, "[$text] misspelled word ct" );
is_deeply( [ $advent->spelling_errors ], [qw/ /], "[$text] misspelled words" );

$text = "word";
is( $advent->__spellcheck($text), 0, "[$text] spellcheck return val" );
is( $advent->num_spelling_errors, 0, "[$text] misspelled word ct" );



( run in 1.190 second using v1.01-cache-2.11-cpan-d8267643d1d )