Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
13a21caa
Commit
13a21caa
authored
Apr 13, 2012
by
antirez
Browse files
New test for scripting engine: DECR_IF_GT.
parent
6f659f34
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/unit/scripting.tcl
View file @
13a21caa
...
@@ -229,6 +229,28 @@ start_server {tags {"scripting"}} {
...
@@ -229,6 +229,28 @@ start_server {tags {"scripting"}} {
catch
{
r eval
{
a=10
}
0
}
e
catch
{
r eval
{
a=10
}
0
}
e
set e
set e
}
{
*ERR*attempted to create global*
}
}
{
*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"
}}
{
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