mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add AS::Multibyte::Chars#match?
This commit is contained in:
parent
d55dea5ef1
commit
381e8cb67a
2 changed files with 7 additions and 1 deletions
|
@ -48,7 +48,7 @@ module ActiveSupport #:nodoc:
|
|||
alias to_s wrapped_string
|
||||
alias to_str wrapped_string
|
||||
|
||||
delegate :<=>, :=~, :acts_like_string?, to: :wrapped_string
|
||||
delegate :<=>, :=~, :match?, :acts_like_string?, to: :wrapped_string
|
||||
|
||||
# Creates a new Chars instance by wrapping _string_.
|
||||
def initialize(string)
|
||||
|
|
|
@ -204,6 +204,12 @@ class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase
|
|||
assert_equal 3, (@chars =~ /わ/u)
|
||||
end
|
||||
|
||||
def test_match_should_return_boolean_for_regexp_match
|
||||
assert_not @chars.match?(/wrong/u)
|
||||
assert @chars.match?(/こに/u)
|
||||
assert @chars.match?(/ち/u)
|
||||
end
|
||||
|
||||
def test_should_use_character_offsets_for_insert_offsets
|
||||
assert_equal "", (+"").mb_chars.insert(0, "")
|
||||
assert_equal "こわにちわ", @chars.insert(1, "わ")
|
||||
|
|
Loading…
Reference in a new issue