convert all uses of Test::Exception to Test::Fatal.
[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;
be0ed157 6use Test::Fatal;
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
be0ed157 13 ::like ::exception {
52ac1d4a 14 has;
be0ed157 15 }, $exception_regex, 'has; fails';
52ac1d4a 16
be0ed157 17 ::like ::exception {
52ac1d4a 18 has undef;
be0ed157 19 }, $exception_regex, 'has undef; fails';
52ac1d4a 20
be0ed157 21 ::ok ! ::exception {
52ac1d4a 22 has "" => (
23 is => 'bare',
24 );
be0ed157 25 }, 'has ""; works now';
52ac1d4a 26
be0ed157 27 ::ok ! ::exception {
52ac1d4a 28 has 0 => (
29 is => 'bare',
30 );
be0ed157 31 }, 'has 0; works now';
f9b5f5f8 32}
33
34{
35 package My::Class;
36 use Moose;
52ac1d4a 37
be0ed157 38 ::like ::exception {
52ac1d4a 39 has;
be0ed157 40 }, $exception_regex, 'has; fails';
52ac1d4a 41
be0ed157 42 ::like ::exception {
52ac1d4a 43 has undef;
be0ed157 44 }, $exception_regex, 'has undef; fails';
52ac1d4a 45
be0ed157 46 ::ok ! ::exception {
52ac1d4a 47 has "" => (
48 is => 'bare',
49 );
be0ed157 50 }, 'has ""; works now';
52ac1d4a 51
be0ed157 52 ::ok ! ::exception {
52ac1d4a 53 has 0 => (
54 is => 'bare',
55 );
be0ed157 56 }, 'has 0; works now';
f9b5f5f8 57}
58
a28e50e4 59done_testing;