use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
use Scalar::Util 'isweak';
can_ok($foo, 'set_foo');
is($foo->get_foo(), undef, '... got an unset value');
- lives_ok {
+ is( exception {
$foo->set_foo(100);
- } '... set_foo wrote successfully';
+ }, undef, '... set_foo wrote successfully' );
is($foo->get_foo(), 100, '... got the correct set value');
ok(!isweak($foo->{foo}), '... it is not a weak reference');
# required writer
- dies_ok {
+ isnt( exception {
Foo->new;
- } '... cannot create without the required attribute';
+ }, undef, '... cannot create without the required attribute' );
can_ok($foo, 'set_foo_required');
is($foo->get_foo_required(), 'required', '... got an unset value');
- lives_ok {
+ is( exception {
$foo->set_foo_required(100);
- } '... set_foo_required wrote successfully';
+ }, undef, '... set_foo_required wrote successfully' );
is($foo->get_foo_required(), 100, '... got the correct set value');
- dies_ok {
+ isnt( exception {
$foo->set_foo_required();
- } '... set_foo_required died successfully with no value';
+ }, undef, '... set_foo_required died successfully with no value' );
- lives_ok {
+ is( exception {
$foo->set_foo_required(undef);
- } '... set_foo_required did accept undef';
+ }, undef, '... set_foo_required did accept undef' );
ok(!isweak($foo->{foo_required}), '... it is not a weak reference');
can_ok($foo, 'set_foo_int');
is($foo->get_foo_int(), undef, '... got an unset value');
- lives_ok {
+ is( exception {
$foo->set_foo_int(100);
- } '... set_foo_int wrote successfully';
+ }, undef, '... set_foo_int wrote successfully' );
is($foo->get_foo_int(), 100, '... got the correct set value');
- dies_ok {
+ isnt( exception {
$foo->set_foo_int("Foo");
- } '... set_foo_int died successfully';
+ }, undef, '... set_foo_int died successfully' );
ok(!isweak($foo->{foo_int}), '... it is not a weak reference');
can_ok($foo, 'set_foo_weak');
is($foo->get_foo_weak(), undef, '... got an unset value');
- lives_ok {
+ is( exception {
$foo->set_foo_weak($test);
- } '... set_foo_weak wrote successfully';
+ }, undef, '... set_foo_weak wrote successfully' );
is($foo->get_foo_weak(), $test, '... got the correct set value');
ok(isweak($foo->{foo_weak}), '... it is a weak reference');