use Data::Dumper::Concise;
use Data::Dump::Streamer;
-my $compiler = MooseX::Antlers::Compiler->load_with_compiler('One');
-
sub dump_meta {
my $meta = $_[0];
local $meta->{methods}{meta};
foo_called(2 => 'trigger called for setter');
}
-my %orig_src = map +($_ => join '', Dump(One->can($_))), qw(new DESTROY foo);
+my $class = 'One';
+test_class($class, \&test_One);
-One->meta->get_method_list; # fill cache
+sub test_class {
+ my ($class, $test) = @_;
-my $orig_meta = dump_meta One->meta;
+ my $compiler = MooseX::Antlers::Compiler->load_with_compiler($class);
-test_One();
+ # FIXME - foo
+ my %orig_src = map +($_ => join '', Dump($class->can($_))), qw(new DESTROY foo);
-my $compiled = $compiler->compiled_source;
+ $class->meta->get_method_list; # fill cache
-#warn $compiled; done_testing; exit 0;
+ my $orig_meta = dump_meta $class->meta;
-Class::Unload->unload('One');
-Class::MOP::remove_metaclass_by_name('One');
+ $test->($class);
-io('/tmp/One.pmc')->print($compiled);
+ my $compiled = $compiler->compiled_source;
-require '/tmp/One.pmc';
+ #warn $compiled; done_testing; exit 0;
-#eval "no warnings; $compiled";
+ Class::Unload->unload($class);
+ Class::MOP::remove_metaclass_by_name($class);
-#die "Shit. failed.\n\n${compiled}\n\nError: $@" if $@;
+ io("/tmp/$class.pmc")->print($compiled);
-my %compiled_src = map +($_ => join '', Dump(One->can($_))), qw(new DESTROY foo);
+ require "/tmp/$class.pmc";
-foreach my $method (qw(new DESTROY foo)) {
- is($compiled_src{$method}, $orig_src{$method}, "${method} restored ok");
-}
+ #eval "no warnings; $compiled";
+
+ #die "Shit. failed.\n\n${compiled}\n\nError: $@" if $@;
-my $compiled_meta = dump_meta One->meta;
+ my %compiled_src = map +($_ => join '', Dump($class->can($_))), qw(new DESTROY foo);
-test_One;
+ # FIXME - foo
+ foreach my $method (qw(new DESTROY foo)) {
+ is($compiled_src{$method}, $orig_src{$method}, "${method} restored ok");
+ }
-#io('orig')->print($orig_meta);
-#io('comp')->print($compiled_meta);
+ my $compiled_meta = dump_meta $class->meta;
-is($orig_meta, $compiled_meta, 'metaclass restored ok');
+ $test->($class);
-# 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
+ #io('orig')->print($orig_meta);
+ #io('comp')->print($compiled_meta);
-#warn Dumper \%attr_refs;
-#warn Dumper \%attr_et;
-#warn Dumper $im_et;
+ is($orig_meta, $compiled_meta, 'metaclass restored ok');
+
+ Class::Unload->unload($class);
+ Class::MOP::remove_metaclass_by_name($class);
+}
done_testing;