File: args.t

package info (click to toggle)
libautodie-perl 2.29-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 764 kB
  • ctags: 299
  • sloc: perl: 3,856; makefile: 2
file content (46 lines) | stat: -rwxr-xr-x 1,354 bytes parent folder | download | duplicates (10)
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
45
46
#!/usr/bin/perl -w
use strict;
use warnings;

use Test::More tests => 7;

require Fatal;

my @default = expand(':default');
my @threads = expand(':threads');
my @io = expand(':io');
my %io_hash = map { $_ => 1 } @io;
my @default_minus_io = grep { !exists($io_hash{$_}) } @default;

is_deeply(translate('!a', 'a'), ['!a'], 'Keeps insist variant');

is_deeply(translate(':default'), \@default,
          'translate and expand agrees');

is_deeply(translate(':default', ':void', ':io'),
          [@default_minus_io, ':void', @io],
          ':void position is respected');

is_deeply(translate(':default', ':void', ':io', ':void', ':threads'),
          [':void', @io, ':void', @threads],
          ':void (twice) position are respected');

is_deeply(translate(':default', '!', ':io'),
    [@default_minus_io, '!', @io], '! position is respected');

is_deeply(translate(':default', '!', ':io', '!', ':threads'),
          ['!', @io, '!', @threads],
          '! (twice) positions are respected');

is_deeply(translate(':default', '!open', '!', ':io'),
    [@default_minus_io, '!open', '!', grep { $_ ne 'open' } @io],
          '!open ! :io works as well');

sub expand {
    # substr is to strip "CORE::" without modifying $_
    return map { substr($_, 6) } @{Fatal->_expand_tag(@_)};
}

sub translate {
    return [Fatal->_translate_import_args(@_)];
}