Login
Exempt STD(IN|OUT|ERR) from RequireBriefOpen.
[gknop/Perl-Critic.git] / t / 04_defaults.t
CommitLineData
faa35de4
JRT
1#!perl
2
e68db767 3##############################################################################
faa35de4
JRT
4# $URL$
5# $Date$
6# $Author$
7# $Revision$
e68db767 8##############################################################################
faa35de4
JRT
9
10use strict;
11use warnings;
0d63e03a 12use English qw(-no_match_vars);
badbf753 13use Test::More tests => 21;
dc93df4f 14use Perl::Critic::Defaults;
faa35de4 15
e68db767 16#-----------------------------------------------------------------------------
faa35de4
JRT
17
18{
dc93df4f
JRT
19 my $d = Perl::Critic::Defaults->new();
20 is($d->force(), 0, 'native default force');
dc93df4f
JRT
21 is($d->only(), 0, 'native default only');
22 is($d->severity(), 5, 'native default severity');
58247edc
JRT
23 is($d->theme(), q{}, 'native default theme');
24 is($d->top(), 0, 'native default top');
badbf753 25 is($d->color(), 1, 'native default color');
5c1a155a 26 is($d->verbose(), 4, 'native default verbose');
badbf753 27 is($d->criticism_fatal, 0, 'native default criticism-fatal');
dc93df4f
JRT
28 is_deeply($d->include(), [], 'native default include');
29 is_deeply($d->exclude(), [], 'native default exclude');
faa35de4
JRT
30}
31
32#-----------------------------------------------------------------------------
33
34{
410cf90b
JRT
35 my %user_defaults = (
36 force => 1,
410cf90b
JRT
37 only => 1,
38 severity => 4,
39 theme => 'pbp',
40 top => 50,
badbf753 41 color => 1,
410cf90b 42 verbose => 7,
badbf753 43 'criticism-fatal' => 1,
410cf90b
JRT
44 include => 'foo bar',
45 exclude => 'baz nuts',
46 );
47
48 my $d = Perl::Critic::Defaults->new( %user_defaults );
49 is($d->force(), 1, 'user default force');
410cf90b
JRT
50 is($d->only(), 1, 'user default only');
51 is($d->severity(), 4, 'user default severity');
52 is($d->theme(), 'pbp', 'user default theme');
53 is($d->top(), 50, 'user default top');
54 is($d->verbose(), 7, 'user default verbose');
badbf753 55 is($d->criticism_fatal(), 1, 'user default criticism_fatal');
410cf90b
JRT
56 is_deeply($d->include(), [ qw(foo bar) ], 'user default include');
57 is_deeply($d->exclude(), [ qw(baz nuts)], 'user default exclude');
58}
59
60#-----------------------------------------------------------------------------
0d63e03a 61# Test exception handling
410cf90b
JRT
62
63{
0d63e03a
JRT
64 my %invalid_defaults = (
65 foo => 1,
66 bar => 2,
dc93df4f
JRT
67 );
68
0d63e03a 69 eval { Perl::Critic::Defaults->new( %invalid_defaults ) };
ee5a2bbd
ES
70 like( $EVAL_ERROR, qr/"foo" is not a supported option/m, 'First invalid default' );
71 like( $EVAL_ERROR, qr/"bar" is not a supported option/m, 'Second invalid default' );
0d63e03a 72
faa35de4
JRT
73}
74
34cc6052
ES
75#-----------------------------------------------------------------------------
76
77# ensure we run true if this test is loaded by
78# t/04_defaults.t_without_optional_dependencies.t
791;
80
0d63e03a 81##############################################################################
737d3b65
CD
82# Local Variables:
83# mode: cperl
84# cperl-indent-level: 4
85# fill-column: 78
86# indent-tabs-mode: nil
87# c-indentation-style: bsd
88# End:
96fed375 89# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :