Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion matter/constraint/grammar/limit.peg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ UnspecifiedLimit <- ("-" / "–" / "N/A"i) EOF {
return &UnspecifiedLimit{}, nil
}

EmptyLimit <- ("empty" / "[]") {
EmptyLimit <- ("empty" / "[]" / "\"\"") {

Choose a reason for hiding this comment

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

high

While this change correctly adds "" as a syntax for EmptyLimit, I've noticed that there are no existing tests for EmptyLimit in matter/constraint/constraint_test.go. It's important to add tests to cover this functionality, especially when modifying the grammar.

Please add test cases for all three variants of EmptyLimit (empty, [], and the new "") to constraintTests in matter/constraint/constraint_test.go. This will ensure the parser behaves as expected and prevent future regressions.

Here are some suggested test cases:

	{
		constraint: "empty",
		dataType:   &types.DataType{BaseType: types.BaseDataTypeList},
		min:        types.DataTypeExtreme{Type: types.DataTypeExtremeTypeEmptyList, Format: types.NumberFormatHex},
		max:        types.DataTypeExtreme{Type: types.DataTypeExtremeTypeEmptyList, Format: types.NumberFormatHex},
	},
	{
		constraint: "[]",
		asciiDoc:   "empty",
		dataType:   &types.DataType{BaseType: types.BaseDataTypeList},
		min:        types.DataTypeExtreme{Type: types.DataTypeExtremeTypeEmptyList, Format: types.NumberFormatHex},
		max:        types.DataTypeExtreme{Type: types.DataTypeExtremeTypeEmptyList, Format: types.NumberFormatHex},
	},
	{
		constraint: `""`,
		asciiDoc:   "empty",
		dataType:   &types.DataType{BaseType: types.BaseDataTypeList},
		min:        types.DataTypeExtreme{Type: types.DataTypeExtremeTypeEmptyList, Format: types.NumberFormatHex},
		max:        types.DataTypeExtreme{Type: types.DataTypeExtremeTypeEmptyList, Format: types.NumberFormatHex},
	},

You might need to adjust them, for example by adding zapMin and zapMax values if applicable.

return &EmptyLimit{}, nil
}

Loading