stmtasexpr.t revision 1.1.1.1
1use warnings; 2use strict; 3 4use Test::More tests => 10; 5 6BEGIN { $^H |= 0x20000; } 7 8my $t; 9 10$t = ""; 11eval q{ 12 use XS::APItest qw(stmtasexpr); 13 $t .= "a"; 14 $t .= "b" . stmtasexpr "c"; . "d"; 15 $t .= "e"; 16}; 17is $@, ""; 18is $t, "abcde"; 19 20$t = ""; 21eval q{ 22 use XS::APItest qw(stmtasexpr); 23 $t .= "a"; 24 $t .= "b" . stmtasexpr if($t eq "a") { "c"; } else { "d"; } . "e"; 25 $t .= "f"; 26}; 27is $@, ""; 28is $t, "abcef"; 29 30$t = ""; 31eval q{ 32 use XS::APItest qw(stmtasexpr); 33 $t .= "a"; 34 $t .= "b" . stmtasexpr if($t eq "z") { "c"; } else { "d"; } . "e"; 35 $t .= "f"; 36}; 37is $@, ""; 38is $t, "abdef"; 39 40$t = ""; 41eval q{ 42 use XS::APItest qw(stmtasexpr); 43 no warnings "void"; 44 $t .= "a"; 45 $t .= "b" . stmtasexpr { "z"; "c"; } . "d"; 46 $t .= "e"; 47}; 48is $@, ""; 49is $t, "abcde"; 50 51$t = ""; 52eval q{ 53 use XS::APItest qw(stmtasexpr); 54 $t .= "a"; 55 $t .= "b" . stmtasexpr x: "c"; . "d"; 56 $t .= "e"; 57}; 58isnt $@, ""; 59is $t, ""; 60 611; 62