Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
98e1bb81
Commit
98e1bb81
authored
Dec 18, 2009
by
antirez
Browse files
still more tests
parent
5384a2d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
test-redis.tcl
View file @
98e1bb81
...
@@ -877,18 +877,23 @@ proc main {server port} {
...
@@ -877,18 +877,23 @@ proc main {server port} {
lsort
[
array names myset
]
lsort
[
array names myset
]
}
{
a b c
}
}
{
a b c
}
test
{
Create a random list
}
{
test
{
Create a random list
and a random set
}
{
set tosort
{}
set tosort
{}
array set seenrand
{}
array set seenrand
{}
for
{
set i 0
}
{
$i
< 10000
}
{
incr i
}
{
for
{
set i 0
}
{
$i
< 10000
}
{
incr i
}
{
while 1
{
while 1
{
# Make sure all the weights are different because
# Make sure all the weights are different because
# Redis does not use a stable sort but Tcl does.
# Redis does not use a stable sort but Tcl does.
set rint
[
expr int
(
rand
()
*1000000
)]
randpath
{
set rint
[
expr int
(
rand
()
*1000000
)]
}
{
set rint
[
expr rand
()]
}
if
{
!
[
info exists seenrand
(
$rint
)]}
break
if
{
!
[
info exists seenrand
(
$rint
)]}
break
}
}
set seenrand
(
$rint
)
x
set seenrand
(
$rint
)
x
$r lpush tosort $i
$r lpush tosort $i
$r sadd tosort-set $i
$r set weight_$i $rint
$r set weight_$i $rint
lappend tosort
[
list $i $rint
]
lappend tosort
[
list $i $rint
]
}
}
...
@@ -904,6 +909,10 @@ proc main {server port} {
...
@@ -904,6 +909,10 @@ proc main {server port} {
$r sort tosort
{
BY weight_*
}
$r sort tosort
{
BY weight_*
}
}
$res
}
$res
test
{
the same SORT with BY, but against the newly created set
}
{
$r sort tosort-set
{
BY weight_*
}
}
$res
test
{
SORT with BY and STORE against the newly created list
}
{
test
{
SORT with BY and STORE against the newly created list
}
{
$r sort tosort
{
BY weight_*
}
store sort-res
$r sort tosort
{
BY weight_*
}
store sort-res
$r lrange sort-res 0 -1
$r lrange sort-res 0 -1
...
...
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