@@ -16,27 +16,36 @@ assert(type(assert(getmetatable(hiredis.NIL))) == "string")
1616
1717---- ----------------------------------------------------------------------------
1818
19- assert (type (hiredis .OK == " table" ))
20- assert (hiredis .OK .name == " OK" )
21- assert (hiredis .OK .type == hiredis .REPLY_STATUS )
22- assert (tostring (hiredis .OK ) == " OK" )
23- assert (getmetatable (hiredis .OK ) == getmetatable (hiredis .NIL ))
19+ assert (type (hiredis .status .OK == " table" ))
20+ assert (hiredis .status .OK .name == " OK" )
21+ assert (hiredis .status .OK .type == hiredis .REPLY_STATUS )
22+ assert (tostring (hiredis .status .OK ) == " OK" )
23+ assert (getmetatable (hiredis .status .OK ) == getmetatable (hiredis .NIL ))
24+
25+ -- deprecated backwards compatibility
26+ assert (hiredis .OK == hiredis .status .OK )
2427
2528---- ----------------------------------------------------------------------------
2629
27- assert (type (hiredis .QUEUED == " table" ))
28- assert (hiredis .QUEUED .name == " QUEUED" )
29- assert (hiredis .QUEUED .type == hiredis .REPLY_STATUS )
30- assert (tostring (hiredis .QUEUED ) == " QUEUED" )
31- assert (getmetatable (hiredis .QUEUED ) == getmetatable (hiredis .NIL ))
30+ assert (type (hiredis .status .QUEUED == " table" ))
31+ assert (hiredis .status .QUEUED .name == " QUEUED" )
32+ assert (hiredis .status .QUEUED .type == hiredis .REPLY_STATUS )
33+ assert (tostring (hiredis .status .QUEUED ) == " QUEUED" )
34+ assert (getmetatable (hiredis .status .QUEUED ) == getmetatable (hiredis .NIL ))
35+
36+ -- deprecated backwards compatibility
37+ assert (hiredis .QUEUED == hiredis .status .QUEUED )
3238
3339---- ----------------------------------------------------------------------------
3440
35- assert (type (hiredis .PONG == " table" ))
36- assert (hiredis .PONG .name == " PONG" )
37- assert (hiredis .PONG .type == hiredis .REPLY_STATUS )
38- assert (tostring (hiredis .PONG ) == " PONG" )
39- assert (getmetatable (hiredis .PONG ) == getmetatable (hiredis .NIL ))
41+ assert (type (hiredis .status .PONG == " table" ))
42+ assert (hiredis .status .PONG .name == " PONG" )
43+ assert (hiredis .status .PONG .type == hiredis .REPLY_STATUS )
44+ assert (tostring (hiredis .status .PONG ) == " PONG" )
45+ assert (getmetatable (hiredis .status .PONG ) == getmetatable (hiredis .NIL ))
46+
47+ -- deprecated backwards compatibility
48+ assert (hiredis .PONG == hiredis .status .PONG )
4049
4150---- ----------------------------------------------------------------------------
4251
@@ -48,7 +57,7 @@ local conn = assert(hiredis.connect("localhost", 6379))
4857
4958---- ----------------------------------------------------------------------------
5059
51- assert (conn :command (" PING" ) == hiredis .PONG )
60+ assert (conn :command (" PING" ) == hiredis .status . PONG )
5261
5362---- ----------------------------------------------------------------------------
5463
@@ -63,6 +72,7 @@ assert(T.type == hiredis.REPLY_STATUS)
6372assert (T .name == " string" )
6473
6574assert (hiredis .unwrap_reply (T ) == " string" )
75+ assert (T == hiredis .status .string )
6676
6777---- ----------------------------------------------------------------------------
6878
@@ -77,6 +87,7 @@ assert(T.type == hiredis.REPLY_STATUS)
7787assert (T .name == " none" )
7888
7989assert (hiredis .unwrap_reply (T ) == " none" )
90+ assert (T == hiredis .status .none )
8091
8192---- ----------------------------------------------------------------------------
8293
@@ -100,34 +111,38 @@ end
100111
101112---- ----------------------------------------------------------------------------
102113
103- assert (assert (conn :command (" MULTI" )) == hiredis .OK )
104- assert (assert (conn :command (" SET" , " MYKEY1" , " MYVALUE1" )) == hiredis .QUEUED )
105- assert (assert (conn :command (" GET" , " MYKEY1" )) == hiredis .QUEUED )
114+ assert (assert (conn :command (" MULTI" )) == hiredis .status .OK )
115+ assert (
116+ assert (conn :command (" SET" , " MYKEY1" , " MYVALUE1" )) == hiredis .status .QUEUED
117+ )
118+ assert (assert (conn :command (" GET" , " MYKEY1" )) == hiredis .status .QUEUED )
106119local t = assert (conn :command (" EXEC" ))
107- assert (t [1 ] == hiredis .OK )
120+ assert (t [1 ] == hiredis .status . OK )
108121assert (t [2 ] == " MYVALUE1" )
109122
110123---- ----------------------------------------------------------------------------
111124
112125-- Based on actual bug scenario.
113- assert (assert (conn :command (" MULTI" )) == hiredis .OK )
114- assert (assert (conn :command (" GET" , " MYKEY1" )) == hiredis .QUEUED )
115- assert (assert (conn :command (" SET" , " MYKEY1" , " MYVALUE2" )) == hiredis .QUEUED )
126+ assert (assert (conn :command (" MULTI" )) == hiredis .status .OK )
127+ assert (assert (conn :command (" GET" , " MYKEY1" )) == hiredis .status .QUEUED )
128+ assert (
129+ assert (conn :command (" SET" , " MYKEY1" , " MYVALUE2" )) == hiredis .status .QUEUED
130+ )
116131local t = assert (conn :command (" EXEC" ))
117132assert (t [1 ] == " MYVALUE1" )
118- assert (t [2 ] == hiredis .OK )
133+ assert (t [2 ] == hiredis .status . OK )
119134
120135---- ----------------------------------------------------------------------------
121136
122137assert (conn :command (" MULTI" ))
123- assert (assert (conn :command (" GET" , " MYKEY1" )) == hiredis .QUEUED )
138+ assert (assert (conn :command (" GET" , " MYKEY1" )) == hiredis .status . QUEUED )
124139
125140local err = assert (conn :command (" SET" ))
126141assert (err .type == hiredis .REPLY_ERROR )
127142assert (err .name == " ERR wrong number of arguments for 'set' command" )
128143assert (tostring (err ) == " ERR wrong number of arguments for 'set' command" )
129144
130- assert (assert (conn :command (" GET" , " MYKEY1" )) == hiredis .QUEUED )
145+ assert (assert (conn :command (" GET" , " MYKEY1" )) == hiredis .status . QUEUED )
131146local t = assert (conn :command (" EXEC" ))
132147
133148for i = 1 , # t do
@@ -138,15 +153,15 @@ end
138153
139154assert (conn :command (" MULTI" ))
140155
141- assert (assert (conn :command (" SET" , " MYKEY2" , 1 )) == hiredis .QUEUED )
156+ assert (assert (conn :command (" SET" , " MYKEY2" , 1 )) == hiredis .status . QUEUED )
142157
143158-- Wrong value type
144- assert (assert (conn :command (" SADD" , " MYKEY1" , " MYVAL" )) == hiredis .QUEUED )
159+ assert (assert (conn :command (" SADD" , " MYKEY1" , " MYVAL" )) == hiredis .status . QUEUED )
145160
146- assert (assert (conn :command (" INCR" , " MYKEY2" )) == hiredis .QUEUED )
161+ assert (assert (conn :command (" INCR" , " MYKEY2" )) == hiredis .status . QUEUED )
147162local t = assert (conn :command (" EXEC" ))
148163
149- assert (t [1 ] == hiredis .OK )
164+ assert (t [1 ] == hiredis .status . OK )
150165assert (t [2 ].type == hiredis .REPLY_ERROR )
151166assert (
152167 t [2 ].name == " ERR Operation against a key holding the wrong kind of value"
@@ -161,13 +176,13 @@ conn:append_command("SADD", "MYKEY1", "MYVAL")
161176conn :append_command (" INCR" , " MYKEY2" )
162177conn :append_command (" EXEC" )
163178
164- assert (assert (conn :get_reply ()) == hiredis .OK ) -- MULTI
165- assert (assert (conn :get_reply ()) == hiredis .QUEUED ) -- SET
166- assert (assert (conn :get_reply ()) == hiredis .QUEUED ) -- SADD
167- assert (assert (conn :get_reply ()) == hiredis .QUEUED ) -- INCR
179+ assert (assert (conn :get_reply ()) == hiredis .status . OK ) -- MULTI
180+ assert (assert (conn :get_reply ()) == hiredis .status . QUEUED ) -- SET
181+ assert (assert (conn :get_reply ()) == hiredis .status . QUEUED ) -- SADD
182+ assert (assert (conn :get_reply ()) == hiredis .status . QUEUED ) -- INCR
168183local t = assert (conn :get_reply ()) -- EXEC
169184
170- assert (t [1 ] == hiredis .OK )
185+ assert (t [1 ] == hiredis .status . OK )
171186assert (t [2 ].type == hiredis .REPLY_ERROR )
172187assert (
173188 t [2 ].name == " ERR Operation against a key holding the wrong kind of value"
285300end
286301
287302do
288- local r = pack (hiredis .unwrap_reply (hiredis .OK ))
303+ local r = pack (hiredis .unwrap_reply (hiredis .status . OK ))
289304 assert (r .n == 2 )
290305 assert (r [1 ] == " OK" )
291306 assert (r [2 ] == hiredis .REPLY_STATUS )
0 commit comments