1#!/usr/bin/perl -w
2use strict;
3use warnings;
4
5use Test::More tests => 7;
6
7require Fatal;
8
9my @default = expand(':default');
10my @threads = expand(':threads');
11my @io = expand(':io');
12my %io_hash = map { $_ => 1 } @io;
13my @default_minus_io = grep { !exists($io_hash{$_}) } @default;
14
15is_deeply(translate('!a', 'a'), ['!a'], 'Keeps insist variant');
16
17is_deeply(translate(':default'), \@default,
18          'translate and expand agrees');
19
20is_deeply(translate(':default', ':void', ':io'),
21          [@default_minus_io, ':void', @io],
22          ':void position is respected');
23
24is_deeply(translate(':default', ':void', ':io', ':void', ':threads'),
25          [':void', @io, ':void', @threads],
26          ':void (twice) position are respected');
27
28is_deeply(translate(':default', '!', ':io'),
29    [@default_minus_io, '!', @io], '! position is respected');
30
31is_deeply(translate(':default', '!', ':io', '!', ':threads'),
32          ['!', @io, '!', @threads],
33          '! (twice) positions are respected');
34
35is_deeply(translate(':default', '!open', '!', ':io'),
36    [@default_minus_io, '!open', '!', grep { $_ ne 'open' } @io],
37          '!open ! :io works as well');
38
39sub expand {
40    # substr is to strip "CORE::" without modifying $_
41    return map { substr($_, 6) } @{Fatal->_expand_tag(@_)};
42}
43
44sub translate {
45    return [Fatal->_translate_import_args(@_)];
46}
47