Skip to content

Commit

Permalink
Allow passing non-Opal objects to Opal.is_a (#1839)
Browse files Browse the repository at this point in the history
  • Loading branch information
janbiedermann authored and iliabylich committed Jun 5, 2018
1 parent 9e5e9ba commit 8cdbc41
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions opal/corelib/runtime.js
Expand Up @@ -1177,6 +1177,8 @@

// The Array of ancestors for a given module/class
Opal.ancestors = function(module) {
if (!module) { return []; }

if (module.$$ancestors_cache_version === Opal.const_cache_version) {
return module.$$ancestors;
}
Expand Down
4 changes: 4 additions & 0 deletions spec/opal/core/runtime/is_a_spec.rb
Expand Up @@ -31,5 +31,9 @@
`!!#{Integer}.$$is_number_class`.should == true
`!!#{Float}.$$is_number_class`.should == true
end

it 'works for non-Opal objects' do
`Opal.is_a({}, Opal.Array)`.should == false
end
end
end

0 comments on commit 8cdbc41

Please sign in to comment.