summaryrefslogtreecommitdiff
path: root/ext/arybase/t/pos.t
diff options
context:
space:
mode:
Diffstat (limited to 'ext/arybase/t/pos.t')
-rw-r--r--ext/arybase/t/pos.t35
1 files changed, 35 insertions, 0 deletions
diff --git a/ext/arybase/t/pos.t b/ext/arybase/t/pos.t
new file mode 100644
index 0000000000..f2f6504a5b
--- /dev/null
+++ b/ext/arybase/t/pos.t
@@ -0,0 +1,35 @@
+use warnings;
+use strict;
+
+use Test::More tests => 12;
+
+our $t = "abcdefghi";
+scalar($t =~ /abcde/g);
+our $r = \$t;
+
+$[ = 3;
+
+is_deeply [ scalar pos($t) ], [ 8 ];
+is_deeply [ pos($t) ], [ 8 ];
+is_deeply [ scalar pos($$r) ], [ 8 ];
+is_deeply [ pos($$r) ], [ 8 ];
+
+scalar($t =~ /x/g);
+
+is_deeply [ scalar pos($t) ], [ undef ];
+is_deeply [ pos($t) ], [ undef ];
+is_deeply [ scalar pos($$r) ], [ undef ];
+is_deeply [ pos($$r) ], [ undef ];
+
+is pos($t), undef;
+pos($t) = 5;
+is 0+pos($t), 5;
+is pos($t), 2;
+my $posr =\ pos($t);
+$$posr = 4;
+{
+ $[ = 0;
+ is 0+$$posr, 1;
+}
+
+1;