mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-18 13:49:59 +01:00
Add a random module.
This commit is contained in:
13
test/random/float.wren
Normal file
13
test/random/float.wren
Normal file
@ -0,0 +1,13 @@
|
||||
import "random" for Random
|
||||
|
||||
var random = Random.new(12345)
|
||||
|
||||
var below = 0
|
||||
for (i in 1..1000) {
|
||||
var n = random.float()
|
||||
if (n < 0.5) below = below + 1
|
||||
}
|
||||
|
||||
// Should be roughly evenly distributed.
|
||||
System.print(below > 450) // expect: true
|
||||
System.print(below < 550) // expect: true
|
||||
Reference in New Issue
Block a user