Data-Pool-Shared

 view release on metacpan or  search on metacpan

xt/metrics_export.t  view on Meta::CPAN

    ok exists $stats->{$k}, "stats has '$k' field";
    ok defined $stats->{$k}, "stats '$k' is defined";
    ok $stats->{$k} =~ /^\d+$/, "stats '$k' is non-negative integer ($stats->{$k})";
}

# Serialize → parse
my $json = eval { encode_json($stats) };
ok !$@, "stats serializes to JSON: $@" if $@;
ok length($json) > 20, "non-trivial JSON: " . substr($json, 0, 80);

my $decoded = decode_json($json);
is_deeply $decoded, $stats, "JSON roundtrip preserves hash";

# Invariants
cmp_ok $stats->{used}, '<=', $stats->{capacity}, "used <= capacity";
cmp_ok $stats->{allocs}, '>=', $stats->{frees}, "allocs >= frees";
is $stats->{used}, $stats->{allocs} - $stats->{frees},
    "used = allocs - frees";

done_testing;



( run in 2.011 seconds using v1.01-cache-2.11-cpan-600a1bdf6e4 )