From: Yasushi Nakajima Date: Mon, 28 Aug 2000 16:38:08 +0000 (+0900) Subject: display_format used as a class method without arguments was broken, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=476757f70a9a13196bdf0a87d8e24804db1e95bc;p=p5sagit%2Fp5-mst-13.2.git display_format used as a class method without arguments was broken, reported in Subject: Math::Complex->display_format() sets style to 'Math::Complex' Message-Id: <200008280738.QAA00215@san.p.kyoto.jkc.co.jp> p4raw-id: //depot/perl@6857 --- diff --git a/lib/Math/Complex.pm b/lib/Math/Complex.pm index ece2aad..e7a071a 100644 --- a/lib/Math/Complex.pm +++ b/lib/Math/Complex.pm @@ -7,10 +7,10 @@ package Math::Complex; -$VERSION = "1.30"; - our($VERSION, @ISA, @EXPORT, %EXPORT_TAGS, $Inf); +$VERSION = 1.31; + BEGIN { unless ($^O eq 'unicosmk') { my $e = $!; @@ -1253,23 +1253,15 @@ sub display_format { my %obj = %{$self->{display_format}}; @display_format{keys %obj} = values %obj; } - if (@_ == 1) { - $display_format{style} = shift; - } else { - my %new = @_; - @display_format{keys %new} = values %new; - } - } else { # Called as a class method - if (@_ = 1) { - $display_format{style} = $self; - } else { - my %new = @_; - @display_format{keys %new} = values %new; - } - undef $self; + } + if (@_ == 1) { + $display_format{style} = shift; + } else { + my %new = @_; + @display_format{keys %new} = values %new; } - if (defined $self) { + if (ref $self) { # Called as an object method $self->{display_format} = { %display_format }; return wantarray ? @@ -1277,6 +1269,7 @@ sub display_format { $self->{display_format}->{style}; } + # Called as a class method %DISPLAY_FORMAT = %display_format; return wantarray ? diff --git a/t/lib/complex.t b/t/lib/complex.t index b659142..43dad7f 100755 --- a/t/lib/complex.t +++ b/t/lib/complex.t @@ -14,7 +14,9 @@ BEGIN { use Math::Complex; -my $VERSION = sprintf("%s", q$Id: complex.t,v 1.9 1998/11/01 00:00:00 dsl Exp $ =~ /(\d+\.d+)/); +use vars qw($VERSION); + +$VERSION = 1.91; my ($args, $op, $target, $test, $test_set, $try, $val, $zvalue, @set, @val); @@ -194,6 +196,13 @@ EOT test_broot(qw(-3 -2.1 0 0.99)); sub test_display_format { + $test++; + push @script, <display_format eq 'cartesian'; + print "ok $test\n"; +EOS + push @script, <display_format eq 'polar'; print "ok $test\n"; EOS @@ -276,12 +285,20 @@ EOS \$j->display_format('style' => 'cartesian', 'format' => '(%.5g)'); EOS + $test++; push @script, <display_format eq 'cartesian'; + print "ok $test\n"; +EOS } test_display_format();