use warnings;
use Test::More;
-use Test::Fatal;
+use Test::Exception;
use Scalar::Util;
# Since this has no default it won't be present yet, but it will
# be after the class is made immutable.
- ok ! exception { $meta->make_immutable; }, '... changed Baz to be immutable';
+ lives_ok {$meta->make_immutable; } '... changed Baz to be immutable';
ok(!$meta->is_mutable, '... our class is no longer mutable');
ok($meta->is_immutable, '... our class is now immutable');
ok(!$meta->make_immutable, '... make immutable now returns nothing');
ok($meta->has_method('new'), '... inlined constructor created for sure');
is_deeply([ map { $_->name } $meta->_inlined_methods ], [ 'new' ], '... really, i mean it');
- ok ! exception { $meta->make_mutable; }, '... changed Baz to be mutable';
+ lives_ok { $meta->make_mutable; } '... changed Baz to be mutable';
ok($meta->is_mutable, '... our class is mutable');
ok(!$meta->is_immutable, '... our class is not immutable');
ok(!$meta->make_mutable, '... make mutable now returns nothing');
my $reef = \ 'reef';
ok($meta->add_package_symbol('$ref', $reef), '... added package symbol');
is($meta->get_package_symbol('$ref'), $reef, '... values match');
- ok ! exception { $meta->remove_package_symbol('$ref') }, '... removed it';
+ lives_ok { $meta->remove_package_symbol('$ref') } '... removed it';
isnt($meta->get_package_symbol('$ref'), $reef, '... values match');
ok( my @supers = $meta->superclasses, '... got the superclasses okay');
for qw(get_meta_instance get_all_attributes
class_precedence_list );
- ok ! exception { $meta->make_immutable; }, '... changed Baz to be immutable again';
+ lives_ok {$meta->make_immutable; } '... changed Baz to be immutable again';
ok($meta->get_method('new'), '... inlined constructor recreated');
}
{
my $meta = Baz->meta;
- ok ! exception { $meta->make_immutable() }, 'Changed Baz to be immutable';
- ok ! exception { $meta->make_mutable() }, '... changed Baz to be mutable';
- ok ! exception { $meta->make_immutable() }, '... changed Baz to be immutable';
+ lives_ok { $meta->make_immutable() } 'Changed Baz to be immutable';
+ lives_ok { $meta->make_mutable() } '... changed Baz to be mutable';
+ lives_ok { $meta->make_immutable() } '... changed Baz to be immutable';
- ok exception { $meta->add_method('xyz', sub{'xxx'}) }, '... exception thrown as expected';
+ dies_ok{ $meta->add_method('xyz', sub{'xxx'}) } '... exception thrown as expected';
- ok exception {
+ dies_ok {
$meta->add_attribute('fickle', accessor => 'fickle')
- }, '... exception thrown as expected';
- ok exception { $meta->remove_attribute('fickle') }, '... exception thrown as expected';
+ } '... exception thrown as expected';
+ dies_ok { $meta->remove_attribute('fickle') } '... exception thrown as expected';
my $reef = \ 'reef';
- ok exception { $meta->add_package_symbol('$ref', $reef) }, '... exception thrown as expected';
- ok exception { $meta->remove_package_symbol('$ref') }, '... exception thrown as expected';
+ dies_ok { $meta->add_package_symbol('$ref', $reef) } '... exception thrown as expected';
+ dies_ok { $meta->remove_package_symbol('$ref') } '... exception thrown as expected';
ok( my @supers = $meta->superclasses, '... got the superclasses okay');
- ok exception { $meta->superclasses('Foo') }, '... set the superclasses';
+ dies_ok { $meta->superclasses('Foo') } '... set the superclasses';
ok( $meta->$_ , "... ${_} works")
for qw(get_meta_instance get_all_attributes
ok($meta->is_mutable, '... our anon class is mutable');
ok(!$meta->is_immutable, '... our anon class is not immutable');
- ok ! exception {$meta->make_immutable(
+ lives_ok {$meta->make_immutable(
inline_accessor => 1,
inline_destructor => 0,
inline_constructor => 1,
)
- }, '... changed class to be immutable';
+ } '... changed class to be immutable';
ok(!$meta->is_mutable, '... our class is no longer mutable');
ok($meta->is_immutable, '... our class is now immutable');
ok(!$meta->make_immutable, '... make immutable now returns nothing');
- ok ! exception { $meta->make_mutable }, '... changed Baz to be mutable';
+ lives_ok { $meta->make_mutable } '... changed Baz to be mutable';
ok($meta->is_mutable, '... our class is mutable');
ok(!$meta->is_immutable, '... our class is not immutable');
ok(!$meta->make_mutable, '... make mutable now returns nothing');
my $reef = \ 'reef';
ok($meta->add_package_symbol('$ref', $reef), '... added package symbol');
is($meta->get_package_symbol('$ref'), $reef, '... values match');
- ok ! exception { $meta->remove_package_symbol('$ref') }, '... removed it';
+ lives_ok { $meta->remove_package_symbol('$ref') } '... removed it';
isnt($meta->get_package_symbol('$ref'), $reef, '... values match');
ok( my @supers = $meta->superclasses, '... got the superclasses okay');
{
my $meta = Baz->meta->create_anon_class(superclasses => ['Baz']);
- ok ! exception {
- $meta->make_immutable(
- inline_accessor => 1,
- inline_destructor => 0,
- inline_constructor => 1,
- )
- }, '... changed class to be immutable';
- ok ! exception { $meta->make_mutable() }, '... changed class to be mutable';
- ok ! exception { $meta->make_immutable }, '... changed class to be immutable';
+ lives_ok {$meta->make_immutable(
+ inline_accessor => 1,
+ inline_destructor => 0,
+ inline_constructor => 1,
+ )
+ } '... changed class to be immutable';
+ lives_ok { $meta->make_mutable() } '... changed class to be mutable';
+ lives_ok {$meta->make_immutable } '... changed class to be immutable';
- ok exception { $meta->add_method('xyz', sub{'xxx'}) }, '... exception thrown as expected';
+ dies_ok{ $meta->add_method('xyz', sub{'xxx'}) } '... exception thrown as expected';
- ok exception {
+ dies_ok {
$meta->add_attribute('fickle', accessor => 'fickle')
- }, '... exception thrown as expected';
- ok exception { $meta->remove_attribute('fickle') }, '... exception thrown as expected';
+ } '... exception thrown as expected';
+ dies_ok { $meta->remove_attribute('fickle') } '... exception thrown as expected';
my $reef = \ 'reef';
- ok exception { $meta->add_package_symbol('$ref', $reef) }, '... exception thrown as expected';
- ok exception { $meta->remove_package_symbol('$ref') }, '... exception thrown as expected';
+ dies_ok { $meta->add_package_symbol('$ref', $reef) } '... exception thrown as expected';
+ dies_ok { $meta->remove_package_symbol('$ref') } '... exception thrown as expected';
ok( my @supers = $meta->superclasses, '... got the superclasses okay');
- ok exception { $meta->superclasses('Foo') }, '... set the superclasses';
+ dies_ok { $meta->superclasses('Foo') } '... set the superclasses';
ok( $meta->$_ , "... ${_} works")
for qw(get_meta_instance get_all_attributes