Created
July 9, 2010 23:23
-
-
Save pcapriotti/470239 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 1bdd22b0a38aafe5ec7c3f58d2460fa390163a2f Mon Sep 17 00:00:00 2001 | |
From: Paolo Capriotti <p.capriotti@gmail.com> | |
Date: Sat, 10 Jul 2010 00:22:24 +0100 | |
Subject: [PATCH 1/2] New spec: rb_class2name should accept a Module argument. | |
--- | |
spec/ruby/optional/capi/ext/module_spec.c | 10 ++++++++++ | |
spec/ruby/optional/capi/module_spec.rb | 6 ++++++ | |
2 files changed, 16 insertions(+), 0 deletions(-) | |
diff --git a/spec/ruby/optional/capi/ext/module_spec.c b/spec/ruby/optional/capi/ext/module_spec.c | |
index 284bffc..09beeda 100644 | |
--- a/spec/ruby/optional/capi/ext/module_spec.c | |
+++ b/spec/ruby/optional/capi/ext/module_spec.c | |
@@ -132,6 +132,12 @@ static VALUE module_specs_rb_undef_method(VALUE self, VALUE cls, VALUE str_name) | |
} | |
#endif | |
+#ifdef HAVE_RB_CLASS2NAME | |
+static VALUE module_specs_rbclass2name(VALUE self, VALUE klass) { | |
+ return rb_str_new2(rb_class2name(klass)); | |
+} | |
+#endif | |
+ | |
void Init_module_spec() { | |
VALUE cls; | |
@@ -213,6 +219,10 @@ void Init_module_spec() { | |
#ifdef HAVE_RB_UNDEF_METHOD | |
rb_define_method(cls, "rb_undef_method", module_specs_rb_undef_method, 2); | |
#endif | |
+ | |
+#ifdef HAVE_RB_CLASS2NAME | |
+ rb_define_method(cls, "rb_class2name", module_specs_rbclass2name, 1); | |
+#endif | |
} | |
#ifdef __cplusplus | |
diff --git a/spec/ruby/optional/capi/module_spec.rb b/spec/ruby/optional/capi/module_spec.rb | |
index 7c6a5f3..7c1b73e 100644 | |
--- a/spec/ruby/optional/capi/module_spec.rb | |
+++ b/spec/ruby/optional/capi/module_spec.rb | |
@@ -276,4 +276,10 @@ describe "CApiModule" do | |
cls.should_not have_instance_method(:ruby_test_method) | |
end | |
end | |
+ | |
+ describe "rb_class2name" do | |
+ it "returns the module name" do | |
+ @m.rb_class2name(CApiModuleSpecs::M).should == "CApiModuleSpecs::M" | |
+ end | |
+ end | |
end | |
-- | |
1.7.0.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment