Upgrade to Time::HiRes 1.9709
[p5sagit/p5-mst-13.2.git] / ext / B / t / optree_misc.t
CommitLineData
c60fdceb 1#!perl
2
3BEGIN {
4 if ($ENV{PERL_CORE}){
5 chdir('t') if -d 't';
6 @INC = ('.', '../lib', '../ext/B/t');
7 } else {
8 unshift @INC, 't';
9 push @INC, "../../t";
10 }
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 }
16}
17use OptreeCheck;
18use Config;
50786ba8 19plan tests => 2;
c60fdceb 20
21SKIP: {
22skip "no perlio in this build", 1 unless $Config::Config{useperlio};
23
24# The regression this is testing is that the first aelemfast, derived
25# from a lexical array, is supposed to be a BASEOP "<0>", while the
26# second, from a global, is an SVOP "<$>" or a PADOP "<#>" depending
27# on threading. In buggy versions, both showed up as SVOPs/PADOPs. See
28# B.xs:cc_opclass() for the relevant code.
29
30checkOptree ( name => 'OP_AELEMFAST opclass',
31 code => sub { my @x; our @y; $x[0] + $y[0]},
be2b1c74 32 strip_open_hints => 1,
c60fdceb 33 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
34# a <1> leavesub[1 ref] K/REFC,1 ->(end)
35# - <@> lineseq KP ->a
be2b1c74 36# 1 <;> nextstate(main 634 optree_misc.t:25) v:>,<,% ->2
c60fdceb 37# 2 <0> padav[@x:634,636] vM/LVINTRO ->3
be2b1c74 38# 3 <;> nextstate(main 635 optree_misc.t:25) v:>,<,% ->4
c60fdceb 39# 5 <1> rv2av[t4] vK/OURINTR,1 ->6
40# 4 <#> gv[*y] s ->5
be2b1c74 41# 6 <;> nextstate(main 636 optree_misc.t:25) v:>,<,%,{ ->7
c60fdceb 42# 9 <2> add[t6] sK/2 ->a
43# - <1> ex-aelem sK/2 ->8
44# 7 <0> aelemfast[@x:634,636] sR* ->8
45# - <0> ex-const s ->-
46# - <1> ex-aelem sK/2 ->9
47# - <1> ex-rv2av sKR/1 ->-
48# 8 <#> aelemfast[*y] s ->9
49# - <0> ex-const s ->-
50EOT_EOT
51# a <1> leavesub[1 ref] K/REFC,1 ->(end)
52# - <@> lineseq KP ->a
be2b1c74 53# 1 <;> nextstate(main 634 optree_misc.t:27) v:>,<,% ->2
c60fdceb 54# 2 <0> padav[@x:634,636] vM/LVINTRO ->3
be2b1c74 55# 3 <;> nextstate(main 635 optree_misc.t:27) v:>,<,% ->4
c60fdceb 56# 5 <1> rv2av[t3] vK/OURINTR,1 ->6
57# 4 <$> gv(*y) s ->5
be2b1c74 58# 6 <;> nextstate(main 636 optree_misc.t:27) v:>,<,%,{ ->7
c60fdceb 59# 9 <2> add[t4] sK/2 ->a
60# - <1> ex-aelem sK/2 ->8
61# 7 <0> aelemfast[@x:634,636] sR* ->8
62# - <0> ex-const s ->-
63# - <1> ex-aelem sK/2 ->9
64# - <1> ex-rv2av sKR/1 ->-
65# 8 <$> aelemfast(*y) s ->9
66# - <0> ex-const s ->-
67EONT_EONT
68
69
70} #skip
71
50786ba8 72my $t = <<'EOT_EOT';
73# 8 <@> leave[1 ref] vKP/REFC ->(end)
74# 1 <0> enter ->2
2acfb4e0 75# 2 <;> nextstate(main 1 -e:1) v:>,<,%,{ ->3
50786ba8 76# 7 <2> sassign vKS/2 ->8
77# 5 <@> index[t2] sK/2 ->6
78# - <0> ex-pushmark s ->3
79# 3 <$> const[PV "foo"] s ->4
80# 4 <$> const[GV "foo"] s ->5
81# - <1> ex-rv2sv sKRM*/1 ->7
82# 6 <#> gvsv[*_] s ->7
83EOT_EOT
84my $nt = <<'EONT_EONT';
85# 8 <@> leave[1 ref] vKP/REFC ->(end)
86# 1 <0> enter ->2
2acfb4e0 87# 2 <;> nextstate(main 1 -e:1) v:>,<,%,{ ->3
50786ba8 88# 7 <2> sassign vKS/2 ->8
89# 5 <@> index[t1] sK/2 ->6
90# - <0> ex-pushmark s ->3
91# 3 <$> const(PV "foo") s ->4
92# 4 <$> const(GV "foo") s ->5
93# - <1> ex-rv2sv sKRM*/1 ->7
94# 6 <$> gvsv(*_) s ->7
95EONT_EONT
96
97if ($] < 5.009) {
98 $t =~ s/GV /BM /;
99 $nt =~ s/GV /BM /;
100}
101
102checkOptree ( name => 'index and PVBM',
22aebd37 103 prog => '$_ = index q(foo), q(foo)',
2acfb4e0 104 strip_open_hints => 1,
50786ba8 105 expect => $t, expect_nt => $nt);
106
c60fdceb 107__END__
108