Repository navigation
test: check formatting against an independent rendering - #398
Conversation
Closes #372 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 37 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…nt the e0 omission Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment: S/M/L PR Classification Guidelines:This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed. Small (S)Characteristics:
Review Effort: Would have taken 5-10 minutes Examples:
Medium (M)Characteristics:
Review Effort: Would have taken 15-30 minutes Examples:
Large (L)Characteristics:
Review Effort: Would have taken 45+ minutes Examples:
Additional Factors to ConsiderWhen deciding between sizes, also consider:
Notes:
|
Closes #372
Formatting tests checked
formatagainstparse(round trip plusformat(parse(s)) == s), against itself ("-" + format(x) == format(-x), two representations agree), or only checked length and some characters. A formatter that is wrong in the same way in every place passes all of these.expectedFormat(c, e, scientific)builds the expected string from the OZStrings.toString(|c|)digits. It does not call the formatter:eplaces from the right.d.ddd, followed byeand the leading digit's exponent (e + digits - 1). Theepart is left out when that exponent is 0._toScientific's NatSpec now states that rule.testExpectedFormatOraclechecks the oracle against hand-written strings.Per the #376 ruling (b), the formatter's int32 and int224 refusal guards are to be dropped, so this PR asserts no guard revert. Only the documented ±1000 plain-mode cap is asserted.
Changes:
"0." + 999 zeros + "1") and1e67("1" + 67 zeros).testFormatNonScientificOutputShapeis removed. Its shape checks are implied by exact equality, andtestFormatNonScientificSucceedsForNonPositiveExponentsnow asserts the oracle over the same domain.testFormatScientificFullExponentDomaincovers every int224 coefficient and int32 exponent and asserts the oracle. Inputs whose leading digit exponent is above int32.max are skipped while src still refuses them.testFormatNonScientificPositiveExponentBoundarycovers e = 1..67, both signs:floor(int224.max / 10^e)must render as the oracle._toScientificNatSpec: theeNpart is omitted whenNis zero.The pre-existing guard-revert tests on main (
testFormatScientificDisplayExponentOverflowReverts,testFormatScientificRevertsNearPositiveInt32Limit,testFormatNonScientificRevertsOnLongPositiveExp, the revert branch oftestFormatParseRoundTripNonScientificSafePosExp,testFormatNonScientificLargePositiveExponent,testFormatNonScientificLargeCoefficientLargeExponent) are left for the #376 change that drops the guards.QA
mutation-probe(adversarial-mutation-test skill): one 39-mutant file oversrc/lib/format/LibFormatDecimalFloat.sol, run against a fresh clone of main51a3451and against this branch02e2156. Suite:forge test --match-path test/src/lib/format/*,FOUNDRY_FUZZ_SEED=0x1. Main kills 34/39, this branch kills 36/39."e"->"e+"for 1000 < displayExponent < 1e9 (killed by the oracle-equality fuzzes; main survives because the string still parses to the same value), and the int32 lower guard tightened by 100.exponent > MAX_NON_SCIENTIFIC_EXPONENT->> MAX + 1(equivalent: any exponent >= 68 already reverts with the sameUnformatableExponent(exponent)),uExp >= 68->>= 69, andlimit /= 10->/= 9. The last two only loosen the positive-exponent refusal guard that test: format refusal rules are copied from undocumented code guards #376 drops. They no longer fail here because the revert assertions were removed.0above 1e40, point characters, e0 rule, plain trailing-zero strip, point placement, leading zeros, cap lower bound) are killed on both.expectedFormattakes theStrings.toString(|c|)digits and places them by the documented plain and scientific rules. It never calls the formatter,parseormaximizeFull, and is pinned bytestExpectedFormatOracleagainst hand-written strings. The fuzz found no disagreement between the formatter and the oracle.RoundTripNonNegative,RoundTripNegative,ScientificFullDomain,NonScientificNegExpFullDomain, theSafePosExpsuccess branch andAtIntDigitBoundarynow assert the oracle. (b)CanonicalAcrossRepresentationsand the-check now assert the oracle;OutputShapeis removed because the oracle assertion covers it. (c)SucceedsForNonPositiveExponentsandScientificNegativeBoundaryDoesNotRevertnow assert the oracle, andExponentAtNegativeCapasserts the full string.🤖 Generated with Claude Code