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

feat: Also simplify Is.EqualTo(0) to Is.Zero #845

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikkelbu
Copy link
Member

Fixes #824

@manfred-brands
Copy link
Member

@mikkelbu I didn't do this because Is.EqualTo(0) is no longer the same as Is.Zero.
The first returns an EqualNumericConstraint<int> and the second EqualConstraint.

Although I think it isn't that relevant for this case, except it allows Is.Zero.IgnoreCase.

On option would be for Is.Zero to return EqualNumericContraint<double>.

Should we also detected other zero values such as 0.0, 0.0f, 0L, etc.

Comment on lines +50 to +53
(SyntaxKind.NullLiteralExpression, _) => NUnitFrameworkConstants.NameOfIsNull,
(SyntaxKind.FalseLiteralExpression, _) => NUnitFrameworkConstants.NameOfIsFalse,
(SyntaxKind.TrueLiteralExpression, _) => NUnitFrameworkConstants.NameOfIsTrue,
(SyntaxKind.NumericLiteralExpression, "0") => NUnitFrameworkConstants.NameOfIsZero,
Copy link
Member

Choose a reason for hiding this comment

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

Suggest not to switch on both, but treat the numeric part different. Which allow checking some more 0 values.

@mikkelbu
Copy link
Member Author

@mikkelbu I didn't do this because Is.EqualTo(0) is no longer the same as Is.Zero. The first returns an EqualNumericConstraint<int> and the second EqualConstraint.

Ahh. I didn't consider this - I thought it was an oversight in the PR

Although I think it isn't that relevant for this case, except it allows Is.Zero.IgnoreCase.
On option would be for Is.Zero to return EqualNumericContraint<double>.

I think this makes sense. It could break somebody, but only people that have some odd/wrong constraints (unless I'm overlooking something)

Should we also detected other zero values such as 0.0, 0.0f, 0L, etc.

Yes - I'll update the PR with your suggestion

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.

Use Is.False / Is.True instead of Is.EqualTo
2 participants