File: devel.t

package info (click to toggle)
libdevel-confess-perl 0.009004-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 208 kB
  • sloc: perl: 991; makefile: 2
file content (55 lines) | stat: -rw-r--r-- 1,079 bytes parent folder | download | duplicates (4)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use strict;
use warnings;
BEGIN {
  $ENV{DEVEL_CONFESS_OPTIONS} = '';
}
use Test::More tests => 2;
use lib 't/lib';
use Capture
  capture_as_debugger => ['-d:Confess'],
  capture_with_debugger => ['-d', '-MDevel::Confess'],
;
use Cwd qw(cwd);

my $code = <<'END_CODE';
BEGIN { print STDERR "started\n" }
package A;

sub f {
#line 1 test-block.pl
    die  "Beware!";
}

sub g {
#line 2 test-block.pl
    f();
}

package main;

#line 3 test-block.pl
A::g();
END_CODE

my $expected = <<"END_OUTPUT";
Beware! at test-block.pl line 1.
\tA::f() called at test-block.pl line 2
\tA::g() called at test-block.pl line 3
END_OUTPUT

{
  my $out = capture_as_debugger $code;
  $out =~ s/\A.*?^started\s+//ms;
  is $out, $expected, 'Devel::Confess usable as a debugger';
}

{
  local %ENV = %ENV;
  delete $ENV{$_} for grep /^PERL5?DB/, keys %ENV;
  delete $ENV{LOGDIR};
  $ENV{HOME} = cwd;
  $ENV{PERLDB_OPTS} = 'NonStop noTTY dieLevel=1';
  my $out = capture_with_debugger $code;
  $out =~ s/\A.*?^started\s+//ms;
  like $out, qr/^\Q$expected/, 'Devel::Confess usable with the debugger';
}