* MooseX::Getopt::Parser::Descriptive: fixed regression: does not require CLI param...
[gitmo/MooseX-Getopt.git] / t / 005_strict.t
index 8a8d634..d706747 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 10;
+use Test::More tests => 27;
 use Test::Exception;
 
 BEGIN {
@@ -80,29 +80,60 @@ BEGIN {
 
 }
 
-{
-    local @ARGV = ();
+foreach my $parser_name (qw(MooseX::Getopt::Parser::Long MooseX::Getopt::Parser::Descriptive)) {
+    SKIP: {
+        if ($parser_name eq 'MooseX::Getopt::Parser::Descriptive') {
+            eval { require Getopt::Long::Descriptive };
+            skip "Getopt::Long::Descriptive not installed", 13 if $@;
+        }
 
-    my $app = App->new_with_options;
-    isa_ok( $app, 'App' );
+        {
+            local @ARGV = ();
 
-    ok( !$app->verbose, '... verbosity is off as expected' );
-    is( $app->length, 24,         '... length is 24 as expected' );
-    is( $app->data,   'file.dat', '... data is file.dat as expected' );
-    is_deeply( $app->libs, [], '... libs is [] as expected' );
-    is_deeply( $app->details, {}, '... details is {} as expected' );
-    is($app->private_stuff, 713, '... private stuff is 713 as expected');
-}
+            my $parser = $parser_name->new;
+            isa_ok($parser, $parser_name);
 
-{
-    local @ARGV = (qw/--private_stuff 317/);
+            my $getopt = MooseX::Getopt::Session->new( parser => $parser );
+            isa_ok($getopt, 'MooseX::Getopt::Session');
 
-    throws_ok { App->new_with_options } qr/Unknown option: private_stuff/;
-}
+            my $app = App->new_with_options( getopt => $getopt );
+            isa_ok( $app, 'App' );
 
-{
-    local @ARGV = (qw/--length 100/);
+            ok( !$app->verbose, '... verbosity is off as expected' );
+            is( $app->length, 24,         '... length is 24 as expected' );
+            is( $app->data,   'file.dat', '... data is file.dat as expected' );
+            is_deeply( $app->libs, [], '... libs is [] as expected' );
+            is_deeply( $app->details, {}, '... details is {} as expected' );
+            is($app->private_stuff, 713, '... private stuff is 713 as expected');
+        }
 
-    throws_ok { App->new_with_options } qr/Unknown option: length/;
-}
+        {
+            local @ARGV = (qw/--private_stuff 317/);
+
+            throws_ok {
+                my $parser = $parser_name->new;
+                isa_ok($parser, $parser_name);
 
+                my $getopt = MooseX::Getopt::Session->new( parser => $parser );
+                isa_ok($getopt, 'MooseX::Getopt::Session');
+
+                App->new_with_options( getopt => $getopt );
+            } qr/Unknown option: private_stuff/;
+        }
+
+        {
+            local @ARGV = (qw/--length 100/);
+
+            throws_ok {
+                my $parser = $parser_name->new;
+                isa_ok($parser, $parser_name);
+
+                my $getopt = MooseX::Getopt::Session->new( parser => $parser );
+                isa_ok($getopt, 'MooseX::Getopt::Session');
+
+                App->new_with_options( getopt => $getopt );
+            } qr/Unknown option: length/;
+        }
+
+    }
+}