Skip to content

Conversation

@tihiyn
Copy link
Contributor

@tihiyn tihiyn commented Jan 28, 2026

In this PR, I separated pow object from real. But the tests are still in real.eo due to the PR size limit.

Resolves: #4751

Summary by CodeRabbit

  • New Features

    • Added org.eolang.ms.pow operation for computing base raised to exponent, with comprehensive handling of edge cases including zero, negative exponents, infinity, and NaN.
  • Tests

    • Extensive test suite added covering integer powers, negative exponents, special values (infinity, NaN), and mixed numeric types.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

Extracted the power operation from org.eolang.ms.real into a new standalone org.eolang.ms.pow module; updated Java binding to accept an explicit num parameter; replaced inline (real e).pow calls with pow e x in EO sources and tests.

Changes

Cohort / File(s) Summary
New pow module & Java binding
eo-runtime/src/main/eo/org/eolang/ms/pow.eo, eo-runtime/src/main/java/EOorg/EOeolang/EOms/EOpow.java
Added org.eolang.ms.pow EO file and introduced EOpow Java class. Java class renamed/rewired to expose an explicit num parameter and compute power from that input rather than RHO.
Real object adjustments
eo-runtime/src/main/eo/org/eolang/ms/real.eo
Removed the inline pow method from real.eo and added an alias referencing org.eolang.ms.pow. Tests and references updated to call the standalone pow.
exp usage update
eo-runtime/src/main/eo/org/eolang/ms/exp.eo
Replaced (real e).pow x style usage with pow e x and added a public alias to org.eolang.ms.pow.

Sequence Diagram(s)

(omitted — changes are localized refactor/extraction and do not introduce a multi-component sequential flow requiring diagram)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped the code and found a pow,
Split from real — a freed up plow.
Now numbers climb with joyful cheer,
Small rabbit drums the change is near. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: separating the pow operation from the real object into a dedicated object.
Linked Issues check ✅ Passed The PR successfully extracts pow into a dedicated ms.pow object, directly addressing issue #4751's objective to create separate utility method objects.
Out of Scope Changes check ✅ Passed All changes are scoped to separating pow from real; no unrelated modifications to other components or functionality are present.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2026

🚀 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 189.642 208.835 19.193 10.12% ms/op Average Time

⚠️ Performance loss: benchmarks.XmirBench.xmirToEO is slower by 19.193 ms/op (10.12%)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@eo-runtime/src/main/eo/org/eolang/ms/pow.eo`:
- Around line 251-255: The test named
tests-positive-int-to-the-pow-of-positive-float-is-float is misleading because
it calls pow 4 5 (both integers); update the test to match its name by changing
the exponent to a float (e.g., replace the second argument with 5.0 in the pow
invocation) or alternatively rename the test to reflect integer arguments (e.g.,
tests-positive-int-to-the-pow-of-positive-int-is-int); edit the test declaration
and the pow call accordingly to keep name and behavior consistent (refer to the
test symbol tests-positive-int-to-the-pow-of-positive-float-is-float and the pow
invocation).
- Around line 42-44: The tests conflict: the case
"throws-on-negative-pow-of-zero" expects pow 0 -567 to throw while
"tests-zero-to-the-negative-pow-is-positive-infinity" expects pow 0 -52 to be
positive-infinity; reconcile them by making the behavior consistent with the
implementation (Java Math.pow returns Infinity). Update the test named
throws-on-negative-pow-of-zero to assert positive-infinity instead of expecting
an exception (replace the throw expectation with the same positive-infinity
assertion used in tests-zero-to-the-negative-pow-is-positive-infinity), keeping
the pow invocation and test name as needed.
- Around line 10-11: The docstring for the pow object contains a stray
apostrophe in "`num'`"; update the documentation line in pow.eo (the header for
the [num x] > pow ? object) to read "num" instead of "num'" so the description
becomes "An operation that raises num to the power of x".
🧹 Nitpick comments (1)
eo-runtime/src/main/java/EOorg/EOeolang/EOms/EOpow.java (1)

19-23: Update outdated Javadoc.

The Javadoc still references "Real.pow" but the class is now a standalone pow operation.

 /**
- * Real.pow.
+ * Pow.
  *
  * `@since` 0.40
  * `@checkstyle` TypeNameCheck (100 lines)
  */

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
eo-runtime/src/main/java/EOorg/EOeolang/EOms/EOpow.java (1)

19-23: Outdated Javadoc comment.

The Javadoc still says "Real.pow" but this class is now a standalone pow object, no longer nested under real.

📝 Suggested fix
 /**
- * Real.pow.
+ * Pow.
  *
  * `@since` 0.40
  * `@checkstyle` TypeNameCheck (100 lines)
  */

@tihiyn
Copy link
Contributor Author

tihiyn commented Jan 28, 2026

@yegor256, check please

@yegor256 yegor256 merged commit 43c56d3 into objectionary:master Jan 29, 2026
27 checks passed
@0crat
Copy link

0crat commented Jan 29, 2026

@tihiyn Hey there! 🎉 Nice work on that contribution - you've earned +12 points! Here's the breakdown: +16 base points, but -4 for going over 100 hits-of-code (you hit 117). To maximize your bonus next time, try to keep contributions under 100 lines and ensure there's a code review - it really helps boost those points! Your running score is now +68, so keep the momentum going and don't forget to check your Zerocracy account.

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