summaryrefslogtreecommitdiff
path: root/t/attributes/attribute_names.t
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-06-06 17:50:16 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-06-06 17:50:16 +0000
commit5ac2026f7eed78958d69d051e7a8e993dcf51205 (patch)
tree298c3d2f08bdfe5689998b11892d72a897985be1 /t/attributes/attribute_names.t
downloadMoose-tarball-5ac2026f7eed78958d69d051e7a8e993dcf51205.tar.gz
Diffstat (limited to 't/attributes/attribute_names.t')
-rw-r--r--t/attributes/attribute_names.t57
1 files changed, 57 insertions, 0 deletions
diff --git a/t/attributes/attribute_names.t b/t/attributes/attribute_names.t
new file mode 100644
index 0000000..af6ee1e
--- /dev/null
+++ b/t/attributes/attribute_names.t
@@ -0,0 +1,57 @@
+use strict;
+use warnings;
+use Test::More;
+use Test::Fatal;
+
+my $exception_regex = qr/You must provide a name for the attribute/;
+{
+ package My::Role;
+ use Moose::Role;
+
+ ::like( ::exception {
+ has;
+ }, $exception_regex, 'has; fails' );
+
+ ::like( ::exception {
+ has undef;
+ }, $exception_regex, 'has undef; fails' );
+
+ ::is( ::exception {
+ has "" => (
+ is => 'bare',
+ );
+ }, undef, 'has ""; works now' );
+
+ ::is( ::exception {
+ has 0 => (
+ is => 'bare',
+ );
+ }, undef, 'has 0; works now' );
+}
+
+{
+ package My::Class;
+ use Moose;
+
+ ::like( ::exception {
+ has;
+ }, $exception_regex, 'has; fails' );
+
+ ::like( ::exception {
+ has undef;
+ }, $exception_regex, 'has undef; fails' );
+
+ ::is( ::exception {
+ has "" => (
+ is => 'bare',
+ );
+ }, undef, 'has ""; works now' );
+
+ ::is( ::exception {
+ has 0 => (
+ is => 'bare',
+ );
+ }, undef, 'has 0; works now' );
+}
+
+done_testing;