Skip to content

#5301: use Expect.Natural in EOresized instead of ad-hoc intValue narrowing#5309

Merged
yegor256 merged 1 commit into
objectionary:masterfrom
morphqdd:5301-resized-expect-natural
Jul 8, 2026
Merged

#5301: use Expect.Natural in EOresized instead of ad-hoc intValue narrowing#5309
yegor256 merged 1 commit into
objectionary:masterfrom
morphqdd:5301-resized-expect-natural

Conversation

@morphqdd

@morphqdd morphqdd commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Closes #5301.

EOmalloc$EOof$EOallocated$EOresized.lambda() built its own ad-hoc Expect chain for id and
new-size that narrows the Double to int with Double::intValue directly, unlike every other
malloc-related atom in this package (EOmalloc$EOof$EOφ, EOmalloc$EOof$EOallocated$EOread,
EOmalloc$EOof$EOallocated$EOwrite), which all use Expect.Natural. Double.intValue() truncates
fractional values silently and saturates out-of-range values instead of throwing, so
<allocated>.resized 5.7 silently resized to 5 bytes instead of rejecting the non-integer size.

Replaced both ad-hoc chains with new Expect.Natural(...), matching the sibling atoms.

Added a throws-on-changing-size-to-fractional test to malloc.eo, mirroring the existing
throws-on-changing-size-to-negative test, covering the fractional-size case that the ad-hoc
chain didn't validate.

Ran the full EO-generated malloc test suite locally (EOmallocEOAtomTest) — all 36 tests pass,
including the new one.

@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Performance Analysis

All benchmarks are within the acceptable range. No critical degradation detected (threshold is 100%). Please refer to the detailed report for more information.

Click to see the detailed report
Test Base Score PR Score Change % Change Unit Mode
benchmarks.XmirBench.xmirToEO 13381.355 13174.753 -206.602 -1.54% ms/op Average Time

✅ Performance gain: benchmarks.XmirBench.xmirToEO is faster by 206.602 ms/op (1.54%)

@morphqdd

morphqdd commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

@yegor256, please take a look when you have a moment.

@yegor256
yegor256 merged commit dec1572 into objectionary:master Jul 8, 2026
25 of 26 checks passed
@0crat

0crat commented Jul 8, 2026

Copy link
Copy Markdown

@morphqdd Thanks for the contribution! You've earned +12 points for this: +16 as a basis; -4 for too few (18) hits-of-code. Please, keep them coming. Your running score is +500; don't forget to check your Zerocracy account too).

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.

EOmalloc$EOof$EOallocated$EOresized incorrectly truncates/saturates new-size rather than employing Expect.Natural

3 participants