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

chore(criteria): Unit test that criteria ShEx constraints match non-ShEx constraints #628

Merged
merged 29 commits into from
Feb 21, 2024

Conversation

lukehesluke
Copy link
Contributor

@lukehesluke lukehesluke commented Feb 20, 2024

Closes #592

For each criteria, generate random data from the ShEx constraints, and check that that data matches the non-ShEx constraints, confirming that they are in alignment.

This work also uncovered a few bugs:

It has also spawned a new issue, due to inconsistencies in the modeling presently:

Note to the reviewer: /built-types/.. files can be ignored during review

Comment on lines -51 to +59
if (reqA[fieldName] != null) {
return { [fieldName]: reqA[fieldName] };
if (extensionConstraint[fieldName] != null && baseConstraint[fieldName] == null) {
return { [fieldName]: extensionConstraint[fieldName] };
}
if (reqB[fieldName] != null) {
return { [fieldName]: reqB[fieldName] };
if (baseConstraint[fieldName] != null && extensionConstraint[fieldName] == null) {
return { [fieldName]: baseConstraint[fieldName] };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to me to have been an error. Why have the getValueIfBothExist(..) invokation down below if we'll never reach that because we would return at the first condition.

Comment on lines +95 to +103
// The extension should overwrite the base if they both exist
(base, extension) => extension,
),
...mergeTestDataNodeConstraintField(
'maxinclusive',
baseConstraint,
extensionConstraint,
// The extension should overwrite the base if they both exist
(base, extension) => extension,
Copy link
Contributor Author

@lukehesluke lukehesluke Feb 20, 2024

Choose a reason for hiding this comment

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

This makes more sense to me given that the language is of a Criteria "extending" another. This is a simpler and more explicit means of doing that (and the previous approach was causing the BookableFiveSpaces criteria to generate a capacity constraint of 2 - 5 rather than just 5)

@lukehesluke lukehesluke marked this pull request as ready for review February 20, 2024 11:28
Copy link
Collaborator

@nickevansuk nickevansuk left a comment

Choose a reason for hiding this comment

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

Looks great!

@lukehesluke lukehesluke merged commit 691f78f into master Feb 21, 2024
32 checks passed
@lukehesluke lukehesluke deleted the feature/shape-expression-unit-tests branch February 21, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment