In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/9c9a25009f0b320688f71537f57c756d2fdd3f53?hp=5e2aa8f5378f1ea747613936965416cd7ab17628>
- Log ----------------------------------------------------------------- commit 9c9a25009f0b320688f71537f57c756d2fdd3f53 Author: David Mitchell <[email protected]> Date: Tue Apr 12 21:22:46 2011 +0100 add tests for $tied op= $tied The tests for C<$tied op $tied> didn't include the mutator variants of the ops (e.g. +=). M t/op/tie_fetch_count.t commit 3216d3097f9c9570546c2f4a76881de927df4bab Author: David Mitchell <[email protected]> Date: Tue Apr 12 17:33:14 2011 +0100 add $tied ^ $tied test when tests were added for C<$tied op $tied>, the '^' op was missed M t/op/tie_fetch_count.t ----------------------------------------------------------------------- Summary of changes: t/op/tie_fetch_count.t | 39 ++++++++++++++++++++++++++++----------- 1 files changed, 28 insertions(+), 11 deletions(-) diff --git a/t/op/tie_fetch_count.t b/t/op/tie_fetch_count.t index e90f2e6..b0c1dd4 100644 --- a/t/op/tie_fetch_count.t +++ b/t/op/tie_fetch_count.t @@ -7,7 +7,7 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; - plan (tests => 172); + plan (tests => 208); } use strict; @@ -22,7 +22,7 @@ my $count = 0; # # when the list is exhausted. sub TIESCALAR {my $pack = shift; bless [@_], $pack;} sub FETCH {$count ++; @{$_ [0]} == 1 ? ${$_ [0]}[0] : shift @{$_ [0]}} -sub STORE {1;} +sub STORE { unshift @{$_[0]}, $_[1] } sub check_count { @@ -182,18 +182,34 @@ $dummy = &$var5 ; check_count '&{}'; # for both operands. They also test that both return values from # FETCH are used. -sub bin_test { +my %mutators = map { ($_ => 1) } qw(. + - * / % ** << >> & | ^); + + +sub _bin_test { + my $int = shift; my $op = shift; - tie my $var, "main", @_[0..$#_-1]; - is(eval "\$var $op \$var", pop, "retval of \$var $op \$var"); - check_count $op, 2; + my $exp = pop; + my @fetches = @_; + + $int = $int ? 'use integer; ' : ''; + + tie my $var, "main", @fetches; + is(eval "$int\$var $op \$var", $exp, "retval of $int\$var $op \$var"); + check_count "$int$op", 2; + + return unless $mutators{$op}; + + tie my $var2, "main", @fetches; + is(eval "$int \$var2 $op= \$var2", $exp, "retval of $int \$var2 $op= \$var2"); + check_count "$int$op=", 3; +} + +sub bin_test { + _bin_test(0, @_); } + sub bin_int_test { - my $op = shift; - tie my $var, "main", @_[0..$#_-1]; - is(eval "use integer; \$var $op \$var", pop, - "retval of \$var $op \$var under use integer"); - check_count "$op under use integer", 2; + _bin_test(1, @_); } bin_test '**', 2, 3, 8; @@ -219,6 +235,7 @@ bin_test 'ne', 1, 2, 1; bin_test 'cmp', 1, 2, -1; bin_test '&' , 1, 2, 0; bin_test '|' , 1, 2, 3; +bin_test '^' , 3, 5, 6; bin_test '.' , 1, 2, 12; bin_test '==', 1, 2, ""; bin_test '+' , 1, 2, 3; -- Perl5 Master Repository
