Add test for strange --version handling
[gitmo/MooseX-Getopt.git] / t / version_with_simpleconfig.pl
diff --git a/t/version_with_simpleconfig.pl b/t/version_with_simpleconfig.pl
new file mode 100644 (file)
index 0000000..a6efd49
--- /dev/null
@@ -0,0 +1,33 @@
+package WithOptionsAndSimpleConfig;
+use Moose;
+
+with 'MooseX::Getopt';
+
+has print_version => (
+    traits        => [qw(Getopt)],
+    isa           => 'Bool',
+    is            => 'ro',
+    cmd_flag      => 'version',
+    cmd_aliases   => 'v',
+);
+
+has configfile => (
+    traits => [qw(NoGetopt)],
+    isa    => 'Str',
+    coerce => 1,
+    is     => 'ro',
+);
+
+with 'MooseX::SimpleConfig';
+
+sub run {
+    my ($self) = @_;
+
+    if ($self->print_version) {
+        print "SUCCESS\n";
+        exit;
+    }
+}
+
+package main;
+WithOptionsAndSimpleConfig->new_with_options;