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

This commit is contained in:
Yukihiro "Matz" Matsumoto
2013-12-26 17:42:41 +09:00
2 changed files with 35 additions and 0 deletions
+1
View File
@@ -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;
+34
View File
@@ -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