Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Handle primitives (CBODY in MRI) in #source_location.

In general, returning nil seems better than a bug exception for
unexpected NODE types.
  • Loading branch information...
commit 57e05186249761d32f3ad6bc6f88d7b3d3106678 1 parent 9bf2789
@oggy authored
Showing with 7 additions and 2 deletions.
  1. +1 −1  ext/mri/mri.c
  2. +6 −1 spec/adapter_spec.rb
View
2  ext/mri/mri.c
@@ -236,7 +236,7 @@ VALUE Looksee_source_location(VALUE self, VALUE unbound_method) {
}
break;
default:
- rb_raise(rb_eRuntimeError, "[LOOKSEE BUG] unexpected NODE type: %d", nd_type(method->body));
+ return Qnil;
}
VALUE file = rb_str_new2(node->nd_file);
VALUE line = INT2NUM(nd_line(node));
View
7 spec/adapter_spec.rb
@@ -439,7 +439,7 @@ def load_source(source)
end
after do
- FileUtils.rm_rf @tmp
+ FileUtils.rm_rf @tmp if @tmp
Object.send(:remove_const, :C) if Object.const_defined?(:C)
end
@@ -531,6 +531,11 @@ def load_source(source)
@adapter.source_location(method).should == [path, 2]
end
+ it "should return nil for primitive methods (MRI CBODY)" do
+ method = Object.instance_method(:__id__)
+ @adapter.source_location(method).should == nil
+ end
+
it "should raise a TypeError if the argument is not an UnboundMethod" do
path = load_source <<-EOS.demargin
|class C

0 comments on commit 57e0518

Please sign in to comment.
Something went wrong with that request. Please try again.