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
59333ffd
Commit
59333ffd
authored
Apr 13, 2012
by
antirez
Browse files
New test for scripting engine: DECR_IF_GT.
parent
9a2dd1ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/scripting.tcl
View file @
59333ffd
...
...
@@ -229,6 +229,28 @@ start_server {tags {"scripting"}} {
catch
{
r eval
{
a=10
}
0
}
e
set e
}
{
*ERR*attempted to create global*
}
test
{
Test an example script DECR_IF_GT
}
{
set decr_if_gt
{
local current
current = redis.call
(
'get',KEYS
[
1
])
if not current then return nil end
if current > ARGV
[
1
]
then
return redis.call
(
'decr',KEYS
[
1
])
else
return redis.call
(
'get',KEYS
[
1
])
end
}
r set foo 5
set res
{}
lappend res
[
r eval $decr_if_gt 1 foo 2
]
lappend res
[
r eval $decr_if_gt 1 foo 2
]
lappend res
[
r eval $decr_if_gt 1 foo 2
]
lappend res
[
r eval $decr_if_gt 1 foo 2
]
lappend res
[
r eval $decr_if_gt 1 foo 2
]
set res
}
{
4 3 2 2 2
}
}
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