#!perl
BEGIN {
- chdir 't';
- @INC = ('../lib', '../ext/B/t');
+ if ($ENV{PERL_CORE}){
+ chdir('t') if -d 't';
+ @INC = ('.', '../lib', '../ext/B/t');
+ } else {
+ unshift @INC, 't';
+ push @INC, "../../t";
+ }
require Config;
if (($Config::Config{'extensions'} !~ /\bB\b/) ){
print "1..0 # Skip -- Perl configured without B module\n";
exit 0;
}
- if ($Config{'extensions'} !~ /\bData\/Dumper\b/) {
- print
- "1..0 # Skip: Data::Dumper was not built, needed by OptreeCheck\n";
- exit 0;
-
- }
- if ($] < 5.009) {
- print "1..0 # Skip -- TODO - provide golden result regexps for 5.8\n";
- exit 0;
- }
- require './test.pl';
+ # require 'test.pl'; # now done by OptreeCheck
}
use OptreeCheck;
use Config;
pass("IF,THEN,ELSE, ?:");
+my @open_todo;
+sub open_todo {
+ if (((caller 0)[10]||{})->{open}) {
+ @open_todo = (skip => "\$^OPEN is set");
+ }
+}
+open_todo;
+
checkOptree ( name => '-basic sub {if shift print then,else}',
bcopts => '-basic',
code => sub { if (shift) { print "then" }
else { print "else" }
},
+ @open_todo,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# 9 <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->9
if ($a) { print "foo" }
else { print "bar" }
},
+ @open_todo,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# d <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->d
code => sub { if (shift) { print "then" }
else { print "else" }
},
+ @open_todo,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# 1 <;> nextstate(main 426 optree.t:16) v
# 2 <#> gv[*_] s
if ($a) { print "foo" }
else { print "bar" }
},
+ @open_todo,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# 1 <;> nextstate(main 423 optree.t:16) v
# 2 <#> gv[*_] s
checkOptree ( name => '-exec sub { print (shift) ? "foo" : "bar" }',
code => sub { print (shift) ? "foo" : "bar" },
bcopts => '-exec',
+ @open_todo,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# 1 <;> nextstate(main 428 optree.t:31) v
# 2 <0> pushmark s
checkOptree ( name => '-exec sub { foreach (1..10) {print "foo $_"} }',
code => sub { foreach (1..10) {print "foo $_"} },
bcopts => '-exec',
+ @open_todo,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# 1 <;> nextstate(main 443 optree.t:158) v
# 2 <0> pushmark s
# 3 <$> const[IV 1] s
# 4 <$> const[IV 10] s
# 5 <#> gv[*_] s
-# 6 <{> enteriter(next->d last->g redo->7) lKS
+# 6 <{> enteriter(next->d last->g redo->7) lKS/8
# e <0> iter s
# f <|> and(other->7) K/1
# 7 <;> nextstate(main 442 optree.t:158) v
# 3 <$> const(IV 1) s
# 4 <$> const(IV 10) s
# 5 <$> gv(*_) s
-# 6 <{> enteriter(next->d last->g redo->7) lKS
+# 6 <{> enteriter(next->d last->g redo->7) lKS/8
# e <0> iter s
# f <|> and(other->7) K/1
# 7 <;> nextstate(main 443 optree_samples.t:182) v
checkOptree ( name => '-basic sub { print "foo $_" foreach (1..10) }',
code => sub { print "foo $_" foreach (1..10) },
bcopts => '-basic',
+ @open_todo,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# h <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->h
# 1 <;> nextstate(main 445 optree.t:167) v ->2
# 2 <;> nextstate(main 445 optree.t:167) v ->3
# g <2> leaveloop K/2 ->h
-# 7 <{> enteriter(next->d last->g redo->8) lKS ->e
+# 7 <{> enteriter(next->d last->g redo->8) lKS/8 ->e
# - <0> ex-pushmark s ->3
# - <1> ex-list lK ->6
# 3 <0> pushmark s ->4
# 1 <;> nextstate(main 446 optree_samples.t:192) v ->2
# 2 <;> nextstate(main 446 optree_samples.t:192) v ->3
# g <2> leaveloop K/2 ->h
-# 7 <{> enteriter(next->d last->g redo->8) lKS ->e
+# 7 <{> enteriter(next->d last->g redo->8) lKS/8 ->e
# - <0> ex-pushmark s ->3
# - <1> ex-list lK ->6
# 3 <0> pushmark s ->4
checkOptree ( name => '-exec -e foreach (1..10) {print qq{foo $_}}',
prog => 'foreach (1..10) {print qq{foo $_}}',
bcopts => '-exec',
+ @open_todo,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# 1 <0> enter
# 2 <;> nextstate(main 2 -e:1) v
# 4 <$> const[IV 1] s
# 5 <$> const[IV 10] s
# 6 <#> gv[*_] s
-# 7 <{> enteriter(next->e last->h redo->8) lKS
+# 7 <{> enteriter(next->e last->h redo->8) lKS/8
# f <0> iter s
# g <|> and(other->8) vK/1
# 8 <;> nextstate(main 1 -e:1) v
# 4 <$> const(IV 1) s
# 5 <$> const(IV 10) s
# 6 <$> gv(*_) s
-# 7 <{> enteriter(next->e last->h redo->8) lKS
+# 7 <{> enteriter(next->e last->h redo->8) lKS/8
# f <0> iter s
# g <|> and(other->8) vK/1
# 8 <;> nextstate(main 1 -e:1) v
checkOptree ( name => '-exec sub { print "foo $_" foreach (1..10) }',
code => sub { print "foo $_" foreach (1..10) },
bcopts => '-exec',
+ @open_todo,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# 1 <;> nextstate(main 445 optree.t:167) v
# 2 <;> nextstate(main 445 optree.t:167) v
# 4 <$> const[IV 1] s
# 5 <$> const[IV 10] s
# 6 <#> gv[*_] s
-# 7 <{> enteriter(next->d last->g redo->8) lKS
+# 7 <{> enteriter(next->d last->g redo->8) lKS/8
# e <0> iter s
# f <|> and(other->8) K/1
# 8 <0> pushmark s
# 4 <$> const(IV 1) s
# 5 <$> const(IV 10) s
# 6 <$> gv(*_) s
-# 7 <{> enteriter(next->d last->g redo->8) lKS
+# 7 <{> enteriter(next->d last->g redo->8) lKS/8
# e <0> iter s
# f <|> and(other->8) K/1
# 8 <0> pushmark s
code => '@foo = grep(!/^\#/, @bar)',
bcopts => '-exec',
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
-# 1 <;> nextstate(main 496 (eval 20):1) v
+# 1 <;> nextstate(main 496 (eval 20):1) v:{
# 2 <0> pushmark s
# 3 <0> pushmark s
# 4 <#> gv[*bar] s
# d <2> aassign[t6] KS/COMMON
# e <1> leavesub[1 ref] K/REFC,1
EOT_EOT
-# 1 <;> nextstate(main 496 (eval 20):1) v
+# 1 <;> nextstate(main 496 (eval 20):1) v:{
# 2 <0> pushmark s
# 3 <0> pushmark s
# 4 <$> gv(*bar) s
code => '%h = map { getkey($_) => $_ } @a',
bcopts => '-exec',
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
-# 1 <;> nextstate(main 501 (eval 22):1) v
+# 1 <;> nextstate(main 501 (eval 22):1) v:{
# 2 <0> pushmark s
# 3 <0> pushmark s
# 4 <#> gv[*a] s
# 6 <@> mapstart lK*
# 7 <|> mapwhile(other->8)[t9] lK
# 8 <0> enter l
-# 9 <;> nextstate(main 500 (eval 22):1) v
+# 9 <;> nextstate(main 500 (eval 22):1) v:{
# a <0> pushmark s
# b <0> pushmark s
# c <#> gvsv[*_] s
# l <2> aassign[t10] KS/COMMON
# m <1> leavesub[1 ref] K/REFC,1
EOT_EOT
-# 1 <;> nextstate(main 501 (eval 22):1) v
+# 1 <;> nextstate(main 501 (eval 22):1) v:{
# 2 <0> pushmark s
# 3 <0> pushmark s
# 4 <$> gv(*a) s
# 6 <@> mapstart lK*
# 7 <|> mapwhile(other->8)[t4] lK
# 8 <0> enter l
-# 9 <;> nextstate(main 500 (eval 22):1) v
+# 9 <;> nextstate(main 500 (eval 22):1) v:{
# a <0> pushmark s
# b <0> pushmark s
# c <$> gvsv(*_) s
# 4 <#> gv[*h] s
# 5 <1> rv2hv[t2] lKRM*/1
# 6 <2> aassign[t3] vKS
-# 7 <;> nextstate(main 506 (eval 24):1) v
+# 7 <;> nextstate(main 506 (eval 24):1) v:{
# 8 <0> pushmark sM
# 9 <#> gv[*a] s
# a <1> rv2av[t6] sKRM/1
# b <#> gv[*_] s
# c <1> rv2gv sKRM/1
-# d <{> enteriter(next->o last->r redo->e) lKS
+# d <{> enteriter(next->o last->r redo->e) lKS/8
# p <0> iter s
# q <|> and(other->e) K/1
-# e <;> nextstate(main 505 (eval 24):1) v
+# e <;> nextstate(main 505 (eval 24):1) v:{
# f <#> gvsv[*_] s
# g <#> gv[*h] s
# h <1> rv2hv sKR/1
# 4 <$> gv(*h) s
# 5 <1> rv2hv[t1] lKRM*/1
# 6 <2> aassign[t2] vKS
-# 7 <;> nextstate(main 506 (eval 24):1) v
+# 7 <;> nextstate(main 506 (eval 24):1) v:{
# 8 <0> pushmark sM
# 9 <$> gv(*a) s
# a <1> rv2av[t3] sKRM/1
# b <$> gv(*_) s
# c <1> rv2gv sKRM/1
-# d <{> enteriter(next->o last->r redo->e) lKS
+# d <{> enteriter(next->o last->r redo->e) lKS/8
# p <0> iter s
# q <|> and(other->e) K/1
-# e <;> nextstate(main 505 (eval 24):1) v
+# e <;> nextstate(main 505 (eval 24):1) v:{
# f <$> gvsv(*_) s
# g <$> gv(*h) s
# h <1> rv2hv sKR/1
# 3 <$> const[AV ] s
# 4 <1> rv2av lKPM/1
# 5 <@> mapstart K
-# 6 <|> mapwhile(other->7)[t7] K
+# 6 <|> mapwhile(other->7)[t5] K
# 7 <#> gvsv[*_] s
# 8 <$> const[IV 42] s
# 9 <2> add[t2] sK/2
checkOptree ( name => '-e use constant j => qq{junk}; print j',
prog => 'use constant j => qq{junk}; print j',
bcopts => '-exec',
+ @open_todo,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# 1 <0> enter
-# 2 <;> nextstate(main 71 -e:1) v
+# 2 <;> nextstate(main 71 -e:1) v:{
# 3 <0> pushmark s
# 4 <$> const[PV "junk"] s
# 5 <@> print vK
# 6 <@> leave[1 ref] vKP/REFC
EOT_EOT
# 1 <0> enter
-# 2 <;> nextstate(main 71 -e:1) v
+# 2 <;> nextstate(main 71 -e:1) v:{
# 3 <0> pushmark s
# 4 <$> const(PV "junk") s
# 5 <@> print vK