We only need local $? if we inline calls to DEMOLISH
[gitmo/Moose.git] / t / attributes / attribute_names.t
CommitLineData
f9b5f5f8 1#!/usr/bin/perl
2
3use strict;
4use warnings;
a28e50e4 5use Test::More;
b10dde3a 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
b10dde3a 13 ::like( ::exception {
52ac1d4a 14 has;
b10dde3a 15 }, $exception_regex, 'has; fails' );
52ac1d4a 16
b10dde3a 17 ::like( ::exception {
52ac1d4a 18 has undef;
b10dde3a 19 }, $exception_regex, 'has undef; fails' );
52ac1d4a 20
b10dde3a 21 ::is( ::exception {
52ac1d4a 22 has "" => (
23 is => 'bare',
24 );
b10dde3a 25 }, undef, 'has ""; works now' );
52ac1d4a 26
b10dde3a 27 ::is( ::exception {
52ac1d4a 28 has 0 => (
29 is => 'bare',
30 );
b10dde3a 31 }, undef, 'has 0; works now' );
f9b5f5f8 32}
33
34{
35 package My::Class;
36 use Moose;
52ac1d4a 37
b10dde3a 38 ::like( ::exception {
52ac1d4a 39 has;
b10dde3a 40 }, $exception_regex, 'has; fails' );
52ac1d4a 41
b10dde3a 42 ::like( ::exception {
52ac1d4a 43 has undef;
b10dde3a 44 }, $exception_regex, 'has undef; fails' );
52ac1d4a 45
b10dde3a 46 ::is( ::exception {
52ac1d4a 47 has "" => (
48 is => 'bare',
49 );
b10dde3a 50 }, undef, 'has ""; works now' );
52ac1d4a 51
b10dde3a 52 ::is( ::exception {
52ac1d4a 53 has 0 => (
54 is => 'bare',
55 );
b10dde3a 56 }, undef, 'has 0; works now' );
f9b5f5f8 57}
58
a28e50e4 59done_testing;