Commit 2ec67c65 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge branch 'singletonfix' of https://github.com/carsonmcdonald/mruby into...

Merge branch 'singletonfix' of https://github.com/carsonmcdonald/mruby into carsonmcdonald-singletonfix
parents b72f3f92 a89cba9f
......@@ -2331,6 +2331,7 @@ codegen(codegen_scope *s, node *tree, int val)
genop(s, MKOP_ABx(OP_EXEC, cursp(), idx));
if (val) {
push();
push();
}
}
break;
......
......@@ -258,3 +258,37 @@ assert('Class#inherited') do
assert_equal(Baz, Foo.subclass_name)
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