use warnings tester with fewer dependencies, issues
[gitmo/MooseX-Getopt.git] / t / 108_usage_attr.t
1 # Re RT#58715 and the claim in the documentation:
2 #   If you have Getopt::Long::Descriptive the usage param is also passed to new.
3
4 # This tests the fix (that fulfills the documentation claim).
5
6 use strict;
7 use warnings FATAL => 'all';
8 use Test::More tests => 4;
9 use Test::Warnings;
10
11 {
12     package MyClass;
13     use strict; use warnings FATAL => 'all';
14     use Moose;
15     with 'MooseX::Getopt';
16 }
17
18 Moose::Meta::Class->create('MyClassWithBasic',
19     superclasses => ['MyClass'],
20     roles => [ 'MooseX::Getopt::Basic' ],
21 );
22
23 my $basic_obj = MyClassWithBasic->new_with_options();
24 ok(!$basic_obj->meta->has_attribute('usage'), 'basic class has no usage attribute');
25
26 Moose::Meta::Class->create('MyClassWithGLD',
27     superclasses => ['MyClass'],
28     roles => [ 'MooseX::Getopt' ],
29 );
30
31 my $gld_obj = MyClassWithGLD->new_with_options();
32
33 ok($gld_obj->meta->has_attribute('usage'), 'class has usage attribute');
34 isa_ok($gld_obj->usage, 'Getopt::Long::Descriptive::Usage');
35