Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c3312760
Commit
c3312760
authored
Apr 18, 2012
by
antirez
Browse files
Tests for scripting PRNG.
parent
1d82bbd4
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/unit/scripting.tcl
View file @
c3312760
...
@@ -251,6 +251,26 @@ start_server {tags {"scripting"}} {
...
@@ -251,6 +251,26 @@ start_server {tags {"scripting"}} {
lappend res
[
r eval $decr_if_gt 1 foo 2
]
lappend res
[
r eval $decr_if_gt 1 foo 2
]
set res
set res
}
{
4 3 2 2 2
}
}
{
4 3 2 2 2
}
test
{
Scripting engine resets PRNG at every script execution
}
{
set rand1
[
r eval
{
return tostring
(
math.random
())}
0
]
set rand2
[
r eval
{
return tostring
(
math.random
())}
0
]
assert_equal $rand1 $rand2
}
test
{
Scripting engine PRNG can be seeded correctly
}
{
set rand1
[
r eval
{
math.randomseed
(
ARGV
[
1
]);
return tostring
(
math.random
())
}
0 10
]
set rand2
[
r eval
{
math.randomseed
(
ARGV
[
1
]);
return tostring
(
math.random
())
}
0 10
]
set rand3
[
r eval
{
math.randomseed
(
ARGV
[
1
]);
return tostring
(
math.random
())
}
0 20
]
assert_equal $rand1 $rand2
assert
{
$rand2
ne $rand3
}
}
}
}
start_server
{
tags
{
"scripting repl"
}}
{
start_server
{
tags
{
"scripting repl"
}}
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment