File: stack_trace.t

package info (click to toggle)
libtest-dbic-expectedqueries-perl 2.002-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 148 kB
  • sloc: perl: 347; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use strict;
use warnings;
use Test::More;
use Test::Deep;
use Test::Warnings;

use lib "lib";
use Test::DBIC::ExpectedQueries;


my $queries = Test::DBIC::ExpectedQueries->new({
    schema => "don't hit anything that uses ->schema and we'll be fine",
});


sub Test::A::abc { Test::B::def(@_) }
sub Test::B::def { shift->_stack_trace() }

*abc = "abc";

subtest "_stack_trace string has correct shape" => sub {
    my $with_newline = "new\nline";
    my $callers = Test::A::abc($queries, $with_newline, sub { "code ref" }, [], {}, \*abc);
    like(
        $callers,
        qr|^SQL executed at t.stack_trace.t line \d+
    Test::B::def\('Test::DBIC::ExpectedQueries<HASH>', 'new\^Jline', '<CODE>', '<ARRAY>', '<HASH>', '<GLOB>'\) called at t.stack_trace.t line \d+
    Test::A::abc\('Test::DBIC::ExpectedQueries<HASH>', 'new\^Jline', '<CODE>', '<ARRAY>', '<HASH>', '<GLOB>'\) called at t.stack_trace.t line \d+
    Test::More::subtest\('_stack_trace string has correct shape', '<CODE>'\) called at t.stack_trace.t line \d+|,
        "Correct frames, and shape"
    );
};

done_testing();