class TestCase::Destroy {
use TestCase::Minimal;
use Fn;
use TestCase::Minimal;
use TestCase::Destroy::Data::Basic;
use TestCase::Destroy::Data::InheritanceParent;
use TestCase::Destroy::Data::InheritanceChild;
use TestCase::Destroy::Data::ExceptionNotOverride;
static method destroy : int () {
{
my $minimal = TestCase::Minimal->new();
my $ret = &destroy_call($minimal);
unless ($minimal->{x} == 3) {
return 0;
}
# The destroy doesn't change the return value.
unless ($ret == 5) {
return 0;
}
}
# Call DESTROY
{
my $object = TestCase::Destroy::Data::Basic->new;
$object->DESTROY;
unless ($object->{y} == 5) {
return 0;
}
}
return 1;
}
static method destroy_call : int ($minimal: TestCase::Minimal) {
my $dest = TestCase::Destroy::Data::Basic->new();
$dest->{minimal} = $minimal;
return 5;
}
static method destroy_exception_no_override : int () {
my $enp = TestCase::Destroy::Data::ExceptionNotOverride->new;
eval { $enp->throw_exception; };
unless (Fn->contains($@, "Excetpion in instance method")) {
return 0;
}
$@ = undef;
return 1;
}
static method inheritance : int () {
$TestCase::Destroy::Data::InheritanceParent::FOO = 0;
{
my $object = TestCase::Destroy::Data::InheritanceChild->new;
}
unless ($TestCase::Destroy::Data::InheritanceParent::FOO == 1) {
return 0;
}
return 1;
}
}