summaryrefslogtreecommitdiff
path: root/lib/Tie/File/t/17_misc_meth.t
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Tie/File/t/17_misc_meth.t')
-rw-r--r--lib/Tie/File/t/17_misc_meth.t45
1 files changed, 35 insertions, 10 deletions
diff --git a/lib/Tie/File/t/17_misc_meth.t b/lib/Tie/File/t/17_misc_meth.t
index 55b694be85..87749616fc 100644
--- a/lib/Tie/File/t/17_misc_meth.t
+++ b/lib/Tie/File/t/17_misc_meth.t
@@ -5,6 +5,7 @@
#
my $file = "tf$$.txt";
+$: = Tie::File::_default_recsep();
1 while unlink $file;
print "1..24\n";
@@ -19,17 +20,19 @@ $N++;
# (3-8) EXTEND
$o->EXTEND(3);
-check_contents("$/$/$/");
+check_contents("$:$:$:");
$o->EXTEND(4);
-check_contents("$/$/$/$/");
+check_contents("$:$:$:$:");
$o->EXTEND(3);
-check_contents("$/$/$/$/");
+check_contents("$:$:$:$:");
# (9-10) CLEAR
@a = ();
check_contents("");
# (11-16) EXISTS
+if ($] >= 5.006) {
+ eval << 'TESTS';
print !exists $a[0] ? "ok $N\n" : "not ok $N\n";
$N++;
$a[0] = "I like pie.";
@@ -45,17 +48,32 @@ print exists $a[1] ? "ok $N\n" : "ok $N\n";
$N++;
print exists $a[2] ? "ok $N\n" : "not ok $N\n";
$N++;
+TESTS
+ } else { # perl 5.005 doesn't have exists $array[1]
+ for (11..16) {
+ print "ok $_ \# skipped (no exists for arrays)\n";
+ $N++;
+ }
+ }
# (17-24) DELETE
+if ($] >= 5.006) {
+ eval << 'TESTS';
delete $a[0];
-check_contents("$/$/GIVE ME PIE$/");
+check_contents("$:$:GIVE ME PIE$:");
delete $a[2];
-check_contents("$/$/");
+check_contents("$:$:");
delete $a[0];
-check_contents("$/$/");
+check_contents("$:$:");
delete $a[1];
-check_contents("$/");
-
+check_contents("$:");
+TESTS
+ } else { # perl 5.005 doesn't have delete $array[1]
+ for (17..24) {
+ print "ok $_ \# skipped (no delete for arrays)\n";
+ $N++;
+ }
+ }
use POSIX 'SEEK_SET';
sub check_contents {
@@ -68,14 +86,21 @@ sub check_contents {
if ($a eq $x) {
print "ok $N\n";
} else {
- s{$/}{\\n}g for $a, $x;
- print "not ok $N\n# expected <$x>, got <$a>\n";
+ ctrlfix(my $msg = "# expected <$x>, got <$a>");
+ print "not ok $N\n$msg\n";
}
$N++;
print $o->_check_integrity($file, $ENV{INTEGRITY}) ? "ok $N\n" : "not ok $N\n";
$N++;
}
+sub ctrlfix {
+ for (@_) {
+ s/\n/\\n/g;
+ s/\r/\\r/g;
+ }
+}
+
END {
undef $o;
untie @a;