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

Partialy implement validation for valid key #307

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Mingun
Copy link
Contributor

@Mingun Mingun commented Sep 10, 2024

This PR adds missing validation for valid keys. Some problems not solved, because I do not know what is the prefered way for you to solve them. Namely:

  • some expected error messages was written with some other check method in mind, namely TypeDetector.assertCompareTypes. Actually the other methods are used which produces another messages. Sometimes this produces false-positives, I guess
  • some tests produces additional errors, the expected messages should be updated accordingly

Below the changed parts in the output (this is how errors looks after this PR).

Fixed (5):

[info] - attr_bad_valid_expr *** FAILED ***
[info]   []
[info]     did not equal
[info]   [attr_bad_valid_expr.ksy: /seq/0/valid/expr:
[info]          error: invalid type: expected boolean, got Int1Type(true)
[info]   ] (SimpleMatchers.scala:34)
[info] - expr_field_unknown_valid_eq_long *** FAILED ***
[info]   []
[info]     did not equal
[info]   [expr_field_unknown_valid_eq_long.ksy: /seq/0/valid/eq:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_eq_long context
[info]   ] (SimpleMatchers.scala:34)
[info] - expr_field_unknown_valid_expr *** FAILED ***
[info]   []
[info]     did not equal
[info]   [expr_field_unknown_valid_expr.ksy: /seq/0/valid/expr:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_expr context
[info]   ] (SimpleMatchers.scala:34)
[info] - expr_field_unknown_valid_range *** FAILED ***
[info]   []
[info]     did not equal
[info]   [expr_field_unknown_valid_range.ksy: /seq/0/valid/min:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_range context
[info]
[info]   expr_field_unknown_valid_range.ksy: /seq/0/valid/max:
[info]          error: unable to access 'qux' in expr_field_unknown_valid_range context
[info]   ] (SimpleMatchers.scala:34)
[info] - expr_field_unknown_valid_eq_short *** FAILED ***
[info]   []
[info]     did not equal
[info]   [expr_field_unknown_valid_eq_short.ksy: /seq/0/valid:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_eq_short context
[info]   ] (SimpleMatchers.scala:34)

Changed error message (6, expected must be corrected or false-positives):

[info] - attr_bad_valid_repeat_eq_short *** FAILED ***
[info]   [attr_bad_valid_repeat_eq_short.ksy: /seq/0/valid:
[info]          error: invalid type: expected IntMultiType(true,Width4,Some(LittleEndian)), got ArrayTypeInStream(CalcIntType)
[info]   ]
[info]     did not equal
[info]   [attr_bad_valid_repeat_eq_short.ksy: /seq/0/valid:
[info]          error: can't compare IntMultiType(true,Width4,Some(LittleEndian)) and ArrayTypeInStream(CalcIntType)
[info]   ] (SimpleMatchers.scala:34)
[info] - attr_bad_valid_eq_short *** FAILED ***
[info]   [attr_bad_valid_eq_short.ksy: /seq/0/valid:
[info]          error: invalid type: expected Int1Type(false), got CalcStrType
[info]   ]
[info]     did not equal
[info]   [attr_bad_valid_eq_short.ksy: /seq/0/valid:
[info]          error: can't compare Int1Type(false) and CalcStrType
[info]   ] (SimpleMatchers.scala:34)
[info] - attr_bad_valid_eq_long *** FAILED ***
[info]   [attr_bad_valid_eq_long.ksy: /seq/0/valid/eq:
[info]          error: invalid type: expected Int1Type(false), got CalcStrType
[info]   ]
[info]     did not equal
[info]   [attr_bad_valid_eq_long.ksy: /seq/0/valid/eq:
[info]          error: can't compare Int1Type(false) and CalcStrType
[info]   ] (SimpleMatchers.scala:34)
[info] - attr_bad_valid_any_of *** FAILED ***
[info]   [attr_bad_valid_any_of.ksy: /seq/0/valid/any-of/0:
[info]          error: invalid type: expected Int1Type(false), got Int1Type(true)
[info]
[info]   attr_bad_valid_any_of.ksy: /seq/0/valid/any-of/1:
[info]          error: invalid type: expected Int1Type(false), got Int1Type(true)
[info]
[info]   attr_bad_valid_any_of.ksy: /seq/0/valid/any-of/2:
[info]          error: invalid type: expected Int1Type(false), got CalcBooleanType
[info]
[info]   attr_bad_valid_any_of.ksy: /seq/0/valid/any-of/3:
[info]          error: invalid type: expected Int1Type(false), got Int1Type(true)
[info]   ]
[info]     did not equal
[info]   [attr_bad_valid_any_of.ksy: /seq/0/valid/any-of/2:
[info]          error: can't compare Int1Type(false) and CalcBooleanType
[info]   ] (SimpleMatchers.scala:34)
[info] - attr_bad_valid_range *** FAILED ***
[info]   [attr_bad_valid_range.ksy: /seq/0/valid/min:
[info]          error: invalid type: expected Int1Type(false), got CalcBooleanType
[info]
[info]   attr_bad_valid_range.ksy: /seq/0/valid/max:
[info]          error: invalid type: expected Int1Type(false), got CalcStrType
[info]   ]
[info]     did not equal
[info]   [attr_bad_valid_range.ksy: /seq/0/valid/min:
[info]          error: can't compare Int1Type(false) and CalcBooleanType
[info]
[info]   attr_bad_valid_range.ksy: /seq/0/valid/max:
[info]          error: can't compare Int1Type(false) and CalcStrType
[info]   ] (SimpleMatchers.scala:34)
[info] - expr_field_unknown_valid_any_of *** FAILED ***
[info]   [expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/0:
[info]          error: invalid type: expected Int1Type(false), got Int1Type(true)
[info]
[info]   expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/1:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_any_of context
[info]
[info]   expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/2:
[info]          error: invalid type: expected Int1Type(false), got Int1Type(true)
[info]
[info]   expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/3:
[info]          error: unable to access 'qux' in expr_field_unknown_valid_any_of context
[info]   ]
[info]     did not equal
[info]   [expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/1:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_any_of context
[info]
[info]   expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/3:
[info]          error: unable to access 'qux' in expr_field_unknown_valid_any_of context
[info]   ] (SimpleMatchers.scala:34)

