-
Notifications
You must be signed in to change notification settings - Fork 6
Validate that '@param' comments on enumerators match a real field of that enumerator. #822
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
Changes from 1 commit
4d96716
ddcc786
fde4c37
720d176
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -208,6 +208,23 @@ mod comments { | |
| check_diagnostics(diagnostics, expected); | ||
| } | ||
|
|
||
| #[test] | ||
| fn enumerator_with_correct_doc_comments() { | ||
| // Arrange | ||
| let slice = " | ||
| module tests | ||
|
|
||
| enum E { | ||
| /// This enumerator has 2 fields. | ||
| /// @param testParam1: A string param | ||
| A(testParam1: string, testParam2: bool) | ||
| } | ||
| "; | ||
|
|
||
| // Act/Assert | ||
| assert_parses(slice); | ||
| } | ||
|
|
||
| #[test] | ||
| fn operation_with_correct_doc_comments() { | ||
| // Arrange | ||
|
|
@@ -395,6 +412,50 @@ mod comments { | |
| check_diagnostics(diagnostics, [expected]); | ||
| } | ||
|
|
||
| #[test] | ||
| fn param_tag_is_rejected_for_enumerators_with_no_fields() { | ||
| // Arrange | ||
| let slice = " | ||
| module tests | ||
|
|
||
| enum E { | ||
| /// @param foo: this parameter doesn't exist. | ||
| A | ||
| } | ||
| "; | ||
|
|
||
| // Act | ||
| let diagnostics = parse_for_diagnostics(slice); | ||
|
|
||
| // Assert | ||
| let expected = Diagnostic::from_lint(Lint::IncorrectDocComment { | ||
| message: "comment has a 'param' tag for 'foo', but enumerator 'A' has no field with that name".to_owned(), | ||
| }); | ||
| check_diagnostics(diagnostics, [expected]); | ||
| } | ||
|
|
||
| #[test] | ||
| fn param_tag_is_rejected_if_its_identifier_does_not_match_a_fields() { | ||
| // Arrange | ||
| let slice = " | ||
| module tests | ||
|
|
||
| enum E { | ||
| /// @param foo: this parameter doesn't exist. | ||
| A(bar: bool) | ||
| } | ||
| "; | ||
|
|
||
| // Act | ||
| let diagnostics = parse_for_diagnostics(slice); | ||
|
|
||
| // Assert | ||
| let expected = Diagnostic::from_lint(Lint::IncorrectDocComment { | ||
| message: "comment has a 'param' tag for 'foo', but enumerator 'A' has no field with that name".to_owned(), | ||
| }); | ||
| check_diagnostics(diagnostics, [expected]); | ||
| } | ||
|
|
||
| #[test] | ||
| fn param_tag_is_rejected_for_operations_with_no_parameters() { | ||
| // Arrange | ||
|
|
@@ -513,7 +574,7 @@ mod comments { | |
| } | ||
|
|
||
| #[test] | ||
| fn param_tags_can_only_be_used_with_operations() { | ||
| fn param_tags_are_rejected_on_incorrect_elements() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we update this expected message and the corresponding diagnostic in validators/comments.rs? Enumerators are now valid owners of @PARAM tags, so 'only operations can have parameters' is misleading. For example: 'comment has a param tag, but only operations and enumerators can use param tags'.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the message, and the names of the validation functions around it! |
||
| // Arrange | ||
| let slice = " | ||
| module tests | ||
|
|
@@ -533,7 +594,7 @@ mod comments { | |
| } | ||
|
|
||
| #[test] | ||
| fn returns_tags_can_only_be_used_with_operations() { | ||
| fn returns_tags_are_rejected_on_incorrect_elements() { | ||
| // Arrange | ||
| let slice = " | ||
| module tests | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.