chdir 't' if -d 't';
@INC = '../lib';
require './test.pl';
- plan (tests => 280);
+ plan (tests => 312);
}
use strict;
$dummy = $var x 1 ; check_count 'x';
@dummy = ($var) x 1 ; check_count 'x';
$dummy = $var . 1 ; check_count '.';
+@dummy = $var .. 1 ; check_count '$tied..1';
+@dummy = 1 .. $var; check_count '1..$tied';
+tie my $v42 => 'main', "z";
+@dummy = $v42 .. "a"; check_count '$tied.."a"';
+@dummy = "a" .. $v42; check_count '"a"..$tied';
# Pre/post in/decrement
$var ++ ; check_count 'post ++';
# Readline/glob
tie my $var0, "main", \*DATA;
$dummy = <$var0> ; check_count '<readline>';
-$dummy = <${var}> ; check_count '<glob>';
+$var = \1;
+$var .= <DATA> ; check_count '$tiedref .= <rcatline>';
+$var = "tied";
+$var .= <DATA> ; check_count '$tiedstr .= <rcatline>';
+$var = *foo;
+$var .= <DATA> ; check_count '$tiedglob .= <rcatline>';
+{ no warnings "glob";
+ $dummy = <${var}> ; check_count '<glob>';
+}
# File operators
for (split //, 'rwxoRWXOezsfdpSbctugkTBMAC') {
# Make $var hold a glob:
$var = *dummy; $dummy = $var; $count = 0;
$dummy = eval "-$_ \$var"; check_count "-$_ \$tied_glob";
+ next if /[guk]/;
$var = *dummy; $dummy = $var; $count = 0;
- $dummy = eval "-$_ \\\$var"; check_count "-$_ \\\$tied_glob";
+ eval "\$dummy = -$_ \\\$var";
+ check_count "-$_ \\\$tied_glob";
}
$dummy = -l $var ; check_count '-l';
+$var = "test.pl";
+$dummy = -e -e -e $var ; check_count '-e -e';
# Matching
$_ = "foo";
$dummy = $var =~ s/ //; check_count 's///';
$dummy = $var ~~ 1 ; check_count '~~';
$dummy = $var =~ y/ //; check_count 'y///';
+ $var = \1;
+$dummy = $var =~y/ /-/; check_count '$ref =~ y///';
/$var/ ; check_count 'm/pattern/';
/$var foo/ ; check_count 'm/$tied foo/';
s/$var// ; check_count 's/pattern//';
}
# Functions that operate on filenames or filehandles
-for ([chdir=>''],[chmod=>'0,'],[chown=>'0,0,'],[utime=>'0,0,']) {
- my($op,$args) = @$_;
+for ([chdir=>''],[chmod=>'0,'],[chown=>'0,0,'],[utime=>'0,0,'],
+ [truncate=>'',',0'],[stat=>''],[lstat=>''],[open=>'my $fh,"<&",'],
+ ['()=sort'=>'',' 1,2,3']) {
+ my($op,$args,$postargs) = @$_; $postargs //= '';
# This line makes $var8 hold a glob:
$var8 = *dummy; $dummy = $var8; $count = 0;
- eval "$op $args \$var8"; check_count "$op $args\$tied_glob";
+ eval "$op $args \$var8 $postargs";
+ check_count "$op $args\$tied_glob$postargs";
$var8 = *dummy; $dummy = $var8; $count = 0;
- eval "$op $args \\\$var8"; check_count "$op $args\\\$tied_glob";
+ my $ref = \$var8;
+ eval "$op $args \$ref $postargs";
+ check_count "$op $args\\\$tied_glob$postargs";
+}
+
+{
+ no warnings;
+ $var = *foo;
+ $dummy = select $var, undef, undef, 0
+ ; check_count 'select $tied_glob, ...';
+ $var = \1;
+ $dummy = select $var, undef, undef, 0
+ ; check_count 'select $tied_ref, ...';
+ $var = undef;
+ $dummy = select $var, undef, undef, 0
+ ; check_count 'select $tied_undef, ...';
+}
+
+chop(my $u = "\xff\x{100}");
+tie $var, "main", $u;
+$dummy = pack "u", $var; check_count 'pack "u", $utf8';
+
+tie $var, "main", "\x{100}";
+pos$var = 0 ; check_count 'lvalue pos $utf8';
+$dummy=sprintf"%1s",$var; check_count 'sprintf "%1s", $utf8';
+$dummy=sprintf"%.1s",$var; check_count 'sprintf "%.1s", $utf8';
+$dummy = substr$var,0,1; check_count 'substr $utf8';
+my $l =\substr$var,0,1;
+$dummy = $$l ; check_count 'reading lvalue substr($utf8)';
+$$l = 0 ; check_count 'setting lvalue substr($utf8)';
+tie $var, "main", "a";
+$$l = "\x{100}" ; check_count 'assigning $utf8 to lvalue substr';
+tie $var1, "main", "a";
+substr$var1,0,0,"\x{100}"; check_count '4-arg substr with utf8 replacement';
+
+{
+ local $SIG{__WARN__} = sub {};
+ $dummy = warn $var ; check_count 'warn $tied';
+ tie $@, => 'main', 1;
+ $dummy = warn ; check_count 'warn() with $@ tied (num)';
+ tie $@, => 'main', \1;
+ $dummy = warn ; check_count 'warn() with $@ tied (ref)';
+ tie $@, => 'main', "foo\n";
+ $dummy = warn ; check_count 'warn() with $@ tied (str)';
+ untie $@;
}
###############################################