Merge branch 'master' of git@github.com:bobtfish/moosex-getopt
Tomas Doran [Thu, 27 Aug 2009 00:27:06 +0000 (01:27 +0100)]
* 'master' of git@github.com:bobtfish/moosex-getopt:
  Cleanup test, removing unneeded code serving no purpose or tested elsewhere
  Enable the argv argument to the constructor.

ChangeLog
lib/MooseX/Getopt.pm
t/101_argv_bug.t [new file with mode: 0644]

index 10b28cf..d4651d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 Revision history for Perl extension MooseX-Getopt
 
+  * MooseX::Getopt
+    - Enable and document the argv parameter to the constructor.
+
 0.20 Wed. July 9 2009
        ~ fix MANIFEST.SKIP to avoid double-packaging
 
index 8369321..0321f62 100644 (file)
@@ -69,7 +69,7 @@ sub new_with_options {
 sub _parse_argv {
     my ( $class, %params ) = @_;
 
-    local @ARGV = @{ $params{argv} || \@ARGV };
+    local @ARGV = @{ $params{params}{argv} || \@ARGV };
 
     my ( $opt_spec, $name_to_init_arg ) = ( HAVE_GLD ? $class->_gld_spec(%params) : $class->_traditional_spec(%params) );
 
diff --git a/t/101_argv_bug.t b/t/101_argv_bug.t
new file mode 100644 (file)
index 0000000..6d75ad5
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+use MooseX::Getopt;
+
+{
+    package App;
+    use Moose;
+
+    with 'MooseX::Getopt';
+
+    has 'length' => (
+        is      => 'ro',
+        isa     => 'Int',
+        default => 24,
+    );
+
+    has 'verbose' => (
+        is     => 'ro',
+        isa    => 'Bool',
+        default => 0,
+    );
+    no Moose;
+}
+
+{
+    my $app = App->new_with_options(argv => [ '--verbose', '--length', 50 ]);
+    isa_ok($app, 'App');
+
+    ok($app->verbose, '... verbosity is turned on as expected');
+    is($app->length, 50, '... length is 50 as expected');
+}
+