diff --git a/spec/core/kernel/add_method_spec.rb b/spec/core/kernel/add_method_spec.rb
new file mode 100644
index 0000000..aba9cec
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Kernel#__add_method__" do
+ it "adds a CompiledMethod to a class or module" do
+ KernelSpecs::D.new.a
+ KernelSpecs::D.new.c.should == :added
+ end
+
+ it "sets the staticscope of the CompiledMethod to the enclosing class or module" do
+ KernelSpecs::D.new.a
+ KernelSpecs::D.method_table[:c][1].staticscope.module.should == KernelSpecs::D
+ end
+end
diff --git a/spec/core/kernel/fixtures/classes.rb b/spec/core/kernel/fixtures/classes.rb
index ac25edb..12d1665 100644
@@ -12,4 +12,11 @@ module KernelSpecs
"zam"
end
end
+
+ class D
+ def a
+ m = def b; :added; end
+ __add_method__ :c, m
+ end
+ end
end
diff --git a/spec/core/module/add_method_spec.rb b/spec/core/module/add_method_spec.rb
new file mode 100644
index 0000000..0a9cd25
@@ -0,0 +1,13 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Module.__add_method__" do
+ it "adds a CompiledMethod to a class or module" do
+ ModuleSpecs::A.a.should == :added
+ ModuleSpecs::B.new.b.should == :added
+ end
+
+ it "sets the staticscope of the CompiledMethod to the enclosing class or module" do
+ ModuleSpecs::A.method_table[:b][1].staticscope.module.should == ModuleSpecs::A
+ end
+end
diff --git a/spec/core/module/fixtures/classes.rb b/spec/core/module/fixtures/classes.rb
index 7b11f90..1f8d700 100644
@@ -5,4 +5,16 @@ module ModuleSpecs
@special = 10
end
end
+
+ module A
+ m = def self.a
+ :added
+ end
+
+ __add_method__ :b, m
+ end
+
+ class B
+ include A
+ end
end