summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2019-11-17 23:24:59 +0900
committerNARUSE, Yui <naruse@airemix.jp>2019-11-28 23:49:28 +0900
commitb5fbefbf2c14742f6d46ecdf3ce712062dfb1d0a (patch)
treed5367d0c20d2323ac8d030ded69efba7e6e76b8b /test
parent76871dea6b05ee441f25c6f694ac21525ed25f93 (diff)
Added Symbol#start_with? and Symbol#end_with? method. [Feature #16348]
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_symbol.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index c47cadf4bb..75335f180d 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -560,4 +560,27 @@ class TestSymbol < Test::Unit::TestCase
puts :a == :a
RUBY
end
+
+ def test_start_with?
+ assert_equal(true, :hello.start_with?("hel"))
+ assert_equal(false, :hello.start_with?("el"))
+ assert_equal(true, :hello.start_with?("el", "he"))
+
+ bug5536 = '[ruby-core:40623]'
+ assert_raise(TypeError, bug5536) {:str.start_with? :not_convertible_to_string}
+
+ assert_equal(true, :hello.start_with?(/hel/))
+ assert_equal("hel", $&)
+ assert_equal(false, :hello.start_with?(/el/))
+ assert_nil($&)
+ end
+
+ def test_end_with?
+ assert_equal(true, :hello.end_with?("llo"))
+ assert_equal(false, :hello.end_with?("ll"))
+ assert_equal(true, :hello.end_with?("el", "lo"))
+
+ bug5536 = '[ruby-core:40623]'
+ assert_raise(TypeError, bug5536) {:str.end_with? :not_convertible_to_string}
+ end
end