Skip to content

Commit e8c20dd

Browse files
committedApr 29, 2015
Module#instance_methods fully compliant with rubyspec
1 parent 7c5c89e commit e8c20dd

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed
 

‎opal/corelib/module.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -358,17 +358,17 @@ def instance_method(name)
358358
}
359359
end
360360

361-
def instance_methods(include_super = false)
361+
def instance_methods(include_super = true)
362362
%x{
363363
var methods = [],
364364
proto = self.$$proto;
365365
366366
for (var prop in proto) {
367-
if (!prop.charAt(0) === '$') {
367+
if (!(prop.charAt(0) === '$')) {
368368
continue;
369369
}
370370
371-
if (typeof(proto[prop]) !== "function") {
371+
if (!(typeof(proto[prop]) === "function")) {
372372
continue;
373373
}
374374

‎spec/filters/unsupported/private_methods.rb

+2
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@
4747
fails "Kernel#format is a private method"
4848
fails "Kernel#sprintf is a private method"
4949
fails "Kernel#warn is a private method"
50+
51+
fails "Module#instance_methods makes a private Object instance method public in Kernel"
5052
end

‎spec/opal/core/runtime/bridged_classes_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ def some_bridged_method
4949

5050
describe ".instance_methdods" do
5151
it "should report methods for class" do
52-
Array.instance_methods.should include(:shift)
52+
Array.instance_methods(false).should include(:shift)
5353
end
5454

5555
it "should not include methods donated from Object/Kernel" do
56-
Array.instance_methods.should_not include(:class)
56+
Array.instance_methods(false).should_not include(:class)
5757
end
5858

5959
it "should not include methods donated from BasicObject" do
60-
Array.instance_methods.should_not include(:__send__)
61-
Array.instance_methods.should_not include(:send)
60+
Array.instance_methods(false).should_not include(:__send__)
61+
Array.instance_methods(false).should_not include(:send)
6262
end
6363
end
6464
end

‎spec/rubyspecs

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ corelib/core/module/class_variable_set_spec
8282
corelib/core/module/module_function_spec
8383
corelib/core/module/const_get_spec
8484
corelib/core/module/include_spec
85+
corelib/core/module/instance_methods_spec
8586

8687
corelib/core/range/begin_spec
8788
corelib/core/range/case_compare_spec

0 commit comments

Comments
 (0)
Please sign in to comment.