various cleanups and minor fixes

This commit is contained in:
Oran Agra
2016-04-25 16:49:57 +03:00
committed by antirez
parent 6710c8dc15
commit cfc08b65b0
12 changed files with 39 additions and 44 deletions

View File

@ -37,13 +37,7 @@ proc assert_error {pattern code} {
}
proc assert_encoding {enc key} {
# Swapped out values don't have an encoding, so make sure that
# the value is swapped in before checking the encoding.
set dbg [r debug object $key]
while {[string match "* swapped at:*" $dbg]} {
r debug swapin $key
set dbg [r debug object $key]
}
assert_match "* encoding:$enc *" $dbg
}

View File

@ -88,7 +88,7 @@ start_server {tags {"bitops"}} {
} {ERR*syntax*}
test {BITCOUNT regression test for github issue #582} {
r del str
r del foo
r setbit foo 0 1
if {[catch {r bitcount foo 0 4294967296} e]} {
assert_match {*ERR*out of range*} $e

View File

@ -194,6 +194,7 @@ start_server {tags {"other"}} {
}
test {APPEND basics} {
r del foo
list [r append foo bar] [r get foo] \
[r append foo 100] [r get foo]
} {3 bar 6 bar100}

View File

@ -62,18 +62,19 @@ start_server {tags {"scripting"}} {
} {NOSCRIPT*}
test {EVAL - Redis integer -> Lua type conversion} {
r set x 0
r eval {
local foo = redis.pcall('incr','x')
local foo = redis.pcall('incr',KEYS[1])
return {type(foo),foo}
} 0
} 1 x
} {number 1}
test {EVAL - Redis bulk -> Lua type conversion} {
r set mykey myval
r eval {
local foo = redis.pcall('get','mykey')
local foo = redis.pcall('get',KEYS[1])
return {type(foo),foo}
} 0
} 1 mykey
} {string myval}
test {EVAL - Redis multi bulk -> Lua type conversion} {
@ -82,39 +83,39 @@ start_server {tags {"scripting"}} {
r rpush mylist b
r rpush mylist c
r eval {
local foo = redis.pcall('lrange','mylist',0,-1)
local foo = redis.pcall('lrange',KEYS[1],0,-1)
return {type(foo),foo[1],foo[2],foo[3],# foo}
} 0
} 1 mylist
} {table a b c 3}
test {EVAL - Redis status reply -> Lua type conversion} {
r eval {
local foo = redis.pcall('set','mykey','myval')
local foo = redis.pcall('set',KEYS[1],'myval')
return {type(foo),foo['ok']}
} 0
} 1 mykey
} {table OK}
test {EVAL - Redis error reply -> Lua type conversion} {
r set mykey myval
r eval {
local foo = redis.pcall('incr','mykey')
local foo = redis.pcall('incr',KEYS[1])
return {type(foo),foo['err']}
} 0
} 1 mykey
} {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.pcall('get','mykey')
local foo = redis.pcall('get',KEYS[1])
return {type(foo),foo == false}
} 0
} 1 mykey
} {boolean 1}
test {EVAL - Is the Lua client using 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.pcall('get','mykey')} 0
r eval {return redis.pcall('get',KEYS[1])} 1 mykey
} {this is DB 10}
test {EVAL - SELECT inside Lua should not affect the caller} {