Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -6367,6 +6367,7 @@ t/op/hashwarn.t See if warnings for bad hash assignments work
t/op/heredoc.t See if heredoc edge and corner cases work
t/op/hexfp.t See if hexadecimal float literals work
t/op/hook/require.t See if require hooks work properly.
t/op/if.t See if "if" blocks get ENTER/LEAVE wrapping
t/op/inc.t See if inc/dec of integers near 32 bit limit work
t/op/inccode.t See if coderefs work in @INC
t/op/inccode-tie.t See if tie to @INC works
Expand Down
39 changes: 36 additions & 3 deletions ext/B/t/concise.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BEGIN {
require 'test.pl'; # we use runperl from 'test.pl', so can't use Test::More
}

plan tests => 167;
plan tests => 169;

require_ok("B::Concise");

Expand Down Expand Up @@ -479,7 +479,40 @@ like $out, qr/$end/, 'OP_AND has op_other';
$out =~ $end;
my $next = $1;

# Check it points to a PUSHMARK
# Check it points to an ENTER...
$end = <<'EOF';
OP \(<NEXT>\)
op_next 0x\w+
op_sibling 0x\w+
op_ppaddr PL_ppaddr\[OP_ENTER\]
EOF

$end =~ s/<NEXT>/$next/;

like $out, qr/$end/, 'OP_AND->op_other points correctly (1/3)';

$end =~ s/\top_next\t\t0x\\w\+/\top_next\t\t\(0x\\w\+\)/;

$out =~ $end;
my $next = $1;

# Then a NEXTSTATE...
$end = <<'EOF';
COP \(<NEXT>\)
op_next 0x\w+
op_sibling 0x\w+
op_ppaddr PL_ppaddr\[OP_NEXTSTATE\]
EOF

$end =~ s/<NEXT>/$next/;

like $out, qr/$end/, 'OP_AND->op_other points correctly (2/3)';

$end =~ s/\top_next\t\t0x\\w\+/\top_next\t\t\(0x\\w\+\)/;
$out =~ $end;
my $next = $1;

# Then finally a PUSHMARK...
$end = <<'EOF';
OP \(<NEXT>\)
op_next 0x\w+
Expand All @@ -489,7 +522,7 @@ EOF

$end =~ s/<NEXT>/$next/;

like $out, qr/$end/, 'OP_AND->op_other points correctly';
like $out, qr/$end/, 'OP_AND->op_other points correctly (3/3)';

# test nextstate hints display

Expand Down
242 changes: 129 additions & 113 deletions ext/B/t/optree_samples.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,43 @@ checkOptree ( name => '-basic sub {if shift print then,else}',
},
strip_open_hints => 1,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# 7 <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->7
# 1 <;> nextstate(main 665 optree_samples.t:24) v:>,<,% ->2
# a <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->a
# 1 <;> nextstate(main 1587 optree_samples.t:20) v ->2
# - <1> null K/1 ->-
# 3 <|> cond_expr(other->4) K/1 ->8
# 3 <|> cond_expr(other->4) K/1 ->b
# 2 <0> shift s* ->3
# - <@> scope K ->-
# - <;> ex-nextstate(main 1594 optree_samples.t:25) v:>,<,% ->4
# 6 <@> print sK ->7
# 4 <0> pushmark s ->5
# 5 <$> const[PV "then"] s ->6
# d <@> leave KP ->7
# 8 <0> enter ->9
# 9 <;> nextstate(main 663 optree_samples.t:25) v:>,<,% ->a
# c <@> print sK ->d
# a <0> pushmark s ->b
# b <$> const[PV "else"] s ->c
# 9 <@> leave KP ->a
# 4 <0> enter ->5
# 5 <;> nextstate(main 1589 optree_samples.t:20) v ->6
# 8 <@> print sK ->9
# 6 <0> pushmark s ->7
# 7 <$> const[PV "then"] s ->8
# g <@> leave KP ->a
# b <0> enter ->c
# c <;> nextstate(main 1591 optree_samples.t:21) v ->d
# f <@> print sK ->g
# d <0> pushmark s ->e
# e <$> const[PV "else"] s ->f
EOT_EOT
# 7 <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->7
# 1 <;> nextstate(main 665 optree_samples.t:24) v:>,<,% ->2
# a <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->a
# 1 <;> nextstate(main 1587 optree_samples.t:20) v ->2
# - <1> null K/1 ->-
# 3 <|> cond_expr(other->4) K/1 ->8
# 3 <|> cond_expr(other->4) K/1 ->b
# 2 <0> shift s* ->3
# - <@> scope K ->-
# - <;> ex-nextstate(main 1594 optree_samples.t:25) v:>,<,% ->4
# 6 <@> print sK ->7
# 4 <0> pushmark s ->5
# 5 <$> const(PV "then") s ->6
# d <@> leave KP ->7
# 8 <0> enter ->9
# 9 <;> nextstate(main 663 optree_samples.t:25) v:>,<,% ->a
# c <@> print sK ->d
# a <0> pushmark s ->b
# b <$> const(PV "else") s ->c
# 9 <@> leave KP ->a
# 4 <0> enter ->5
# 5 <;> nextstate(main 1589 optree_samples.t:20) v ->6
# 8 <@> print sK ->9
# 6 <0> pushmark s ->7
# 7 <$> const(PV "then") s ->8
# g <@> leave KP ->a
# b <0> enter ->c
# c <;> nextstate(main 1591 optree_samples.t:21) v ->d
# f <@> print sK ->g
# d <0> pushmark s ->e
# e <$> const(PV "else") s ->f
EONT_EONT

