diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2021-02-17 04:52:46 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-17 11:52:46 +0100 |
commit | 4f118721be7b515f1d5e6fb66ae9e73ddb819f02 (patch) | |
tree | 58914fca366d8b1344e5700a5ea0be240ee547e2 /tests | |
parent | f32ffb6ed821cc01e52c48181a4caa15e73c0362 (diff) | |
download | Nim-4f118721be7b515f1d5e6fb66ae9e73ddb819f02.tar.gz |
make system random work in VM (#17059)
* make system random work in VM
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/tsysrand.nim | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/tests/stdlib/tsysrand.nim b/tests/stdlib/tsysrand.nim index d248849f8..2d00dafe0 100644 --- a/tests/stdlib/tsysrand.nim +++ b/tests/stdlib/tsysrand.nim @@ -1,13 +1,36 @@ discard """ targets: "c cpp js" + matrix: "--experimental:vmopsDanger" """ import std/sysrand -doAssert urandom(0).len == 0 -doAssert urandom(10).len == 10 -doAssert urandom(20).len == 20 -doAssert urandom(120).len == 120 -doAssert urandom(113).len == 113 -doAssert urandom(1234) != urandom(1234) # unlikely to fail in practice +template main() = + block: + var x = array[5, byte].default + doAssert urandom(x) + + block: + var x = newSeq[byte](5) + doAssert urandom(x) + + block: + var x = @[byte(0), 0, 0, 0, 0] + doAssert urandom(x) + + block: + var x = @[byte(1), 2, 3, 4, 5] + doAssert urandom(x) + + block: + doAssert urandom(0).len == 0 + doAssert urandom(10).len == 10 + doAssert urandom(20).len == 20 + doAssert urandom(120).len == 120 + doAssert urandom(113).len == 113 + doAssert urandom(1234) != urandom(1234) # unlikely to fail in practice + + +static: main() +main() |