summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-26 07:05:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-26 07:05:42 +0000
commit2102e6443a357117e6a730ef12e0c2ea35749881 (patch)
treeb12c38858055e56cb060d291be249ed9b5865f6b /test
parent990e3e6d9abe0f9d10be04dc5b724ece86a7a76a (diff)
* string.c (rb_str_partition, rb_str_rpartition)
(rb_str_start_with, rb_str_end_with): preserve the last match data. [ruby-core:39671] [Bug #5351] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@33527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_string.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 7510bb9cb7..073aecd6f8 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -237,4 +237,26 @@ class TestString < Test::Unit::TestCase
assert_equal("", result[5])
assert_equal("", result[6])
end
+
+ def test_start_with
+ assert_equal(true, "abc".start_with?("a"))
+ assert_equal(false, "abc".start_with?("A"))
+ /\w/ =~ "xyz"
+ "abc".start_with?("a")
+ assert_equal("x", $&)
+ /\w/ =~ ""
+ "abc".start_with?("a")
+ assert_nil($&)
+ end
+
+ def test_end_with
+ assert_equal(true, "abc".end_with?("c"))
+ assert_equal(false, "abc".end_with?("C"))
+ /\w/ =~ "xyz"
+ "abc".end_with?("c")
+ assert_equal("x", $&)
+ /\w/ =~ ""
+ "abc".end_with?("c")
+ assert_nil($&)
+ end
end