This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make Config.t warnings and strictures clean
[perl5.git] / ext / B / t / debug.t
CommitLineData
87a42246
MS
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 if ($^O eq 'MacOS') {
6 @INC = qw(: ::lib ::macos:lib);
7 } else {
8 @INC = '.';
9 push @INC, '../lib';
10 }
9cd8f857
NC
11 require Config;
12 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
13 print "1..0 # Skip -- Perl configured without B module\n";
14 exit 0;
15 }
87a42246
MS
16}
17
18$| = 1;
19use warnings;
20use strict;
21use Config;
22
23print "1..3\n";
24
25my $test = 1;
26
27sub ok { print "ok $test\n"; $test++ }
28
29
30my $a;
31my $Is_VMS = $^O eq 'VMS';
32my $Is_MacOS = $^O eq 'MacOS';
33
34my $path = join " ", map { qq["-I$_"] } @INC;
35my $redir = $Is_MacOS ? "" : "2>&1";
36
37$a = `$^X $path "-MO=Debug" -e 1 $redir`;
38print "not " unless $a =~
39/\bLISTOP\b.*\bOP\b.*\bCOP\b.*\bOP\b/s;
40ok;
41
42
43$a = `$^X $path "-MO=Terse" -e 1 $redir`;
44print "not " unless $a =~
45/\bLISTOP\b.*leave.*\n OP\b.*enter.*\n COP\b.*nextstate.*\n OP\b.*null/s;
46ok;
47
48$a = `$^X $path "-MO=Terse" -ane "s/foo/bar/" $redir`;
49$a =~ s/\(0x[^)]+\)//g;
50$a =~ s/\[[^\]]+\]//g;
51$a =~ s/-e syntax OK//;
52$a =~ s/[^a-z ]+//g;
53$a =~ s/\s+/ /g;
54$a =~ s/\b(s|foo|bar|ullsv)\b\s?//g;
55$a =~ s/^\s+//;
56$a =~ s/\s+$//;
57my $is_thread = $Config{use5005threads} && $Config{use5005threads} eq 'define';
58if ($is_thread) {
59 $b=<<EOF;
60leave enter nextstate label leaveloop enterloop null and defined null
61threadsv readline gv lineseq nextstate aassign null pushmark split pushre
241416b8 62threadsv const null pushmark rvav gv nextstate subst const unstack
87a42246
MS
63EOF
64} else {
65 $b=<<EOF;
66leave enter nextstate label leaveloop enterloop null and defined null
67null gvsv readline gv lineseq nextstate aassign null pushmark split pushre
241416b8 68null gvsv const null pushmark rvav gv nextstate subst const unstack
87a42246
MS
69EOF
70}
71$b=~s/\n/ /g;$b=~s/\s+/ /g;
72$b =~ s/\s+$//;
73print "# [$a]\n# vs\n# [$b]\nnot " if $a ne $b;
74ok;
75