diff options
author | Zefram <zefram@fysh.org> | 2010-10-14 17:02:36 +0100 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-10-21 05:53:50 -0700 |
commit | 9eb5c532bf567fdd066254fcaacf4a66722714c5 (patch) | |
tree | 518311ad05d028dab7c1ef9be5bddfb43083e951 /ext/XS-APItest/t | |
parent | 1e2159890b8bf881fbc717f671f87ba2dec1da46 (diff) | |
download | perl-9eb5c532bf567fdd066254fcaacf4a66722714c5.tar.gz |
fix and test PL_expect in recdescent parsing
Set PL_expect at the start of parse_fullstmt() as well as at the start
of parse_stmtseq(). Test both.
Diffstat (limited to 'ext/XS-APItest/t')
-rw-r--r-- | ext/XS-APItest/t/stmtasexpr.t | 51 | ||||
-rw-r--r-- | ext/XS-APItest/t/stmtsasexpr.t | 62 |
2 files changed, 113 insertions, 0 deletions
diff --git a/ext/XS-APItest/t/stmtasexpr.t b/ext/XS-APItest/t/stmtasexpr.t new file mode 100644 index 0000000000..44aae8a271 --- /dev/null +++ b/ext/XS-APItest/t/stmtasexpr.t @@ -0,0 +1,51 @@ +use warnings; +use strict; + +use Test::More tests => 8; + +BEGIN { $^H |= 0x20000; } + +my $t; + +$t = ""; +eval q{ + use XS::APItest qw(stmtasexpr); + $t .= "a"; + $t .= "b" . stmtasexpr "c"; . "d"; + $t .= "e"; +}; +is $@, ""; +is $t, "abcde"; + +$t = ""; +eval q{ + use XS::APItest qw(stmtasexpr); + $t .= "a"; + $t .= "b" . stmtasexpr if($t eq "a") { "c"; } else { "d"; } . "e"; + $t .= "f"; +}; +is $@, ""; +is $t, "abcef"; + +$t = ""; +eval q{ + use XS::APItest qw(stmtasexpr); + $t .= "a"; + $t .= "b" . stmtasexpr if($t eq "z") { "c"; } else { "d"; } . "e"; + $t .= "f"; +}; +is $@, ""; +is $t, "abdef"; + +$t = ""; +eval q{ + use XS::APItest qw(stmtasexpr); + no warnings "void"; + $t .= "a"; + $t .= "b" . stmtasexpr { "z"; "c"; } . "d"; + $t .= "e"; +}; +is $@, ""; +is $t, "abcde"; + +1; diff --git a/ext/XS-APItest/t/stmtsasexpr.t b/ext/XS-APItest/t/stmtsasexpr.t new file mode 100644 index 0000000000..5e3391cdee --- /dev/null +++ b/ext/XS-APItest/t/stmtsasexpr.t @@ -0,0 +1,62 @@ +use warnings; +use strict; + +use Test::More tests => 10; + +BEGIN { $^H |= 0x20000; } + +my $t; + +$t = ""; +eval q{ + use XS::APItest qw(stmtsasexpr); + $t .= "a"; + $t .= "b" . stmtsasexpr { "c"; } . "d"; + $t .= "e"; +}; +is $@, ""; +is $t, "abcde"; + +$t = ""; +eval q{ + use XS::APItest qw(stmtsasexpr); + no warnings "void"; + $t .= "a"; + $t .= "b" . stmtsasexpr { "z"; "c"; } . "d"; + $t .= "e"; +}; +is $@, ""; +is $t, "abcde"; + +$t = ""; +eval q{ + use XS::APItest qw(stmtsasexpr); + $t .= "a"; + $t .= "b" . stmtsasexpr { if($t eq "a") { "c"; } else { "d"; } } . "e"; + $t .= "f"; +}; +is $@, ""; +is $t, "abcef"; + +$t = ""; +eval q{ + use XS::APItest qw(stmtsasexpr); + $t .= "a"; + $t .= "b" . stmtsasexpr { if($t eq "z") { "c"; } else { "d"; } } . "e"; + $t .= "f"; +}; +is $@, ""; +is $t, "abdef"; + +$t = ""; +eval q{ + use XS::APItest qw(stmtsasexpr); + no warnings "void"; + $t .= "a"; + $t .= "b" . stmtsasexpr { { "z"; "c"; } } . "d"; + $t .= "e"; +}; +is $@, ""; +is $t, "abcde"; + +1; |