File: metaphone.t

package info (click to toggle)
libtext-metaphone-perl 20160805-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 120 kB
  • sloc: ansic: 269; perl: 91; makefile: 3
file content (40 lines) | stat: -rw-r--r-- 1,184 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl -w

use Test::More 'no_plan';

BEGIN { use_ok "Text::Metaphone"; }

my %test_phones = (
           'recrudescence' => 'RKRTSNS',
           'moist' => 'MST',
           'Gutenberg' => 'KTNBRK',
           'recridessence' => 'RKRTSNS',
           'crapulance' => 'KRPLNS',
           'cough' => 'KF',
           'coffee' => 'KF',
           'tchrist' => 'TKRST',
           'Schwern' => 'XWRN',
           'Schwartz' => 'XWRTS',
           'Avulsion' => 'AFLXN',
           'Aeon' => 'EN',
           'Mushrooms' => 'MXRMS',
           'Way'       => 'W',
           'What'      => 'HT',
           'Wierd'     => 'WRT',
           ''          => '',
           'picklehead'=> 'PKLHT',

           # Caused a crash because phoned word == length of word revealing
           # an off-by-one allocation mistake.
           'nsxkgbsfdtp' => 'NSKSKKBSFTT',

           # An X on the end can make the phoned word one larger than the original.
           'jgVqiNdxNVLpVBxQBlxghDx' => 'JKFKNTKSNFLPFBKSKBLKSTKS',
           'ax1x1x'                  => 'AKSKSKS'
           );

foreach my $word (keys %test_phones) {
    is Metaphone($word), $test_phones{$word}, "$word";
}