Revert most of the conversion to Test::Fatal so we can redo it
[gitmo/Moose.git] / t / 020_attributes / 023_attribute_names.t
CommitLineData
f9b5f5f8 1#!/usr/bin/perl
2
3use strict;
4use warnings;
a28e50e4 5use Test::More;
53a4d826 6use Test::Exception;
f9b5f5f8 7
f9b5f5f8 8my $exception_regex = qr/You must provide a name for the attribute/;
9{
10 package My::Role;
11 use Moose::Role;
52ac1d4a 12
53a4d826 13 ::throws_ok {
52ac1d4a 14 has;
53a4d826 15 } $exception_regex, 'has; fails';
52ac1d4a 16
53a4d826 17 ::throws_ok {
52ac1d4a 18 has undef;
53a4d826 19 } $exception_regex, 'has undef; fails';
52ac1d4a 20
53a4d826 21 ::lives_ok {
52ac1d4a 22 has "" => (
23 is => 'bare',
24 );
53a4d826 25 } 'has ""; works now';
52ac1d4a 26
53a4d826 27 ::lives_ok {
52ac1d4a 28 has 0 => (
29 is => 'bare',
30 );
53a4d826 31 } 'has 0; works now';
f9b5f5f8 32}
33
34{
35 package My::Class;
36 use Moose;
52ac1d4a 37
53a4d826 38 ::throws_ok {
52ac1d4a 39 has;
53a4d826 40 } $exception_regex, 'has; fails';
52ac1d4a 41
53a4d826 42 ::throws_ok {
52ac1d4a 43 has undef;
53a4d826 44 } $exception_regex, 'has undef; fails';
52ac1d4a 45
53a4d826 46 ::lives_ok {
52ac1d4a 47 has "" => (
48 is => 'bare',
49 );
53a4d826 50 } 'has ""; works now';
52ac1d4a 51
53a4d826 52 ::lives_ok {
52ac1d4a 53 has 0 => (
54 is => 'bare',
55 );
53a4d826 56 } 'has 0; works now';
f9b5f5f8 57}
58
a28e50e4 59done_testing;