From 39a65f93feb4bb5348db302a33dcd5c3fcd2fcff Mon Sep 17 00:00:00 2001 From: karishka1222 Date: Sun, 29 Jun 2025 11:40:47 +0300 Subject: [PATCH 1/8] fix: make random test deterministic to avoid flakiness --- eo-runtime/src/main/eo/org/eolang/math/random.eo | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eo-runtime/src/main/eo/org/eolang/math/random.eo b/eo-runtime/src/main/eo/org/eolang/math/random.eo index cb5c8774e8c..09f39b6056a 100644 --- a/eo-runtime/src/main/eo/org/eolang/math/random.eo +++ b/eo-runtime/src/main/eo/org/eolang/math/random.eo @@ -97,6 +97,9 @@ (random 123).fixed > rand # This unit test is supposed to check the functionality of the corresponding object. + # Fixed flaky test: instead of comparing two pseudo-random numbers (which can be equal + # due to identical system time), we compare two deterministic random numbers with + # different seeds. This ensures the test is reliable and deterministic. [] +> tests-two-random-numbers-not-equal not. > @ - random.pseudo.eq random.pseudo + (random 123).fixed.eq (random 456).fixed From 57f806e37ce753ac6ae21422d675e665bb6363a7 Mon Sep 17 00:00:00 2001 From: karishka1222 Date: Fri, 18 Jul 2025 11:04:15 +0300 Subject: [PATCH 2/8] fix flaky random.pseudo by adding a global counter to seed --- eo-runtime/src/main/eo/org/eolang/math/random.eo | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/math/random.eo b/eo-runtime/src/main/eo/org/eolang/math/random.eo index 09f39b6056a..8c7a0825764 100644 --- a/eo-runtime/src/main/eo/org/eolang/math/random.eo +++ b/eo-runtime/src/main/eo/org/eolang/math/random.eo @@ -34,9 +34,18 @@ 11 00-0F-FF-FF-FF-FF-FF-FF + # Global counter to ensure unique seed even if time is the same + 0 > pseudo-counter + # New random with pseudo-random seed. [] > pseudo - random time-seed > @ + seq. > @ + pseudo-counter.write + pseudo-counter.plus 1 + random + plus. + time-seed + pseudo-counter (posix "gettimeofday" *).output > timeval as-number. > time-seed plus. @@ -102,4 +111,4 @@ # different seeds. This ensures the test is reliable and deterministic. [] +> tests-two-random-numbers-not-equal not. > @ - (random 123).fixed.eq (random 456).fixed + random.pseudo.eq random.pseudo From 502d54db8b30feeb9ad85459f28fa39bc5460935 Mon Sep 17 00:00:00 2001 From: karishka1222 Date: Fri, 18 Jul 2025 11:05:31 +0300 Subject: [PATCH 3/8] deleted comment --- eo-runtime/src/main/eo/org/eolang/math/random.eo | 3 --- 1 file changed, 3 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/math/random.eo b/eo-runtime/src/main/eo/org/eolang/math/random.eo index 8c7a0825764..342879fd1a7 100644 --- a/eo-runtime/src/main/eo/org/eolang/math/random.eo +++ b/eo-runtime/src/main/eo/org/eolang/math/random.eo @@ -106,9 +106,6 @@ (random 123).fixed > rand # This unit test is supposed to check the functionality of the corresponding object. - # Fixed flaky test: instead of comparing two pseudo-random numbers (which can be equal - # due to identical system time), we compare two deterministic random numbers with - # different seeds. This ensures the test is reliable and deterministic. [] +> tests-two-random-numbers-not-equal not. > @ random.pseudo.eq random.pseudo From 83292580df945e5781e5f950ce00ec602114d281 Mon Sep 17 00:00:00 2001 From: karishka1222 Date: Fri, 25 Jul 2025 11:37:37 +0300 Subject: [PATCH 4/8] fixed ci cd --- eo-runtime/src/main/eo/org/eolang/math/random.eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-runtime/src/main/eo/org/eolang/math/random.eo b/eo-runtime/src/main/eo/org/eolang/math/random.eo index 5d8622bedcd..f2392a8ce69 100644 --- a/eo-runtime/src/main/eo/org/eolang/math/random.eo +++ b/eo-runtime/src/main/eo/org/eolang/math/random.eo @@ -41,7 +41,7 @@ # New random with pseudo-random seed. [] > pseudo - seq. > @ + seq. > @ pseudo-counter.write pseudo-counter.plus 1 random From 1958015813ccfaa570f0d5849ea00fc3b61f4ec0 Mon Sep 17 00:00:00 2001 From: karishka1222 Date: Fri, 25 Jul 2025 11:45:25 +0300 Subject: [PATCH 5/8] fixed ci cd --- .../src/main/eo/org/eolang/math/random.eo | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/math/random.eo b/eo-runtime/src/main/eo/org/eolang/math/random.eo index f2392a8ce69..c9301bcec3b 100644 --- a/eo-runtime/src/main/eo/org/eolang/math/random.eo +++ b/eo-runtime/src/main/eo/org/eolang/math/random.eo @@ -7,8 +7,6 @@ +version 0.0.0 +spdx SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com +spdx SPDX-License-Identifier: MIT -+unlint redundant-object:20 -+unlint redundant-object:28 # Generates a pseudo-random number. [seed] > random @@ -58,18 +56,12 @@ plus. as-i64. and. - time-bytes.left const-1 - ((one.left 53).as-i64.minus one).as-bytes - plus. - as-i64. - and. - time-bytes.left const-3 - ((one.left const-1).as-i64.minus one).as-bytes - as-i64. - and. - time-bytes - ((one.left const-3).as-i64.minus one).as-bytes - (posix "gettimeofday" *).output > timeval + time-bytes.left const-3 + ((one.left const-1).as-i64.minus one).as-bytes + as-i64. + and. + time-bytes + ((one.left const-3).as-i64.minus one).as-bytes as-bytes. > time-bytes as-i64. if. @@ -80,6 +72,7 @@ as-number. timeval.tv-usec.as-i64.div 1000.as-i64 35 > const-1 + 53 > const-2 17 > const-3 00-00-00-00-00-00-00-01 > one @@ -115,4 +108,4 @@ # This unit test is supposed to check the functionality of the corresponding object. [] +> tests-two-random-numbers-not-equal not. > @ - random.pseudo.eq random.pseudo + random.pseudo.eq random.pseudo \ No newline at end of file From e965bebd0e5a404311ecd0ef95c31e0d5097e45f Mon Sep 17 00:00:00 2001 From: karishka1222 Date: Fri, 25 Jul 2025 11:56:49 +0300 Subject: [PATCH 6/8] fixed ci cd --- eo-runtime/src/main/eo/org/eolang/math/random.eo | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eo-runtime/src/main/eo/org/eolang/math/random.eo b/eo-runtime/src/main/eo/org/eolang/math/random.eo index c9301bcec3b..cb08eb8bea3 100644 --- a/eo-runtime/src/main/eo/org/eolang/math/random.eo +++ b/eo-runtime/src/main/eo/org/eolang/math/random.eo @@ -108,4 +108,7 @@ # This unit test is supposed to check the functionality of the corresponding object. [] +> tests-two-random-numbers-not-equal not. > @ - random.pseudo.eq random.pseudo \ No newline at end of file + (eq. + random.pseudo + random.pseudo + ) \ No newline at end of file From a6d682fa7b19f1524a9a7bfc99390d002df23a57 Mon Sep 17 00:00:00 2001 From: karishka1222 Date: Fri, 25 Jul 2025 12:08:50 +0300 Subject: [PATCH 7/8] fixed ci cd --- .../src/main/eo/org/eolang/math/random.eo | 58 +++++++++---------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/eo-runtime/src/main/eo/org/eolang/math/random.eo b/eo-runtime/src/main/eo/org/eolang/math/random.eo index cb08eb8bea3..78396cdbb82 100644 --- a/eo-runtime/src/main/eo/org/eolang/math/random.eo +++ b/eo-runtime/src/main/eo/org/eolang/math/random.eo @@ -76,39 +76,35 @@ 17 > const-3 00-00-00-00-00-00-00-01 > one - # This unit test is supposed to check the functionality of the corresponding object. - [] +> tests-random-with-seed - not. > @ - eq. - r.next - r.next.next - random 51 > r +[] +> tests-random-with-seed + not. > @ + eq. + r.next + r.next.next + random 51 > r - # This unit test is supposed to check the functionality of the corresponding object. - [] +> tests-seeded-randoms-are-equal - eq. > @ - (random 1654).next.next.next - (random 1654).next.next.next +[] +> tests-seeded-randoms-are-equal + eq. > @ + (random 1654).next.next.next + (random 1654).next.next.next - # This unit test is supposed to check the functionality of the corresponding object. - [] +> tests-random-is-in-range - and. > @ +[] +> tests-random-is-in-range + and. > @ + and. and. - and. - rand.lt 1 - (rand.lt 0).not - and. - rand.next.lt 1 - (rand.next.lt 0).not + rand.lt 1 + (rand.lt 0).not and. - rand.next.next.lt 1 - (rand.next.next.lt 0).not - (random 123).fixed > rand + rand.next.lt 1 + (rand.next.lt 0).not + and. + rand.next.next.lt 1 + (rand.next.next.lt 0).not + (random 123).fixed > rand - # This unit test is supposed to check the functionality of the corresponding object. - [] +> tests-two-random-numbers-not-equal - not. > @ - (eq. - random.pseudo - random.pseudo - ) \ No newline at end of file +[] +> tests-two-random-numbers-not-equal + not. > @ + (eq. + (random.pseudo) + (random.pseudo) + ) \ No newline at end of file From 98edb013a29b4675c21f83994254d466d0f83262 Mon Sep 17 00:00:00 2001 From: karishka1222 Date: Fri, 25 Jul 2025 12:11:52 +0300 Subject: [PATCH 8/8] fixed ci cd --- eo-runtime/src/main/eo/org/eolang/math/random.eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-runtime/src/main/eo/org/eolang/math/random.eo b/eo-runtime/src/main/eo/org/eolang/math/random.eo index 78396cdbb82..462efe61145 100644 --- a/eo-runtime/src/main/eo/org/eolang/math/random.eo +++ b/eo-runtime/src/main/eo/org/eolang/math/random.eo @@ -38,7 +38,7 @@ 0 > pseudo-counter # New random with pseudo-random seed. - [] > pseudo + > pseudo seq. > @ pseudo-counter.write pseudo-counter.plus 1