On 2014-11-29 10:03:28, BERZINV wrote:
Show quoted text> Le Sam 29 Nov 2014 08:58:48, SPROUT a écrit :
> > On Fri Nov 28 14:41:16 2014, SREZIC wrote:
> > > I see the following test fails for perls between 5.8 and 5.21,
> > > linux
> > > and freebsd:
> > >
> > > # Failed test 'test if the string "TEST" is lower case'
> > > # at t/String.t line 227.
> > >
> > > # Failed test 'test if the string "tEST" is lower case'
> > > # at t/String.t line 228.
> > >
> > > # Failed test 'test if the string "test" is upper case'
> > > # at t/String.t line 233.
> > >
> > > # Failed test 'test if the string "tEST" is upper case'
> > > # at t/String.t line 235.
> >
> > It works for me on Mac OS X Mountain Lion. Is this a locale-related
> > issue?
>
>
> I've tested different locales with different Perl versions on multiple
> machines and it always works.
>
> for example is_upper() method is implemented as this:
>
> sub is_upper {
> my $self = shift;
> return $self->string eq $self->to_upper->string;
> }
>
> And to_upper() just uses the Perl function uc()
> (
http://perldoc.perl.org/functions/uc.html).
>
> Very simple code and I don't get why this fails some tests.
The is_upper and is_lower implementations look broken. to_upper and to_lower are *changing* $self, so after calling the is* methods the string will actually have the upper resp. lower value! Try the following:
#!perl
use strict;
use Test::More 'no_plan';
use Object::String;
my $s = str('UPPER');
is $s->string, 'UPPER';
$s->is_lower;
is $s->string, 'UPPER';
__END__