Tests for rpeep optimisations in e45d8982ae
authorMatthew Horsfall (alh) <wolfsage@gmail.com>
Fri, 13 Dec 2013 17:57:47 +0000 (12:57 -0500)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 14 Dec 2013 14:23:04 +0000 (06:23 -0800)
ext/B/t/optree_samples.t

index a4f84c6..82fe192 100644 (file)
@@ -14,7 +14,7 @@ BEGIN {
 }
 use OptreeCheck;
 use Config;
-plan tests     => 37;
+plan tests     => 43;
 
 pass("GENERAL OPTREE EXAMPLES");
 
@@ -653,6 +653,60 @@ EOT_EOT
 # 3  <1> leavesub[1 ref] K/REFC,1
 EONT_EONT
 
+pass("rpeep - if ($a || $b)");
+
+checkOptree ( name     => 'if ($a || $b) { } return 1',
+             code      => 'if ($a || $b) { } return 1',
+             bcopts    => '-exec',
+             expect    => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
+# 1  <;> nextstate(main 997 (eval 15):1) v
+# 2  <#> gvsv[*a] s
+# 3  <|> or(other->4) sK/1
+# 4      <#> gvsv[*b] s
+# 5      <|> and(other->6) vK/1
+# 6  <0> stub v
+# 7  <;> nextstate(main 997 (eval 15):1) v
+# 8  <$> const[IV 1] s
+# 9  <1> leavesub[1 ref] K/REFC,1
+EOT_EOT
+# 1  <;> nextstate(main 997 (eval 15):1) v
+# 2  <$> gvsv(*a) s
+# 3  <|> or(other->4) sK/1
+# 4      <$> gvsv(*b) s
+# 5      <|> and(other->6) vK/1
+# 6  <0> stub v
+# 7  <;> nextstate(main 3 (eval 3):1) v
+# 8  <$> const(IV 1) s
+# 9  <1> leavesub[1 ref] K/REFC,1
+EONT_EONT
+
+pass("rpeep - unless ($a && $b)");
+
+checkOptree ( name     => 'unless ($a && $b) { } return 1',
+             code      => 'unless ($a && $b) { } return 1',
+             bcopts    => '-exec',
+             expect    => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
+# 1  <;> nextstate(main 997 (eval 15):1) v
+# 2  <#> gvsv[*a] s
+# 3  <|> and(other->4) sK/1
+# 4      <#> gvsv[*b] s
+# 5      <|> or(other->6) vK/1
+# 6  <0> stub v
+# 7  <;> nextstate(main 997 (eval 15):1) v
+# 8  <$> const[IV 1] s
+# 9  <1> leavesub[1 ref] K/REFC,1
+EOT_EOT
+# 1  <;> nextstate(main 997 (eval 15):1) v
+# 2  <$> gvsv(*a) s
+# 3  <|> and(other->4) sK/1
+# 4      <$> gvsv(*b) s
+# 5      <|> or(other->6) vK/1
+# 6  <0> stub v
+# 7  <;> nextstate(main 3 (eval 3):1) v
+# 8  <$> const(IV 1) s
+# 9  <1> leavesub[1 ref] K/REFC,1
+EONT_EONT
+
 __END__
 
 #######################################################################