Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add spec for rb_make_backtrace

  • Loading branch information...
commit 257d6499e617374d1c64fb8a0217c5fb9fee1845 1 parent 7569ff3
@dbussink dbussink authored
View
11 spec/ruby/optional/capi/ext/kernel_spec.c
@@ -254,6 +254,12 @@ static VALUE kernel_spec_rb_f_sprintf(VALUE self, VALUE ary) {
}
#endif
+#ifdef HAVE_RB_MAKE_BACKTRACE
+static VALUE kernel_spec_rb_make_backtrace(VALUE self) {
+ return rb_make_backtrace();
+}
+#endif
+
void Init_kernel_spec() {
VALUE cls;
cls = rb_define_class("CApiKernelSpecs", rb_cObject);
@@ -345,6 +351,11 @@ void Init_kernel_spec() {
#ifdef HAVE_RB_F_SPRINTF
rb_define_method(cls, "rb_f_sprintf", kernel_spec_rb_f_sprintf, 1);
#endif
+
+#ifdef HAVE_RB_MAKE_BACKTRACE
+ rb_define_method(cls, "rb_make_backtrace", kernel_spec_rb_make_backtrace, 0);
+#endif
+
}
#ifdef __cplusplus
View
1  spec/ruby/optional/capi/ext/rubyspec.h
@@ -312,6 +312,7 @@
#ifdef RUBY_VERSION_IS_1_9
#define HAVE_RB_THROW_OBJ 1
#define HAVE_RB_CATCH_OBJ 1
+#define HAVE_RB_MAKE_BACKTRACE 1
#endif
#define HAVE_RB_WARN 1
#define HAVE_RB_YIELD 1
View
10 spec/ruby/optional/capi/kernel_spec.rb
@@ -404,4 +404,14 @@
@s.rb_f_sprintf(["%d %f %s", 10, 2.5, "test"]).should == "10 2.500000 test"
end
end
+
+ ruby_version_is "1.9" do
+ describe "rb_make_backtrace" do
+ it "returns a caller backtrace" do
+ backtrace = @s.rb_make_backtrace
+ lines = backtrace.select {|l| l =~ /#{__FILE__}/ }
+ lines.should_not be_empty
+ end
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.