Skip to content

Commit a60c8be

Browse files
committed
tests/lapi: use math.mininteger and math.maxinteger [TO SQUASH]
1 parent ebe7adb commit a60c8be

13 files changed

+66
-33
lines changed

tests/lapi/bitop_arshift_test.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ local arshift = bitop.arshift
1717

1818
local function TestOneInput(buf)
1919
local fdp = luzer.FuzzedDataProvider(buf)
20-
local x = test_lib.random_number(fdp)
21-
local y = test_lib.random_number(fdp)
20+
local MAX_INT = test_lib.MAX_INT()
21+
local MIN_INT = test_lib.MIN_INT()
22+
local x = fdp:consume_number(MIN_INT(), MAX_INT())
23+
local y = fdp:consume_number(MIN_INT(), MAX_INT())
2224
arshift(x, y)
2325
end
2426

tests/lapi/bitop_band_test.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ end
2424

2525
local function TestOneInput(buf)
2626
local fdp = luzer.FuzzedDataProvider(buf)
27-
local x = test_lib.random_number(fdp)
28-
local y = test_lib.random_number(fdp)
29-
local z = test_lib.random_number(fdp)
27+
local MAX_INT = test_lib.MAX_INT()
28+
local MIN_INT = test_lib.MIN_INT()
29+
local x = fdp:consume_number(MIN_INT, MAX_INT)
30+
local y = fdp:consume_number(MIN_INT, MAX_INT)
31+
local z = fdp:consume_number(MIN_INT, MAX_INT)
3032

3133
assert(band(x, band(y, z)) ==
3234
band(band(x, y), z), "x & (y & z) ~= (x & y) & z")

tests/lapi/bitop_bnot_test.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ end
1818

1919
local function TestOneInput(buf)
2020
local fdp = luzer.FuzzedDataProvider(buf)
21-
local x = test_lib.random_number(fdp)
21+
local MAX_INT = test_lib.MAX_INT()
22+
local MIN_INT = test_lib.MIN_INT()
23+
local x = fdp:consume_number(MIN_INT, MAX_INT)
2224
bnot(x)
2325

2426
-- For any integer x, the following identity holds [1]:

tests/lapi/bitop_bor_test.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ end
2525

2626
local function TestOneInput(buf)
2727
local fdp = luzer.FuzzedDataProvider(buf)
28-
local x = test_lib.random_number(fdp)
29-
local y = test_lib.random_number(fdp)
30-
local z = test_lib.random_number(fdp)
28+
local MAX_INT = test_lib.MAX_INT()
29+
local MIN_INT = test_lib.MIN_INT()
30+
local x = fdp:consume_number(MIN_INT, MAX_INT)
31+
local y = fdp:consume_number(MIN_INT, MAX_INT)
32+
local z = fdp:consume_number(MIN_INT, MAX_INT)
3133
bor(x, y)
3234

3335
assert(bor(x, y) == bor(y, x), "x | y ~= y | x")

tests/lapi/bitop_bswap_test.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ local bswap = bitop.bswap
1515

1616
local function TestOneInput(buf)
1717
local fdp = luzer.FuzzedDataProvider(buf)
18-
local x = test_lib.random_number(fdp)
19-
local y = test_lib.random_number(fdp)
18+
local MAX_INT = test_lib.MAX_INT()
19+
local MIN_INT = test_lib.MIN_INT()
20+
local x = fdp:consume_number(MIN_INT, MAX_INT)
21+
local y = fdp:consume_number(MIN_INT, MAX_INT)
2022
bswap(x, y)
2123
end
2224

tests/lapi/bitop_bxor_test.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ end
2727

2828
local function TestOneInput(buf)
2929
local fdp = luzer.FuzzedDataProvider(buf)
30-
local x = test_lib.random_number(fdp)
31-
local y = test_lib.random_number(fdp)
32-
local z = test_lib.random_number(fdp)
30+
local MAX_INT = test_lib.MAX_INT()
31+
local MIN_INT = test_lib.MIN_INT()
32+
local x = fdp:consume_number(MIN_INT, MAX_INT)
33+
local y = fdp:consume_number(MIN_INT, MAX_INT)
34+
local z = fdp:consume_number(MIN_INT, MAX_INT)
3335

3436
assert(bxor(x, y) == bxor(y, x), "x ^ y ~= y ^ x")
3537
assert(bxor(x, bxor(y, z)) == bxor(bxor(x, y), z),

tests/lapi/bitop_lshift_test.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ end
2020

2121
local function TestOneInput(buf)
2222
local fdp = luzer.FuzzedDataProvider(buf)
23-
local x = test_lib.random_number(fdp)
24-
local y = test_lib.random_number(fdp)
23+
local MAX_INT = test_lib.MAX_INT()
24+
local MIN_INT = test_lib.MIN_INT()
25+
local x = fdp:consume_number(MIN_INT, MAX_INT)
26+
local y = fdp:consume_number(MIN_INT, MAX_INT)
2527
lshift(x, y)
2628

2729
-- For positive displacements, the following equality holds [1]:

tests/lapi/bitop_rol_test.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ local rol = bitop.rol
2020

2121
local function TestOneInput(buf)
2222
local fdp = luzer.FuzzedDataProvider(buf)
23-
local x = test_lib.random_number(fdp)
24-
local y = test_lib.random_number(fdp)
23+
local MAX_INT = test_lib.MAX_INT()
24+
local MIN_INT = test_lib.MIN_INT()
25+
local x = fdp:consume_number(MIN_INT, MAX_INT)
26+
local y = fdp:consume_number(MIN_INT, MAX_INT)
2527
rol(x, y)
2628

2729
-- For any valid displacement, the following identity holds [1]:

tests/lapi/bitop_ror_test.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ local ror = bitop.ror
1717

1818
local function TestOneInput(buf)
1919
local fdp = luzer.FuzzedDataProvider(buf)
20-
local x = test_lib.random_number(fdp)
21-
local y = test_lib.random_number(fdp)
20+
local MAX_INT = test_lib.MAX_INT()
21+
local MIN_INT = test_lib.MIN_INT()
22+
local x = fdp:consume_number(MIN_INT, MAX_INT)
23+
local y = fdp:consume_number(MIN_INT, MAX_INT)
2224
ror(x, y)
2325

2426
-- For any valid displacement, the following identity holds

tests/lapi/bitop_rshift_test.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ end
2424

2525
local function TestOneInput(buf)
2626
local fdp = luzer.FuzzedDataProvider(buf)
27-
local x = test_lib.random_number(fdp)
28-
local y = test_lib.random_number(fdp)
27+
local MAX_INT = test_lib.MAX_INT()
28+
local MIN_INT = test_lib.MIN_INT()
29+
local x = fdp:consume_number(MIN_INT, MAX_INT)
30+
local y = fdp:consume_number(MIN_INT, MAX_INT)
2931
rshift(x, y)
3032

3133
-- For positive displacements, the following equality holds

0 commit comments

Comments
 (0)