File: single_file.t

package info (click to toggle)
libtest-roo-perl 1.004-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 376 kB
  • sloc: perl: 522; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 737 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use Test::Roo;

use MooX::Types::MooseLike::Base qw/ArrayRef/;
use Path::Tiny;

has corpus => (
    is       => 'ro',
    isa      => sub { -f shift },
    required => 1,
);

has lines => (
    is  => 'lazy',
    isa => ArrayRef,
);

sub _build_lines {
    my ($self) = @_;
    return [ map { lc } path( $self->corpus )->lines ];
}

test 'sorted' => sub {
    my $self = shift;
    is_deeply( $self->lines, [ sort @{$self->lines} ], "alphabetized");
};

test 'a to z' => sub {
    my $self = shift;
    my %letters = map { substr($_,0,1) => 1 } @{ $self->lines };
    is_deeply( [sort keys %letters], ["a" .. "z"], "all letters found" );
};


run_me( { corpus => "/usr/share/dict/words" } );
# ... test other corpuses ...

done_testing;