Add fallback to tmpfile for use in cases where user's relying on
[p5sagit/p5-mst-13.2.git] / t / lib / b.t
CommitLineData
ee8c7f54 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 unshift @INC, '../lib';
6}
7
8$| = 1;
9use warnings;
10use strict;
11use Config;
12
13print "1..10\n";
14
15my $test = 1;
16
17sub ok { print "ok $test\n"; $test++ }
18
19use B::Deparse;
20my $deparse = B::Deparse->new() or print "not ";
21ok;
22
23print "not " if "{\n 1;\n}" ne $deparse->coderef2text(sub {1});
24ok;
25
26print "not " if "{\n '???';\n 2;\n}" ne
27 $deparse->coderef2text(sub {1;2});
28ok;
29
30print "not " if "{\n \$test /= 2 if ++\$test;\n}" ne
31 $deparse->coderef2text(sub {++$test and $test/=2;});
32ok;
33
34my $a = `$^X -I../lib -MO=Deparse -anle 1 2>&1`;
35$a =~ s/-e syntax OK\n//g;
36$b = <<'EOF';
37
38LINE: while (defined($_ = <ARGV>)) {
39 chomp $_;
40 @F = split(/\s+/, $_, 0);
41 '???'
42}
43continue {
44 '???'
45}
46
47EOF
48print "# [$a]\n\# vs\n# [$b]\nnot " if $a ne $b;
49ok;
50
51#6
52$a = `$^X -I../lib -MO=Debug -e 1 2>&1`;
53print "not " unless $a =~
54/\bLISTOP\b.*\bOP\b.*\bCOP\b.*\bOP\b/s;
55ok;
56
57#7
58$a = `$^X -I../lib -MO=Terse -e 1 2>&1`;
59print "not " unless $a =~
60/\bLISTOP\b.*leave.*\bOP\b.*enter.*\bCOP\b.*nextstate.*\bOP\b.*null/s;
61ok;
62
63$a = `$^X -I../lib -MO=Terse -ane "s/foo/bar/" 2>&1`;
64$a =~ s/\(0x[^)]+\)//g;
65$a =~ s/\[[^\]]+\]//g;
66$a =~ s/-e syntax OK//;
67$a =~ s/[^a-z ]+//g;
68$a =~ s/\s+/ /g;
69$a =~ s/\b(s|foo|bar|ullsv)\b\s?//g;
70$a =~ s/^\s+//;
71$a =~ s/\s+$//;
72$b=<<EOF;
73leave enter nextstate label leaveloop enterloop null and defined null
74null gvsv readline gv lineseq nextstate aassign null pushmark split pushre
75null gvsv const null pushmark rvav gv nextstate subst const unstack
76nextstate
77EOF
78$b=~s/\n/ /g;$b=~s/\s+/ /g;
79$b =~ s/\s+$//;
80print "# [$a] vs [$b]\nnot " if $a ne $b;
81ok;
82
83chomp($a = `$^X -I../lib -MB::Stash -Mwarnings -e1`);
84$a = join ',', sort split /,/, $a;
85$a =~ s/-uWin32,//;
86$b = '-uCarp,-uCarp::Heavy,-uDB,-uExporter,-uExporter::Heavy,-uattributes,'
87 . '-umain,-uwarnings';
88print "# [$a] vs [$b]\nnot " if $a ne $b;
89ok;
90
91$a = `$^X -I../lib -MO=Showlex -e "my %one" 2>&1`;
92print "# [$a]\nnot " unless $a =~ /sv_undef.*PVNV.*%one.*sv_undef.*HV/s;
93ok;