Skip to content

Commit c179472

Browse files
committed
Added tests checking ability of the scripting engine to reorder the output of commands with a random output regarding signle elements position in the multi bulk reply.
1 parent 44d77bb commit c179472

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/unit/scripting.tcl

+24
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,30 @@ start_server {tags {"scripting"}} {
190190
[r script load "return 'loaded'"] \
191191
[r evalsha b534286061d4b9e4026607613b95c06c06015ae8 0]
192192
} {b534286061d4b9e4026607613b95c06c06015ae8 loaded}
193+
194+
test "In the context of Lua the output of random commands gets ordered" {
195+
r del myset
196+
r sadd myset a b c d e f g h i l m n o p q r s t u v z aa aaa azz
197+
r eval {return redis.call('smembers','myset')} 0
198+
} {a aa aaa azz b c d e f g h i l m n o p q r s t u v z}
199+
200+
test "SORT is normally not re-ordered by the scripting engine" {
201+
r del myset
202+
r sadd myset 1 2 3 4 10
203+
r eval {return redis.call('sort','myset','desc')} 0
204+
} {10 4 3 2 1}
205+
206+
test "SORT BY <constant> output gets ordered by scripting" {
207+
r del myset
208+
r sadd myset a b c d e f g h i l m n o p q r s t u v z aa aaa azz
209+
r eval {return redis.call('sort','myset','by','_')} 0
210+
} {a aa aaa azz b c d e f g h i l m n o p q r s t u v z}
211+
212+
test "SORT output containing NULLs is well handled by scripting" {
213+
r del myset
214+
r sadd myset a b c
215+
r eval {return redis.call('sort','myset','by','_','get','#','get','_:*')} 0
216+
} {{} {} {} a b c}
193217
}
194218

195219
start_server {tags {"scripting repl"}} {

0 commit comments

Comments
 (0)