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

Add tests for stage 3 proposal error cause #2965

Merged
merged 2 commits into from
Apr 23, 2021

Conversation

legendecas
Copy link
Member

@legendecas legendecas commented Mar 18, 2021

Implementation Status:

Copy link
Contributor

@jugglinmike jugglinmike 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 patch, @legendecas!

Test262 has some automated checks that run against all pull requests, and the results are available at the bottom of each GitHub Pull Request page. The checks are labeled as "build & lint tests." For this Pull Request, the check is reporting a problem:

Linting complete. 3 errors found.
/home/circleci/test262/test/built-ins/Error/cause_property.js: HARNESS - verifyConfigurable & verifyProperty may not be used in the same file
/home/circleci/test262/test/built-ins/NativeErrors/AggregateError/cause-property.js: HARNESS - verifyConfigurable & verifyProperty may not be used in the same file
/home/circleci/test262/test/built-ins/NativeErrors/cause_property_native_error.js: HARNESS - verifyConfigurable & verifyProperty may not be used in the same file

The verifyProperty is capable of verifying the entire property descriptor. Would you mind updating your patch to use that instead of verifyNotEnumerable, verifyWritable, and verifyConfigurable?

(We recommend using verifyProperty instead of a combination of the more targeted functions because it's so tricky to get the sequence of those functions right. As a bonus, verifyProperty fails with a message describing every violated expectation--implementers will only see the first violation from the more targeted functions.)

Here are some ideas about improving coverage:

  • InstallErrorCause has two observable behaviors that we're not testing yet. They're strange edge cases, but those make them the most likely for implementers to miss!

      1. If Type(options) is Object and ? HasProperty(options, "cause") is true, then

      Could you add a test for when HasProperty returns an abrupt completion?

    • Let cause be ? Get(options, "cause").

      Could you add a test for when Get returns an abrupt completion?

  • In all cases, the error "message" is installed before the error "cause." This might seem inconsequential, but if implementers get it backwards, then that could lead to interoperability bugs. For example:

    var sequence = [];
    new Error(
      {toString() { sequence.push('toString'); }},
      {get cause() { sequence.push('cause'); }}
    );
    

---*/

var message = "my-message";
var cause = new Error("my-cause");
Copy link
Contributor

Choose a reason for hiding this comment

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

Although we expect developers to set the cause to Error instances, there's nothing in the proposal which requires that. Would you mind using a plain Object instead? That will help verify that the feature is value-agnostic without reducing the test's ability to assert identity.

@jugglinmike
Copy link
Contributor

Hi again, @legendecas. Would you like a hand making those changes?

@legendecas
Copy link
Member Author

@jugglinmike sorry for the delay, just updated the tests to include your great suggestions. thanks.

Copy link
Contributor

@jugglinmike jugglinmike left a comment

Choose a reason for hiding this comment

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

Hi there, @legendecas! I noticed that you pushed up a new version yesterday, so I've taken another look. (In the future, if you could avoid rewriting previously-submitted commits, that will make it easier for folks to review your changes.)

This new version is great! There are a few minor improvements that we can still make, but they don't concern correctness, so I'll make a follow-up patch to discuss further.

However, there was one issue that was related to correctness: the Proxy constructor was being invoked without the new operator. That prevented the test from passing in conforming runtimes. Since the correction was straightforward and since I'd like to make these tests available to consumers as soon as possible, I've gone ahead and pushed a fix to this branch. Hope you don't mind!

@legendecas
Copy link
Member Author

@jugglinmike thanks a lot for the correctness update! It is not quite easy to check the test correctness with tools that I'm aware of. I'm so sorry for the poor updates 😵 .

@legendecas legendecas deleted the error-cause-property branch April 26, 2021 03:30
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