1#!./perl -w
2
3no strict;
4
5BEGIN {
6    if ($ENV{PERL_CORE}) {
7	@INC = '../lib';
8	chdir 't';
9    }
10}
11
12use Getopt::Long;
13my $want_version="2.24";
14die("Getopt::Long version $want_version required--this is only version ".
15    $Getopt::Long::VERSION)
16  unless $Getopt::Long::VERSION ge $want_version;
17print "1..14\n";
18
19@ARGV = qw(-Foo -baR --foo bar);
20my $p = new Getopt::Long::Parser (config => ["no_ignore_case"]);
21undef $opt_baR;
22undef $opt_bar;
23print "ok 1\n" if $p->getoptions ("foo", "Foo=s");
24print ((defined $opt_foo)   ? "" : "not ", "ok 2\n");
25print (($opt_foo == 1)      ? "" : "not ", "ok 3\n");
26print ((defined $opt_Foo)   ? "" : "not ", "ok 4\n");
27print (($opt_Foo eq "-baR") ? "" : "not ", "ok 5\n");
28print ((@ARGV == 1)         ? "" : "not ", "ok 6\n");
29print (($ARGV[0] eq "bar")  ? "" : "not ", "ok 7\n");
30print (!(defined $opt_baR)  ? "" : "not ", "ok 8\n");
31print (!(defined $opt_bar)  ? "" : "not ", "ok 9\n");
32
33my @args = (qw[-test 1]);
34my $o = Getopt::Long::Parser->new;
35print "ok 10\n" if $o->getoptionsfromarray(\@args, "test=i");
36print ((defined $opt_test) ? "" : "not ", "ok 11\n");
37print (($opt_test == 1)    ? "" : "not ", "ok 12\n");
38print ((@ARGV == 1)        ? "" : "not ", "ok 13\n");
39print ((@args == 0)        ? "" : "not ", "ok 14\n");
40