}
sub foo_called {
- &cmp_ok(One->get_called_foo, '==', @_); # cmp_ok has a $$$;$ proto
+ &cmp_ok(shift->get_called_foo, '==', @_); # cmp_ok has a $$$;$ proto
}
sub test_One {
+ my $class = shift;
- ok(One->can('foo'), 'foo accessor installed');
+ ok($class->can('foo'), $class . ' foo accessor installed');
- dies_ok { One->new } 'foo is required';
+ dies_ok { $class->new } $class . ' foo is required';
- foo_called(0 => 'trigger not called yet');
+ foo_called($class, 0 => $class . ' trigger not called yet');
- my $one = One->new(foo => 1);
+ my $i = $class->new(foo => 1);
- foo_called(1 => 'trigger called once (constructor)');
+ foo_called($class, 1 => $class . ' trigger called once (constructor)');
- cmp_ok($one->foo, '==', 1, 'read ok');
+ cmp_ok($i->foo, '==', 1, $class . ' read ok');
- foo_called(1 => 'trigger not called for read');
+ foo_called($class, 1 => $class . ' trigger not called for read');
- $one->foo(2);
+ $i->foo(2);
- foo_called(2 => 'trigger called for setter');
+ foo_called($class, 2 => $class . ' trigger called for setter');
}
-my $class = 'One';
-test_class($class, \&test_One);
+test_class('One', \&test_One);
+test_class('Two', \&test_One);
+test_class('Three', \&test_One);
sub test_class {
my ($class, $test) = @_;
#io('orig')->print($orig_meta);
#io('comp')->print($compiled_meta);
- is($orig_meta, $compiled_meta, 'metaclass restored ok');
+ is($orig_meta, $compiled_meta, $class . ' metaclass restored ok');
Class::Unload->unload($class);
Class::MOP::remove_metaclass_by_name($class);