Eliminate $Is_VMS code from the test.
[p5sagit/p5-mst-13.2.git] / t / lib / b.t
CommitLineData
ccc418af 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
20822f61 5 @INC = '../lib';
ccc418af 6}
7
8$| = 1;
9use warnings;
10use strict;
11use Config;
12
9b86dfa2 13print "1..13\n";
ccc418af 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;
9b86dfa2 33{
34my $a = <<'EOF';
35{
36 $test = sub : lvalue {
37 1;
38 }
39 ;
40}
41EOF
42chomp $a;
43print "not " if $deparse->coderef2text(sub{$test = sub : lvalue { 1 }}) ne $a;
44ok;
45
46$a =~ s/lvalue/method/;
47print "not " if $deparse->coderef2text(sub{$test = sub : method { 1 }}) ne $a;
48ok;
49
50$a =~ s/method/locked method/;
51print "not " if $deparse->coderef2text(sub{$test = sub : method locked { 1 }})
52 ne $a;
53ok;
54}
ccc418af 55
885a8af1 56my $a;
57my $Is_VMS = $^O eq 'VMS';
6b462c4a 58$a = `$^X "-I../lib" "-MO=Deparse" -anle 1 2>&1`;
5fb4d820 59$a =~ s/-e syntax OK\n//g;
ccc418af 60$b = <<'EOF';
ccc418af 61
62LINE: while (defined($_ = <ARGV>)) {
63 chomp $_;
64 @F = split(/\s+/, $_, 0);
65 '???'
66}
67continue {
68 '???'
69}
70
71EOF
5fb4d820 72print "# [$a]\n\# vs\n# [$b]\nnot " if $a ne $b;
ccc418af 73ok;
74
75#6
6b462c4a 76$a = `$^X "-I../lib" "-MO=Debug" -e 1 2>&1`;
ccc418af 77print "not " unless $a =~
78/\bLISTOP\b.*\bOP\b.*\bCOP\b.*\bOP\b/s;
79ok;
80
81#7
6b462c4a 82$a = `$^X "-I../lib" "-MO=Terse" -e 1 2>&1`;
ccc418af 83print "not " unless $a =~
84/\bLISTOP\b.*leave.*\bOP\b.*enter.*\bCOP\b.*nextstate.*\bOP\b.*null/s;
85ok;
86
6b462c4a 87$a = `$^X "-I../lib" "-MO=Terse" -ane "s/foo/bar/" 2>&1`;
ccc418af 88$a =~ s/\(0x[^)]+\)//g;
89$a =~ s/\[[^\]]+\]//g;
90$a =~ s/-e syntax OK//;
91$a =~ s/[^a-z ]+//g;
92$a =~ s/\s+/ /g;
b2ec7025 93$a =~ s/\b(s|foo|bar|ullsv)\b\s?//g;
ccc418af 94$a =~ s/^\s+//;
95$a =~ s/\s+$//;
208edb77 96my $is_thread = $Config{use5005threads} && $Config{use5005threads} eq 'define';
97if ($is_thread) {
cfe9256d 98 $b=<<EOF;
99leave enter nextstate label leaveloop enterloop null and defined null
100threadsv readline gv lineseq nextstate aassign null pushmark split pushre
101threadsv const null pushmark rvav gv nextstate subst const unstack nextstate
102EOF
103} else {
104 $b=<<EOF;
ccc418af 105leave enter nextstate label leaveloop enterloop null and defined null
106null gvsv readline gv lineseq nextstate aassign null pushmark split pushre
cfe9256d 107null gvsv const null pushmark rvav gv nextstate subst const unstack nextstate
ccc418af 108EOF
cfe9256d 109}
ccc418af 110$b=~s/\n/ /g;$b=~s/\s+/ /g;
111$b =~ s/\s+$//;
cfe9256d 112print "# [$a]\n# vs\n# [$b]\nnot " if $a ne $b;
ccc418af 113ok;
114
6b462c4a 115chomp($a = `$^X "-I../lib" "-MB::Stash" "-Mwarnings" -e1`);
ccc418af 116$a = join ',', sort split /,/, $a;
754a99e1 117$a =~ s/-uWin32,// if $^O eq 'MSWin32';
118$a =~ s/-u(Cwd|File|File::Copy|OS2),//g if $^O eq 'os2';
5d129265 119$a =~ s/-uCwd,// if $^O eq 'cygwin';
f3ff050f 120if ($Config{static_ext} eq ' ') {
121 $b = '-uCarp,-uCarp::Heavy,-uDB,-uExporter,-uExporter::Heavy,-uattributes,'
122 . '-umain,-uwarnings';
123 print "# [$a] vs [$b]\nnot " if $a ne $b;
124 ok;
125} else {
126 print "ok $test # skipped: one or more static extensions\n"; $test++;
127}
ccc418af 128
208edb77 129if ($is_thread) {
cfe9256d 130 print "# use5005threads: test $test skipped\n";
131} else {
6b462c4a 132 $a = `$^X "-I../lib" "-MO=Showlex" -e "my %one" 2>&1`;
cfe9256d 133 print "# [$a]\nnot " unless $a =~ /sv_undef.*PVNV.*%one.*sv_undef.*HV/s;
885a8af1 134}
ccc418af 135ok;