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:
parent
13a3690271
commit
16cef77d37
@ -105,7 +105,7 @@ def self.wants?(string)
|
||||
# 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 @@ def test_forwarded_method_with_non_string_result_should_be_returned_vertabim
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user