checkOptree ( name => '-basic (see above, with my $a = shift)',
Expand All @@ -67,49 +69,51 @@ checkOptree ( name => '-basic (see above, with my $a = shift)',
},
strip_open_hints => 1,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# a <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->a
# 1 <;> nextstate(main 666 optree_samples.t:70) v:>,<,% ->2
# 3 <1> padsv_store[$a:666,670] vKS/LVINTRO ->4
# d <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->d
# 1 <;> nextstate(main 1595 optree_samples.t:64) v ->2
# 3 <1> padsv_store[$a:1595,1602] vKS/LVINTRO ->4
# 2 <0> shift s* ->3
# - <0> ex-padsv sRM*/LVINTRO ->3
# 4 <;> nextstate(main 670 optree_samples.t:71) v:>,<,% ->5
# 4 <;> nextstate(main 1596 optree_samples.t:65) v ->5
# - <1> null K/1 ->-
# 6 <|> cond_expr(other->7) K/1 ->b
# 5 <0> padsv[$a:666,670] s ->6
# - <@> scope K ->-
# - <;> ex-nextstate(main 1510 optree_samples.t:66) v:>,<,% ->7
# 9 <@> print sK ->a
# 7 <0> pushmark s ->8
# 8 <$> const[PV "foo"] s ->9
# g <@> leave KP ->a
# b <0> enter ->c
# c <;> nextstate(main 1510 optree_samples.t:66) v:>,<,% ->d
# f <@> print sK ->g
# d <0> pushmark s ->e
# e <$> const[PV "bar"] s ->f
# 6 <|> cond_expr(other->7) K/1 ->e
# 5 <0> padsv[$a:1595,1602] s ->6
# c <@> leave KP ->d
# 7 <0> enter ->8
# 8 <;> nextstate(main 1598 optree_samples.t:65) v ->9
# b <@> print sK ->c
# 9 <0> pushmark s ->a
# a <$> const[PV "foo"] s ->b
# j <@> leave KP ->d
# e <0> enter ->f
# f <;> nextstate(main 1600 optree_samples.t:66) v ->g
# i <@> print sK ->j
# g <0> pushmark s ->h
# h <$> const[PV "bar"] s ->i
EOT_EOT
# a <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->a
# 1 <;> nextstate(main 666 optree_samples.t:70) v:>,<,% ->2
# 3 <1> padsv_store[$a:666,670] vKS/LVINTRO ->4
# d <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->d
# 1 <;> nextstate(main 1595 optree_samples.t:64) v ->2
# 3 <1> padsv_store[$a:1595,1602] vKS/LVINTRO ->4
# 2 <0> shift s* ->3
# - <0> ex-padsv sRM*/LVINTRO ->3
# 4 <;> nextstate(main 670 optree_samples.t:71) v:>,<,% ->5
# 4 <;> nextstate(main 1596 optree_samples.t:65) v ->5
# - <1> null K/1 ->-
# 6 <|> cond_expr(other->7) K/1 ->b
# 5 <0> padsv[$a:666,670] s ->6
# - <@> scope K ->-
# - <;> ex-nextstate(main 1510 optree_samples.t:70) v:>,<,% ->7
# 9 <@> print sK ->a
# 7 <0> pushmark s ->8
# 8 <$> const(PV "foo") s ->9
# g <@> leave KP ->a
# b <0> enter ->c
# c <;> nextstate(main 668 optree_samples.t:72) v:>,<,% ->d
# f <@> print sK ->g
# d <0> pushmark s ->e
# e <$> const(PV "bar") s ->f
# 6 <|> cond_expr(other->7) K/1 ->e
# 5 <0> padsv[$a:1595,1602] s ->6
# c <@> leave KP ->d
# 7 <0> enter ->8
# 8 <;> nextstate(main 1598 optree_samples.t:65) v ->9
# b <@> print sK ->c
# 9 <0> pushmark s ->a
# a <$> const(PV "foo") s ->b
# j <@> leave KP ->d
# e <0> enter ->f
# f <;> nextstate(main 1600 optree_samples.t:66) v ->g
# i <@> print sK ->j
# g <0> pushmark s ->h
# h <$> const(PV "bar") s ->i
EONT_EONT

checkOptree ( name => '-exec sub {if shift print then,else}',
Expand All @@ -122,32 +126,38 @@ checkOptree ( name => '-exec sub {if shift print then,else}',
# 1 <;> nextstate(main 674 optree_samples.t:125) v:>,<,%
# 2 <0> shift s*
# 3 <|> cond_expr(other->4) K/1
# 4 <0> pushmark s
# 5 <$> const[PV "then"] s
# 6 <@> print sK
# goto 7
# 8 <0> enter
# 9 <;> nextstate(main 672 optree_samples.t:126) v:>,<,%
# a <0> pushmark s
# b <$> const[PV "else"] s
# c <@> print sK
# d <@> leave KP
# 7 <1> leavesub[1 ref] K/REFC,1
# 4 <0> enter
# 5 <;> nextstate(main 1606 optree_samples.t:121) v
# 6 <0> pushmark s
# 7 <$> const[PV "then"] s
# 8 <@> print sK
# 9 <@> leave KP
# goto a
# b <0> enter
# c <;> nextstate(main 1608 optree_samples.t:122) v
# d <0> pushmark s
# e <$> const[PV "else"] s
# f <@> print sK
# g <@> leave KP
# a <1> leavesub[1 ref] K/REFC,1
EOT_EOT
# 1 <;> nextstate(main 674 optree_samples.t:129) v:>,<,%
# 1 <;> nextstate(main 674 optree_samples.t:125) v:>,<,%
# 2 <0> shift s*
# 3 <|> cond_expr(other->4) K/1
# 4 <0> pushmark s
# 5 <$> const(PV "then") s
# 6 <@> print sK
# goto 7
# 8 <0> enter
# 9 <;> nextstate(main 672 optree_samples.t:130) v:>,<,%
# a <0> pushmark s
# b <$> const(PV "else") s
# c <@> print sK
# d <@> leave KP
# 7 <1> leavesub[1 ref] K/REFC,1
# 4 <0> enter
# 5 <;> nextstate(main 1606 optree_samples.t:121) v
# 6 <0> pushmark s
# 7 <$> const(PV "then") s
# 8 <@> print sK
# 9 <@> leave KP
# goto a
# b <0> enter
# c <;> nextstate(main 1608 optree_samples.t:122) v
# d <0> pushmark s
# e <$> const(PV "else") s
# f <@> print sK
# g <@> leave KP
# a <1> leavesub[1 ref] K/REFC,1
EONT_EONT

checkOptree ( name => '-exec (see above, with my $a = shift)',
Expand All @@ -164,35 +174,41 @@ checkOptree ( name => '-exec (see above, with my $a = shift)',
# 4 <;> nextstate(main 679 optree_samples.t:166) v:>,<,%
# 5 <0> padsv[$a:675,679] s
# 6 <|> cond_expr(other->7) K/1
# 7 <0> pushmark s
# 8 <$> const[PV "foo"] s
# 9 <@> print sK
# goto a
# b <0> enter
# c <;> nextstate(main 677 optree_samples.t:167) v:>,<,%
# d <0> pushmark s
# e <$> const[PV "bar"] s
# f <@> print sK
# g <@> leave KP
# a <1> leavesub[1 ref] K/REFC,1
# 7 <0> enter
# 8 <;> nextstate(main 1615 optree_samples.t:160) v
# 9 <0> pushmark s
# a <$> const[PV "foo"] s
# b <@> print sK
# c <@> leave KP
# goto d
# e <0> enter
# f <;> nextstate(main 1617 optree_samples.t:161) v
# g <0> pushmark s
# h <$> const[PV "bar"] s
# i <@> print sK
# j <@> leave KP
# d <1> leavesub[1 ref] K/REFC,1
EOT_EOT
# 1 <;> nextstate(main 675 optree_samples.t:171) v:>,<,%
# 1 <;> nextstate(main 675 optree_samples.t:165) v:>,<,%
# 2 <0> shift s*
# 3 <1> padsv_store[$a:1522,1529] vKS/LVINTRO
# 4 <;> nextstate(main 679 optree_samples.t:172) v:>,<,%
# 4 <;> nextstate(main 679 optree_samples.t:166) v:>,<,%
# 5 <0> padsv[$a:675,679] s
# 6 <|> cond_expr(other->7) K/1
# 7 <0> pushmark s
# 8 <$> const(PV "foo") s
# 9 <@> print sK
# goto a
# b <0> enter
# c <;> nextstate(main 677 optree_samples.t:173) v:>,<,%
# d <0> pushmark s
# e <$> const(PV "bar") s
# f <@> print sK
# g <@> leave KP
# a <1> leavesub[1 ref] K/REFC,1
# 7 <0> enter
# 8 <;> nextstate(main 1615 optree_samples.t:160) v
# 9 <0> pushmark s
# a <$> const(PV "foo") s
# b <@> print sK
# c <@> leave KP
# goto d
# e <0> enter
# f <;> nextstate(main 1617 optree_samples.t:161) v
# g <0> pushmark s
# h <$> const(PV "bar") s
# i <@> print sK
# j <@> leave KP
# d <1> leavesub[1 ref] K/REFC,1
EONT_EONT

checkOptree ( name => '-exec sub { print (shift) ? "foo" : "bar" }',
Expand Down
Loading
Loading