aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-10-15 07:38:52 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-10-15 07:38:52 +0000
commit656a20a4d3d2a18b0752fda1110b4d6569528bf2 (patch)
treead3d74de585659e0293ca741c1fdab8b6ab2861b /activesupport/test
parent660a696a3f5f20ccd12faaf5a989b1ace34c447b (diff)
downloadrails-656a20a4d3d2a18b0752fda1110b4d6569528bf2.tar.gz
rails-656a20a4d3d2a18b0752fda1110b4d6569528bf2.tar.bz2
rails-656a20a4d3d2a18b0752fda1110b4d6569528bf2.zip
Multibyte: String#slice supports regexp argument. Closes #9646.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7910 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/multibyte_handler_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/test/multibyte_handler_test.rb b/activesupport/test/multibyte_handler_test.rb
index 174d7b790d..77b125641d 100644
--- a/activesupport/test/multibyte_handler_test.rb
+++ b/activesupport/test/multibyte_handler_test.rb
@@ -160,6 +160,11 @@ module UTF8HandlingTest
assert_equal "d Блå ffi", @handler.slice(@string, 3, 7), "Unicode characters have to be returned"
assert_equal "A", @handler.slice(@string, 0, 1), "Slicing from an offset should return characters"
assert_equal " Блå ffi ", @handler.slice(@string, 4..10), "Unicode characters have to be returned"
+ assert_equal "ffi бла", @handler.slice(@string, /ffi бла/u), "Slicing on Regexps should be supported"
+ assert_equal "ffi бла", @handler.slice(@string, /ffi \w\wа/u), "Slicing on Regexps should be supported"
+ assert_equal nil, @handler.slice(@string, /unknown/u), "Slicing on Regexps with no match should return nil"
+ assert_equal "ffi бла", @handler.slice(@string, /(ffi бла)/u,1), "Slicing on Regexps with a match group should be supported"
+ assert_equal nil, @handler.slice(@string, /(ffi)/u,2), "Slicing with a Regexp and asking for an invalid match group should return nil"
assert_equal "", @handler.slice(@string, 7..6), "Range is empty, should return an empty string"
assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.slice(@bytestring, 2..3) }
assert_raise(TypeError, "With 2 args, should raise TypeError for non-Numeric or Regexp first argument") { @handler.slice(@string, 2..3, 1) }