]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/redis/redis-tests.factor
feature(redis): lua script words
[factor.git] / extra / redis / redis-tests.factor
index 3d53953f065c7cf1537b36fa13bba59dc03adc10..249b93cb265001ec12b38b2e702fc92aebf33031 100644 (file)
@@ -4,42 +4,40 @@
 USING: continuations kernel redis math math.parser sequences
 sorting tools.test ;
 
-QUALIFIED: redis
-
 IN: redis.tests
 
-: with-redis ( quot -- )
+: with-redis-test ( quot -- )
     [ redis-flushdb ] prepose
-    <redis> swap redis:with-redis ; inline
+    <redis> swap with-redis ; inline
 
-{ -1 } [ [ "foo" redis-decr ] with-redis ] unit-test
+{ -1 } [ [ "foo" redis-decr ] with-redis-test ] unit-test
 
-{ 1 } [ [ "foo" redis-incr ] with-redis ] unit-test
+{ 1 } [ [ "foo" redis-incr ] with-redis-test ] unit-test
 
 { -2 } [
-    [ 2 "foo" redis-decrby ] with-redis
+    [ 2 "foo" redis-decrby ] with-redis-test
 ] unit-test
 
-{ 2 } [ [ 2 "foo" redis-incrby ] with-redis ] unit-test
+{ 2 } [ [ 2 "foo" redis-incrby ] with-redis-test ] unit-test
 
 { "hello" } [
     [
         "hello" "foo" redis-set
         "foo" redis-get
-    ] with-redis
+    ] with-redis-test
 ] unit-test
 
 { { "aa" "ab" "ac" } } [
     [
         { "aa" "ab" "ac" "bd" } [ "hello" swap redis-set ] each
         "a*" redis-keys natural-sort
-    ] with-redis
+    ] with-redis-test
 ] unit-test
 
 { "hello" } [
     [
         "world" "hello" redis-set redis-randomkey
-    ] with-redis
+    ] with-redis-test
 ] unit-test
 
 { { "3" "2" "1" } "1" "5" "3" } [
@@ -50,7 +48,7 @@ IN: redis.tests
         0 -1 "list" redis-lrange
         "5" 1 "list" redis-lset
         3 [ "list" redis-rpop ] times
-    ] with-redis
+    ] with-redis-test
 ] unit-test
 
 { { "world" } "1" 2 } [
@@ -59,12 +57,26 @@ IN: redis.tests
         "hello" redis-hkeys
         "world" "hello" redis-hget
         1 "world" "hello" redis-hincrby
-    ] with-redis
+    ] with-redis-test
 ] unit-test
 
 { t } [
     [
         "world" "hello" redis-set
         [ "hello" redis-incr ] [ drop t ] recover
-    ] with-redis
+    ] with-redis-test
+] unit-test
+
+{ "e0e1f9fabfc9d4800c877a703b823ac0578ff8db" } [
+    [ "return 1" redis-script-load ] with-redis-test
+] unit-test
+
+{ { 0 0 } } [
+    [ { "foo" "bar" } redis-script-exists ] with-redis-test
+] unit-test
+
+{ } [ [ redis-script-flush ] with-redis-test ] unit-test
+
+{ { "foo" } } [
+    [ "return { ARGV[1] }" { } { "foo" } redis-script-eval ] with-redis-test
 ] unit-test