redis/tests/unit
Matt Stancliff 3fecb96122 Lua: Add bitop
A few people have written custom C commands because bit
manipulation isn't exposed through Lua.  Let's give
them Mike Pall's bitop.

This adds bitop 1.0.2 (2012-05-08) from http://bitop.luajit.org/

bitop is imported as "bit" into the global namespace.

New Lua commands: bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor,
bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap

Verification of working (the asserts would abort on error, so (nil) is correct):
127.0.0.1:6379> eval "assert(bit.tobit(1) == 1); assert(bit.band(1) == 1); assert(bit.bxor(1,2) == 3); assert(bit.bor(1,2,4,8,16,32,64,128) == 255)" 0
(nil)
127.0.0.1:6379> eval 'assert(0x7fffffff == 2147483647, "broken hex literals"); assert(0xffffffff == -1 or 0xffffffff == 2^32-1, "broken hex literals"); assert(tostring(-1) == "-1", "broken tostring()"); assert(tostring(0xffffffff) == "-1" or tostring(0xffffffff) == "4294967295", "broken tostring()")' 0
(nil)

Tests also integrated into the scripting tests and can be run with:
./runtest --single unit/scripting

Tests are excerpted from `bittest.lua` included in the bitop distribution.
2014-10-09 11:51:30 -04:00
..
type Test: check sorted set elements order after union. 2014-07-22 17:52:04 +02:00
aofrw.tcl Test: more reliable AOF rewrite test under write load. 2014-07-10 16:42:43 +02:00
auth.tcl Remove trailing spaces from tests 2014-09-29 06:49:08 -04:00
basic.tcl Merge pull request #1902 from mattsta/comment-fixes 2014-10-06 09:44:54 +02:00
bitops.tcl Remove trailing spaces from tests 2014-09-29 06:49:08 -04:00
dump.tcl Test: dump.tcl fixed for RESTORE new error msg. 2014-05-22 15:56:17 +02:00
expire.tcl Test: regression test for issue #1026. 2013-03-28 11:46:14 +01:00
hyperloglog.tcl HyperLogLog regression test for issue #1762. 2014-05-19 15:44:04 +02:00
introspection.tcl Remove trailing spaces from tests 2014-09-29 06:49:08 -04:00
latency-monitor.tcl LATENCY command / monitor basic tests. 2014-07-10 16:23:54 +02:00
limits.tcl More robust maxclients test. 2012-04-18 11:34:18 +02:00
maxmemory.tcl Remove trailing spaces from tests 2014-09-29 06:49:08 -04:00
memefficiency.tcl Fix false positive in memory efficiency test. 2013-11-25 10:21:46 +01:00
multi.tcl Test: test replication of MULTI/EXEC. 2013-03-27 11:44:50 +01:00
obuf-limits.tcl Test: obuf-limits test false positive removed. 2013-03-25 11:56:34 +01:00
other.tcl Test: MULTI/EXEC tests moved into multi.tcl. 2012-11-22 10:32:12 +01:00
printver.tcl Print version info before running the test 2011-05-20 11:44:54 +02:00
protocol.tcl Return proper error on requests with an unbalanced number of quotes. 2013-12-08 12:58:12 +02:00
pubsub.tcl pubsub: Return integers for NUMSUB, not strings 2014-08-08 11:19:37 +02:00
quit.tcl Add tests for OK on QUIT 2010-10-15 12:54:53 +02:00
scan.tcl Added tests for [SHZ]SCAN with MATCH. 2013-11-05 15:19:44 +01:00
scripting.tcl Lua: Add bitop 2014-10-09 11:51:30 -04:00
slowlog.tcl Slowlog: don't log EXEC but just the executed commands. 2013-01-19 12:53:21 +01:00
sort.tcl Fix spelling in some test cases 2014-09-29 06:49:08 -04:00