Fixed (4):
```
[info] - attr_bad_valid_expr *** FAILED ***
[info]   []
[info]     did not equal
[info]   [attr_bad_valid_expr.ksy: /seq/0/valid/expr:
[info]          error: invalid type: expected boolean, got Int1Type(true)
[info]   ] (SimpleMatchers.scala:34)
[info] - expr_field_unknown_valid_eq_long *** FAILED ***
[info]   []
[info]     did not equal
[info]   [expr_field_unknown_valid_eq_long.ksy: /seq/0/valid/eq:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_eq_long context
[info]   ] (SimpleMatchers.scala:34)
[info] - expr_field_unknown_valid_expr *** FAILED ***
[info]   []
[info]     did not equal
[info]   [expr_field_unknown_valid_expr.ksy: /seq/0/valid/expr:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_expr context
[info]   ] (SimpleMatchers.scala:34)
[info] - expr_field_unknown_valid_range *** FAILED ***
[info]   []
[info]     did not equal
[info]   [expr_field_unknown_valid_range.ksy: /seq/0/valid/min:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_range context
[info]
[info]   expr_field_unknown_valid_range.ksy: /seq/0/valid/max:
[info]          error: unable to access 'qux' in expr_field_unknown_valid_range context
[info]   ] (SimpleMatchers.scala:34)
```
Changed error message (4, must correct model to distinguish between `valid` and `valid.eq`):
```
[info] - attr_bad_valid_eq_long *** FAILED ***
[info]   [attr_bad_valid_eq_long.ksy: /seq/0/valid/eq:
[info]          error: invalid type: expected Int1Type(false), got CalcStrType
[info]   ]
[info]     did not equal
[info]   [attr_bad_valid_eq_long.ksy: /seq/0/valid/eq:
[info]          error: can't compare Int1Type(false) and CalcStrType
[info]   ] (SimpleMatchers.scala:34)
[info] - attr_bad_valid_eq_short *** FAILED ***
[info]   [attr_bad_valid_eq_short.ksy: /seq/0/valid/eq:
[info]          error: invalid type: expected Int1Type(false), got CalcStrType
[info]   ]
[info]     did not equal
[info]   [attr_bad_valid_eq_short.ksy: /seq/0/valid:
[info]          error: can't compare Int1Type(false) and CalcStrType
[info]   ] (SimpleMatchers.scala:34)
[info] - attr_bad_valid_repeat_eq_short *** FAILED ***
[info]   [attr_bad_valid_repeat_eq_short.ksy: /seq/0/valid/eq:
[info]          error: invalid type: expected IntMultiType(true,Width4,Some(LittleEndian)), got ArrayTypeInStream(CalcIntType)
[info]   ]
[info]     did not equal
[info]   [attr_bad_valid_repeat_eq_short.ksy: /seq/0/valid:
[info]          error: can't compare IntMultiType(true,Width4,Some(LittleEndian)) and ArrayTypeInStream(CalcIntType)
[info]   ] (SimpleMatchers.scala:34)
[info] - expr_field_unknown_valid_eq_short *** FAILED ***
[info]   [expr_field_unknown_valid_eq_short.ksy: /seq/0/valid/eq:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_eq_short context
[info]   ]
[info]     did not equal
[info]   [expr_field_unknown_valid_eq_short.ksy: /seq/0/valid:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_eq_short context
[info]   ] (SimpleMatchers.scala:34)
```
Changed error message (3, expected must be corrected or false-positives):
```
[info] - attr_bad_valid_any_of *** FAILED ***
[info]   [attr_bad_valid_any_of.ksy: /seq/0/valid/any-of/0:
[info]          error: invalid type: expected Int1Type(false), got Int1Type(true)
[info]
[info]   attr_bad_valid_any_of.ksy: /seq/0/valid/any-of/1:
[info]          error: invalid type: expected Int1Type(false), got Int1Type(true)
[info]
[info]   attr_bad_valid_any_of.ksy: /seq/0/valid/any-of/2:
[info]          error: invalid type: expected Int1Type(false), got CalcBooleanType
[info]
[info]   attr_bad_valid_any_of.ksy: /seq/0/valid/any-of/3:
[info]          error: invalid type: expected Int1Type(false), got Int1Type(true)
[info]   ]
[info]     did not equal
[info]   [attr_bad_valid_any_of.ksy: /seq/0/valid/any-of/2:
[info]          error: can't compare Int1Type(false) and CalcBooleanType
[info]   ] (SimpleMatchers.scala:34)
[info] - attr_bad_valid_range *** FAILED ***
[info]   [attr_bad_valid_range.ksy: /seq/0/valid/min:
[info]          error: invalid type: expected Int1Type(false), got CalcBooleanType
[info]
[info]   attr_bad_valid_range.ksy: /seq/0/valid/max:
[info]          error: invalid type: expected Int1Type(false), got CalcStrType
[info]   ]
[info]     did not equal
[info]   [attr_bad_valid_range.ksy: /seq/0/valid/min:
[info]          error: can't compare Int1Type(false) and CalcBooleanType
[info]
[info]   attr_bad_valid_range.ksy: /seq/0/valid/max:
[info]          error: can't compare Int1Type(false) and CalcStrType
[info]   ] (SimpleMatchers.scala:34)
[info] - expr_field_unknown_valid_any_of *** FAILED ***
[info]   [expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/0:
[info]          error: invalid type: expected Int1Type(false), got Int1Type(true)
[info]
[info]   expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/1:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_any_of context
[info]
[info]   expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/2:
[info]          error: invalid type: expected Int1Type(false), got Int1Type(true)
[info]
[info]   expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/3:
[info]          error: unable to access 'qux' in expr_field_unknown_valid_any_of context
[info]   ]
[info]     did not equal
[info]   [expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/1:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_any_of context
[info]
[info]   expr_field_unknown_valid_any_of.ksy: /seq/0/valid/any-of/3:
[info]          error: unable to access 'qux' in expr_field_unknown_valid_any_of context
[info]   ] (SimpleMatchers.scala:34)
```
…Equals` and make it abstract

Fixed (1):

[info] - expr_field_unknown_valid_eq_short *** FAILED ***
[info]   [expr_field_unknown_valid_eq_short.ksy: /seq/0/valid/eq:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_eq_short context
[info]   ]
[info]     did not equal
[info]   [expr_field_unknown_valid_eq_short.ksy: /seq/0/valid:
[info]          error: unable to access 'bar' in expr_field_unknown_valid_eq_short context
[info]   ] (SimpleMatchers.scala:34)
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.

1 participant