Class ConstraintLiterals
magnitude + suffix — use this, do not
re-derive it.
🔑 A suffixed value varies along TWO axes. Money is an amount AND a currency;
Dimension is a magnitude AND a unit. Everything that generates or judges such a value has to
keep the two apart: the fuzz generator moves the magnitude while pinning the suffix
(ConstraintValueSearch), and the front end rejects a constraint whose literals disagree
about the suffix in the first place. One splitter serves both, so they cannot disagree about where
a magnitude ends.
Why cross-suffix comparison is a hard error rather than a curiosity. The compile-time
evaluator answers UNKNOWN, not FAIL, when the suffixes differ — measured, 10cm against
>= 500mm is UNKNOWN even though 10cm is plainly below 500mm, and 100.00#USD against
a GBP range likewise. UNKNOWN never raises E08260, so such a value slips past every compile-time
check and Panics at run time instead. A constraint that mixes suffixes therefore cannot be
satisfied by anything, and a generated value carrying the wrong suffix is a test that fails for a
reason having nothing to do with the code under test.
-
Method Summary
Modifier and TypeMethodDescriptionEvery distinct non-empty suffix the constraint's literals carry, in first-seen order.static DoublemagnitudeOf(String literal) A literal's leading numeric magnitude —10000of10000#GBP,500of500mm— or null when it has none, or when what follows is not a bare suffix.static StringA literal's trailing suffix —#GBP,mm— or empty for a bare number and for anything that is not a suffixed quantity at all.
-
Method Details
-
magnitudeOf
-
suffixOf
-
distinctSuffixes
Every distinct non-empty suffix the constraint's literals carry, in first-seen order.More than one means the constraint compares across suffixes somewhere, which nothing can satisfy — see this class's note on UNKNOWN verdicts.
- Parameters:
expr- the constraint, may be null- Returns:
- the distinct suffixes
-