-
Notifications
You must be signed in to change notification settings - Fork 200
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
Equality (==
) does not work properly inflight
#4118
Comments
Found about this with @hasanaburayyan while doing some tests. |
@Chriscbr FYI |
It appears to be an issue with how Object.values and equality behave in a VM:
error:
|
I don't think it ever worked |
I updated the example in my code above -- it's quite interesting that In either case, I seems What if we compile |
@Chriscbr freaking dope catch, I did not think about testing this in a vm. I was pretty baffled at why the hell there was a difference. |
I think @Chriscbr's solution makes sense - we should implement our own equality logic instead of the current solution, which uses |
This is the first time I am writing tests, so admittedly my tests are not that versatile. But as I also believe that std tests should be straightforward, I do not totally mind it. Since `keys()` and `values()` methods of maps seems to return an array that fails to assert "is the same as another array of same elements" (which seems to be a [bug](#4118)), I had to iterate over the array values and confirm it works as expected. closes: #4363 ## Checklist - [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [ ] Description explains motivation and solution - [ ] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
It looks like the code shared in the original post works since we're executing preflight code inside of a worker thread - but the assertion still fails for inflight code: test "inflight" {
let j = Json { hello: 123, world: [1, 2, 3] };
assert(Json.values(j) == [Json 123, Json [1, 2, 3]]);
} I've updated the issue title to reflect this. |
==
) does not work properly inflight
See #4725, which I think would be an ideal solution for this issue |
Congrats! 🚀 This was released in Wing 0.59.43. |
I tried this:
app.w
I run this command:
wing test app.w
This happened:
The preflight code assertion passes, but the inflight assertion fails:
I expected this:
I expected Wing assertion to work, because the compiled JS code doesn't throw any error when pasted into Node.js REPL.
preflight.js
Is there a workaround?
No response
Component
Compiler
Wing Version
No response
Node.js Version
No response
Platform(s)
No response
Anything else?
No response
Community Notes
The text was updated successfully, but these errors were encountered: