Also see Moose::Manual::Delta for more details of, and workarounds
for, noteworthy changes.
+NEXT
+
+ [BUG FIXES]
+
+ * A number of native trait methods which expected strings as arguments did
+ not allow the empty string. This included Array->join, String->match,
+ String->replace, and String->substr. Reported by Whitney Jackson. RT
+ #61961. (Dave Rolsky)
+
+
1.15 Tue, Oct 5, 2010
[API CHANGES]
return $self->_inline_throw_error(
q{'The first argument passed to replace must be a string or regexp reference'}
)
- . q{ unless Moose::Util::_STRINGLIKE( $_[0] ) || Params::Util::_REGEX( $_[0] );}
+ . q{ unless Moose::Util::_STRINGLIKE0( $_[0] ) || Params::Util::_REGEX( $_[0] );}
. $self->_inline_throw_error(
q{'The second argument passed to replace must be a string or code reference'}
- ) . q{ unless Moose::Util::_STRINGLIKE( $_[1] ) || Params::Util::_CODELIKE( $_[1] );};
+ ) . q{ unless Moose::Util::_STRINGLIKE0( $_[1] ) || Params::Util::_CODELIKE( $_[1] );};
}
sub _potential_value {
'substitution using string as replacement'
);
+ $obj->_string('foo');
+ $obj->replace( qr/oo/, q{} );
+
+ is( $obj->_string, 'f',
+ 'replace accepts an empty string as second argument' );
+
+ $obj->replace( q{}, 'a' );
+
+ is( $obj->_string, 'af',
+ 'replace accepts an empty string as first argument' );
+
throws_ok { $obj->replace( {}, 'x' ) }
qr/The first argument passed to replace must be a string or regexp reference/,
'replace throws an error when the first argument is not a string or regexp';
'match -barx against /[aq]/ returns matches'
);
+ is_deeply(
+ [ $obj->match(qr/([az]).*([fy])/) ], [ 'a', 'f' ],
+ 'match -barx against /[aq]/ returns matches'
+ );
+
ok(
scalar $obj->match('b'),
'match with string as argument returns true'
);
+ ok(
+ scalar $obj->match(q{}),
+ 'match with empty string as argument returns true'
+ );
+
throws_ok { $obj->match }
qr/Cannot call match without at least 1 argument/,
'match throws an error when no arguments are passed';
'substr as setter with three arguments'
);
+ $obj->substr( 1, 3, '' );
+
+ is(
+ $obj->_string, 's long string',
+ 'substr as setter with three arguments, replacment is empty string'
+ );
+
throws_ok { $obj->substr }
qr/Cannot call substr without at least 1 argument/,
'substr throws an error when no argumemts are passed';