Fix author test fail
[gitmo/MooseX-Getopt.git] / t / 110_sort_usage_by_attr_order.t
CommitLineData
73038480 1
2# The usage information prints the 'documentation' value for all Getopt
3# attributes, except the order is not deterministic (rather, it uses the order
4# in which the attributes are stored in the metaclass 'attributes' hash).
5# Let's sort them by insertion order, which should lead to nicer output:
6# If MooseX::Getopt is applied early, the help options will be on top
7# the help options will always be on top (assuming this role is applied
8# early), followed by options added by parent classes and roles, and then
9# options added by this class.
10
11use strict; use warnings;
12use Test::More tests => 1;
13use Test::Exception;
14
15{
16 package MyClass;
17 use strict; use warnings;
18 use Moose;
19 with 'MooseX::Getopt';
20
21 has $_ => (
22 is => 'ro', isa => 'Str',
23 traits => ['Getopt'],
24 documentation => 'Documentation for "' . $_ . '"',
25 ) foreach qw(foo bar baz);
26}
27
28my $obj = MyClass->new_with_options();
29
ce93a16f 30my $expected = <<"USAGE";
73038480 31usage: 110_sort_usage_by_attr_order.t [-?] [long options...]
ce93a16f 32\t-? --usage --help Prints this usage information.
33\t--foo Documentation for "foo"
34\t--bar Documentation for "bar"
35\t--baz Documentation for "baz"
73038480 36USAGE
37
38is($obj->usage->text, $expected, 'Usage text has nicely sorted options');