Login
* Increased VERSION to 0.18_01
[gknop/Perl-Critic.git] / t / 08_document.t
CommitLineData
b22c8627
JRT
1#############################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##############################################################################
7
8use strict;
9use warnings;
10use Test::More tests => 7;
11
12#-----------------------------------------------------------------------------
13
14use_ok('Perl::Critic::Document');
15can_ok('Perl::Critic::Document', 'new');
16can_ok('Perl::Critic::Document', 'find');
17
18{
19 my $code = q{'print 'Hello World';}; #Has 6 PPI::Element
20 my $ppi_doc = PPI::Document->new( \$code );
21 my $pc_doc = Perl::Critic::Document->new( $ppi_doc );
22 isa_ok($pc_doc, 'Perl::Critic::Document');
23
24
25 my $nodes_ref = $pc_doc->find('PPI::Element');
26 is( scalar @{ $nodes_ref }, 6, 'Search by class name');
27
28 $nodes_ref = $pc_doc->find( sub{ return 1 } );
29 is( scalar @{ $nodes_ref }, 6, 'Search by wanted() handler');
30
31 $nodes_ref = $pc_doc->find( q{} );
32 is( $nodes_ref, undef, 'Search by empty class name');
33}