diff options
author | George Ogata <george.ogata@gmail.com> | 2008-12-30 14:16:15 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-03-07 22:41:11 +0000 |
commit | 74387884819e8b6e16c3f67388610b8d1192cb4d (patch) | |
tree | 4bb0d6e6457ef628737f0674b516bd8071309ae7 /activesupport/test/multibyte_chars_test.rb | |
parent | ea8488caef77cb8cf2031d344e74981ab6ea0e57 (diff) | |
download | rails-74387884819e8b6e16c3f67388610b8d1192cb4d.tar.gz rails-74387884819e8b6e16c3f67388610b8d1192cb4d.tar.bz2 rails-74387884819e8b6e16c3f67388610b8d1192cb4d.zip |
Make Chars#slice! behave more like String#slice! [#1243 state:resolved]
- Chars#slice! now returns the slice instead of itself
- Chars#slice! now removes the slice from itself
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activesupport/test/multibyte_chars_test.rb')
-rw-r--r-- | activesupport/test/multibyte_chars_test.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb index 067c461837..0644dbe603 100644 --- a/activesupport/test/multibyte_chars_test.rb +++ b/activesupport/test/multibyte_chars_test.rb @@ -123,7 +123,6 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase [:rstrip!, :lstrip!, :strip!, :reverse!, :upcase!, :downcase!, :capitalize!].each do |method| assert_equal @chars.object_id, @chars.send(method).object_id end - assert_equal @chars.object_id, @chars.slice!(1).object_id end def test_overridden_bang_methods_change_wrapped_string @@ -133,10 +132,6 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase proxy.send(method) assert_not_equal original, proxy.to_s end - proxy = chars('Café') - proxy.slice!(3) - assert_equal 'é', proxy.to_s - proxy = chars('òu') proxy.capitalize! assert_equal 'Òu', proxy.to_s @@ -391,6 +386,15 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase assert_equal nil, @chars.slice(7..6) end + def test_slice_bang_returns_sliced_out_substring + assert_equal 'にち', @chars.slice!(1..2) + end + + def test_slice_bang_removes_the_slice_from_the_receiver + @chars.slice!(1..2) + assert_equal 'こわ', @chars + end + def test_slice_should_throw_exceptions_on_invalid_arguments assert_raise(TypeError) { @chars.slice(2..3, 1) } assert_raise(TypeError) { @chars.slice(1, 2..3) } |