-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS::Object inherits BasicObject #541
Changes from 2 commits
253e5d6
fcca293
ec73465
9e05673
a2aa724
11850aa
58e3853
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,18 @@ const test = async (instantiate) => { | |
|
||
await vm.evalAsync(` | ||
require 'test/unit' | ||
|
||
# Define the methods to be used for unit testing assertions. | ||
# Use refinements to limit the scope of influence. | ||
require 'pp' | ||
module JsObjectTestable | ||
refine JS::Object do | ||
[:object_id, :pretty_inspect].each do |method| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If those definitions are just for testing, it might be better to fix testing libraries in the long term. I just opened a test-unit fix for BasicObject support. test-unit/test-unit#262 But it's fine for now. Could you add FIXME comments mentioning the fix PR and potential future fix? |
||
define_method(method, ::Object.instance_method(method)) | ||
end | ||
end | ||
end | ||
|
||
require_relative '${rootTestFile}' | ||
ok = Test::Unit::AutoRunner.run | ||
exit(1) unless ok | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that JS objects unlikely define methods suffixed with
?
, it makes sense to me to definenil?
,is_a?
, andrespond_to?
for convenience and better compatibility with libraries without BasicObject support.One question, where do we use
raise
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, it seems that there is no need to consider collisions of methods suffixed with ?.
We raise an exception when the method call fails.
ruby.wasm/packages/gems/js/lib/js.rb
Lines 254 to 255 in 4c12c77