2013-02-28 22:13:21 -08:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
2013-03-01 08:14:55 -08:00
|
|
|
zci answer_type => 'anagram';
|
2014-10-04 01:45:40 -07:00
|
|
|
zci is_cached => 1;
|
2013-02-28 22:13:21 -08:00
|
|
|
|
|
|
|
ddg_goodie_test(
|
2013-03-01 08:14:55 -08:00
|
|
|
[qw(DDG::Goodie::Anagram)],
|
2014-10-04 01:45:40 -07:00
|
|
|
# Sucessful anagram tests.
|
|
|
|
'Anagrams for filter' => test_zci('trifle', html => qr/Anagrams of "filter"/),
|
2014-10-07 11:57:04 -07:00
|
|
|
'anagram filter' => test_zci('trifle', html => qr/Anagrams of "filter"/),
|
2014-10-04 01:45:40 -07:00
|
|
|
'anagrams of events' => test_zci('Steven', html => qr/Anagrams of "events"/),
|
|
|
|
'anagram of algorithm' => test_zci('logarithm', html => qr/Anagrams of "algorithm"/),
|
|
|
|
'show anagram of algorithm' => test_zci('logarithm', html => qr/Anagrams of "algorithm"/),
|
|
|
|
'anagrams for times' => test_zci('emits, items, mites, smite', html => qr/Anagrams of "times"/),
|
|
|
|
'show anagrams of stop' => test_zci('Post, opts, post, pots, spot, tops', html => qr/Anagrams of "stop"/),
|
|
|
|
'find anagram for stop' => test_zci('Post, opts, post, pots, spot, tops', html => qr/Anagrams of "stop"/),
|
2014-10-07 11:57:04 -07:00
|
|
|
'anagrams lost' => test_zci('lots, slot', html => qr/Anagrams of "lost"/),
|
2014-10-04 01:45:40 -07:00
|
|
|
'anagrams of lost' => test_zci('lots, slot', html => qr/Anagrams of "lost"/),
|
|
|
|
'anagram for lost' => test_zci('lots, slot', html => qr/Anagrams of "lost"/),
|
|
|
|
'anagram of lost' => test_zci('lots, slot', html => qr/Anagrams of "lost"/),
|
|
|
|
'anagram of filter' => test_zci('trifle', html => qr/Anagrams of "filter"/),
|
|
|
|
'anagram of Filter' => test_zci('trifle', html => qr/Anagrams of "Filter"/),
|
|
|
|
'anagram of "partial men"' => test_zci('Parliament, parliament', html => qr/Anagrams of "partial men"/),
|
|
|
|
'find anagram for partial men' => test_zci('Parliament, parliament', html => qr/Anagrams of "partial men"/),
|
|
|
|
# Uncached scrambles tests.
|
|
|
|
'anagrams of favorite' => test_zci(
|
|
|
|
'favorite',
|
|
|
|
html => qr/we found no anagrams for "favorite".*scrambled it for you:/,
|
|
|
|
is_cached => 0
|
|
|
|
),
|
|
|
|
'anagram for "Mixing it up"' => test_zci(
|
|
|
|
'Mixing it up',
|
|
|
|
html => qr/we found no anagrams for "Mixing it up".*scrambled it for you:/,
|
|
|
|
is_cached => 0
|
|
|
|
),
|
|
|
|
# Full HTML test.
|
|
|
|
'anagrams of slot' => test_zci(
|
2014-10-03 10:28:18 -07:00
|
|
|
'lost, lots',
|
|
|
|
html =>
|
2014-10-04 01:41:49 -07:00
|
|
|
"<div class='zci--anagrams'><span class='text--secondary'>Anagrams of \"slot\"</span><br/><span class='text--primary'>lost, lots</span></div>",
|
2014-10-03 10:28:18 -07:00
|
|
|
),
|
2014-10-04 01:45:40 -07:00
|
|
|
# No result tests.
|
|
|
|
'anagram of' => undef,
|
2014-10-07 11:57:04 -07:00
|
|
|
'anagrams for' => undef,
|
2014-10-04 01:45:40 -07:00
|
|
|
'anagrams for ""' => undef,
|
|
|
|
'anagrams for "867-5309"' => undef,
|
2014-02-10 13:24:52 -08:00
|
|
|
);
|
2013-02-28 22:13:21 -08:00
|
|
|
|
|
|
|
done_testing;
|