DDG/Test/Language.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 85.7% 36 / 42 SCAR 11.1
CC
3
Cov
85%
__ANON__
6.0
__ANON__
2.0
import
1.0
CRAP 3.0
« DDG/Meta/Block.pm ↑ Summary DDG/Test/Location.pm »
1 package DDG::Test::Language;
2 8 our $AUTHORITY = 'cpan:DDG';
3 # ABSTRACT: Gives functions for getting test L<DDG::Language> objects.
4 8 $DDG::Test::Language::VERSION = '1016';
5 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use DDG::Language;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use Package::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 8 our %languages = (
13 'us' => {
14 'flagicon' => 'us',
15 'flag_url' => 'https://duckduckgo.com/f2/us.png',
16 'name_in_local' => 'English of United States',
17 'rtl' => 0,
18 'locale' => 'en_US',
19 'nplurals' => 2,
20 'name_in_english' => 'English of United States',
21 },
22 'de' => {
23 'flagicon' => 'de',
24 'flag_url' => 'https://duckduckgo.com/f2/de.png',
25 'name_in_local' => 'Deutsch von Deutschland',
26 'rtl' => 0,
27 'locale' => 'de_DE',
28 'nplurals' => 2,
29 'name_in_english' => 'German of Germany',
30 },
31 'my' => {
32 'flagicon' => 'my',
33 'flag_url' => 'https://duckduckgo.com/f2/my.png',
34 'name_in_local' => 'Bahasa Malaysia di Malaysia',
35 'rtl' => 0,
36 'locale' => 'ms_MY',
37 'nplurals' => 1,
38 'name_in_english' => 'Malay in Malaysia',
39 },
40 );
41  
42 sub import {
43 9 ▶ my ( $class, %params ) = @_;
Subroutine import: called CC=1 SCAR=0.4
44 9 my $target = caller;
45 9 my $stash = Package::Stash->new($target);
46  
47  
48 $stash->add_symbol('&test_language', sub {
49 16 ▶ my $language_key = shift;
Subroutine __ANON__: called CC=2 SCAR=7.0
50 16 ▶ die "Unknown language_key \"".$language_key."\"" unless defined $languages{$language_key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $DDG::Test::Language::languages{$language_key} 0 16 16
51 16 return DDG::Language->new( %{$languages{$language_key}} );
52 9 });
53  
54  
55 $stash->add_symbol('&test_language_by_env', sub {
56 0 ▶ my $language_key = defined $ENV{DDG_TEST_LANGUAGE} ? $ENV{DDG_TEST_LANGUAGE} : 'us';
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
defined $ENV{'DDG_TEST_LANGUAGE'} ? : 0 0 0
57 0 $stash->get_symbol('&test_language')->($language_key);
58 9 });
59  
60 }
61  
62 8 1;
63  
64 __END__
« DDG/Meta/Block.pm ↑ Summary DDG/Test/Location.pm »