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