App-Test-Generator
view release on metacpan or search on metacpan
t/Analyzer-Complexity.t view on Meta::CPAN
done_testing();
};
# ==================================================================
# analyze -- ? and other operators inside strings/comments
# must NOT inflate the cyclomatic score
# --------------------------------------------------
# Regression: the logical-operator count previously matched
# &&/||/? against the raw source body, so a literal "?" inside a
# string message (e.g. a prompt like "Are you sure?") or a
# keyword inside a comment was miscounted as a real decision point.
# ==================================================================
subtest 'analyze: ?/keywords inside strings or comments do not inflate score' => sub {
# A bare string containing "?" but no real ternary operator
my $report = _analyze_body('sub confirm { return "Are you sure?"; }');
is($report->{cyclomatic_score}, $CYCLOMATIC_BASE,
'"?" inside a string literal does not add to cyclomatic_score');
# "if"/"die" appear only inside a comment, not as real code
$report = _analyze_body(
t/CoverageGuided_Fuzzer_unit.t view on Meta::CPAN
timeout => 1,
iterations => 1,
target_sub => sub { sleep 30; return 1 },
);
my $start = time();
my $r;
lives_ok(sub { $r = $f->run() }, 'run() returns rather than hanging');
my $elapsed = time() - $start;
ok($elapsed < 25, "run() returned promptly (elapsed=${elapsed}s), not after the full sleep")
or diag("run() took ${elapsed}s â timeout did not abort the hanging call");
ok(scalar(@{$f->bugs()}) >= 1, 'hanging call recorded as a bug');
like($f->bugs()->[0]{error}, qr/timed out/, 'bug error mentions the timeout');
};
subtest 'run() with timeout disabled (0) does not wrap target_sub in alarm' => sub {
my $f = _fuzzer(
timeout => 0,
iterations => 3,
( run in 1.103 second using v1.01-cache-2.11-cpan-0b5f733616e )