File: 05dicts.t

package info (click to toggle)
libdata-phrasebook-perl 0.35-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 276 kB
  • sloc: perl: 1,242; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,197 bytes parent folder | download | duplicates (4)
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
41
42
43
44
#!/usr/bin/perl -w
use strict;

use Test::More tests => 11;
use Data::Phrasebook;

# load up the default dict
my $book = Data::Phrasebook->new(class  => 'Plain',
                                 loader => 'Text',
                                 file   => 't/phrases',
								 );

my @dicts = $book->dicts();
is(scalar(@dicts),3);
is($dicts[0],'english.txt');

$book->dict('english.txt');
is($book->fetch('foo'), "this is English");

# now switch to the second one
$book->dict('german.txt');
is($book->fetch('foo'), "diese ist Deutsche");

# what are the current keywords?
my @tkeys = qw(baz foo);
my @keywords = $book->keywords();
is_deeply(\@keywords,\@tkeys);

# what are the keywords in the first dictionary?
@tkeys = qw(bar foo);
@keywords = $book->keywords('t/phrases','english.txt');
is_deeply(\@keywords,\@tkeys);

# do we still have the second one loaded?
is($book->fetch('foo'), "diese ist Deutsche");


# now use multiple dictionaries
$book->dict('english.txt','german.txt','french.txt');
is($book->fetch('foo'), "this is English");
is($book->fetch('bar'), "this is a test");
is($book->fetch('baz'), "Guten Tag");
is($book->fetch('ook'), "tout vous avez besoin d'est un phrasebook");