1#!/usr/bin/perl
2
3# Copyright 2008 Kevin Ryde
4
5# This file is part of Perl-Critic-Pulp.
6#
7# Perl-Critic-Pulp is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by the
9# Free Software Foundation; either version 3, or (at your option) any later
10# version.
11#
12# Perl-Critic-Pulp is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15# for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with Perl-Critic-Pulp.  If not, see <http://www.gnu.org/licenses/>.
19
20
21use strict;
22use warnings;
23use Perl::Critic::Policy::Compatibility::ProhibitTestMoreLikeModifiers;
24use Test::More tests => 13;
25use Perl::Critic;
26
27my $single_policy = 'Compatibility::ProhibitTestMoreLikeModifiers';
28my $critic = Perl::Critic->new
29  ('-profile' => '',
30   '-single-policy' => $single_policy);
31{ my @p = $critic->policies;
32  is (scalar @p, 1,
33     "single policy $single_policy");
34}
35
36ok ($Perl::Critic::Policy::Compatibility::ProhibitTestMoreLikeModifiers::VERSION >= 11,
37    'VERSION variable');
38ok (Perl::Critic::Policy::Compatibility::ProhibitTestMoreLikeModifiers->VERSION  >= 11,
39    'VERSION method');
40
41foreach my $data (## no critic (RequireInterpolationOfMetachars)
42
43                  [ 1, 'Test::More::like ($x, qr/y/i)' ],
44                  [ 1, 'Test::More::like ($x, \'/y/i\')' ],
45                  [ 1, 'Test::More::like ($x, "/y/i")' ],
46                  [ 1, 'Test::More::like ($x, q{/y/i})' ],
47
48                  [ 1, 'use Test::More; like ($x, \'/^y$/m\')' ],
49                  [ 1, 'use Test::More; like ($x, "/^y$/m")' ],
50                  [ 1, 'use Test::More; like ($x, qq{/^y$/m})' ],
51
52                  [ 0, 'Test::More::like ($x, qr/y/)' ],
53                  [ 0, 'Test::More::like ($x, "/y/")' ],
54                  [ 0, 'Test::More::like ($x, qr/y/, "desc")' ],
55
56                  ## use critic
57                 ) {
58  my ($want_count, $str) = @$data;
59
60  my @violations = $critic->critique (\$str);
61  foreach (@violations) {
62    diag ($_->description);
63  }
64  my $got_count = scalar @violations;
65  is ($got_count, $want_count, $str);
66}
67
68exit 0;
69