From: Matt S Trout Date: Fri, 4 Dec 2009 13:57:58 +0000 (+0000) Subject: first pass at testing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a39b801f07ae3f019341068c428f1360efeb9886;p=gitmo%2FMooseX-Antlers.git first pass at testing --- diff --git a/t/lib/One.pm b/t/lib/One.pm new file mode 100644 index 0000000..519e901 --- /dev/null +++ b/t/lib/One.pm @@ -0,0 +1,11 @@ +package One; + +use Moose; + +my $called_foo = 0; + +sub get_called_foo { $called_foo } + +has foo => (is => 'rw', required => 1, trigger => sub { $called_foo++ }); + +1; diff --git a/t/one.t b/t/one.t new file mode 100644 index 0000000..eddb112 --- /dev/null +++ b/t/one.t @@ -0,0 +1,54 @@ +use strict; +use warnings FATAL => 'all'; +use aliased 'MooseX::Antlers::EvalTracker'; +use aliased 'MooseX::Antlers::RefTracker'; +use aliased 'MooseX::Antlers::RefFilter'; +use B qw(perlstring); +use lib 't/lib'; +use Test::More; + +my %attr_refs; +my %attr_methods; + +{ + require Moose; + my $orig = Moose->can('import'); + no warnings 'redefine'; + local *Moose::import = sub { + my $targ = caller; + Moose->$orig({ into => $targ }); + my $has = $targ->can('has'); + { + no strict 'refs'; + *{"${targ}::has"} = sub { + $attr_refs{$_[0]} = RefTracker->trace_refs( + '$attributes{'.perlstring($_[0]).'}' + => \@_ + ); + my $et = EvalTracker->new->enable; + $has->(@_); + $attr_methods{$_[0]} = $et->recorded_coderefs; + }; + } + }; + require One; +} + +ok(One->can('foo'), 'foo accessor installed'); + +use Data::Dump::Streamer; + +my $orig_foo_src = Dump(One->can('foo')); + +# write test_class method that checks method including call +# Class::Unload One +# build compiled source +# eval compiled source +# run test_class after that as well as before unload + +use Data::Dumper::Concise; + +#warn Dumper \%attr_refs; +#warn Dumper \%attr_methods; + +done_testing;