summaryrefslogtreecommitdiff
path: root/ext/XS-APItest/t/postinc.t
diff options
context:
space:
mode:
Diffstat (limited to 'ext/XS-APItest/t/postinc.t')
-rw-r--r--ext/XS-APItest/t/postinc.t60
1 files changed, 60 insertions, 0 deletions
diff --git a/ext/XS-APItest/t/postinc.t b/ext/XS-APItest/t/postinc.t
new file mode 100644
index 0000000000..64196f0ab4
--- /dev/null
+++ b/ext/XS-APItest/t/postinc.t
@@ -0,0 +1,60 @@
+use warnings;
+use strict;
+
+use Test::More tests => 8;
+
+BEGIN { $^H |= 0x20000; }
+
+my $t;
+
+$t = "";
+eval q{
+ use XS::APItest qw(postinc);
+ $t .= "a";
+ my $x = 3;
+ $t .= "b(".postinc($x).")";
+ $t .= "c(".$x.")";
+ $t .= "d";
+};
+is $@, "";
+is $t, "ab(3)c(4)d";
+
+$t = "";
+eval q{
+ use XS::APItest qw(postinc);
+ $t .= "a";
+ my $x = 3;
+ $t .= "b(".postinc($x+1).")";
+ $t .= "c(".$x.")";
+ $t .= "d";
+};
+isnt $@, "";
+is $t, "";
+
+$t = "";
+eval q{
+ use XS::APItest qw(postinc);
+ $t .= "a";
+ my %x = (z => 3);
+ my $z = postinc($x{z});
+ $t .= "b(".$z.")";
+ $t .= "c(".$x{z}.")";
+ $t .= "d";
+};
+is $@, "";
+is $t, "ab(3)c(4)d";
+
+$t = "";
+eval q{
+ use XS::APItest qw(postinc);
+ $t .= "a";
+ my %x;
+ my $z = postinc($x{z});
+ $t .= "b(".$z.")";
+ $t .= "c(".$x{z}.")";
+ $t .= "d";
+};
+is $@, "";
+is $t, "ab(0)c(1)d";
+
+1;