Changeset 2212


Ignore:
Timestamp:
12/28/08 06:55:52 (3 years ago)
Author:
szabgab
Message:

more beginners related test

Location:
trunk/Padre
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Document/Perl/Beginner.pm

    r2211 r2212  
    33use strict; 
    44use warnings; 
     5 
     6=head1 NAME 
     7 
     8Padre::Document::Perl::Beginner - naive implementation of some beginner specific error checking 
     9 
     10=head1 SYNOPSIS 
     11 
     12 use Padre::Document::Perl::Beginner; 
     13 my $b = Padre::Document::Perl::Beginner->new; 
     14 if (not $b->check($data)) { 
     15    warn $b->error; 
     16 } 
     17 
     18=head1 DESCRIPTION 
     19 
     20This is a naive implementation. It needs to be replaces by one using L<PPI>. 
     21 
     22In Perl 5 there are lots of pitfals the unaware, especially 
     23the beginner can easily fall in. 
     24This module provides a method called C<check> that can check a perl script  
     25(provided as parameter as a single string) and recognize problematic code. 
     26 
     27=head1 Examples 
     28 
     29 split /,/, @data; 
     30  
     31Here @data is in scalar context returning the number of elemenets. Spotted in this form: 
     32 
     33 split /,/, @ARGV; 
     34 
     35 
     36See L<http://padre.perlide.org/ticket/52> and L<http://www.perlmonks.org/?node_id=728569> 
     37 
     38 
     39=head1 COPYRIGHT 
     40 
     41Copyright 2008 Gabor Szabo. L<http://www.szabgab.com/> 
     42 
     43=head1 LICENSE 
     44 
     45This program is free software; you can redistribute it and/or 
     46modify it under the same terms as Perl 5 itself. 
     47 
     48=head1 WARRANTY 
     49 
     50There is no warranty whatsoever. 
     51 
     52=head1 CREDITS and THANKS 
     53 
     54 
     55 
     56=cut 
     57 
    558 
    659sub new { 
  • trunk/Padre/t/75-perl-beginner.t

    r2211 r2212  
    1717BEGIN { $tests += 1; } 
    1818 
    19 SCOPE: { 
    20     my $data = slurp (File::Spec->catfile('t', 'files', 'beginner', 'split1.pl')); 
    21     ok(! defined($b->check($data)), 'split1.pl'); 
    22     is($b->error, "The second parameter of split is a string, not an array", "split1.pl error"); 
    23     BEGIN { $tests += 2; } 
     19my %tests = ( 
     20    'split1.pl' => "The second parameter of split is a string, not an array", 
     21    'split2.pl' => "The second parameter of split is a string, not an array", 
     22); 
     23 
     24foreach my $file (keys %tests) { 
     25    my $data = slurp (File::Spec->catfile('t', 'files', 'beginner', $file)); 
     26    ok(! defined($b->check($data)), $file); 
     27    is($b->error, $tests{$file}, "$file error"); 
     28    BEGIN { $tests += 2 * 2; } 
    2429} 
    2530 
Note: See TracChangeset for help on using the changeset viewer.