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

Validation Tests #359

Merged
merged 20 commits into from
Jun 16, 2023
Merged

Validation Tests #359

merged 20 commits into from
Jun 16, 2023

Conversation

f3l1x98
Copy link
Contributor

@f3l1x98 f3l1x98 commented Jun 14, 2023

This adds the missing validation tests for

  • RangeLiteral
  • RegexLiteral
  • JayveeModel
  • PropertyAssignment
  • TransformBody
  • TransformOutputAssignment
  • TypedConstraintDefinition
  • ValuetypeDefinition
  • ExpressionConstraintDefinition

@f3l1x98 f3l1x98 requested a review from felix-oq June 14, 2023 08:01
@f3l1x98 f3l1x98 changed the title Missing validation tests [WIP] Missing validation tests Jun 14, 2023
Copy link
Contributor

@felix-oq felix-oq left a comment

Choose a reason for hiding this comment

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

As a first comment, consider using lower-case letters for the input / output ports of transforms. That way the test models follow the naming convention established by the electric-vehicles.jv example.

@f3l1x98
Copy link
Contributor Author

f3l1x98 commented Jun 14, 2023

I have one question:
When exactly is the linking done?
Is it done separately or during parse, because if I use

valuetype ValueType oftype text {
  constraints: [
    Test
  ];
}

valuetype Test oftype text {
  constraints: [];
}

as input for the valuetype-definition test that tests


the test never "throws" the error as expected.
The reason for that is, that during the type-inference of the collection values expression?.value?.ref (more precise ref) in inferTypeFromReferenceLiteral is undefined, which from my understanding can either mean that linking has not been done, or the linking failed.

@f3l1x98 f3l1x98 changed the title [WIP] Missing validation tests Missing validation tests Jun 14, 2023
Copy link
Contributor

@felix-oq felix-oq left a comment

Choose a reason for hiding this comment

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

Awesome, well done!

expect(validationAcceptorMock).toHaveBeenCalledTimes(2);
expect(validationAcceptorMock).toHaveBeenCalledWith(
'error',
`The pipelinedefinition name "Pipeline" needs to be unique.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you actually found a bug here. It message is supposed to state The pipeline name "Pipeline" needs to be unique.

Same for transforms, valuetypes and constraints.

Copy link
Member

Choose a reason for hiding this comment

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

Do you want to directly fix the bug? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@georg-schwarz not sure if you mean me, but if yes I would do that in a separate PR and create an issue for that 😄

@felix-oq
Copy link
Contributor

felix-oq commented Jun 14, 2023

I have one question:
When exactly is the linking done?

...

The reason for that is, that during the type-inference of the collection values expression?.value?.ref (more precise ref) in inferTypeFromReferenceLiteral is undefined, which from my understanding can either mean that linking has not been done, or the linking failed.

The linking is done during the creation of the LangiumDocument, see here for more details. The reason, it does not link in your case is that valuetypes are not referencable in expressions due to the grammar (except for valuetype assignments). You can have a look at it in expression.langium. So the linker does not even attempt perform the linking in this case because it is considered illegal.

Co-authored-by: Felix Quast <51856713+felix-oq@users.noreply.github.com>
@f3l1x98
Copy link
Contributor Author

f3l1x98 commented Jun 14, 2023

I have one question:
When exactly is the linking done?
...
The reason for that is, that during the type-inference of the collection values expression?.value?.ref (more precise ref) in inferTypeFromReferenceLiteral is undefined, which from my understanding can either mean that linking has not been done, or the linking failed.

The linking is done during the creation of the LangiumDocument, see here for more details. The reason, it does not link in your case is that valuetypes are not referencable in expressions due to the grammar (except for valuetype assignments). You can have a look at it in expression.langium. So the linker does not even attempt perform the linking in this case because it is considered illegal.

I understand, forgot to check whether the grammar considers this valid.
Thank you 👍

@georg-schwarz georg-schwarz changed the title Missing validation tests Validation Tests Jun 14, 2023
Copy link
Member

@georg-schwarz georg-schwarz left a comment

Choose a reason for hiding this comment

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

Please make sure to follow the jest naming pattern for consistency. I added one example.

describe should always point to the subject under test (the class or broader functionality). It is a test file, so no need to mention it is a test.

it should always start with a "should" defining the expected behavior, potentially followed by a "when" later to distinguish different preconditions.

Copy link
Member

@georg-schwarz georg-schwarz left a comment

Choose a reason for hiding this comment

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

Love it, well done!

@georg-schwarz georg-schwarz merged commit 98fedbe into main Jun 16, 2023
@georg-schwarz georg-schwarz deleted the feature/language-server-testing branch June 16, 2023 14:18
@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants