Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
b02e0388
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b02e0388
编写于
5月 24, 2011
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Scripting tests added
上级
112c4442
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
127 addition
and
0 deletion
+127
-0
tests/test_helper.tcl
tests/test_helper.tcl
+1
-0
tests/unit/scripting.tcl
tests/unit/scripting.tcl
+126
-0
未找到文件。
tests/test_helper.tcl
浏览文件 @
b02e0388
...
...
@@ -125,6 +125,7 @@ proc execute_everything {} {
execute_tests
"integration/aof"
# execute_tests
"integration/redis-cli"
execute_tests
"unit/pubsub"
execute_tests
"unit/scripting"
# run tests with VM enabled
set ::global_overrides
{
vm-enabled yes
}
...
...
tests/unit/scripting.tcl
0 → 100644
浏览文件 @
b02e0388
start_server
{
tags
{
"scripting"
}}
{
test
{
EVAL - Does Lua interpreter replies to our requests?
}
{
r eval
{
return 'hello'
}
0
}
{
hello
}
test
{
EVAL - Lua integer -> Redis protocol type conversion
}
{
r eval
{
return 100.5
}
0
}
{
100
}
test
{
EVAL - Lua string -> Redis protocol type conversion
}
{
r eval
{
return 'hello world'
}
0
}
{
hello world
}
test
{
EVAL - Lua true boolean -> Redis protocol type conversion
}
{
r eval
{
return true
}
0
}
{
1
}
test
{
EVAL - Lua false boolean -> Redis protocol type conversion
}
{
r eval
{
return false
}
0
}
{}
test
{
EVAL - Lua status code reply -> Redis protocol type conversion
}
{
r eval
{
return
{
ok='fine'
}}
0
}
{
fine
}
test
{
EVAL - Lua error reply -> Redis protocol type conversion
}
{
catch
{
r eval
{
return
{
err='this is an error'
}}
0
}
e
set _ $e
}
{
this is an error
}
test
{
EVAL - Lua table -> Redis protocol type conversion
}
{
r eval
{
return
{
1,2,3,'ciao',
{
1,2
}}}
0
}
{
1 2 3 ciao
{
1 2
}}
test
{
EVAL - Are the KEYS and ARGS arrays populated correctly?
}
{
r eval
{
return
{
KEYS
[
1
]
,KEYS
[
2
]
,ARGV
[
1
]
,ARGV
[
2
]}}
2 a b c d
}
{
a b c d
}
test
{
EVAL - is Lua able to call Redis API?
}
{
r set mykey myval
r eval
{
return redis.call
(
'get','mykey'
)}
0
}
{
myval
}
test
{
EVALSHA - Can we call a SHA1 if already defined?
}
{
r evalsha 9bd632c7d33e571e9f24556ebed26c3479a87129 0
}
{
myval
}
test
{
EVALSHA - Do we get an error on non defined SHA1?
}
{
catch
{
r evalsha ffffffffffffffffffffffffffffffffffffffff 0
}
e
set _ $e
}
{
NOSCRIPT*
}
test
{
EVAL - Redis integer -> Lua type conversion
}
{
r eval
{
local foo = redis.call
(
'incr','x'
)
return
{
type
(
foo
)
,foo
}
}
0
}
{
number 1
}
test
{
EVAL - Redis bulk -> Lua type conversion
}
{
r set mykey myval
r eval
{
local foo = redis.call
(
'get','mykey'
)
return
{
type
(
foo
)
,foo
}
}
0
}
{
string myval
}
test
{
EVAL - Redis multi bulk -> Lua type conversion
}
{
r del mylist
r rpush mylist a
r rpush mylist b
r rpush mylist c
r eval
{
local foo = redis.call
(
'lrange','mylist',0,-1
)
return
{
type
(
foo
)
,foo
[
1
]
,foo
[
2
]
,foo
[
3
]
,# foo
}
}
0
}
{
table a b c 3
}
test
{
EVAL - Redis status reply -> Lua type conversion
}
{
r eval
{
local foo = redis.call
(
'set','mykey','myval'
)
return
{
type
(
foo
)
,foo
[
'ok'
]}
}
0
}
{
table OK
}
test
{
EVAL - Redis error reply -> Lua type conversion
}
{
r set mykey myval
r eval
{
local foo = redis.call
(
'incr','mykey'
)
return
{
type
(
foo
)
,foo
[
'err'
]}
}
0
}
{
table
{
ERR value is not an integer or out of range
}}
test
{
EVAL - Redis nil bulk reply -> Lua type conversion
}
{
r del mykey
r eval
{
local foo = redis.call
(
'get','mykey'
)
return
{
type
(
foo
)
,foo == false
}
}
0
}
{
boolean 1
}
test
{
EVAL - Is Lua affecting the currently selected DB?
}
{
r set mykey
"this is DB 9"
r select 10
r set mykey
"this is DB 10"
r eval
{
return redis.call
(
'get','mykey'
)}
0
}
{
this is DB 10
}
test
{
EVAL - Is Lua seleced DB retained?
}
{
r eval
{
return redis.call
(
'select','9'
)}
0
r get mykey
}
{
this is DB 9
}
test
{
EVAL - Script can't run more than configured time limit
}
{
r config set lua-time-limit 1
catch
{
r eval
{
local i = 0
while true do i=i+1 end
}
0
}
e
set _ $e
}
{
*execution time*
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录