warn instead of dying
[gitmo/Moose.git] / t / 020_attributes / 023_attribute_names.t
CommitLineData
f9b5f5f8 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use Test::More tests => 8;
6use Test::Exception;
7
8# note: not sure about "" and 0 being illegal attribute names
9# but I'm just copying what Class::MOP::Attribute does
10
11my $exception_regex = qr/You must provide a name for the attribute/;
12{
13 package My::Role;
14 use Moose::Role;
15 ::throws_ok{ has; } $exception_regex, 'has; fails';
16 ::throws_ok{ has undef; } $exception_regex, 'has undef; fails';
17 ::throws_ok{ has ""; } $exception_regex, 'has ""; fails';
18 ::throws_ok{ has 0; } $exception_regex, 'has 0; fails';
19}
20
21{
22 package My::Class;
23 use Moose;
24 ::throws_ok{ has; } $exception_regex, 'has; fails';
25 ::throws_ok{ has undef; } $exception_regex, 'has undef; fails';
26 ::throws_ok{ has ""; } $exception_regex, 'has ""; fails';
27 ::throws_ok{ has 0; } $exception_regex, 'has 0; fails';
28}
29