Skip to content

Pre conditions #150

Open
Open
@MalcolmMcLean

Description

@MalcolmMcLean

The example used is sqrt() which needs a non-negative input. If passed nan or infinity we should presumably return NaN/infinity. So that's the first question - should that be stated in expects? if we agree that NaN is a defined result, a naive Expects( x >= 0 ) will fail. That's one issue.

Another is that not all preconditions can be so easily stated. Geometrical routines may be undefined for degenerate inputs. So if we are asked whether two "lines" which consist of two co-incident points intersect, is that meant to fail an "Expects"? That's a simple example, you can make the invalid input arbitrarily complex. At what point should the routine treat the input as normal processing and return an error flag / something (you can just decide arbitrarily whether two co-incident points intersect or not), throw an exception?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions