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

[js-api] Add spec tests for proposed API additions #155

Merged
merged 5 commits into from
Jun 25, 2021

Conversation

takikawa
Copy link
Collaborator

@takikawa takikawa commented Jun 2, 2021

This PR adds preliminary web-platform / JS API spec tests for the proposed exception handling API from #154 and discussed in #150.

Copy link
Contributor

@Ms2ger Ms2ger left a comment

Choose a reason for hiding this comment

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

These should all have the .tentative. flag until the proposal merges into the main spec.

Ms2ger pushed a commit to Ms2ger/exception-handling that referenced this pull request Jun 9, 2021
This has already been updated in the upstream spec, but also needs to be
fixed in proposals.
@takikawa
Copy link
Collaborator Author

This PR is now updated to match the recent event to tag renaming in the spec.

Copy link
Contributor

@Ms2ger Ms2ger left a comment

Choose a reason for hiding this comment

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

Anything blocking this?

Copy link
Member

@aheejin aheejin left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! Sorry for the late reply. Is there any reason file names have 'tentative' in them, even if they are tentative? (Aren't all files tentative in a sense, unless it is standardized..?) Is that a rule in the spec repo?

Anyway can you wait for a little more while before merging?

// META: script=/wasm/jsapi/assertions.js

function assert_type(argument) {
const tag = new WebAssembly.Tag(argument);
Copy link
Member

Choose a reason for hiding this comment

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

It looks some functions use two spaces while others use four spaces. What's our rule for other JS spec tests? It'd better be consistent.

Copy link
Collaborator Author

@takikawa takikawa Jun 23, 2021

Choose a reason for hiding this comment

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

Thanks for noticing that, I think 2-space is the norm based on other tests. I've just reformatted all the files I added with prettier to be consistent with 2-space. @Ms2ger is that fine for spec test style? (would be happy to apply a different linter too if there's a recommended one)

@takikawa
Copy link
Collaborator Author

takikawa commented Jun 22, 2021

Is there any reason file names have 'tentative' in them, even if they are tentative? (Aren't all files tentative in a sense, unless it is standardized..?) Is that a rule in the spec repo?

I'm not sure exactly what the rules are, @Ms2ger would know better what the standard practice is here I think, but I think the idea was to keep it tentative until the proposal spec is merged into the main spec.

The test framework docs says this about the tentative flag:

.tentative : Indicates that a test makes assertions not yet required by any specification, or in contradiction to some specification. This is useful when implementation experience is needed to inform the specification. It should be apparent in context why the test is tentative and what needs to be resolved to make it non-tentative.

BTW, I just noticed it's also possible to set the whole directory as tentative. Would it be better if I did that for these tests?

Anyway can you wait for a little more while before merging?

That's ok with me. I guess it would make sense to wait until the JS API spec text is merged too, is there anything else it should block on?

@aheejin aheejin mentioned this pull request Jun 22, 2021
@Ms2ger
Copy link
Contributor

Ms2ger commented Jun 23, 2021

These tests are all going into WPT as well, as soon as they're merged here, so are marked as tentative until phase 5. I forgot about marking the directory as tentative; no preference either way on that.

Copy link
Member

@aheejin aheejin left a comment

Choose a reason for hiding this comment

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

Sorry for the delayed reply and thanks for your patience. Also sorry I'm not very familiar with the spec tests convention, so I might ask easy questions.

  • For the usage of 'tentative': Then are other wasm proposal repos all using 'tentative' for their JS API tests until they reach Phase 5?
  • How can I run these JS API tests?

Comment on lines +16 to +19
test(() => {
const argument = { parameters: [] };
assert_throws_js(TypeError, () => WebAssembly.Tag(argument));
}, "Calling");
Copy link
Member

Choose a reason for hiding this comment

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

Why does this throw? Are we not allowed to have a tag with zero argument? I don't recall such a restriction though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Comment on lines +20 to +23
test(() => {
const argument = new WebAssembly.Tag({ parameters: [] });
assert_throws_js(TypeError, () => WebAssembly.Exception(argument));
}, "Calling");
Copy link
Member

Choose a reason for hiding this comment

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

Why does this throw?

Copy link
Contributor

Choose a reason for hiding this comment

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

The issue here is the absence of the new keyword, which leads to NewTarget being undefined, which causes an exception in step 1.2 of the "create an interface object" algorithm.

// META: script=/wasm/jsapi/assertions.js

function assert_type(argument) {
const exception = new WebAssembly.Exception(argument);
Copy link
Member

Choose a reason for hiding this comment

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

The indentation for this file is 4 spaces, unlike other files

Copy link
Contributor

@Ms2ger Ms2ger left a comment

Choose a reason for hiding this comment

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

For the usage of 'tentative': Then are other wasm proposal repos all using 'tentative' for their JS API tests until they reach Phase 5?

If I did the review, they should. I can try to find a place to document this as well.

How can I run these JS API tests?

Once they're in WPT, they'll be published at wpt.live (example).

Comment on lines +20 to +23
test(() => {
const argument = new WebAssembly.Tag({ parameters: [] });
assert_throws_js(TypeError, () => WebAssembly.Exception(argument));
}, "Calling");
Copy link
Contributor

Choose a reason for hiding this comment

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

The issue here is the absence of the new keyword, which leads to NewTarget being undefined, which causes an exception in step 1.2 of the "create an interface object" algorithm.

Comment on lines +16 to +19
test(() => {
const argument = { parameters: [] };
assert_throws_js(TypeError, () => WebAssembly.Tag(argument));
}, "Calling");
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Copy link
Member

@aheejin aheejin left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation!

@Ms2ger Ms2ger merged commit f92692f into WebAssembly:master Jun 25, 2021
@aheejin aheejin mentioned this pull request Sep 7, 2021
11 tasks
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.

3 participants