mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fix AS::MB::Chars#+ to not alter self [#4646 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
committed by
José Valim
parent
13a3690271
commit
16cef77d37
@@ -105,7 +105,7 @@ module ActiveSupport #:nodoc:
|
||||
# Example:
|
||||
# ('Café'.mb_chars + ' périferôl').to_s #=> "Café périferôl"
|
||||
def +(other)
|
||||
self << other
|
||||
chars(@wrapped_string + other)
|
||||
end
|
||||
|
||||
# Like <tt>String#=~</tt> only it returns the character offset (in codepoints) instead of the byte offset.
|
||||
|
||||
@@ -49,13 +49,15 @@ class MultibyteCharsTest < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_should_concatenate
|
||||
assert_equal 'ab', 'a'.mb_chars + 'b'
|
||||
assert_equal 'ab', 'a' + 'b'.mb_chars
|
||||
assert_equal 'ab', 'a'.mb_chars + 'b'.mb_chars
|
||||
mb_a = 'a'.mb_chars
|
||||
mb_b = 'b'.mb_chars
|
||||
assert_equal 'ab', mb_a + 'b'
|
||||
assert_equal 'ab', 'a' + mb_b
|
||||
assert_equal 'ab', mb_a + mb_b
|
||||
|
||||
assert_equal 'ab', 'a'.mb_chars << 'b'
|
||||
assert_equal 'ab', 'a' << 'b'.mb_chars
|
||||
assert_equal 'ab', 'a'.mb_chars << 'b'.mb_chars
|
||||
assert_equal 'ab', mb_a << 'b'
|
||||
assert_equal 'ab', 'a' << mb_b
|
||||
assert_equal 'abb', mb_a << mb_b
|
||||
end
|
||||
|
||||
def test_consumes_utf8_strings
|
||||
|
||||
Reference in New Issue
Block a user