Record Class FunctionSummary.RequirePredicate
java.lang.Object
java.lang.Record
org.ek9lang.compiler.symbolic.FunctionSummary.RequirePredicate
- Record Components:
paramIndex- the 0-based position of the constrained parameter in the callee's signatureparamName- the parameter's name (for readability / caller-side matching)op- the normalised relational operator (<,<=,>,>=,==,<>)literal- the integer literal the parameter is compared against
- Enclosing class:
FunctionSummary
-
Constructor Summary
ConstructorsConstructorDescriptionRequirePredicate(int paramIndex, String paramName, String op, long literal) Creates an instance of aRequirePredicaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadmits(long value) WhethervalueSATISFIES this precondition — the complement ofviolatingArgValue(), and the primitive a generator needs to keep an argument out of a test that could only everPanic.longThe admitted value sitting hard against the boundary — the in-contract edge worth driving.final booleanIndicates whether some other object is "equal to" this one.booleanWhether this precondition guarantees the parameter is non-zero — so a division by that parameter, dominated by thisrequire, is discharged (cannot divide by zero).final inthashCode()Returns a hash code value for this object.longliteral()Returns the value of theliteralrecord component.op()Returns the value of theoprecord component.intReturns the value of theparamIndexrecord component.Returns the value of theparamNamerecord component.final StringtoString()Returns a string representation of this record class.longThe argument value that violates this precondition — the boundary at (or just past) the literal, depending on the operator.
-
Constructor Details
-
RequirePredicate
Creates an instance of aRequirePredicaterecord class.- Parameters:
paramIndex- the value for theparamIndexrecord componentparamName- the value for theparamNamerecord componentop- the value for theoprecord componentliteral- the value for theliteralrecord component
-
-
Method Details
-
excludesZero
public boolean excludesZero()Whether this precondition guarantees the parameter is non-zero — so a division by that parameter, dominated by thisrequire, is discharged (cannot divide by zero). -
admits
public boolean admits(long value) WhethervalueSATISFIES this precondition — the complement ofviolatingArgValue(), and the primitive a generator needs to keep an argument out of a test that could only everPanic.🔑 An unmodelled operator admits everything. This analysis is one-sided by design (McMinn et al.): it may RETAIN a value it could have excluded, and must NEVER exclude one it cannot prove excluded. Over-retention costs a redundant test; over-exclusion silently deletes the case that would have found the bug.
- Parameters:
value- the candidate argument- Returns:
- true when the precondition holds for
value, or the operator is not modelled
-
boundaryAdmittedValue
public long boundaryAdmittedValue()The admitted value sitting hard against the boundary — the in-contract edge worth driving.require n > 0yields1;require n >= 18yields18.This is the DECLARED half of boundary extraction (
SPEC-test-data-generation.md§2, analysis D). Its out-of-contract twin isviolatingArgValue(), which belongs in a Panic-asserting test rather than an ordinary one.- Returns:
- the closest argument value that satisfies this precondition
-
violatingArgValue
public long violatingArgValue()The argument value that violates this precondition — the boundary at (or just past) the literal, depending on the operator. Feeding this back through a caller's argument transform yields the caller input that panics. E.g.require x <> 0is violated byx = 0. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
paramIndex
public int paramIndex()Returns the value of theparamIndexrecord component.- Returns:
- the value of the
paramIndexrecord component
-
paramName
-
op
-
literal
-