diff --git a/TODO b/TODO index e1b1db6d67e8c97bb784c26739c1263cc8f27108..70db8357fc85372e8b602ab9da7070fdaec424b8 100644 --- a/TODO +++ b/TODO @@ -3,7 +3,7 @@ VERSION 1.1 TODO * For now only the last argument gets integer encoded, so make sure that: 1) every multi bulk commands implemented will have the last arg that is indeed a value, and not used otherwise. 2) to explicitly call the function to encode the object in MSET and other commands where there are multiple "values". * Man pages for MSET MSETNX and SRANDMEMBER, Z-commands, ... * Use strcoll() to compare objects in sorted sets, like it already happens for SORT. -* LPOPPUSH, EXPIRE, EXPIREAT, ZSCORE, SRANDMEMBER tests. +* RPOPLPUSH, EXPIRE, EXPIREAT, ZSCORE, SRANDMEMBER tests. * Write docs for the "STORE" operaiton of SORT, and GET "#" option. * Append only mode: testing and a command to rebuild the log from scratch. * Redis-cli should be able to select a different DB than 0 using some switch. diff --git a/redis.tcl b/redis.tcl index 61dae0c1226a9040b6cda3d602e044f7fcea8a39..3407d5d1443efc547a32a2d6e50144d90939aa60 100644 --- a/redis.tcl +++ b/redis.tcl @@ -20,7 +20,7 @@ array set ::redis::multibulkarg {} # Flag commands requiring last argument as a bulk write operation foreach redis_bulk_cmd { - set setnx rpush lpush lset lrem sadd srem sismember echo getset smove zadd zrem zscore + set setnx rpush lpush lset lrem sadd srem sismember echo getset smove zadd zrem zscore rpoplpush } { set ::redis::bulkarg($redis_bulk_cmd) {} } diff --git a/test-redis.tcl b/test-redis.tcl index 400b0db5e464302f4d10ca73385d7bd6e06d5851..737ad06b4cce5aa6c31417464f3878e257e8858f 100644 --- a/test-redis.tcl +++ b/test-redis.tcl @@ -257,6 +257,45 @@ proc main {server port} { format $err } {ERR*} + test {RPOPLPUSH base case} { + $r del mylist + $r rpush mylist a + $r rpush mylist b + $r rpush mylist c + $r rpush mylist d + set v1 [$r rpoplpush mylist newlist] + set v2 [$r rpoplpush mylist newlist] + set l1 [$r lrange mylist 0 -1] + set l2 [$r lrange newlist 0 -1] + list $v1 $v2 $l1 $l2 + } {d c {a b} {c d}} + + test {RPOPLPUSH with the same list as src and dst} { + $r del mylist + $r rpush mylist a + $r rpush mylist b + $r rpush mylist c + set l1 [$r lrange mylist 0 -1] + set v [$r rpoplpush mylist mylist] + set l2 [$r lrange mylist 0 -1] + list $l1 $v $l2 + } {{a b c} c {c a b}} + + test {RPOPLPUSH target list already exists} { + $r del mylist + $r del newlist + $r rpush mylist a + $r rpush mylist b + $r rpush mylist c + $r rpush mylist d + $r rpush newlist x + set v1 [$r rpoplpush mylist newlist] + set v2 [$r rpoplpush mylist newlist] + set l1 [$r lrange mylist 0 -1] + set l2 [$r lrange newlist 0 -1] + list $v1 $v2 $l1 $l2 + } {d c {a b} {c d x}} + test {RENAME basic usage} { $r set mykey hello $r rename mykey mykey1