Changeset 2212
- Timestamp:
- 12/28/08 06:55:52 (3 years ago)
- Location:
- trunk/Padre
- Files:
-
- 1 added
- 2 edited
-
lib/Padre/Document/Perl/Beginner.pm (modified) (1 diff)
-
t/75-perl-beginner.t (modified) (1 diff)
-
t/files/beginner/split2.pl (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/Document/Perl/Beginner.pm
r2211 r2212 3 3 use strict; 4 4 use warnings; 5 6 =head1 NAME 7 8 Padre::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 20 This is a naive implementation. It needs to be replaces by one using L<PPI>. 21 22 In Perl 5 there are lots of pitfals the unaware, especially 23 the beginner can easily fall in. 24 This 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 31 Here @data is in scalar context returning the number of elemenets. Spotted in this form: 32 33 split /,/, @ARGV; 34 35 36 See L<http://padre.perlide.org/ticket/52> and L<http://www.perlmonks.org/?node_id=728569> 37 38 39 =head1 COPYRIGHT 40 41 Copyright 2008 Gabor Szabo. L<http://www.szabgab.com/> 42 43 =head1 LICENSE 44 45 This program is free software; you can redistribute it and/or 46 modify it under the same terms as Perl 5 itself. 47 48 =head1 WARRANTY 49 50 There is no warranty whatsoever. 51 52 =head1 CREDITS and THANKS 53 54 55 56 =cut 57 5 58 6 59 sub new { -
trunk/Padre/t/75-perl-beginner.t
r2211 r2212 17 17 BEGIN { $tests += 1; } 18 18 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; } 19 my %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 24 foreach 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; } 24 29 } 25 30
Note: See TracChangeset
for help on using the changeset viewer.
