diff options
author | jluehrs2 <jluehrs2@uiuc.edu> | 2008-02-02 01:23:43 -0500 |
---|---|---|
committer | jluehrs2 <jluehrs2@uiuc.edu> | 2008-02-02 01:23:43 -0500 |
commit | 3a5a6804854e68cc30b3065f4492e7f2e08ce235 (patch) | |
tree | 180bfa3ae226e2cd0becf04795ff619e8e97d180 /t | |
parent | 6e82d3c1989660a7ade48d4bdf4be3af945a5994 (diff) | |
download | games-word-3a5a6804854e68cc30b3065f4492e7f2e08ce235.tar.gz games-word-3a5a6804854e68cc30b3065f4492e7f2e08ce235.zip |
fix up the tests for the change to random_permutation
Diffstat (limited to 't')
-rw-r--r-- | t/010-random-permutation.t | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/t/010-random-permutation.t b/t/010-random-permutation.t index 8151294..cbfe275 100644 --- a/t/010-random-permutation.t +++ b/t/010-random-permutation.t @@ -1,24 +1,15 @@ #!perl -T use strict; use warnings; -use Test::More; +use Test::More tests => 51; +use Test::Deep; use Games::Word qw/random_permutation/; -my %blah_permutations = ( - 0 => "blah", 1 => "blha", 2 => "balh", 3 => "bahl", - 4 => "bhla", 5 => "bhal", 6 => "lbah", 7 => "lbha", - 8 => "labh", 9 => "lahb", 10 => "lhba", 11 => "lhab", - 12 => "ablh", 13 => "abhl", 14 => "albh", 15 => "alhb", - 16 => "ahbl", 17 => "ahlb", 18 => "hbla", 19 => "hbal", - 20 => "hlba", 21 => "hlab", 22 => "habl", 23 => "halb", -); -plan tests => 1 + (scalar keys %blah_permutations) + 2; - is(random_permutation(""), "", "testing permutation of empty string"); -while (my ($k, $v) = each %blah_permutations) { - is(random_permutation("blah", $k), $v, "testing random_permutation of 'blah'"); + +for my $word (qw/foo bar baz quux blah/) { + for (1..10) { + cmp_deeply([split //, random_permutation $word], bag(split //, $word), + "random tests"); + } } -eval { random_permutation("blah", 24) }; -like($@, qr/^invalid permutation index/, "testing permutation index bounds"); -eval { random_permutation("blah", -1) }; -like($@, qr/^invalid permutation index/, "testing permutation index bounds"); |