diff options
| -rw-r--r-- | test.R | 44 | ||||
| -rw-r--r-- | test.py | 34 |
2 files changed, 78 insertions, 0 deletions
@@ -0,0 +1,44 @@ + +source('./SyncRNG.R') + +test.randi <- function() +{ + s <- SyncRNG(seed=123456) + for (i in 1:5) + cat(s$randi(), '\n') +} + +test.rand <- function() +{ + s <- SyncRNG(seed=123456) + for (i in 1:5) + cat(s$rand(), '\n') +} + +test.randbelow <- function() +{ + s <- SyncRNG(seed=123456) + for (i in 1:5) + cat(s$randbelow(i), '\n') +} + +test.shuffle <- function() +{ + s <- SyncRNG(seed=123456) + x <- c(1:5) + for (i in 1:5) { + y <- s$shuffle(x) + x <- y + cat(y, '\n') + } +} + +main <- function() +{ + test.randi() + test.rand() + test.randbelow() + test.shuffle() +} + +main() @@ -0,0 +1,34 @@ + +from SyncRNG import SyncRNG + +def test_randi(): + s = SyncRNG(seed=123456) + for i in range(5): + print(s.randi()) + +def test_rand(): + s = SyncRNG(seed=123456) + for i in range(5): + print(s.rand()) + +def test_randbelow(): + s = SyncRNG(seed=123456) + for i in range(5): + print(s.randbelow(i+1)) + +def test_shuffle(): + s = SyncRNG(seed=123456) + x = [1, 2, 3, 4, 5] + for i in range(5): + y = s.shuffle(x) + x = y + print(y) + +def main(): + test_randi() + test_rand() + test_randbelow() + test_shuffle() + +if __name__ == '__main__': + main() |
