Permalink
Browse files

Make the utf-handler return the correct value for non-matching regula…

…r expressions. Closes #9049 [manfred]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7273 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent fe3e03e commit 73f72eeec2d0cc689735f52de4a5c3c80c4c1e85 @NZKoz NZKoz committed Aug 5, 2007
View
@@ -1,5 +1,7 @@
*SVN*
+* Make the utf-handler return the correct value for non-matching regular expressions. Closes #9049 [manfred]
+
* Add ljust, rjust and center to utf8-handler. Closes #9165 [manfred]
* Fix Time#advance bug when trying to advance a year from leap day. Closes #8655 [gbuesing]
@@ -316,8 +316,8 @@ def compose(str)
# Used to translate an offset from bytes to characters, for instance one received from a regular expression match
def translate_offset(str, byte_offset)
- return 0 if str == ''
return nil if byte_offset.nil?
+ return 0 if str == ''
chunk = str[0..byte_offset]
begin
begin
@@ -81,6 +81,8 @@ def test_regexp
with_kcode('UTF8') do
assert_equal 9, (@s[:utf8].chars =~ /ffi/),
"Regex matching should be unicode aware"
+ assert_nil((''.chars =~ /\d+/),
+ "Non-matching regular expressions should return nil")
end
end
@@ -118,7 +120,7 @@ def test_method_chaining
def test_passthrough_on_kcode
# The easiest way to check if the passthrough is in place is through #size
- with_kcode('nonce') do
+ with_kcode('none') do
assert_equal 26, @s[:utf8].chars.size
end
with_kcode('UTF8') do

0 comments on commit 73f72ee

Please sign in to comment.