Commit 66747603 authored by Carson McDonald's avatar Carson McDonald

Add more testing for singletons

parent c70e2f70
...@@ -258,3 +258,37 @@ assert('Class#inherited') do ...@@ -258,3 +258,37 @@ assert('Class#inherited') do
assert_equal(Baz, Foo.subclass_name) assert_equal(Baz, Foo.subclass_name)
end end
assert('singleton tests') do
bar = String.new
baz = class << bar
def self.run_baz
200
end
end
assert_false baz.singleton_methods.include? :run_baz
assert_raise(NoMethodError, 'should raise NoMethodError') do
baz.run_baz
end
assert_raise(NoMethodError, 'should raise NoMethodError') do
bar.run_baz
end
baz = class << bar
def self.run_baz
300
end
self
end
assert_true baz.singleton_methods.include? :run_baz
assert_equal 300, baz.run_baz
assert_raise(NoMethodError, 'should raise NoMethodError') do
bar.run_baz
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment