xref: /openbsd-src/gnu/usr.bin/perl/t/run/switchDx.t (revision e068048151d29f2562a32185e21a8ba885482260)
1#!./perl -w
2BEGIN {
3    chdir 't' if -d 't';
4    @INC = '../lib';
5    require './test.pl';
6    skip_all_if_miniperl();
7}
8
9use Config;
10
11my $perlio_log = "perlio$$.txt";
12
13skip_all "DEBUGGING build required"
14  unless $::Config{ccflags} =~ /(?<!\S)-DDEBUGGING(?!\S)/
15         or $^O eq 'VMS' && $::Config{usedebugging_perl} eq 'Y';
16
17plan tests => 9;
18
19END {
20    unlink $perlio_log;
21}
22{
23    unlink $perlio_log;
24    local $ENV{PERLIO_DEBUG} = $perlio_log;
25    fresh_perl_is("print qq(hello\n)", "hello\n",
26                  { stderr => 1 },
27                  "No perlio debug file without -Di...");
28    ok(!-e $perlio_log, "...no perlio.txt found");
29    fresh_perl_like("print qq(hello\n)", qr/\nEXECUTING...\n{1,2}hello\n?/,
30                  { stderr => 1, switches => [ "-Di" ] },
31                  "Perlio debug file with both -Di and PERLIO_DEBUG...");
32    ok(-e $perlio_log, "... perlio debugging file found with -Di and PERLIO_DEBUG");
33
34    unlink $perlio_log;
35    SKIP: {
36        if (not $Config{taint_support}) {
37            skip("Your perl was built without taint support", 2);
38        }
39        fresh_perl_like("print qq(hello\n)", qr/define raw/,
40                      { stderr => 1, switches => [ "-TDi" ] },
41                      "Perlio debug output to stderr with -TDi (with PERLIO_DEBUG)...");
42        ok(!-e $perlio_log, "...no perlio debugging file found");
43    }
44}
45
46{
47    local $ENV{PERLIO_DEBUG};
48    fresh_perl_like("print qq(hello)", qr/define raw/,
49                    { stderr => 1, switches => [ '-Di' ] },
50                   "-Di defaults to stderr");
51    SKIP: {
52        skip("Your perl was built without taint support", 1)
53            unless $Config{taint_support};
54
55        fresh_perl_like("print qq(hello)", qr/define raw/,
56                    { stderr => 1, switches => [ '-TDi' ] },
57                   "Perlio debug output to STDERR with -TDi (no PERLIO_DEBUG)");
58    }
59}
60{
61    # -DXv tests
62    fresh_perl_like('{ my $n=1; *foo= sub () { $n }; }',
63                    qr/To: CV=0x[a-f0-9]+ \(ANON\), OUTSIDE=0x0 \(null\)/,
64                    { stderr => 1, switches => [ '-DXv' ] },
65                    "-DXv does not assert when dumping anonymous constant sub");
66}
67