~ubuntu-branches/ubuntu/trusty/libtest-roo-perl/trusty-proposed

« back to all changes in this revision

Viewing changes to examples/cookbook/lib/CorpusCheck.pm

  • Committer: Package Import Robot
  • Author(s): gregor herrmann
  • Date: 2014-01-14 19:25:11 UTC
  • Revision ID: package-import@ubuntu.com-20140114192511-9ycl4dc1zgamfnek
Tags: upstream-1.002
ImportĀ upstreamĀ versionĀ 1.002

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package CorpusCheck;
 
2
use Test::Roo;
 
3
 
 
4
use MooX::Types::MooseLike::Base qw/ArrayRef/;
 
5
use Path::Tiny;
 
6
 
 
7
has corpus => (
 
8
    is       => 'ro',
 
9
    isa      => sub { -f shift },
 
10
    required => 1,
 
11
);
 
12
 
 
13
has lines => (
 
14
    is  => 'lazy',
 
15
    isa => ArrayRef,
 
16
);
 
17
 
 
18
sub _build_lines {
 
19
    my ($self) = @_;
 
20
    return [ map { lc } path( $self->corpus )->lines ];
 
21
}
 
22
 
 
23
test 'sorted' => sub {
 
24
    my $self = shift;
 
25
    is_deeply( $self->lines, [ sort @{$self->lines} ], "alphabetized");
 
26
};
 
27
 
 
28
test 'a to z' => sub {
 
29
    my $self = shift;
 
30
    my %letters = map { substr($_,0,1) => 1 } @{ $self->lines };
 
31
    is_deeply( [sort keys %letters], ["a" .. "z"], "all letters found" );
 
32
};
 
33
 
 
34
1;