Skip to content
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

Wasm: update CrossSection.toPolygons() return value to match type #963

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

dsafa
Copy link
Contributor

@dsafa dsafa commented Sep 29, 2024

Closes #943

I used the existing support for a map callback in vec2polygons.

Also started with a simple test for bindings. I guess the hard part of writing the tests is trying to test the custom bindings and not emscripten or the c++ code.

Copy link

codecov bot commented Sep 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.76%. Comparing base (d437097) to head (72f7ad3).
Report is 111 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #963      +/-   ##
==========================================
- Coverage   91.84%   86.76%   -5.08%     
==========================================
  Files          37       61      +24     
  Lines        4976     8492    +3516     
  Branches        0     1044    +1044     
==========================================
+ Hits         4570     7368    +2798     
- Misses        406     1124     +718     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


suite('CrossSection Bindings', () => {
test('ToPolygons return correct shape', () => {
const polygons = manifoldModule.CrossSection.square().toPolygons();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, is the CI running this test yet? Our current JS tests are in the form of examples, but we could certainly use better coverage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the actions, seems like its running since vitest should should be running *.test.* files by default

@@ -190,7 +190,7 @@ Module.setup = function() {

Module.CrossSection.prototype.toPolygons = function() {
const vec = this._ToPolygons();
const result = vec2polygons(vec);
const result = vec2polygons(vec, v => [v.x, v.y]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to double-check, which API do we like better? The one we implemented or the one we documented? Because we could equally update the type instead of this.

Copy link
Contributor Author

@dsafa dsafa Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, since there is a static factory function called ofPolygons, I would assume that toPolygons would return the same type.

Copy link
Owner

@elalish elalish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks! Would you mind pulling master? We just had a huge refactor that changed the names of our CI runs - this should clear it up. Also, looks like you need to run clang-format.

@dsafa
Copy link
Contributor Author

dsafa commented Sep 30, 2024

Thanks, I keep forgetting to run format

@dsafa
Copy link
Contributor Author

dsafa commented Sep 30, 2024

Also this slipped my mind, but I guess this would count as a breaking change for the npm package? although its a ts bug fix, if someone was using this in js, it would break

@elalish
Copy link
Owner

elalish commented Sep 30, 2024

Yes, good timing, as we're stacking up breaking changes right now anyway for v3.0.

@elalish elalish merged commit 5a157a0 into elalish:master Sep 30, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

js bindings: CrossSection.toPolygons() return value doesn't match typescript type
2 participants