Permalink
Browse files

we now use lua-cjson for the test suite; lua-yajl is more difficult t…

…o install.
  • Loading branch information...
1 parent 35364f0 commit a6870f4cbe414e40eb9cd57ef8c4f5842fe21d20 @agentzh agentzh committed Jul 7, 2011
Showing with 37 additions and 37 deletions.
  1. +2 −2 Makefile
  2. +3 −3 t/pipeline.t
  3. +32 −32 t/sanity.t
View
@@ -49,12 +49,12 @@ clean:
$(RM) *.so *.lo lz/*.so
test: parser.so
- prove -r t
+ LUA_CPATH="$$HOME/work/lua-cjson-1.0.2/?.so;;" prove -r t
valtest: parser.so
if [ ! -d lz ]; then mkdir lz; fi
cp parser.so lz/
- TEST_LUA_USE_VALGRIND=1 prove -r t
+ LUA_CPATH="$$HOME/work/lua-cjson-1.0.2/?.so;;" TEST_LUA_USE_VALGRIND=1 prove -r t
dist:
if [ -d $(dist) ]; then rm -r $(dist); fi
View
@@ -228,7 +228,7 @@ res[2][2] == 4 == 4
=== TEST 9: multiple multi-bulk replies
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
replies = '*2\r\n$-1\r\n$5\r\nhello\r\n*1\r\n$1\r\na\r\n$2\r\nef\r\n'
results = parser.parse_replies(replies, 2)
@@ -238,12 +238,12 @@ print("res[2] count == " .. #results[2])
local res = results[1]
-print("res[1][1] == " .. yajl.to_string(res[1]))
+print("res[1][1] == " .. cjson.encode(res[1]))
print("res[1][2] == " .. res[2] .. ' == ' .. parser.MULTI_BULK_REPLY)
res = results[2]
-print("res[2][1] == " .. yajl.to_string(res[1]))
+print("res[2][1] == " .. cjson.encode(res[1]))
print("res[2][2] == " .. res[2] .. ' == ' .. parser.MULTI_BULK_REPLY)
--- out
View
@@ -252,12 +252,12 @@ res\tbad bulk reply\n"
=== TEST 19: good multi bulk reply (1 bulk)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
reply = '*1\r\n$1\r\na\r\n'
res, typ = parser.parse_reply(reply)
print("typ == " .. typ .. ' == ' .. parser.MULTI_BULK_REPLY)
-print("res == " .. yajl.to_string(res))
+print("res == " .. cjson.encode(res))
--- out eval
qq{typ == 5 == 5
res == ["a"]\n}
@@ -266,12 +266,12 @@ res == ["a"]\n}
=== TEST 20: good multi bulk reply (4 bulks)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
reply = '*4\r\n$1\r\na\r\n$-1\r\n$0\r\n\r\n$5\r\nhello\r\n'
res, typ = parser.parse_reply(reply)
print("typ == " .. typ .. ' == ' .. parser.MULTI_BULK_REPLY)
-print("res == " .. yajl.to_string(res))
+print("res == " .. cjson.encode(res))
--- out eval
qq{typ == 5 == 5
res == ["a",null,"","hello"]\n}
@@ -280,12 +280,12 @@ res == ["a",null,"","hello"]\n}
=== TEST 21: bad multi bulk reply (4 bulks)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
reply = '*4\r\n$1\r\na\r\n$-1\r\n$0\r\n\n$5\r\nhello\r\n'
res, typ = parser.parse_reply(reply)
print("typ == " .. typ .. ' == ' .. parser.MULTI_BULK_REPLY)
-print("res == " .. yajl.to_string(res))
+print("res == " .. cjson.encode(res))
--- out eval
qq{typ == 0 == 5
res == "bad multi bulk reply"\n}
@@ -294,12 +294,12 @@ res == "bad multi bulk reply"\n}
=== TEST 22: bad multi bulk reply (4 bulks)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
reply = '*6\r\n$1\r\na\r\n$-1\r\n$0\r\n\n$5\r\nhello\r\n'
res, typ = parser.parse_reply(reply)
print("typ == " .. typ .. ' == ' .. parser.MULTI_BULK_REPLY)
-print("res == " .. yajl.to_string(res))
+print("res == " .. cjson.encode(res))
--- out eval
qq{typ == 0 == 5
res == "bad multi bulk reply"\n}
@@ -308,12 +308,12 @@ res == "bad multi bulk reply"\n}
=== TEST 23: bad multi bulk reply (4 bulks)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
reply = '*6\n$1\r\na\r\n$-1\r\n$0\r\n\n$5\r\nhello\r\n'
res, typ = parser.parse_reply(reply)
print("typ == " .. typ .. ' == ' .. parser.MULTI_BULK_REPLY)
-print("res == " .. yajl.to_string(res))
+print("res == " .. cjson.encode(res))
--- out eval
qq{typ == 0 == 5
res == "bad multi bulk reply"\n}
@@ -322,12 +322,12 @@ res == "bad multi bulk reply"\n}
=== TEST 24: bad multi bulk reply (4 bulks)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
reply = '*6$1\r\na\r\n$-1\r\n$0\r\n\n$5\r\nhello\r\n'
res, typ = parser.parse_reply(reply)
print("typ == " .. typ .. ' == ' .. parser.MULTI_BULK_REPLY)
-print("res == " .. yajl.to_string(res))
+print("res == " .. cjson.encode(res))
--- out eval
qq{typ == 0 == 5
res == "bad multi bulk reply"\n}
@@ -336,96 +336,96 @@ res == "bad multi bulk reply"\n}
=== TEST 25: build query (empty param table)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
q = {}
local query = parser.build_query(q)
-print("query == " .. yajl.to_string(query))
+print("query == " .. cjson.encode(query))
--- err
empty input param table
=== TEST 26: build query (single param)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
q = {'ping'}
local query = parser.build_query(q)
-print("query == " .. yajl.to_string(query))
+print("query == " .. cjson.encode(query))
--- out
query == "*1\r\n$4\r\nping\r\n"
=== TEST 27: build query (single param)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
q = {'get', 'one', '\r\n'}
local query = parser.build_query(q)
-print("query == " .. yajl.to_string(query))
+print("query == " .. cjson.encode(query))
--- out
query == "*3\r\n$3\r\nget\r\n$3\r\none\r\n$2\r\n\r\n\r\n"
=== TEST 28: build query (empty param "")
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
q = {''}
local query = parser.build_query(q)
-print("query == " .. yajl.to_string(query))
+print("query == " .. cjson.encode(query))
--- out
query == "*1\r\n$0\r\n\r\n"
=== TEST 29: build query (empty param "")
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
q = {''}
local query = parser.build_query(q)
-print("query == " .. yajl.to_string(query))
+print("query == " .. cjson.encode(query))
--- out
query == "*1\r\n$0\r\n\r\n"
=== TEST 30: build query (nil param)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
q = {parser.null}
local query = parser.build_query(q)
-print("query == " .. yajl.to_string(query))
+print("query == " .. cjson.encode(query))
--- out
query == "*1\r\n$-1\r\n"
=== TEST 31: build query (numeric param)
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
q = {'set', 'foo', 3.1415926}
local query = parser.build_query(q)
-print("query == " .. yajl.to_string(query))
+print("query == " .. cjson.encode(query))
--- out
query == "*3\r\n$3\r\nset\r\n$3\r\nfoo\r\n$9\r\n3.1415926\r\n"
=== TEST 32: multi bulk reply contains single line reply
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
reply = '*5\r\n$1\r\na\r\n:1\r\n-Bad argument\r\n+32\r\n$3\r\nfoo\r\n'
res, typ = parser.parse_reply(reply)
print("typ == " .. typ .. ' == ' .. parser.MULTI_BULK_REPLY)
-print("res == " .. yajl.to_string(res))
+print("res == " .. cjson.encode(res))
--- out eval
qq{typ == 5 == 5
res == ["a","1","Bad argument","32","foo"]\n}
@@ -434,12 +434,12 @@ res == ["a","1","Bad argument","32","foo"]\n}
=== TEST 33: we allow left-over bytes
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
reply = '*3\r\n$1\r\na\r\n:1\r\n-Bad argument\r\n+32\r\n$3\r\nfoo\r\n'
res, typ = parser.parse_reply(reply)
print("typ == " .. typ .. ' == ' .. parser.MULTI_BULK_REPLY)
-print("res == " .. yajl.to_string(res))
+print("res == " .. cjson.encode(res))
--- out eval
qq{typ == 5 == 5
res == ["a","1","Bad argument"]\n}
@@ -448,11 +448,11 @@ res == ["a","1","Bad argument"]\n}
=== TEST 34: bug reported by James Hurst
--- lua
-yajl = require('yajl')
+cjson = require('cjson')
parser = require("redis.parser")
reply = "*3\r\n$9\r\nsubscribe\r\n$38\r\nledge:d1d0ed5f3251473795548ab392181d06\r\n:1\r\n*3\r\n$7\r\nmessage\r\n$38\r\nledge:d1d0ed5f3251473795548ab392181d06\r\n$8\r\nfinished\r\n"
resp = parser.parse_replies(reply, 2)
-print("res == " .. yajl.to_string(resp))
+print("res == " .. cjson.encode(resp))
--- out
res == [[["subscribe","ledge:d1d0ed5f3251473795548ab392181d06","1"],5],[["message","ledge:d1d0ed5f3251473795548ab392181d06","finished"],5]]

0 comments on commit a6870f4

Please sign in to comment.