diff options
-rw-r--r-- | .gitignore | 17 | ||||
-rw-r--r-- | Changes | 27 | ||||
-rw-r--r-- | bin/cryptogram.pl | 1 | ||||
-rw-r--r-- | bin/jotto.pl | 1 | ||||
-rw-r--r-- | bin/mastermind.pl | 1 | ||||
-rw-r--r-- | bin/solve-ghost.pl | 1 | ||||
-rw-r--r-- | bin/solve-spook.pl | 1 | ||||
-rw-r--r-- | bin/solve-superghost.pl | 1 | ||||
-rw-r--r-- | bin/solve-xghost.pl | 1 | ||||
-rw-r--r-- | dist.ini | 11 | ||||
-rw-r--r-- | lib/Games/Word.pm | 28 | ||||
-rw-r--r-- | lib/Games/Word/Wordlist.pm | 84 | ||||
-rw-r--r-- | t/000-load.t | 10 | ||||
-rw-r--r-- | t/010-random-permutation.t | 15 | ||||
-rw-r--r-- | t/anagrams.t (renamed from t/024-anagrams.t) | 10 | ||||
-rw-r--r-- | t/array-wordlist.t (renamed from t/002-array-wordlist.t) | 5 | ||||
-rw-r--r-- | t/is-permutation.t (renamed from t/011-is-permutation.t) | 7 | ||||
-rw-r--r-- | t/is-word-nocache.t (renamed from t/023-is-word-nocache.t) | 6 | ||||
-rw-r--r-- | t/is-word.t (renamed from t/021-is-word.t) | 6 | ||||
-rw-r--r-- | t/random-permutation.t | 20 | ||||
-rw-r--r-- | t/random-string-from.t (renamed from t/013-random-string-from.t) | 16 | ||||
-rw-r--r-- | t/random-word-nocache.t (renamed from t/022-random-word-nocache.t) | 6 | ||||
-rw-r--r-- | t/random-word.t (renamed from t/020-random-word.t) | 5 | ||||
-rw-r--r-- | t/shared-letters.t (renamed from t/012-shared-letters.t) | 6 | ||||
-rw-r--r-- | t/subpermutations.t (renamed from t/015-subpermutations.t) | 22 | ||||
-rw-r--r-- | t/substrings.t (renamed from t/014-substrings.t) | 27 | ||||
-rw-r--r-- | t/subwords.t (renamed from t/025-subwords.t) | 10 | ||||
-rw-r--r-- | t/system-wordlist-nocache.t (renamed from t/003-system-wordlist-nocache.t) | 23 | ||||
-rw-r--r-- | t/system-wordlist.t (renamed from t/001-system-wordlist.t) | 5 |
29 files changed, 180 insertions, 193 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d809b97 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +cover_db +META.* +MYMETA.* +Makefile +blib +inc +pm_to_blib +MANIFEST +Makefile.old +nytprof.out +MANIFEST.bak +*.sw[po] +.DS_Store +.build +Games-Word-* +*.bs +*.o @@ -1,14 +1,19 @@ Revision history for Games-Word -0.05 Nov 16, 2009 - A few minor cleanups, convert to Dist::Zilla -0.04 Dec 18, 2008 - Fix is_substring -0.03 Dec 17, 2008 - More test fixups - Add spook solver -0.02 Feb 04, 2008 - Fix up some docs and tests. -0.01 Feb 03, 2008 - First version, released on an unsuspecting world. +{{$NEXT}} +0.05 2009-11-16 + - A few minor cleanups, convert to Dist::Zilla + +0.04 2008-12-18 + - Fix is_substring + +0.03 2008-12-17 + - More test fixups + - Add spook solver + +0.02 2008-02-04 + - Fix up some docs and tests. + +0.01 2008-02-03 + - First version, released on an unsuspecting world. diff --git a/bin/cryptogram.pl b/bin/cryptogram.pl index 7d89e6c..e965af7 100644 --- a/bin/cryptogram.pl +++ b/bin/cryptogram.pl @@ -2,6 +2,7 @@ use strict; use warnings; use Games::Word qw/random_permutation/; +# PODNAME: cryptogram.pl my $alphabet = 'abcdefghijklmnopqrstuvwxyz'; my $key = random_permutation $alphabet; diff --git a/bin/jotto.pl b/bin/jotto.pl index 4d9f509..f26c9b1 100644 --- a/bin/jotto.pl +++ b/bin/jotto.pl @@ -3,6 +3,7 @@ use strict; use warnings; use Games::Word qw/shared_letters/; use Games::Word::Wordlist; +# PODNAME: jotto.pl my $wl = Games::Word::Wordlist->new('/usr/share/dict/words'); $wl->remove_words($wl->words_like(qr/^(.{0,4}|.{6,})$/)); diff --git a/bin/mastermind.pl b/bin/mastermind.pl index 8f8ab34..b3c595e 100644 --- a/bin/mastermind.pl +++ b/bin/mastermind.pl @@ -3,6 +3,7 @@ use strict; use warnings; use Games::Word qw/random_string_from shared_letters shared_letters_by_position/; +# PODNAME: mastermind.pl my $word = random_string_from "abcdefg", 5; while (1) { diff --git a/bin/solve-ghost.pl b/bin/solve-ghost.pl index c65cd91..f969a39 100644 --- a/bin/solve-ghost.pl +++ b/bin/solve-ghost.pl @@ -2,6 +2,7 @@ use strict; use warnings; use Games::Word::Wordlist; +# PODNAME: solve-ghost.pl die "Usage: $0 <word_prefix>\n" unless @ARGV; my $wl = Games::Word::Wordlist->new('/usr/share/dict/words'); diff --git a/bin/solve-spook.pl b/bin/solve-spook.pl index f28c8e8..2ef27de 100644 --- a/bin/solve-spook.pl +++ b/bin/solve-spook.pl @@ -2,6 +2,7 @@ use strict; use warnings; use Games::Word::Wordlist; +# PODNAME: solve-spook.pl die "Usage: $0 <letter_pool>\n" unless @ARGV; my $wl = Games::Word::Wordlist->new('/usr/share/dict/words'); diff --git a/bin/solve-superghost.pl b/bin/solve-superghost.pl index e5fcbee..d3a1eee 100644 --- a/bin/solve-superghost.pl +++ b/bin/solve-superghost.pl @@ -2,6 +2,7 @@ use strict; use warnings; use Games::Word::Wordlist; +# PODNAME: solve-superghost.pl die "Usage: $0 <subword>\n" unless @ARGV; my $wl = Games::Word::Wordlist->new('/usr/share/dict/words'); diff --git a/bin/solve-xghost.pl b/bin/solve-xghost.pl index 7502803..aea1872 100644 --- a/bin/solve-xghost.pl +++ b/bin/solve-xghost.pl @@ -2,6 +2,7 @@ use strict; use warnings; use Games::Word::Wordlist; +# PODNAME: solve-xghost.pl die "Usage: $0 <subword>\n" unless @ARGV; my $wl = Games::Word::Wordlist->new('/usr/share/dict/words'); @@ -1,14 +1,11 @@ name = Games-Word -version = 0.05 author = Jesse Luehrs <doy at tozt dot net> license = Perl_5 copyright_holder = Jesse Luehrs abstract = utility functions for writing word games -[@Classic] +[@DOY] +dist = Games-Word +repository = github -[Prereq] -List::MoreUtils = 0 -Math::Combinatorics = 0 -Test::Deep = 0 -Test::Exception = 0 +[AutoPrereqs] diff --git a/lib/Games/Word.pm b/lib/Games/Word.pm index e1a423f..232112e 100644 --- a/lib/Games/Word.pm +++ b/lib/Games/Word.pm @@ -10,10 +10,7 @@ our @EXPORT_OK = qw/random_permutation is_permutation all_permutations use Math::Combinatorics qw/factorial/; use Test::Deep::NoTest; - -=head1 NAME - -Games::Word - utility functions for writing word games +# ABSTRACT: utility functions for writing word games =head1 SYNOPSIS @@ -28,7 +25,9 @@ Games::Word - utility functions for writing word games =head1 DESCRIPTION -Games::Word provides several utility functions for writing word games, such as manipulating permutations of strings, testing for similarity of strings, and finding strings from a given source of characters. +Games::Word provides several utility functions for writing word games, such as +manipulating permutations of strings, testing for similarity of strings, and +finding strings from a given source of characters. =over 4 @@ -244,14 +243,6 @@ sub all_subpermutations { return map { all_permutations $_ } all_substrings shift; } -=head1 SEE ALSO - -L<Games::Word::Wordlist> - -=head1 AUTHOR - -Jesse Luehrs, C<< <doy at tozt dot net> >> - =head1 BUGS No known bugs. @@ -260,6 +251,10 @@ Please report any bugs through RT: email C<bug-games-word at rt.cpan.org>, or browse L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Word>. +=head1 SEE ALSO + +L<Games::Word::Wordlist> + =head1 SUPPORT You can find this documentation for this module with the perldoc command. @@ -288,13 +283,6 @@ L<http://search.cpan.org/dist/Games-Word> =back -=head1 COPYRIGHT AND LICENSE - -Copyright 2008-2009 Jesse Luehrs. - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - =cut 1; diff --git a/lib/Games/Word/Wordlist.pm b/lib/Games/Word/Wordlist.pm index 30d2be4..4a8c113 100644 --- a/lib/Games/Word/Wordlist.pm +++ b/lib/Games/Word/Wordlist.pm @@ -3,10 +3,7 @@ use strict; use warnings; use Games::Word qw/all_permutations all_subpermutations/; use List::MoreUtils qw/uniq/; - -=head1 NAME - -Games::Word::Wordlist - manages a list of words +# ABSTRACT: manages a list of words =head1 SYNOPSIS @@ -25,11 +22,7 @@ randomly or by regex. =cut -=head1 CONSTRUCTOR - -=over 4 - -=item new <FILENAME|ARRAYREF> PARAMHASH +=method new <FILENAME|ARRAYREF> PARAMHASH The constructor initializes the word list with words, either from a file or from an arrayref, given as the first argument. The remaining arguments are a @@ -48,8 +41,6 @@ program. =back -=back - =cut sub new { @@ -86,11 +77,7 @@ sub new { return $self; } -=head1 METHODS - -=over 4 - -=item add_words <FILENAME|ARRAYREF> +=method add_words <FILENAME|ARRAYREF> Add words to the word list. Only works if the word list has been cached. @@ -117,7 +104,7 @@ sub add_words { return; } -=item remove_words LIST +=method remove_words LIST Removes words in LIST from the word list. Only works if the word list is cached. @@ -134,7 +121,7 @@ sub remove_words { return; } -=item words +=method words Returns the number of words in the word list. @@ -186,7 +173,7 @@ sub _random_word_nocache { return $word; } -=item random_word [LENGTH] +=method random_word [LENGTH] Returns a random word from the word list, optionally of length LENGTH. @@ -219,7 +206,7 @@ sub _is_word_nocache { return 0; } -=item is_word STRING +=method is_word STRING Returns true if STRING is found in the word list, and false otherwise. @@ -254,7 +241,7 @@ sub _each_word_nocache { return; } -=item each_word CODE +=method each_word CODE Call CODE for each word in the word list. The current word will be passed into CODE as its only argument. @@ -268,7 +255,7 @@ sub each_word { return $self->_each_word_nocache(@_); } -=item anagrams STRING +=method anagrams STRING Returns a list of all permutations of STRING that are found in the word list. @@ -281,7 +268,7 @@ sub anagrams { return grep {$self->is_word($_)} all_permutations($word); } -=item words_like REGEX +=method words_like REGEX Returns a list containing all words in the word list which match REGEX. @@ -297,7 +284,7 @@ sub words_like { return @words; } -=item subwords_of STRING +=method subwords_of STRING Returns a list of words from the word list which can be made using the letters in STRING. @@ -311,59 +298,10 @@ sub subwords_of { return grep {$self->is_word($_)} all_subpermutations($string); } -=back - =head1 SEE ALSO L<Games::Word> -=head1 AUTHOR - -Jesse Luehrs, C<< <doy at tozt dot net> >> - -=head1 BUGS - -No known bugs. - -Please report any bugs through RT: email -C<bug-games-word at rt.cpan.org>, or browse -L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Word>. - -=head1 SUPPORT - -You can find this documentation for this module with the perldoc command. - - perldoc Games::Word::Wordlist - -You can also look for information at: - -=over 4 - -=item * AnnoCPAN: Annotated CPAN documentation - -L<http://annocpan.org/dist/Games-Word> - -=item * CPAN Ratings - -L<http://cpanratings.perl.org/d/Games-Word> - -=item * RT: CPAN's request tracker - -L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-Word> - -=item * Search CPAN - -L<http://search.cpan.org/dist/Games-Word> - -=back - -=head1 COPYRIGHT AND LICENSE - -Copyright 2008-2009 Jesse Luehrs. - -This program is free software; you can redistribute it and/or modify it -under the same terms as Perl itself. - =cut 1; diff --git a/t/000-load.t b/t/000-load.t deleted file mode 100644 index e23f727..0000000 --- a/t/000-load.t +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More tests => 2; - -my @modules = qw(Games::Word Games::Word::Wordlist); - -for my $module (@modules) { - use_ok $module or BAIL_OUT("couldn't use $module"); -} diff --git a/t/010-random-permutation.t b/t/010-random-permutation.t deleted file mode 100644 index 4adcda3..0000000 --- a/t/010-random-permutation.t +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More tests => 51; -use Test::Deep; -use Games::Word qw/random_permutation/; - -is(random_permutation(""), "", "testing permutation of empty string"); - -for my $word (qw/foo bar baz quux blah/) { - for (1..10) { - cmp_deeply([split //, random_permutation $word], bag(split //, $word), - "random tests"); - } -} diff --git a/t/024-anagrams.t b/t/anagrams.t index 9de5ad0..68b18d4 100644 --- a/t/024-anagrams.t +++ b/t/anagrams.t @@ -1,8 +1,8 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 1; -use Test::Deep; +use Test::More; + use Games::Word::Wordlist; my @words = qw/stop spot tops post posts stops spartan poster pot sop spa/; @@ -10,5 +10,7 @@ my @words = qw/stop spot tops post posts stops spartan poster pot sop spa/; my $wl = Games::Word::Wordlist->new(\@words); my @anagrams = $wl->anagrams("stop"); -cmp_deeply(\@anagrams, bag('stop', 'spot', 'tops', 'post'), - "anagrams returns the correct words"); +is_deeply([sort @anagrams], [qw(post spot stop tops)], + "anagrams returns the correct words"); + +done_testing; diff --git a/t/002-array-wordlist.t b/t/array-wordlist.t index 4f235c0..f949860 100644 --- a/t/002-array-wordlist.t +++ b/t/array-wordlist.t @@ -1,7 +1,8 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 3; +use Test::More; + use Games::Word::Wordlist; my @words = qw/foo bar baz/; @@ -11,3 +12,5 @@ $wl->add_words(['zab', 'rab', 'oof', 'foo']); is($wl->words, 6, "adding words results in the correct number of words"); $wl->remove_words(qw/rab foo quux/); is($wl->words, 4, "deleting words results in the correct number of words"); + +done_testing; diff --git a/t/011-is-permutation.t b/t/is-permutation.t index e6e1abe..378d992 100644 --- a/t/011-is-permutation.t +++ b/t/is-permutation.t @@ -1,8 +1,9 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 20; -use Games::Word qw/random_permutation is_permutation/; +use Test::More; + +use Games::Word qw(random_permutation is_permutation); ok( is_permutation("", ""), "testing empty string"); ok( is_permutation("blah", "blah"), "testing same string"); @@ -16,3 +17,5 @@ ok(!is_permutation("blaah", "bblah"), "more duplicate letter tests"); for (1..12) { ok(is_permutation("blah", random_permutation("blah")), "random tests"); } + +done_testing; diff --git a/t/023-is-word-nocache.t b/t/is-word-nocache.t index 3b51e15..7ca6939 100644 --- a/t/023-is-word-nocache.t +++ b/t/is-word-nocache.t @@ -1,8 +1,8 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 11; -use Test::Exception; +use Test::More; + use Games::Word::Wordlist; my $word_file = ''; @@ -19,3 +19,5 @@ SKIP: { } ok(!$wl->is_word("notaword"), "testing is_word with a non-word"); } + +done_testing; diff --git a/t/021-is-word.t b/t/is-word.t index 2c6045f..a7daff0 100644 --- a/t/021-is-word.t +++ b/t/is-word.t @@ -1,8 +1,8 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 10; -use Test::Exception; +use Test::More; + use Games::Word::Wordlist; my $wl = Games::Word::Wordlist->new(['foo', 'bar', 'baz']); @@ -10,3 +10,5 @@ for (1..10) { ok($wl->is_word($wl->random_word), "testing checking to see if a random word from the word list is a word"); } + +done_testing; diff --git a/t/random-permutation.t b/t/random-permutation.t new file mode 100644 index 0000000..ca9f004 --- /dev/null +++ b/t/random-permutation.t @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Games::Word qw(random_permutation); + +is(random_permutation(""), "", "testing permutation of empty string"); + +for my $word (qw/foo bar baz quux blah/) { + for (1..10) { + is_deeply( + [sort split //, random_permutation($word)], + [sort split //, $word], + "random tests" + ); + } +} + +done_testing; diff --git a/t/013-random-string-from.t b/t/random-string-from.t index 78e907f..b4abc89 100644 --- a/t/013-random-string-from.t +++ b/t/random-string-from.t @@ -1,15 +1,19 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 23; +use Test::More; use Test::Deep; -use Test::Exception; -use Games::Word qw/random_string_from/; +use Test::Fatal; + +use Games::Word qw(random_string_from); is(random_string_from("", 0), "", "0 length random_string_from an empty string"); -throws_ok { random_string_from("", 5) } qr/invalid letter list/, - "random_string_from an empty string"; +like( + exception { random_string_from("", 5) }, + qr/invalid letter list/, + "random_string_from an empty string" +); is(random_string_from("abcde", 0), "", "0 length random_string_from"); my @letters = qw/a b c d e/; @@ -20,3 +24,5 @@ for my $i (1..10) { $bag->add(@letters) for 1..$i; cmp_deeply([split(//, $str)], $bag, "random test of random_string_from"); } + +done_testing; diff --git a/t/022-random-word-nocache.t b/t/random-word-nocache.t index d5c9c19..0c7fb1d 100644 --- a/t/022-random-word-nocache.t +++ b/t/random-word-nocache.t @@ -1,8 +1,8 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 4; -use Test::Exception; +use Test::More; + use Games::Word::Wordlist; my $word_file = ''; @@ -30,3 +30,5 @@ SKIP: { is($wl->random_word(999), undef, "random_word returns undef if no words are found"); } + +done_testing; diff --git a/t/020-random-word.t b/t/random-word.t index b642c27..6c5801d 100644 --- a/t/020-random-word.t +++ b/t/random-word.t @@ -1,7 +1,8 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 6; +use Test::More; + use Games::Word::Wordlist; my $wl = Games::Word::Wordlist->new(['foo', 'bar', 'baz', 'quux']); @@ -24,3 +25,5 @@ is($wl->random_word(5), undef, my $wl2 = Games::Word::Wordlist->new([]); is($wl2->random_word, undef, "random word returns undef with an empty word list"); + +done_testing; diff --git a/t/012-shared-letters.t b/t/shared-letters.t index 9e249c2..238ed23 100644 --- a/t/012-shared-letters.t +++ b/t/shared-letters.t @@ -2,7 +2,8 @@ use strict; use warnings; use Test::More; -use Games::Word qw/shared_letters shared_letters_by_position/; + +use Games::Word qw(shared_letters shared_letters_by_position); my @tests = ( {a => "abcde", b => "edcba", sl => 5, slbp => 1, @@ -24,7 +25,6 @@ my @tests = ( {a => "bacaa", b => "gabca", sl => 4, slbp => 2, slbp_full => [undef, 'a', undef, undef, 'a']}, ); -plan tests => 3 * @tests; for (@tests) { my %test = %$_; @@ -36,3 +36,5 @@ for (@tests) { is_deeply([shared_letters_by_position($a, $b)], $test{slbp_full}, "testing shared_letters_by_position (list): '$a' vs '$b'"); } + +done_testing; diff --git a/t/015-subpermutations.t b/t/subpermutations.t index 36e57d8..bf16ec3 100644 --- a/t/015-subpermutations.t +++ b/t/subpermutations.t @@ -2,9 +2,8 @@ use strict; use warnings; use Test::More; -use Test::Deep; -use List::Util qw/sum/; -use Games::Word qw/is_subpermutation all_subpermutations/; + +use Games::Word qw(is_subpermutation all_subpermutations); my %is_subpermutation_tests = ( "" => [""], @@ -21,14 +20,17 @@ my %all_subpermutations_tests = ( "abc" => ["", "a", "b", "c", "ab", "ac", "bc", "ba", "ca", "cb", "abc", "acb", "bac", "bca", "cab", "cba"], ); -plan tests => (sum map { scalar @$_ } values %is_subpermutation_tests) + - keys %all_subpermutations_tests; -while (my ($word, $subpermutations) = each %is_subpermutation_tests) { +for my $word (keys %is_subpermutation_tests) { ok(is_subpermutation($_, $word), "is '$_' a subpermutation of '$word'?") - for @$subpermutations; + for @{ $is_subpermutation_tests{$word} }; } -while (my ($word, $subpermutations) = each %all_subpermutations_tests) { - cmp_deeply([all_subpermutations($word)], bag(@$subpermutations), - "do we get all of the subpermutations of '$word'?"); +for my $word (keys %all_subpermutations_tests) { + is_deeply( + [sort(all_subpermutations($word))], + [sort(@{ $all_subpermutations_tests{$word} })], + "do we get all of the subpermutations of '$word'?" + ); } + +done_testing; diff --git a/t/014-substrings.t b/t/substrings.t index e61d264..c4f478b 100644 --- a/t/014-substrings.t +++ b/t/substrings.t @@ -2,9 +2,8 @@ use strict; use warnings; use Test::More; -use Test::Deep; -use List::Util qw/sum/; -use Games::Word qw/is_substring all_substrings/; + +use Games::Word qw(is_substring all_substrings); my %is_substring_tests = ( "" => [""], @@ -24,19 +23,21 @@ my %all_substrings_tests = ( "aab" => ['', "a", "a", "b", "aa", "ab", "ab", "aab"], "abc" => ['', "a", "b", "c", "ab", "ac", "bc", "abc"], ); -plan tests => (sum map { scalar @$_ } values %is_substring_tests, - values %isnt_substring_tests) + - keys %all_substrings_tests; -while (my ($word, $substrings) = each %is_substring_tests) { +for my $word (keys %is_substring_tests) { ok(is_substring($_, $word), "is '$_' a substring of '$word'?") - for @$substrings; + for @{ $is_substring_tests{$word} }; } -while (my ($word, $substrings) = each %isnt_substring_tests) { +for my $word (keys %isnt_substring_tests) { ok(!is_substring($_, $word), "is '$_' not a substring of '$word'?") - for @$substrings; + for @{ $isnt_substring_tests{$word} }; } -while (my ($word, $substrings) = each %all_substrings_tests) { - cmp_deeply([all_substrings($word)], bag(@$substrings), - "do we get all of the substrings of '$word'?"); +for my $word (keys %all_substrings_tests) { + is_deeply( + [sort(all_substrings($word))], + [sort(@{ $all_substrings_tests{$word} })], + "do we get all of the substrings of '$word'?" + ); } + +done_testing; diff --git a/t/025-subwords.t b/t/subwords.t index b117158..30b39b2 100644 --- a/t/025-subwords.t +++ b/t/subwords.t @@ -1,8 +1,8 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 1; -use Test::Deep; +use Test::More; + use Games::Word::Wordlist; my @words = qw/stop spot tops post posts stops spartan poster pot sop spa/; @@ -10,5 +10,7 @@ my @words = qw/stop spot tops post posts stops spartan poster pot sop spa/; my $wl = Games::Word::Wordlist->new(\@words); my @subwords = $wl->subwords_of("stop"); -cmp_deeply(\@subwords, bag('stop', 'spot', 'tops', 'post', 'pot', 'sop'), - "subwords_of returns the correct words"); +is_deeply([sort @subwords], [qw(post pot sop spot stop tops)], + "subwords_of returns the correct words"); + +done_testing; diff --git a/t/003-system-wordlist-nocache.t b/t/system-wordlist-nocache.t index d8c0066..417a061 100644 --- a/t/003-system-wordlist-nocache.t +++ b/t/system-wordlist-nocache.t @@ -1,8 +1,9 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 3; -use Test::Exception; +use Test::More; +use Test::Fatal; + use Games::Word::Wordlist; my $word_file = ''; @@ -17,10 +18,16 @@ SKIP: { for (<$fh>) {} is($wl->words, $., "we read in the correct number of words"); - throws_ok { $wl->add_words([qw/foo bar baz/]) } - qr/Can't add words to a non-cached word list/, - "adding words dies"; - throws_ok { $wl->remove_words("word", "throw") } - qr/Can't remove words from a non-cached word list/, - "removing words dies"; + like( + exception { $wl->add_words([qw/foo bar baz/]) }, + qr/Can't add words to a non-cached word list/, + "adding words dies" + ); + like( + exception { $wl->remove_words("word", "throw") }, + qr/Can't remove words from a non-cached word list/, + "removing words dies" + ); } + +done_testing; diff --git a/t/001-system-wordlist.t b/t/system-wordlist.t index 90f1a99..b4bcdda 100644 --- a/t/001-system-wordlist.t +++ b/t/system-wordlist.t @@ -1,7 +1,8 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 1; +use Test::More; + use Games::Word::Wordlist; my $word_file = ''; @@ -16,3 +17,5 @@ SKIP: { for (<$fh>) {} is($wl->words, $., "we read in the correct number of words"); } + +done_testing; |