diff options
Diffstat (limited to 'test/ruby/test_string.rb')
-rw-r--r-- | test/ruby/test_string.rb | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 9cc193ce41..47f349cc18 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -659,6 +659,15 @@ class TestString < Test::Unit::TestCase assert(!S("not").empty?) end + def test_end_with? + assert_send([S("hello"), :end_with?, S("llo")]) + assert_not_send([S("hello"), :end_with?, S("ll")]) + assert_send([S("hello"), :end_with?, S("el"), S("lo")]) + + bug5536 = '[ruby-core:40623]' + assert_raise(TypeError, bug5536) {S("str").end_with? :not_convertible_to_string} + end + def test_eql? a = S("hello") assert(a.eql?(S("hello"))) @@ -1207,6 +1216,15 @@ class TestString < Test::Unit::TestCase assert_nil(a.squeeze!) end + def test_start_with? + assert_send([S("hello"), :start_with?, S("hel")]) + assert_not_send([S("hello"), :start_with?, S("el")]) + assert_send([S("hello"), :start_with?, S("el"), S("he")]) + + bug5536 = '[ruby-core:40623]' + assert_raise(TypeError, bug5536) {S("str").start_with? :not_convertible_to_string} + end + def test_strip assert_equal(S("x"), S(" x ").strip) assert_equal(S("x"), S(" \n\r\t x \t\r\n\n ").strip) @@ -1774,10 +1792,6 @@ class TestString < Test::Unit::TestCase assert_nil(l.slice!(/\A.*\n/), "[ruby-dev:31665]") end - def test_end_with? - assert("abc".end_with?("c")) - end - def test_times2 s1 = '' 100.times {|n| |