File: bug-mixed-stringy.t

package info (click to toggle)
libmoosex-types-structured-perl 0.36-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 496 kB
  • ctags: 28
  • sloc: perl: 757; makefile: 11
file content (53 lines) | stat: -rw-r--r-- 869 bytes parent folder | download | duplicates (4)
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
52
53
use strict;
use warnings;

use Test::More 0.88;

{
  package Test::MooseX::Types::Structured::StringyBug;

  use Moose;
  use MooseX::Types::Moose qw(Str);
  use MooseX::Types::Structured qw(Tuple Dict);
  use Moose::Util::TypeConstraints;

  subtype "TestStringTypes::SubType",
    as Str,
    where { 1 };

  has 'attr1' => (
    is  => 'ro',
    required => 1,
    isa => Dict[
      foo1 => Str,
      foo2 => "Int",
      foo3 => "TestStringTypes::SubType",
    ],
  );

  has 'attr2' => (
    is  => 'ro',
    required => 1,
    isa => Tuple[
      Str,
      "Int",
      "TestStringTypes::SubType",
    ],
  );
}

my %init_args = (
  attr1 => {
    foo1 => 'a',
    foo2 => 2,
    foo3 => 'c',
  },
  attr2 => ['a', 2, 'c'],
);

ok(
  Test::MooseX::Types::Structured::StringyBug->new(%init_args),
  'Made a class with mixed constraint types',
);

done_testing;