File: fileopt.t

package info (click to toggle)
libgetopt-argvfile-perl 1.10-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 160 kB
  • ctags: 7
  • sloc: perl: 318; makefile: 38
file content (74 lines) | stat: -rw-r--r-- 1,554 bytes parent folder | download | duplicates (5)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

# set pragma
use strict;

# load test module
use Test::More qw(no_plan);

# load the module
use Getopt::ArgvFile qw(argvFile);

# declare expected result
my @expected=(
              '-A',
              'A',
              '-b',
              'bb',
              '-ccc',
              'ccc ccc ccc',
              '-ddd',
              '\'d1 d2" d3\' d4 d5 d6',
              '-eee',
              '"e1 e2\\\' e3" e4 e5 e6',
              'par1',
              'par2',
              'par3',
              '@casca',
              '-case',
              'lower',
             );

# action!
argvFile(default=>1, fileOption=>'config');

# perform first check
is(@ARGV, @expected);
is_deeply(\@ARGV, \@expected);

# declare an alternative array
my @options;

# action! (no prefix in the declared name)
argvFile(default=>1, fileOption=>'config', array=>\@options);

# perform second check
is(@options, @expected);
is_deeply(\@options, \@expected);


# prefix option name declaration by "-"
undef(@options);
argvFile(default=>1, fileOption=>'-config', array=>\@options);

# perform next check
is(@options, @expected);
is_deeply(\@options, \@expected);


# prefix option name declaration by "--"
undef(@options);
argvFile(default=>1, fileOption=>'--config', array=>\@options);

# perform next check
is(@options, @expected);
is_deeply(\@options, \@expected);


# prefix option name declaration by "+"
undef(@options);
argvFile(default=>1, fileOption=>'+config', array=>\@options);

# perform next check
is(@options, @expected);
is_deeply(\@options, \@expected);