Add function list to pod
[gitmo/Mouse.git] / t / 001_mouse / 010-required.t
CommitLineData
c3398f5b 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More tests => 3;
eab81545 5use Test::Exception;
c3398f5b 6
7do {
8 package Class;
9 use Mouse;
10
11 has foo => (
74be9f76 12 is => 'bare',
c3398f5b 13 required => 1,
14 );
15
16 has bar => (
74be9f76 17 is => 'bare',
c3398f5b 18 required => 1,
19 default => 50,
20 );
21
22 has baz => (
74be9f76 23 is => 'bare',
c3398f5b 24 required => 1,
25 default => sub { 10 },
26 );
27
28 has quux => (
29 is => "rw",
30 required => 1,
31 lazy => 1,
32 default => sub { "yay" },
33 );
34};
35
398327c3 36throws_ok { Class->new } qr/Attribute \(foo\) is required/, "required attribute is required";
c3398f5b 37lives_ok { Class->new(foo => 5) } "foo is the only required but unfulfilled attribute";
38lives_ok { Class->new(foo => 1, bar => 1, baz => 1, quux => 1) } "all attributes specified";
39