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

Make test params readonly so they can't be accidentally permanently modified #3097

Merged
merged 7 commits into from
Oct 26, 2023

Conversation

kainino0x
Copy link
Collaborator

@kainino0x kainino0x commented Oct 25, 2023

This should hopefully categorically prevent bugs like the one fixed in #3096.

Verified this only has the expected changes on the generated JS by comparing the build out directory.

git checkout main
npm run standalone
npx prettier --write out/**/*.js
git add -f out/**/*.js
git checkout readonly-params
npm run standalone
npx prettier --write out/**/*>js
git diff > readonly-params.diff

https://gist.github.com/kainino0x/2851c43552987738ef2e9125389eb092
Only the unittests changed, and of course they pass (they're checked on presubmit).

Issue: None


Requirements for PR author:

  • All missing test coverage is tracked with "TODO" or .unimplemented().
  • New helpers are /** documented */ and new helper files are found in helper_index.txt.
  • Test behaves as expected in a WebGPU implementation. (If not passing, explain above.)

Requirements for reviewer sign-off:

  • Tests are properly located in the test tree.
  • Test descriptions allow a reader to "read only the test plans and evaluate coverage completeness", and accurately reflect the test code.
  • Tests provide complete coverage (including validation control cases). Missing coverage MUST be covered by TODOs.
  • Helpers and types promote readability and maintainability.

When landing this PR, be sure to make any necessary issue status updates.

This should hopefully categorically prevent bugs like the one fixed in
gpuweb#3096
@github-actions
Copy link

Previews, as seen when this build job started (d6be35d):
Run tests | View tsdoc

@github-actions
Copy link

Previews, as seen when this build job started (fd23313):
Run tests | View tsdoc

@kainino0x kainino0x requested a review from lokokung October 26, 2023 00:14
@kainino0x kainino0x marked this pull request as ready for review October 26, 2023 00:14
@github-actions
Copy link

Previews, as seen when this build job started (3b67a77):
Run tests | View tsdoc

Copy link
Contributor

@lokokung lokokung left a comment

Choose a reason for hiding this comment

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

Ah... the typing for the tuples is rather nasty lol... The nested arrays is also not the prettiest... Otherwise seems fine. Just out of curiosity, if we pass a super large tuple or quadruply nested array, does it just give a compile error? Or will it do something else?

src/unittests/floating_point.spec.ts Show resolved Hide resolved
@kainino0x
Copy link
Collaborator Author

Just out of curiosity, if we pass a super large tuple or quadruply nested array, does it just give a compile error? Or will it do something else?

Nested array should be fine, as it's recursive. If we pass a tuple larger than 7, it will coerce to an array, e.g. [A,B,C,D,E,F,G,H] will become ReadonlyArray<A|B|C|D|E|F|G|H>

@kainino0x kainino0x merged commit f3196f8 into gpuweb:main Oct 26, 2023
2 checks passed
@kainino0x kainino0x deleted the readonly-params branch October 26, 2023 05:08
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.

2 participants