Ancient

 view release on metacpan or  search on metacpan

t/9047-leak-doubly-leaktrace.t  view on Meta::CPAN

        }
    } 'new and destroy does not leak';
};

subtest 'add operations no leak' => sub {
    no_leaks_ok {
        for (1..50) {
            my $list = doubly->new(0);
            for my $i (1..10) {
                $list->add($i);
            }
            # $list goes out of scope and is cleaned up
        }
    } 'add operations does not leak';
};

# ============================================
# Navigation operations
# ============================================

subtest 'start/end navigation no leak' => sub {
    my $list = doubly->new(1);
    $list->add(2)->add(3)->add(4)->add(5);
    no_leaks_ok {
        for (1..500) {
            my $s = $list->start;
            my $e = $list->end;
        }
    } 'start/end navigation does not leak';
};

subtest 'next/prev navigation no leak' => sub {
    my $list = doubly->new(1);
    $list->add(2)->add(3)->add(4)->add(5);
    my $node = $list->start;
    no_leaks_ok {
        for (1..500) {
            $node = $node->next unless $node->is_end;
            $node = $node->prev unless $node->is_start;
        }
    } 'next/prev navigation does not leak';
};

# ============================================
# Data access
# ============================================

subtest 'data get no leak' => sub {
    my $list = doubly->new("value");
    no_leaks_ok {
        for (1..500) {
            my $d = $list->data;
        }
    } 'data get does not leak';
};

subtest 'data set no leak' => sub {
    my $list = doubly->new("initial");
    no_leaks_ok {
        for (1..500) {
            $list->data("updated_$_");
        }
    } 'data set does not leak';
};

# ============================================
# Predicates
# ============================================

subtest 'is_start/is_end no leak' => sub {
    my $list = doubly->new(1);
    $list->add(2)->add(3);
    my $start = $list->start;
    my $end = $list->end;
    no_leaks_ok {
        for (1..500) {
            my $s = $start->is_start;
            my $e = $end->is_end;
            my $ns = $start->is_end;
            my $ne = $end->is_start;
        }
    } 'is_start/is_end does not leak';
};

subtest 'length no leak' => sub {
    my $list = doubly->new(1);
    $list->add(2)->add(3)->add(4)->add(5);
    no_leaks_ok {
        for (1..500) {
            my $len = $list->length;
        }
    } 'length does not leak';
};

# ============================================
# Insert operations
# ============================================

subtest 'insert_before/after no leak' => sub {
    no_leaks_ok {
        for (1..25) {
            my $list = doubly->new("middle");
            for my $i (1..5) {
                $list->insert_before("before_$i");
                $list->insert_after("after_$i");
            }
        }
    } 'insert_before/after does not leak';
};

subtest 'insert_at_start/end no leak' => sub {
    no_leaks_ok {
        for (1..25) {
            my $list = doubly->new("middle");
            for my $i (1..5) {
                $list->insert_at_start("start_$i");
                $list->insert_at_end("end_$i");
            }
        }
    } 'insert_at_start/end does not leak';
};



( run in 0.753 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )