Skip to content

ref: tests for fixed-point package - #248

Merged
ericnordelo merged 6 commits into
release-v1.1from
fixed-point-tests-restructure
Mar 10, 2026
Merged

ref: tests for fixed-point package#248
ericnordelo merged 6 commits into
release-v1.1from
fixed-point-tests-restructure

Conversation

@immrsd

@immrsd immrsd commented Mar 10, 2026

Copy link
Copy Markdown
Collaborator

Primary changes

  • Restructures the fixed-point test suite by splitting test cases in separate files
  • Adds more test cases to test math functions more thoroughly

Summary by CodeRabbit

  • Tests
    • Replaced large monolithic sd29x9 and ud30x9 test suites with many focused modules (abs, arithmetic, bitwise, casting, ceil, floor, comparison, div, mod, mul, pow, negate, wrap, unchecked, helpers, etc.) to improve coverage and organization.
    • Removed legacy monolithic sd29x9/ud30x9 test files; no changes to public APIs.

@immrsd immrsd self-assigned this Mar 10, 2026
@coderabbitai

coderabbitai Bot commented Mar 10, 2026

Copy link
Copy Markdown

Walkthrough

Replaced two large monolithic Move test files (sd29x9 and ud30x9) with many focused test modules and small helper modules covering abs, arithmetic, bitwise, casting, ceil, floor, comparison, div, mod, mul, negate, pow, unchecked, and wrap; also removed the original monolithic test files.

Changes

Cohort / File(s) Summary
SD29x9 Monolith (removed)
math/fixed_point/tests/sd29x9_tests.move
Removed the single-file sd29x9 test suite (~920 lines).
SD29x9 Modular Tests (added)
math/fixed_point/tests/sd29x9_tests/helpers.move, .../abs_tests.move, .../arithmetic_tests.move, .../bitwise_tests.move, .../casting_tests.move, .../ceil_tests.move, .../comparison_tests.move, .../div_tests.move, .../floor_tests.move, .../mod_tests.move, .../mul_tests.move, .../negate_tests.move, .../pow_tests.move, .../unchecked_tests.move, .../wrap_tests.move
Added many focused Move test modules and a helpers module for SD29x9; tests cover operation-specific semantics, boundary/edge cases, and expected aborts for overflow or invalid conversions.
UD30x9 Monolith (removed)
math/fixed_point/tests/ud30x9_tests.move
Removed the single-file ud30x9 test suite (~677 lines).
UD30x9 Modular Tests (added)
math/fixed_point/tests/ud30x9_tests/helpers.move, .../abs_tests.move, .../arithmetic_tests.move, .../bitwise_tests.move, .../casting_tests.move, .../ceil_tests.move, .../comparison_tests.move, .../div_tests.move, .../floor_tests.move, .../mul_tests.move, .../pow_tests.move, .../unchecked_tests.move, .../wrap_tests.move
Added many focused Move test modules and a helpers module for UD30x9; tests mirror SD29x9 coverage where applicable and exercise unsigned-specific semantics and conversions.
Tests: public helpers added
math/fixed_point/tests/sd29x9_tests/helpers.move, math/fixed_point/tests/ud30x9_tests/helpers.move
Introduced Pair structs, constructor/unpack helpers, and value constructors/assert helpers used across modular tests.
API surface
math/fixed_point/tests/...
No production/public API or exported entity changes in library code; changes are test files and test-only helpers only.

Sequence Diagram(s)

(Skipped — changes are test additions/removals and do not introduce new multi-component runtime control flow requiring a sequence diagram.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • 0xNeshi
  • ericnordelo

Poem

🐰 I split one big carrot into many small bites,
Tests hopping through fields of bits and bytes,
From abs to pow and wrap to cast,
Each rabbit-reader checks results fast,
Hooray for tidy tests and clearer nights!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description covers the primary objectives but does not follow the repository's template structure with required sections like issue resolution, PR checklist items, and proper formatting. Adopt the repository template by adding issue reference, completing the PR checklist (Tests, Documentation, Changelog), and providing structured descriptions of changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title is partially related to the changeset - it mentions restructuring tests for the fixed-point package, which aligns with the primary changes, but lacks specificity about the scope and scale of additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fixed-point-tests-restructure

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Mar 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.87%. Comparing base (1426e0a) to head (ac78baf).
⚠️ Report is 1 commits behind head on release-v1.1.

Additional details and impacted files
@@               Coverage Diff                @@
##           release-v1.1     #248      +/-   ##
================================================
+ Coverage         89.74%   89.87%   +0.12%     
================================================
  Files                19       19              
  Lines              1785     1787       +2     
  Branches            484      484              
================================================
+ Hits               1602     1606       +4     
  Misses              168      168              
+ Partials             15       13       -2     
Flag Coverage Δ
contracts/access 44.87% <ø> (ø)
math/core 86.12% <ø> (ø)
math/fixed_point 58.48% <ø> (+0.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
math/fixed_point/tests/ud30x9_tests/unchecked_tests.move (1)

63-68: Exercise the inverse property across wrap-around.

Lines 65-67 only use values far from MAX_VALUE, so this verifies the non-wrapping path but not the modular behavior unchecked_* is supposed to guarantee.

Suggested addition
-    let cases = vector[fixed(10), fixed(100), fixed(1_000_000), fixed(42)];
+    let cases = vector[
+        fixed(10),
+        fixed(100),
+        fixed(1_000_000),
+        fixed(42),
+        fixed(MAX_VALUE - 2),
+    ];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@math/fixed_point/tests/ud30x9_tests/unchecked_tests.move` around lines 63 -
68, The test unchecked_add_and_sub_are_inverse only checks non-wrapping values;
extend it to exercise wrap-around by adding cases near the type bounds and using
deltas that cause overflow, e.g., include values like MAX_VALUE, MAX_VALUE - 1,
MIN_VALUE, MIN_VALUE + 1 (referencing the fixed type's max/min constants) and a
delta that will force wrapping so that for each x the property
x.unchecked_add(delta).unchecked_sub(delta) == x (and optionally
x.unchecked_sub(delta).unchecked_add(delta) == x) is validated; update the cases
vector in unchecked_add_and_sub_are_inverse and reuse
unchecked_add/unckecked_sub to assert the modular inverse behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@math/fixed_point/tests/sd29x9_tests/arithmetic_tests.move`:
- Around line 58-60: The three duplicated addition assertions should instead
exercise subtraction boundaries so the subtraction side of
sub_handles_edge_cases is tested: replace the second and third expect calls
(currently using .add in combinations with max, min, epsilon, epsilon.negate(),
and max.negate()) so they perform the corresponding .sub operations (e.g., test
max.sub(epsilon).sub(epsilon) yields expected min, and
min.sub(epsilon).negate().sub(epsilon) yields expected max) — update the expect
expressions that reference max, min, epsilon, max.negate(), and epsilon.negate()
to use .sub where the subtraction boundary is intended.

In `@math/fixed_point/tests/sd29x9_tests/mul_tests.move`:
- Around line 16-24: The zero-multiplication table in the tests omits the
extreme operands; update the vector used in mul() tests (the values variable) to
include sd29x9::min() and sd29x9::max() so the test exercises min * 0 and max *
0 (and their sign/normalization behavior) alongside existing entries; ensure
these are added to the same vector passed into the zero-multiplication
assertions so the cases are covered without changing test structure.

In `@math/fixed_point/tests/sd29x9_tests/pow_tests.move`:
- Around line 48-51: The test pow_supports_high_exponents currently only calls
val.pow(255) to check it doesn't abort; replace that with an explicit assertion
of the result: compute the expected fixed-point representation for pos(SCALE +
250_000_000).pow(255) (i.e., (1.25)^255 scaled by SCALE) and assert equality (or
assert an exact known integer literal for the scaled result) against the
returned value from val.pow(255); reference the test function
pow_supports_high_exponents, the variable val, the pos(SCALE + 250_000_000)
initializer, and the pow(255) call to locate and update the assertion.

---

Nitpick comments:
In `@math/fixed_point/tests/ud30x9_tests/unchecked_tests.move`:
- Around line 63-68: The test unchecked_add_and_sub_are_inverse only checks
non-wrapping values; extend it to exercise wrap-around by adding cases near the
type bounds and using deltas that cause overflow, e.g., include values like
MAX_VALUE, MAX_VALUE - 1, MIN_VALUE, MIN_VALUE + 1 (referencing the fixed type's
max/min constants) and a delta that will force wrapping so that for each x the
property x.unchecked_add(delta).unchecked_sub(delta) == x (and optionally
x.unchecked_sub(delta).unchecked_add(delta) == x) is validated; update the cases
vector in unchecked_add_and_sub_are_inverse and reuse
unchecked_add/unckecked_sub to assert the modular inverse behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b6f55cf9-1257-458d-b8c5-29657b897fc9

📥 Commits

Reviewing files that changed from the base of the PR and between 1426e0a and 831e94f.

📒 Files selected for processing (30)
  • math/fixed_point/tests/sd29x9_tests.move
  • math/fixed_point/tests/sd29x9_tests/abs_tests.move
  • math/fixed_point/tests/sd29x9_tests/arithmetic_tests.move
  • math/fixed_point/tests/sd29x9_tests/bitwise_tests.move
  • math/fixed_point/tests/sd29x9_tests/casting_tests.move
  • math/fixed_point/tests/sd29x9_tests/ceil_tests.move
  • math/fixed_point/tests/sd29x9_tests/comparison_tests.move
  • math/fixed_point/tests/sd29x9_tests/div_tests.move
  • math/fixed_point/tests/sd29x9_tests/floor_tests.move
  • math/fixed_point/tests/sd29x9_tests/helpers.move
  • math/fixed_point/tests/sd29x9_tests/mod_tests.move
  • math/fixed_point/tests/sd29x9_tests/mul_tests.move
  • math/fixed_point/tests/sd29x9_tests/negate_tests.move
  • math/fixed_point/tests/sd29x9_tests/pow_tests.move
  • math/fixed_point/tests/sd29x9_tests/unchecked_tests.move
  • math/fixed_point/tests/sd29x9_tests/wrap_tests.move
  • math/fixed_point/tests/ud30x9_tests.move
  • math/fixed_point/tests/ud30x9_tests/abs_tests.move
  • math/fixed_point/tests/ud30x9_tests/arithmetic_tests.move
  • math/fixed_point/tests/ud30x9_tests/bitwise_tests.move
  • math/fixed_point/tests/ud30x9_tests/casting_tests.move
  • math/fixed_point/tests/ud30x9_tests/ceil_tests.move
  • math/fixed_point/tests/ud30x9_tests/comparison_tests.move
  • math/fixed_point/tests/ud30x9_tests/div_tests.move
  • math/fixed_point/tests/ud30x9_tests/floor_tests.move
  • math/fixed_point/tests/ud30x9_tests/helpers.move
  • math/fixed_point/tests/ud30x9_tests/mul_tests.move
  • math/fixed_point/tests/ud30x9_tests/pow_tests.move
  • math/fixed_point/tests/ud30x9_tests/unchecked_tests.move
  • math/fixed_point/tests/ud30x9_tests/wrap_tests.move
💤 Files with no reviewable changes (2)
  • math/fixed_point/tests/sd29x9_tests.move
  • math/fixed_point/tests/ud30x9_tests.move

Comment thread math/fixed_point/tests/sd29x9_tests/arithmetic_tests.move Outdated
Comment thread math/fixed_point/tests/sd29x9_tests/mul_tests.move
Comment thread math/fixed_point/tests/sd29x9_tests/pow_tests.move
ericnordelo
ericnordelo previously approved these changes Mar 10, 2026

@ericnordelo ericnordelo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the minor AI review comments, it looks good to me. Good work.

@bidzyyys

Copy link
Copy Markdown
Collaborator

@coderabbitai review again

@coderabbitai

coderabbitai Bot commented Mar 10, 2026

Copy link
Copy Markdown

@bidzyyys Sure! I'll kick off a fresh review of the PR right away.

✅ Actions performed

Full review triggered.

bidzyyys
bidzyyys previously approved these changes Mar 10, 2026
@bidzyyys bidzyyys changed the title Tests for fixed-point package ref: tests for fixed-point package Mar 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@math/fixed_point/tests/sd29x9_tests/wrap_tests.move`:
- Around line 39-47: The tests wrap_small_positive and
wrap_negative_one_is_all_ones currently only validate the helper functions pos()
and neg(); update each test to call sd29x9::wrap() directly with the same
underlying inputs and assert the expected outputs (e.g., call sd29x9::wrap(...)
for the small positive case and for the -1 case and compare to 1 and ALL_ONES
respectively), you can still keep the helper assertions if desired but make sure
sd29x9::wrap() is asserted explicitly in each test so the wrap() behavior is
pinned independent of pos()/neg() helpers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0753ebcc-b4bd-490f-9774-b66f57c6f59e

📥 Commits

Reviewing files that changed from the base of the PR and between 1426e0a and db37fb8.

📒 Files selected for processing (30)
  • math/fixed_point/tests/sd29x9_tests.move
  • math/fixed_point/tests/sd29x9_tests/abs_tests.move
  • math/fixed_point/tests/sd29x9_tests/arithmetic_tests.move
  • math/fixed_point/tests/sd29x9_tests/bitwise_tests.move
  • math/fixed_point/tests/sd29x9_tests/casting_tests.move
  • math/fixed_point/tests/sd29x9_tests/ceil_tests.move
  • math/fixed_point/tests/sd29x9_tests/comparison_tests.move
  • math/fixed_point/tests/sd29x9_tests/div_tests.move
  • math/fixed_point/tests/sd29x9_tests/floor_tests.move
  • math/fixed_point/tests/sd29x9_tests/helpers.move
  • math/fixed_point/tests/sd29x9_tests/mod_tests.move
  • math/fixed_point/tests/sd29x9_tests/mul_tests.move
  • math/fixed_point/tests/sd29x9_tests/negate_tests.move
  • math/fixed_point/tests/sd29x9_tests/pow_tests.move
  • math/fixed_point/tests/sd29x9_tests/unchecked_tests.move
  • math/fixed_point/tests/sd29x9_tests/wrap_tests.move
  • math/fixed_point/tests/ud30x9_tests.move
  • math/fixed_point/tests/ud30x9_tests/abs_tests.move
  • math/fixed_point/tests/ud30x9_tests/arithmetic_tests.move
  • math/fixed_point/tests/ud30x9_tests/bitwise_tests.move
  • math/fixed_point/tests/ud30x9_tests/casting_tests.move
  • math/fixed_point/tests/ud30x9_tests/ceil_tests.move
  • math/fixed_point/tests/ud30x9_tests/comparison_tests.move
  • math/fixed_point/tests/ud30x9_tests/div_tests.move
  • math/fixed_point/tests/ud30x9_tests/floor_tests.move
  • math/fixed_point/tests/ud30x9_tests/helpers.move
  • math/fixed_point/tests/ud30x9_tests/mul_tests.move
  • math/fixed_point/tests/ud30x9_tests/pow_tests.move
  • math/fixed_point/tests/ud30x9_tests/unchecked_tests.move
  • math/fixed_point/tests/ud30x9_tests/wrap_tests.move
💤 Files with no reviewable changes (2)
  • math/fixed_point/tests/sd29x9_tests.move
  • math/fixed_point/tests/ud30x9_tests.move

Comment thread math/fixed_point/tests/sd29x9_tests/wrap_tests.move
@bidzyyys
bidzyyys changed the base branch from main to release-v1.1 March 10, 2026 12:09
@bidzyyys
bidzyyys dismissed stale reviews from ericnordelo and themself March 10, 2026 12:09

The base branch was changed.

@bidzyyys
bidzyyys requested a review from ericnordelo March 10, 2026 12:11
@bidzyyys

bidzyyys commented Mar 10, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai review again

@coderabbitai

coderabbitai Bot commented Mar 10, 2026

Copy link
Copy Markdown

@bidzyyys Sure! I'll kick off a fresh review of the PR right away.

✅ Actions performed

Full review triggered.

@bidzyyys
bidzyyys self-requested a review March 10, 2026 12:13

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
math/fixed_point/tests/ud30x9_tests/helpers.move (1)

19-25: Move shared UD30x9 test constants into this helper module.

Now that the suite is split across many files, SCALE/MAX_VALUE are being re-declared in multiple UD30x9 test modules. Keeping those shared fixtures alongside fixed/expect would make the suite less repetitive and reduce drift if the numeric format ever changes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@math/fixed_point/tests/ud30x9_tests/helpers.move` around lines 19 - 25, The
test suite duplicates SCALE and MAX_VALUE across UD30x9 test modules; move those
shared constants into the same helpers.move module that already defines
fixed(value: u128): UD30x9 and expect(left: UD30x9, right: UD30x9) so all tests
import them from one place—add public(package) const SCALE and MAX_VALUE
(matching UD30x9 format) to the helpers.move file and update tests to use
helpers.SCALE and helpers.MAX_VALUE rather than redeclaring them, leaving fixed
and expect unchanged.
math/fixed_point/tests/sd29x9_tests/helpers.move (1)

19-28: Centralize shared SD29x9 fixtures here.

This helper is already the shared entry point for constructors and assertions. Pulling SCALE and any other common test constants into it would remove the repeated per-file declarations across the split SD29x9 suite.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@math/fixed_point/tests/sd29x9_tests/helpers.move` around lines 19 - 28, Add
shared test constants (e.g., public(package) const SCALE: u128 and any other
repeated constants) into this helper module so all SD29x9 tests can import them
from one place; keep the existing factory helpers (pos, neg) and assertion
(expect) as-is (sd29x9::wrap, SD29x9, pos, neg, expect) and update test files to
use the centralized SCALE and other constants instead of redefining them
per-file. Ensure the constants are exported with public(package) visibility and
named consistently so callers can reference SCALE, and add any additional
commonly reused constants here to avoid duplication across the SD29x9 suite.
math/fixed_point/tests/ud30x9_tests/pow_tests.move (1)

44-52: Consider consolidating duplicate overflow tests.

Both pow_overflow_aborts_for_large_base and pow_overflow_aborts_with_correct_abort_code test the same behavior (overflow abort with EOverflow). The only difference is the exponent (2 vs 32), but both trigger overflow on max(). One test would suffice unless there's specific behavior you want to pin for different exponent magnitudes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@math/fixed_point/tests/ud30x9_tests/pow_tests.move` around lines 44 - 52,
These two tests duplicate the same overflow behavior for ud30x9::max().pow(...);
consolidate by keeping a single overflow test (e.g.,
pow_overflow_aborts_for_large_base) that asserts the expected_failure(abort_code
= ud30x9_base::EOverflow) when calling ud30x9::max().pow(...) and remove the
other redundant test; alternatively, replace both with one parameterized test or
a small loop inside one test that calls ud30x9::max().pow(exponent) for
exponents (2, 32) and expects ud30x9_base::EOverflow, ensuring the test name and
expected_failure attribute reference pow and EOverflow accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@math/fixed_point/tests/ud30x9_tests/casting_tests.move`:
- Around line 4-8: Add an import for std::option so option::some() and
option::none() are in scope: update the top-of-file imports (where use
openzeppelin_fp_math::sd29x9, ud30x9, ud30x9_base, ud30x9_test_helpers::fixed,
and std::unit_test::assert_eq are declared) to include use std::option; so the
tests that call option::some and option::none compile.

---

Nitpick comments:
In `@math/fixed_point/tests/sd29x9_tests/helpers.move`:
- Around line 19-28: Add shared test constants (e.g., public(package) const
SCALE: u128 and any other repeated constants) into this helper module so all
SD29x9 tests can import them from one place; keep the existing factory helpers
(pos, neg) and assertion (expect) as-is (sd29x9::wrap, SD29x9, pos, neg, expect)
and update test files to use the centralized SCALE and other constants instead
of redefining them per-file. Ensure the constants are exported with
public(package) visibility and named consistently so callers can reference
SCALE, and add any additional commonly reused constants here to avoid
duplication across the SD29x9 suite.

In `@math/fixed_point/tests/ud30x9_tests/helpers.move`:
- Around line 19-25: The test suite duplicates SCALE and MAX_VALUE across UD30x9
test modules; move those shared constants into the same helpers.move module that
already defines fixed(value: u128): UD30x9 and expect(left: UD30x9, right:
UD30x9) so all tests import them from one place—add public(package) const SCALE
and MAX_VALUE (matching UD30x9 format) to the helpers.move file and update tests
to use helpers.SCALE and helpers.MAX_VALUE rather than redeclaring them, leaving
fixed and expect unchanged.

In `@math/fixed_point/tests/ud30x9_tests/pow_tests.move`:
- Around line 44-52: These two tests duplicate the same overflow behavior for
ud30x9::max().pow(...); consolidate by keeping a single overflow test (e.g.,
pow_overflow_aborts_for_large_base) that asserts the expected_failure(abort_code
= ud30x9_base::EOverflow) when calling ud30x9::max().pow(...) and remove the
other redundant test; alternatively, replace both with one parameterized test or
a small loop inside one test that calls ud30x9::max().pow(exponent) for
exponents (2, 32) and expects ud30x9_base::EOverflow, ensuring the test name and
expected_failure attribute reference pow and EOverflow accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fc97247c-22c4-484f-8266-a2506a69ba3d

📥 Commits

Reviewing files that changed from the base of the PR and between 1426e0a and ac78baf.

📒 Files selected for processing (30)
  • math/fixed_point/tests/sd29x9_tests.move
  • math/fixed_point/tests/sd29x9_tests/abs_tests.move
  • math/fixed_point/tests/sd29x9_tests/arithmetic_tests.move
  • math/fixed_point/tests/sd29x9_tests/bitwise_tests.move
  • math/fixed_point/tests/sd29x9_tests/casting_tests.move
  • math/fixed_point/tests/sd29x9_tests/ceil_tests.move
  • math/fixed_point/tests/sd29x9_tests/comparison_tests.move
  • math/fixed_point/tests/sd29x9_tests/div_tests.move
  • math/fixed_point/tests/sd29x9_tests/floor_tests.move
  • math/fixed_point/tests/sd29x9_tests/helpers.move
  • math/fixed_point/tests/sd29x9_tests/mod_tests.move
  • math/fixed_point/tests/sd29x9_tests/mul_tests.move
  • math/fixed_point/tests/sd29x9_tests/negate_tests.move
  • math/fixed_point/tests/sd29x9_tests/pow_tests.move
  • math/fixed_point/tests/sd29x9_tests/unchecked_tests.move
  • math/fixed_point/tests/sd29x9_tests/wrap_tests.move
  • math/fixed_point/tests/ud30x9_tests.move
  • math/fixed_point/tests/ud30x9_tests/abs_tests.move
  • math/fixed_point/tests/ud30x9_tests/arithmetic_tests.move
  • math/fixed_point/tests/ud30x9_tests/bitwise_tests.move
  • math/fixed_point/tests/ud30x9_tests/casting_tests.move
  • math/fixed_point/tests/ud30x9_tests/ceil_tests.move
  • math/fixed_point/tests/ud30x9_tests/comparison_tests.move
  • math/fixed_point/tests/ud30x9_tests/div_tests.move
  • math/fixed_point/tests/ud30x9_tests/floor_tests.move
  • math/fixed_point/tests/ud30x9_tests/helpers.move
  • math/fixed_point/tests/ud30x9_tests/mul_tests.move
  • math/fixed_point/tests/ud30x9_tests/pow_tests.move
  • math/fixed_point/tests/ud30x9_tests/unchecked_tests.move
  • math/fixed_point/tests/ud30x9_tests/wrap_tests.move
💤 Files with no reviewable changes (2)
  • math/fixed_point/tests/sd29x9_tests.move
  • math/fixed_point/tests/ud30x9_tests.move

Comment thread math/fixed_point/tests/ud30x9_tests/casting_tests.move

@ericnordelo ericnordelo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ericnordelo
ericnordelo merged commit f2cd250 into release-v1.1 Mar 10, 2026
14 checks passed
@ericnordelo
ericnordelo deleted the fixed-point-tests-restructure branch March 10, 2026 12:30
bidzyyys added a commit that referenced this pull request Mar 16, 2026
* ref: tests for fixed-point package (#248)

* Removed test files aggregating all type's tests

* Refactor fixed-point test suite, add more test cases

* Format files

* tests: apply AI comments

* fix: apply review comments

* fix: apply comment

---------

Co-authored-by: Daniel Bigos <daniel.bigos@icloud.com>

* feat: update CHANGELOG (#249)

* ref: apply auditor3 improvements to rc (#254)

* feat: update CHANGELOG

* feat: apply improvements

* build: sui v1.67.3 (#252)

* ref: apply auditor3 fp math improvements (#255)

* feat: update CHANGELOG

* feat: update comment

* feat: add more doc entries

* feat: add more comments

* feat: apply copilot suggestions

---------

Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>
Co-authored-by: Daniel Bigos <daniel.bigos@icloud.com>
Co-authored-by: Daniel Bigos <daniel.bigos@openzeppelin.com>
ericnordelo added a commit that referenced this pull request Apr 21, 2026
* ref: tests for fixed-point package (#248)

* Removed test files aggregating all type's tests

* Refactor fixed-point test suite, add more test cases

* Format files

* tests: apply AI comments

* fix: apply review comments

* fix: apply comment

---------

Co-authored-by: Daniel Bigos <daniel.bigos@icloud.com>

* feat: update CHANGELOG (#249)

* ref: apply auditor3 improvements to rc (#254)

* feat: update CHANGELOG

* feat: apply improvements

* build: sui v1.67.3 (#252)

* ref: apply auditor3 fp math improvements (#255)

* feat: update CHANGELOG

* feat: update comment

* feat: add more doc entries

* feat: add more comments

* feat: apply copilot suggestions

* build: Sui mainnet-v1.68.1 (#265)

* test: change expect helper function into macro (#282)

* test: change expect helper function into macro

* test: fmt

* test: remove expect macro

* test: use assert_eq instead of .eq on fp values

* fix: add missing 10^77 entry to u256::is_power_of_ten lookup table (#291)

* fix: add missing 10^77 entry to u256::is_power_of_ten lookup table

* chore: add missing PR id to changelog entry

* docs: fix module name in quick_sort example docs (#296)

* fix: Fixed-Point `pow` Now Uses Binary Exponentiation (#281)

* ref: use binary exponentiation in sd29x9 pow

* test: change pow invariant to exact result value

* ref: add newline

* doc: update

* fix: assert base limit in sd29x9 pow

* test: increase exp in pow_overflow_aborts_for_large_base

* ref: apply binary exponentiation in ud30x9::pow

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Enhance pow_tests with grouping behavior check (#283)

* Enhance pow_tests with grouping behavior check

Add test for rounding behavior in binary exponentiation with large exponents.

* Add expect_ne to sd29x9_pow_tests

* Add inequality assertion macro for SD29x9

Added a new macro 'expect_ne' to assert inequality between two SD29x9 values.

* Improve expect_ne macro with debugging output

Refactor expect_ne macro to unwrap values and add debug output on assertion failure.

* Refactor expect_ne macro for better readability

Refactor expect_ne macro to unwrap values after assignment.

* Fix debug print statements in assertion check

* Enhance ud30x9 pow tests with expect_ne for validation

Added expect_ne helper to validate non-equality in pow tests.

* Enhance pow test with comment on exponent behavior

Add comment about rounding/truncation behavior in pow test.

* Update math/fixed_point/sources/sd29x9/sd29x9_base.move

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* test: Add expect_ne macro for inequality assertions in ud30x9

* Refactor pow test for clarity and reuse result

* test: precalculate val.pow(255) in ud30x9

* test: fix to use fixed instead of pos in ud30x9

* refactor: extract binary_pow helper, replace expect with assert_eq in pow_tests, use pow(2) for overflow test

Agent-Logs-Url: https://github.com/OpenZeppelin/contracts-sui/sessions/96584ab5-2b3d-4442-9775-45db402402a7

Co-authored-by: bidzyyys <25967634+bidzyyys@users.noreply.github.com>

* refactor: format binary_pow parameters and adjust pow overflow test exponent

* ref: revert pow logic: no longer use internal helper

* test: remove redundant unwraps

* test: revert changes to unwrap

* ref: shadow exp instead of mutating fun param

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bidzyyys <25967634+bidzyyys@users.noreply.github.com>

* fix: `EUnderflow` for `SD30x9` (N-03) (#297)

* Fix audit issue N-03

* Add changelog entry

---------

Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>

* fix: changed `mod`, add `rem` (L-03) (#301)

* Add `rem` function for truncated remainder semantics on SD29x9

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Redefine `mod` on SD29x9 to use Euclidean remainder semantics

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Update changelog

* Improve the mod code slightly

* Remove unnecessary dots from the changelog

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Daniel Bigos <daniel.bigos@openzeppelin.com>
Co-authored-by: Nenad <nenad.misic@openzeppelin.com>

* feat: improve fp math conversion API (#264)

* feat: update CHANGELOG

* feat: add conversion API

* feat: add pending files

* feat: improve API

* feat: add missing files

* feat: update CHANGELOG

* feat: remove casting

* feat: reuse macro constant

* feat: apply review updates

* fix: nits

* feat: apply review updates

---------

Co-authored-by: Daniel Bigos <daniel.bigos@openzeppelin.com>
Co-authored-by: Nenad <nenad.misic@openzeppelin.com>

* Remove SD29x9 bitwise operations (#285)

* feat: update CHANGELOG

* refactor: remove bitwise operations for SD

---------

Co-authored-by: Nenad <nenad.misic@openzeppelin.com>

* Rounding Direction improvements (L-06 & N-04) (#289)

* feat: update CHANGELOG

* feat: apply review updates

* feat: add division checks

* feat: apply review updates

* feat: apply copilot suggestions

* feat: centralize common helpers

* feat: update CHNGELOG

* feat: apply suggestion

* ref: sd29x9::pow intermediate positive values are strictly < min. neg. value (#280)

* ref: sd29x9::pow intermediate pos. value must be < min. neg. value

* refactor: rename limit to min_negative and simplify overflow check in pow

Agent-Logs-Url: https://github.com/OpenZeppelin/contracts-sui/sessions/af15164d-616a-4f49-9fd9-8abc5f612c5f

Co-authored-by: 0xNeshi <19427053+0xNeshi@users.noreply.github.com>

* chore: update changelog

* chore: fix pr id

* ref: rename min_negative->max_mag in wrap_components

* refactor: use macro expressions for max whole value constants

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* feat: Support both checked and unchecked versions of left and right shift (#288)

* feat: rename lshift -> unchecked_lshift

* chore: update changelog

* docs: add missing error documentation for EOverflow in ud30x9

* ref: use ud30x9::zero instead of manual wrap(0)

* feat: add new checked version of ud30x9::lshift

* feat: rename ud30x9::rshift -> unchecked_rshift

* feat: add new checked version of ud30x9::rshift

* docs: mention unchecked shifts in README

* chore: add missing PR ids to new changelog entries

* ref: reimplement to avoid casts in lshift

* ref: remove zero-value special cases from lshift and rshift

* feat: add EInvalidShiftSize error for shift operations

Replace EOverflow with EInvalidShiftSize for shift size validation in lshift and rshift functions. Update corresponding test cases to expect the new error code.

* chore: fix pr id

* chore: reword changelog

* docs: clarify EOverflow range

* docs: reference checked and unchecked shifts in each other's docs

* chore: move back `rem` changeling

* chore: remove rem entry from changed

* refactor: use `std::u128::max_value!()` macro in `lshift`

* build: Sui mainnet-v1.69.2 (#302)

* ref: replace Lomuto partition with three-way partitioning in quicksort  (#298)

* feat: use insertion sort for vectors with up to 10 elements

* ref: replace Lomuto partition with three-way partitioning in quicksort

Replace the Lomuto partition scheme with three-way partitioning (Dutch National Flag scheme) to handle duplicate elements more efficiently. Move insertion sort optimization from preprocessing to inline handling of small sub-partitions (≤10 elements) during partitioning. Remove the standalone `insertion_sort_by` helper macro as it's now inlined.

* chore: changelog

* chore: fix wording in changelog

* fix: update vector size check

* docs: reword three way partition comment

* test: add quick_sort tests

* test: remove redundant quick_sort test cases

Remove three test cases that are already covered by existing tests: quick_sort_partition_edge_case_pivot - Subset of quick_sort_already_sorted; ≤10 elements doesn't test pivot
quick_sort_single_large_value_at_start - Same pattern as quick_sort_mostly_sorted_with_one_outlier
quick_sort_single_small_value_at_end - Same pattern as quick_sort_mostly_sorted_with_one_outlier_at_end

* ref: swap in insertion sort only when prev. is strictly less

* test: remove comment mentions of specific code lines

* test: clarify comment and fix test function name

Update comment in quick_sort_by_descending_large_vector to clarify that >10 elements forces quicksort partitioning before insertion sort. Rename quick_sort_by_sort_by_id_ascending to quick_sort_by_id_ascending to remove redundant "sort_by" prefix.

* chore: mention quick_sort in changelog

* docs: align generic type name with actual quick_sort_by generic name

* test: increase code coverage with quick_sort tests

* Revert "test: increase code coverage with quick_sort tests"

This reverts commit 47439ca.

* docs: clarify quick_sort worst-case complexity and comparator requirements

Update documentation for `quick_sort` and `quick_sort_by` to clarify that O(n²) worst-case is practically unreachable due to median-of-three pivot selection and three-way partitioning. Add warning that strict comparators (e.g., `<` instead of `<=`) can degrade performance to O(n²) with duplicate elements by defeating three-way partitioning optimization.

* docs: clarify impact of sctrict comparison operators

* docs: soften wording for worst case scenario

* test: ensure quick_sort_by_median_of_three_crafted_inputs covers all branches

* fix: handle empty, single-element & edge cases in quick_sort

* docs: align range notation for eq_end

---------

Co-authored-by: Daniel Bigos <daniel.bigos@openzeppelin.com>

* feat: update CHANGELOG

* feat: update error constant name

* Fix error constant name (#303)

* feat: update CHANGELOG

* feat: update error constant name

* fix: CHANGELOG

* fix: comment

* Add audit reports (#305)

* feat: update CHANGELOG

* feat: add audits

* feat: add published info

---------

Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>
Co-authored-by: Daniel Bigos <daniel.bigos@icloud.com>
Co-authored-by: Daniel Bigos <daniel.bigos@openzeppelin.com>
Co-authored-by: Nenad <nenad.misic@openzeppelin.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bidzyyys <25967634+bidzyyys@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

3 participants