1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add tests for Kernel#singleton_class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2010-03-25 19:00:30 +00:00
parent c36f4b164b
commit 908667e45a

View file

@ -373,4 +373,25 @@ class TestObject < Test::Unit::TestCase
end
end.call
end
def test_singleton_class
x = Object.new
xs = class << x; self; end
assert_equal(xs, x.singleton_class)
y = Object.new
ys = y.singleton_class
assert_equal(class << y; self; end, ys)
assert_equal(NilClass, nil.singleton_class)
assert_equal(TrueClass, true.singleton_class)
assert_equal(FalseClass, false.singleton_class)
assert_raise(TypeError) do
123.singleton_class
end
assert_raise(TypeError) do
:foo.singleton_class
end
end
end