Skip Menu |

This queue is for tickets about the MooseX-ClassAttribute CPAN distribution.

Report information
The Basics
Id: 45260
Status: open
Priority: 0/
Queue: MooseX-ClassAttribute

People
Owner: Nobody in particular
Requestors: me [...] evancarroll.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: Evan Carroll <me [...] evancarroll.com>
Subject: [PATCH] added new test
Date: Thu, 23 Apr 2009 17:54:12 -0500
To: bug-MooseX-ClassAttribute [...] rt.cpan.org
From: Evan Carroll <me [...] evancarroll.com>
--- t/05-with-initializer.t | 86 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 86 insertions(+), 0 deletions(-) create mode 100644 t/05-with-initializer.t diff --git a/t/05-with-initializer.t b/t/05-with-initializer.t new file mode 100644 index 0000000..343524f --- /dev/null +++ b/t/05-with-initializer.t @@ -0,0 +1,86 @@ +#!/usr/bin/env perl + +## COPYRIGHT EVAN CARROLL me+cpan < @T > evancarroll <dot> com +## FOR SUPPORT ON THIS TEST VISIT irc.freenode.net/#perlcafe +package ClassFoo; +use Moose; +use MooseX::ClassAttribute; + +class_has 'chas' => ( + isa => 'Str' + , is => 'ro' + , default => 'Foobar' + , initializer => sub { die __PACKAGE__ } +); + +package ClassBar; +use Moose; + +has 'chas' => ( + isa => 'Str' + , is => 'ro' + , default => 'Foobar' + , initializer => sub { die __PACKAGE__ } +); + +package ClassBaz; +use Moose; +use MooseX::ClassAttribute; + +class_has 'chas' => ( + isa => 'Str' + , is => 'rw' + , default => 'Foobar' + , trigger => sub { die __PACKAGE__ } +); + +package ClassQuz; +use Moose; + +has 'chas' => ( + isa => 'Str' + , is => 'rw' + , default => 'Foobar' + , trigger => sub { die __PACKAGE__ } +); + + +package main; +use Test::More tests => 4; + +eval { ClassFoo->new() }; +like ( $@, qr/ClassFoo/, "ClassFoo's class_has (ClassAttribute) initializer fires" ); + +diag( qq{ + IIRC: This is a bug, the default/initializer is supposed to be order dependant on + the attribute, unfortunately this module borks that. +} ); + +eval { ClassBar->new() }; +like ( $@, qr/ClassBar/, "ClassBar's has (non-ClassAttribute) initializer fires" ); + +eval { ClassBaz->new->chas('foobar') }; +like ( $@, qr/ClassBaz/, "ClassBaz's class_has (ClassAttribute) trigger fires" ); + +eval { ClassQuz->new->chas('foobar') }; +like ( $@, qr/ClassQuz/, "ClassQuz's has (non-ClassAttribute) trigger fires" ); + +=head1 DONATIONS + +If you'd like to thank me for the work I've done on this module, +please consider making a "donation" to me via PayPal. I spend a lot of +free time creating free software, and would appreciate any support +you'd care to offer. + +Please note that B<I am not suggesting that you must do this> in order +for me to continue working on this particular software. I will + continue to do so, inasmuch as I have in the past, for as long as it + interests me. + + Similarly, a donation made in this way will probably not make me work + on this software much more, unless I get so many donations that I can + consider working on free software full time, which seems unlikely at + best. + + To donate, log into PayPal contact me at me+freemoney@evancarroll.com + -- 1.6.0.4
Cute, but no thanks. Feel free to submit a new ticket with a patch minus the obnoxious copyright and copy of my donation section.
On Thu Apr 23 20:20:15 2009, DROLSKY wrote: Show quoted text
> Cute, but no thanks. Feel free to submit a new ticket with a patch minus > the obnoxious copyright and copy of my donation section.
18:08 < EvanCarroll> Evan Carroll, releases all cpan code, and code submitted to rt into public domain. Enjoy.
Bug is still open.. The initializer still doesn't fire on class_has. -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
In the process of making this module Moose 2.0 ready, this bug seems to be fixed. However he test was flawed. The initializer fires at class creation time so there was no way to catch that exception. The fixed version can be found in the topic/moose2 branch. It requires Moose 1.9902 though. http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/MooseX- ClassAttribute.git;a=shortlog;h=refs/heads/topic/moose Am Di 26. Okt 2010, 13:05:27, ECARROLL schrieb: Show quoted text
> Bug is still open.. The initializer still doesn't fire on class_has. >