aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-01 07:50:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-01 07:50:53 +0000
commitdc460944bb483b45908ab028fa64467113a45ddc (patch)
treea52f0e7e2806d023f52a05d7e35032dc04eed1b2 /test
parent430d3bd6e0cc4a2fd0616c1a2a11e371248d0737 (diff)
downloadruby-dc460944bb483b45908ab028fa64467113a45ddc.tar.gz
object.c: Kernel#yield_self
* object.c (rb_obj_yield_self): new method which yields the receiver and returns the result. [ruby-core:46320] [Feature #6721] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_object.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index d93d5594a7..6a1a82546a 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -18,6 +18,14 @@ class TestObject < Test::Unit::TestCase
assert_same(object, object.itself, feature6373)
end
+ def test_yield_self
+ feature = '[ruby-core:46320] [Feature #6721]'
+ object = Object.new
+ assert_same(self, object.yield_self {self}, feature)
+ assert_same(object, object.yield_self {|x| break x}, feature)
+ assert_instance_of(Enumerator, object.yield_self)
+ end
+
def test_dup
assert_equal 1, 1.dup
assert_equal true, true.dup