-
Notifications
You must be signed in to change notification settings - Fork 28
#3180. Add tests for NullableUndefineableJSAnyExtension. #3205
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
base: master
Are you sure you want to change the base?
Conversation
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.
LGTM.
@srujzs, it would be great if you could take a look at this as well!
|
||
Expect.isTrue(globalContext["n"].isNull); | ||
Expect.isFalse(42.toJS.isNull); | ||
Expect.isFalse(globalContext["u"].isNull); |
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.
This is the most interesting case. I don't know whether or not isNull
should see any difference between null
and undefined
.
The documentation says
Currently, there is no way to distinguish between JavaScript
undefined
and JavaScriptnull
when compiling to Wasm. Therefore, this getter
should only be used for code that compiles to JavaScript and will throw
when compiling to Wasm.
.. so there may be a need to treat compilation to Wasm and compilation to JS differently.
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.
Thanks for the cc, Erik! And thanks for adding tests, Sergey!
Yes, when compiling to Wasm, we're forced to convert to Wasm's null ref regardless of whether the JS value is undefined
or null
in order to maintain the same nullability semantics for interop across all compilers, so there's no way of distinguishing.
In some future, we may provide an opt-in annotation users to preserve undefined
separately, but that doesn't exist yet.
So, both isNull
and isUndefined
need to be handled differently based on the platforms.
var s = "s"; | ||
'''); | ||
|
||
Expect.isFalse(globalContext["n"].isUndefined); |
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.
This would again rely on the ability for Dart code to see a difference between JS null
and JS undefined
. Similarly for line 27.
Yes, we use status files for these purposes. But in this particular case I think that it's simpler to use |
OK. I'm just wondering, if this test is executed on any platform where the generated code isn't JavaScript, presumably the |
|
After rereading the docs... @srujzs is using of |
It's a runtime-error (you specifically get an |
Thank you. I thought that it throws on |
No description provided.