File: mxrp.t

package info (click to toggle)
libtest-routine-perl 0.031-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 296 kB
  • sloc: perl: 705; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 858 bytes parent folder | download | duplicates (5)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/env perl
use strict;
use warnings;

use Test::Routine::Util;
use Test::More;

BEGIN { plan skip_all => 'Test::Routine and MXRP not yet compatible'; }

{
  package Test::ThingHasID;
  use MooseX::Role::Parameterized;
  use Test::Routine;
  use Test::More;

  parameter id_method => (
    is  => 'ro',
    isa => 'Str',
    default => 'id',
  );

  role {
    my $p = shift;
    my $id_method = $p->id_method;

    requires $id_method;

    test thing_has_numeric_id => sub {
      my ($self) = @_;

      my $id = $self->$id_method;
      like($id, qr/\A[0-9]+\z/, "the thing's id is a string of ascii digits");
    };
  }
}

{
  package HasIdentifier;
  use Moose;
  with 'Test::ThingHasID' => { id_method => 'identifier' };

  sub identifier { return 123 }
}

run_tests(
  "we can use mxrp",
  'HasIdentifier',
);

# ...and we're done!
done_testing;