Skip to content

Commit

Permalink
Fix bug so instance_methods of bridged classes acts correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 20, 2013
1 parent e3a33d1 commit e5103ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions corelib/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ def instance_methods(include_super = false)
continue;
}
if (!include_super && proto[prop]._donated) {
continue;
}
if (prop.charAt(0) === '$') {
methods.push(prop.substr(1));
}
Expand Down
1 change: 1 addition & 0 deletions corelib/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@
for (var j = 0, jj = defined.length; j < jj; j++) {
var method = defined[j];
dest[method] = klass._proto[method];
dest[method]._donated = true;
}

if (includee.__dep__) {
Expand Down
18 changes: 18 additions & 0 deletions spec/opal/runtime/bridged_classes_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'spec_helper'

describe "Bridged Classes" do
describe ".instance_methdods" do
it "should report methods for class" do
Array.instance_methods.should include(:shift)
end

it "should not include methods donated from Object/Kernel" do
Array.instance_methods.should_not include(:class)
end

it "should not include methods donated from BasicObject" do
Array.instance_methods.should_not include(:__send__)
Array.instance_methods.should_not include(:send)
end
end
end

0 comments on commit e5103ad

Please sign in to comment.