summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-25 19:00:30 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-25 19:00:30 +0000
commit908667e45a9cbbb954530f3c46e7a73a261d5a7d (patch)
treefbd5f733d33d3dfef393f1f1a9ee7a47338068b4
parentc36f4b164bdf47046804103a403bec800aceac88 (diff)
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
-rw-r--r--test/ruby/test_object.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index b06cdd15f1..8350fb2a94 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -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