### ----------------------------------------------------
### -- FINALIZER
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: t/03-basic.rakutest
### ----------------------------------------------------
use Test;

use lib $*PROGRAM.sibling("lib");
use Frobnicate-Role;

plan 6;

my $finalized;
{
    use FINALIZER;
    dbiconnect( { $finalized = True } );
    nok $finalized, 'did we not finalize yet inside scope';
}
ok $finalized, 'did we finalize when leaving scope';

{
    use FINALIZER;
    $finalized = 0;
    my $frobnicator = dbiconnect( { ++$finalized } );
    is $finalized, 0, 'did we not finalize yet inside scope';
    is +$*FINALIZER.blocks, 1, 'do we have a finalizer block for this';

    $frobnicator.finalize;

    is $finalized, 1, 'did we finalize';
    is +$*FINALIZER.blocks, 0, 'is the finalizer block gone';
}

# vim: expandtab shiftwidth=4


