We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c8e0df9 commit 4a0af62Copy full SHA for 4a0af62
tests/lapi/bitop_arshift_test.lua
@@ -9,6 +9,7 @@ local luzer = require("luzer")
9
local test_lib = require("lib")
10
11
if test_lib.lua_version() ~= "LuaJIT" then
12
+ print("Unsupported version.")
13
os.exit(0)
14
end
15
tests/lapi/bitop_band_test.lua
@@ -31,10 +31,9 @@ local function TestOneInput(buf)
31
32
assert(band(x, band(y, z)) == band(band(x, y), z))
33
assert(band(x, 0) == 0)
34
-
35
- -- FIXME: assert(band(x, test_lib.MAX_INT) == x)
36
assert(band(x, y) == band(y, x))
37
assert(band(x, x) == x)
+ assert(band(x, -1) == x)
38
39
40
local args = {
tests/lapi/bitop_bnot_test.lua
@@ -24,9 +24,13 @@ local function TestOneInput(buf)
24
assert(type(res) == "number")
25
26
-- For any integer x, the following identity holds [1]:
27
+ --
28
-- 1. https://www.lua.org/manual/5.2/manual.html
- -- FIXME: assert(bnot(x) == (-1 - x) % 2^32)
29
- assert(bnot(bnot(x)) == x)
+ if test_lib.lua_version() == "LuaJIT" then
30
+ assert(bnot(x) == (-1 - x) % 2^32)
+ else
+ assert(bnot(x) == (-1 - x))
+ end
tests/lapi/bitop_bor_test.lua
@@ -34,10 +34,15 @@ local function TestOneInput(buf)
assert(bor(x, y) == bor(y, x))
assert(bor(x, bor(y, z)) == bor(bor(x, y), z))
assert(bor(x, 0) == x)
- -- FIXME: assert(bor(x, test_lib.MAX_INT) == test_lib.MAX_INT)
assert(bor(x, x) == x)
+ local MAX_UINT = bor(test_lib.MAX_INT, test_lib.MIN_INT)
41
+ assert(bor(x, MAX_UINT) == MAX_UINT)
42
43
+ local MAX_UINT64 = bor(test_lib.MAX_INT64, test_lib.MIN_INT64)
44
+ assert(bor(x, MAX_UINT64) == MAX_UINT64)
45
46
47
48
tests/lapi/bitop_bswap_test.lua
tests/lapi/bitop_bxor_test.lua
@@ -35,12 +35,21 @@ local function TestOneInput(buf)
assert(bxor(x, y) == bxor(y, x))
assert(bxor(x, bxor(y, z)) == bxor(bxor(x, y), z))
assert(bxor(x, x) == 0)
+ -- a ^ b = (a | b) & (~a | ~b)
+ assert(bxor(x, y) == band(bor(x, y), bor(bnot(x), bnot(y))))
+ -- a ^ b = (a & ~b) | (~a & b)
assert(bxor(x, y) == bor(band(x, bnot(y)), band(bnot(x), y)))
- -- FIXME: assert(bxor(x, 0xffff) == bnot(x))
- -- FIXME: assert(bxor(x, 0) == 0)
+ assert(bxor(x, y, y) == x)
assert(bxor(bxor(x, y), y) == x)
- assert(bxor(x, y) == band(bor(x, y), bor(bnot(x), bnot(y))))
+
+ assert(bxor(x, MAX_UINT) == bnot(x))
49
50
+ assert(bxor(x, MAX_UINT64) == bnot(x))
51
52
+ assert(bxor(x, 0) == x)
53
54
55
tests/lapi/bitop_lshift_test.lua
@@ -21,16 +21,10 @@ end
21
local function TestOneInput(buf)
22
local fdp = luzer.FuzzedDataProvider(buf)
23
local MAX_INT = test_lib.MAX_INT
- local MIN_INT = test_lib.MIN_INT
- local x = fdp:consume_integer(MIN_INT, MAX_INT)
- local n = fdp:consume_integer(MIN_INT, MAX_INT)
+ local x = fdp:consume_integer(0, MAX_INT)
+ local n = fdp:consume_integer(1, 32)
local res = lshift(x, n)
- -- For positive displacements, the following equality holds [1]:
- --
- -- 1. https://www.lua.org/manual/5.2/manual.html
- -- FIXME: assert(lshift(x, n) == (x * 2^n) % 2^32)
tests/lapi/bitop_rol_test.lua
@@ -12,6 +12,7 @@ local luzer = require("luzer")
16
17
18
tests/lapi/bitop_ror_test.lua
tests/lapi/bitop_rshift_test.lua
@@ -24,17 +24,10 @@ end
local res = rshift(x, n)
- -- For positive displacements, the following equality holds
- -- [1]:
- -- FIXME: assert(rshift(x, n) == math.floor(x % 2^32 / 2^n))
0 commit comments