Skip to content

Commit e868dba

Browse files
committed
FIX: not truncating random time to seconds only
resolves: Oldes/Rebol-issues#911
1 parent a264a69 commit e868dba

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/core/t-time.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@
532532
Set_Random(secs);
533533
return R_UNSET;
534534
}
535-
secs = Random_Range(secs / SEC_SEC, D_REF(3)) * SEC_SEC;
535+
secs = Random_Range(secs, D_REF(3));
536536
goto fixTime;
537537

538538
case A_PICK:

src/tests/units/time-test.r3

+13
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ Rebol [
103103

104104
===end-group===
105105

106+
===start-group=== "random"
107+
--test-- "random time!"
108+
;@@ https://github.com/Oldes/Rebol-issues/issues/911
109+
t: random 0:0:0.10
110+
--assert all [t > 0:0 t < 0:0:0.10]
111+
t: random 1:0:0
112+
--assert all [t > 0:0 t < 1:0:0]
113+
114+
115+
===end-group===
116+
117+
118+
106119
;===start-group=== "time protect"
107120
; ;@@ https://github.com/Oldes/Rebol-issues/issues/2416
108121
; --test-- "time protect 1"

0 commit comments

Comments
 (0)