Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no squash] Unittest and some documentation things #14238

Merged
merged 9 commits into from Jan 14, 2024
Merged

Conversation

sfan5
Copy link
Member

@sfan5 sfan5 commented Jan 10, 2024

notable thing: you can now properly run unit tests from an installed MT build because it no longer tries to read from /home/you/where/ever/the/source/was (when it isn't anymore).
it will still skip some if you don't have devtest however.

@sfan5 sfan5 added Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements Bugfix 🐛 PRs that fix a bug labels Jan 10, 2024
Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

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

first comments

src/unittest/test_moveaction.cpp Show resolved Hide resolved
src/unittest/test_servermodmanager.cpp Outdated Show resolved Hide resolved
doc/developing/misc.md Outdated Show resolved Hide resolved
{
m_next = seed;
}

inline int next()
inline u32 next()
{
m_next = m_next * 1103515245 + 12345;
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of scope for this PR to fix, but isn't there some integer overflow UB here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wondered about that too and signed overflow is indeed UB.
Converting it to unsigned (while keeping compatibility with the negative seeds) would be a bother...

@@ -70,14 +70,14 @@ class PseudoRandom {
PcgRandom, we cannot modify this RNG's range as it would change the
output of this RNG for reverse compatibility.
*/
if ((u32)(max - min) > (RANDOM_RANGE + 1) / 10)
if ((u32)(max - min) > (RANDOM_RANGE + 1) / 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the 10 become 5?

Copy link
Member Author

Choose a reason for hiding this comment

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

see commit msg

@@ -8057,7 +8057,9 @@ A 32-bit pseudorandom number generator.
Uses PCG32, an algorithm of the permuted congruential generator family,
offering very strong randomness.

It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`.
* constructor `PcgRandom(seed, [seq])`
* `seed`: 64-bit unsigned seed
Copy link
Contributor

Choose a reason for hiding this comment

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

Not this PR's job to fix, but this is fishy since on the Lua side of things, we can only represent integers up to 2^53 accurately.

Copy link
Member Author

Choose a reason for hiding this comment

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

🤷

doc/developing/misc.md Outdated Show resolved Hide resolved
I think it's better suited here than in the wiki.
@sfan5 sfan5 merged commit dd094d7 into minetest:master Jan 14, 2024
15 checks passed
@sfan5 sfan5 deleted the psr branch January 14, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix 🐛 PRs that fix a bug Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements One approval ✅ ◻️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants