From 15639db7c9172c93f10d840317dd01f9d0d777cf Mon Sep 17 00:00:00 2001 From: FirstLemon Date: Fri, 26 Sep 2025 23:49:35 +0200 Subject: [PATCH 1/2] bit: providing the tests --- lua/tests/gmod/unit/libraries/bit/arshift.lua | 42 +++++++++++++ lua/tests/gmod/unit/libraries/bit/band.lua | 54 ++++++++++++++++ lua/tests/gmod/unit/libraries/bit/bnot.lua | 42 +++++++++++++ lua/tests/gmod/unit/libraries/bit/bor.lua | 62 +++++++++++++++++++ lua/tests/gmod/unit/libraries/bit/bswap.lua | 45 ++++++++++++++ lua/tests/gmod/unit/libraries/bit/bxor.lua | 56 +++++++++++++++++ lua/tests/gmod/unit/libraries/bit/lshift.lua | 53 ++++++++++++++++ lua/tests/gmod/unit/libraries/bit/rol.lua | 54 ++++++++++++++++ lua/tests/gmod/unit/libraries/bit/ror.lua | 54 ++++++++++++++++ lua/tests/gmod/unit/libraries/bit/rshift.lua | 51 +++++++++++++++ lua/tests/gmod/unit/libraries/bit/tobit.lua | 53 ++++++++++++++++ lua/tests/gmod/unit/libraries/bit/tohex.lua | 37 +++++++++++ 12 files changed, 603 insertions(+) create mode 100644 lua/tests/gmod/unit/libraries/bit/arshift.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/band.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/bnot.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/bor.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/bswap.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/bxor.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/lshift.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/rol.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/ror.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/rshift.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/tobit.lua create mode 100644 lua/tests/gmod/unit/libraries/bit/tohex.lua diff --git a/lua/tests/gmod/unit/libraries/bit/arshift.lua b/lua/tests/gmod/unit/libraries/bit/arshift.lua new file mode 100644 index 0000000..293df9a --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/arshift.lua @@ -0,0 +1,42 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.arshift", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.arshift ).to.beA( "function" ) + end + }, + + { + name = "Should correctly shift positive numbers", + func = function() + expect( bit.arshift( 8, 1 ) ).to.equal( 4 ) + expect( bit.arshift( 16, 2 ) ).to.equal( 4 ) + expect( bit.arshift( 0, 1 ) ).to.equal( 0 ) + expect( bit.arshift( 312, 0 ) ).to.equal( 312 ) + expect( bit.arshift( 123, 32 ) ).to.equal( 123 ) + end + }, + + { + name = "Returns correct values for negative arhithmetic shifting", + func = function() + expect( bit.arshift( -8, 1 ) ).to.equal( -4 ) + expect( bit.arshift( -16, 2 ) ).to.equal( -4 ) + expect( bit.arshift( -12345, 5 ) ).to.equal( -386 ) + expect( bit.arshift( -1, 10 ) ).to.equal( -1 ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.arshift, nil, nil ).to.err() + expect( bit.arshift, "abc", "def" ).to.err() + expect( bit.arshift, {}, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/band.lua b/lua/tests/gmod/unit/libraries/bit/band.lua new file mode 100644 index 0000000..453050d --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/band.lua @@ -0,0 +1,54 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.band", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.band ).to.beA( "function" ) + end + }, + + { + name = "Should handle positive numbers correctly", + func = function() + expect( bit.band( 8, 8 ) ).to.equal( 8 ) + expect( bit.band( 42, 17 ) ).to.equal( 0 ) + expect( bit.band( 13, 7 ) ).to.equal( 5 ) + end + }, + + { + name = "Should handle negative numbers correctly", + func = function() + expect( bit.band( -8, 8 ) ).to.equal( 8 ) + expect( bit.band( -10, -12 ) ).to.equal( -12 ) + end + }, + + { + name = "Functions properly with more than 2 args", + func = function() + expect( bit.band( 15, 67, 13 ) ).to.equal( 1 ) + expect( bit.band( 300, 200, 300 ) ).to.equal( 8 ) + expect( bit.band( 1, 2, 4, 8, 16, 32, 64 ) ).to.equal( 0 ) + end + }, + + { + name = "Returns same result when args are flipped", + func = function() + expect( bit.band( 123, 456 ) ).to.equal( bit.band( 456, 123 ) ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.band, nil, nil ).to.err() + expect( bit.band, "abc", "def" ).to.err() + expect( bit.band, {}, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/bnot.lua b/lua/tests/gmod/unit/libraries/bit/bnot.lua new file mode 100644 index 0000000..463465b --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/bnot.lua @@ -0,0 +1,42 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.bnot", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.bnot ).to.beA( "function" ) + end + }, + + { + name = "Should correctly invert positive and negative numbers", + func = function() + expect( bit.bnot( 8 ) ).to.equal( -9 ) + expect( bit.bnot( 32 ) ).to.equal( -33 ) + expect( bit.bnot( -27534 ) ).to.equal( 27533 ) + expect( bit.bnot( -69 ) ).to.equal( 68 ) + end + }, + + { + name = "Should handle edge cases correctly", + func = function() + expect( bit.bnot( 0 ) ).to.equal( -1 ) + expect( bit.bnot( -1 ) ).to.equal( 0 ) + + expect( bit.bnot( 2147483647 ) ).to.equal( -2147483648 ) + expect( bit.bnot( -2147483648 ) ).to.equal( 2147483647 ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.bnot, nil ).to.err() + expect( bit.bnot, "abc" ).to.err() + expect( bit.bnot, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/bor.lua b/lua/tests/gmod/unit/libraries/bit/bor.lua new file mode 100644 index 0000000..6f4272f --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/bor.lua @@ -0,0 +1,62 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.bor", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.bor ).to.beA( "function" ) + end + }, + + { + name = "Should handle positive numbers correctly", + func = function() + expect( bit.bor( 8, 8 ) ).to.equal( 8 ) + expect( bit.bor( 8, 1 ) ).to.equal( 9 ) + expect( bit.bor( 27533, 17 ) ).to.equal( 27549 ) + end + }, + + { + name = "Should handle negative numbers correctly", + func = function() + expect( bit.bor( -1, 0 ) ).to.equal( -1 ) + expect( bit.bor( -8, 1 ) ).to.equal( -7 ) + expect( bit.bor( -100, 50 ) ).to.equal( -66 ) + end + }, + + { + name = "Should handle zero values correctly", + func = function() + expect( bit.bor( 0, 69 ) ).to.equal( 69 ) + expect( bit.bor( -42, 0 ) ).to.equal( -42 ) + end + }, + + { + name = "Returns correct value with multiple args", + func = function() + expect( bit.bor( 1, 2, 4, 8 ) ).to.equal( 15 ) + end + }, + + { + name = "Handles Min and max values", + func = function() + expect( bit.bor( 2147483647, 2147483648 ) ).to.equal( -1 ) + expect( bit.bor( -2147483648, 0 ) ).to.equal( -2147483648 ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.bor, nil, nil ).to.err() + expect( bit.bor, "abc", "def" ).to.err() + expect( bit.bor, {}, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/bswap.lua b/lua/tests/gmod/unit/libraries/bit/bswap.lua new file mode 100644 index 0000000..fdd4fa2 --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/bswap.lua @@ -0,0 +1,45 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.bswap", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.bswap ).to.beA( "function" ) + end + }, + + { + name = "positive number byte swap", + func = function() + expect( bit.bswap( 327 ) ).to.equal( 1191247872 ) + expect( bit.bswap( 8 ) ).to.equal( 134217728 ) + end + }, + + { + name = "Negative number byte swap", + func = function() + expect( bit.bswap( -8 ) ).to.equal( -117440513 ) + expect( bit.bswap( -100 ) ).to.equal( -1660944385 ) + end + }, + + { + name = "Swapping 0 and -1 returns the correct value", + func = function() + expect( bit.bswap( 0 ) ).to.equal( 0 ) + expect( bit.bswap( -1 ) ).to.equal( -1 ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.bswap, nil ).to.err() + expect( bit.bswap, "abc" ).to.err() + expect( bit.bswap, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/bxor.lua b/lua/tests/gmod/unit/libraries/bit/bxor.lua new file mode 100644 index 0000000..1650fd5 --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/bxor.lua @@ -0,0 +1,56 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.bxor", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.bxor ).to.beA( "function" ) + end + }, + + { + name = "Positive XOR operation", + func = function() + expect( bit.bxor( 19, 82 ) ).to.equal( 65 ) + expect( bit.bxor( 327, 63 ) ).to.equal( 376 ) + expect( bit.bxor( 234, 0 ) ).to.equal( 234 ) + expect( bit.bxor( 32, 32 ) ).to.equal( 0 ) + end + }, + + { + name = "Negative XOR operation", + func = function() + expect( bit.bxor( -99, -55 ) ).to.equal( 84 ) + expect( bit.bxor( -420, -67 ) ).to.equal( 481 ) + expect( bit.bxor( -32, 0 ) ).to.equal( -32 ) + expect( bit.bxor( 42, -1 ) ).to.equal( -43 ) + end + }, + + { + name = "Handles min and max 32-bit integers correctly", + func = function() + expect( bit.bxor( 2147483647, -2147483648 ) ).to.equal( -1 ) + expect( bit.bxor( 2147483647, 1 ) ).to.equal( 2147483646 ) + end + }, + + { + name = "Handles multiple arguments correctly", + func = function() + expect( bit.bxor( 1, 2, 3, 4, 5 ) ).to.equal( 1 ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.bxor, nil, nil ).to.err() + expect( bit.bxor, "abc", "def" ).to.err() + expect( bit.bxor, {}, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/lshift.lua b/lua/tests/gmod/unit/libraries/bit/lshift.lua new file mode 100644 index 0000000..2b0d55f --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/lshift.lua @@ -0,0 +1,53 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.lshift", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.lshift ).to.beA( "function" ) + end + }, + + { + name = "Should correctly shift positive numbers", + func = function() + expect( bit.lshift( 15, 4 ) ).to.equal( 240 ) + expect( bit.lshift( 96, 4 ) ).to.equal( 1536 ) + expect( bit.lshift( 63, 2 ) ).to.equal( 252 ) + end + }, + + { + name = "Should correctly shift negative numbers", + func = function() + expect( bit.lshift( -8, 1 ) ).to.equal( -16 ) + end + }, + + { + name = "Values are getting clamped over the signed 32-bit int limit", + func = function() + expect( bit.lshift( 4294967295, 1 ) ).to.equal( -2 ) + expect( bit.lshift( 1, 31 ) ).to.equal( -2147483648 ) + end + }, + + { + name = "Shifting 0 times should return the same value", + func = function() + expect( bit.lshift( 1, 0 ) ).to.equal( 1 ) + expect( bit.lshift( 12345678, 0 ) ).to.equal( 12345678 ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.lshift, nil, nil ).to.err() + expect( bit.lshift, "abc", "def" ).to.err() + expect( bit.lshift, {}, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/rol.lua b/lua/tests/gmod/unit/libraries/bit/rol.lua new file mode 100644 index 0000000..c3c1130 --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/rol.lua @@ -0,0 +1,54 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.rol", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.rol ).to.beA( "function" ) + end + }, + + { + name = "Rotating positive numbers returning the correct values", + func = function() + expect( bit.rol( 8, 1 ) ).to.equal( 16 ) + expect( bit.rol( 16, 1 ) ).to.equal( 32 ) + expect( bit.rol( 469, 4 ) ).to.equal( 7504 ) + end + }, + + { + name = "Rotating negative numbers returning the correct values", + func = function() + expect( bit.rol( -8, 1 ) ).to.equal( -15 ) + expect( bit.rol( -16, 1 ) ).to.equal( -31 ) + expect( bit.rol( -469, 4 ) ).to.equal( -7489 ) + end + }, + + { + name = "Returning input value on 0 rotations", + func = function() + expect( bit.rol( 412, 0 ) ).to.equal( 412 ) + end + }, + + { + name = "Functions properly when rotating by 32", + func = function() + expect( bit.rol( 1, 32 ) ).to.equal( 1 ) + expect( bit.rol( 16, 32 ) ).to.equal( 16 ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.rol, nil, nil ).to.err() + expect( bit.rol, "abc", "def" ).to.err() + expect( bit.rol, {}, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/ror.lua b/lua/tests/gmod/unit/libraries/bit/ror.lua new file mode 100644 index 0000000..f11f01a --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/ror.lua @@ -0,0 +1,54 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.ror", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.ror ).to.beA( "function" ) + end + }, + + { + name = "Rotating positive numbers returning the correct values", + func = function() + expect( bit.ror( 8, 1 ) ).to.equal( 4 ) + expect( bit.ror( 16, 1 ) ).to.equal( 8 ) + expect( bit.ror( 469, 4 ) ).to.equal( 1342177309 ) + end + }, + + { + name = "Rotating negative numbers returning the correct values", + func = function() + expect( bit.ror( -8, 1 ) ).to.equal( 2147483644 ) + expect( bit.ror( -16, 1 ) ).to.equal( 2147483640 ) + expect( bit.ror( -469, 4 ) ).to.equal( -1073741854 ) + end + }, + + { + name = "Returning input value on 0 rotations", + func = function() + expect( bit.ror( 412, 0 ) ).to.equal( 412 ) + end + }, + + { + name = "Functions properly when rotating over the limit", + func = function() + expect( bit.ror( 1, 32 ) ).to.equal( 1 ) + expect( bit.ror( 16, 16 ) ).to.equal( 1048576 ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.ror, nil, nil ).to.err() + expect( bit.ror, "abc", "def" ).to.err() + expect( bit.ror, {}, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/rshift.lua b/lua/tests/gmod/unit/libraries/bit/rshift.lua new file mode 100644 index 0000000..4e5cbe8 --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/rshift.lua @@ -0,0 +1,51 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.rshift", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.rshift ).to.beA( "function" ) + end + }, + + { + name = "Returns the correct values", + func = function() + expect( bit.rshift( 8, 1 ) ).to.equal( 4 ) + expect( bit.rshift( 16, 2 ) ).to.equal( 4 ) + end + }, + + { + name = "Returns the correct valueswith negative input numbers", + func = function() + expect( bit.rshift( -8, 1 ) ).to.equal( 2147483644 ) + expect( bit.rshift( -16, 2 ) ).to.equal( 1073741820 ) + end + }, + + { + name = "Shifting 0 should remain 0", + func = function() + expect( bit.rshift( 0, 1 ) ).to.equal( 0 ) + end + }, + + { + name = "Shifting 0 times", + func = function() + expect( bit.rshift( 312, 0 ) ).to.equal( 312 ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.rshift, nil, nil ).to.err() + expect( bit.rshift, "abc", "def" ).to.err() + expect( bit.rshift, {}, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/tobit.lua b/lua/tests/gmod/unit/libraries/bit/tobit.lua new file mode 100644 index 0000000..238eeac --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/tobit.lua @@ -0,0 +1,53 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.tobit", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.tobit ).to.beA( "function" ) + end + }, + + { + name = "Should return unchanged values", + func = function() + expect( bit.tobit( 1 ) ).to.equal( 1 ) + expect( bit.tobit( -1 ) ).to.equal( -1 ) + end + }, + + { + name = "Should work correctly on positive boundary values", + func = function() + expect( bit.tobit( 2147483647 ) ).to.equal( 2147483647 ) + expect( bit.tobit( 2147483648 ) ).to.equal( -2147483648 ) + end + }, + + { + name = "Should work correctly on negative boundary values", + func = function() + expect( bit.tobit( -2147483647 ) ).to.equal( -2147483647 ) + expect( bit.tobit( -2147483648 ) ).to.equal( -2147483648 ) + end + }, + + { + name = "Handles float values by truncating them", + func = function() + expect( bit.tobit( 1.123 ) ).to.equal( 1 ) + expect( bit.tobit( -1.123 ) ).to.equal( -1 ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.tobit, nil ).to.err() + expect( bit.tobit, "abc" ).to.err() + expect( bit.tobit, {} ).to.err() + end + }, + } +} \ No newline at end of file diff --git a/lua/tests/gmod/unit/libraries/bit/tohex.lua b/lua/tests/gmod/unit/libraries/bit/tohex.lua new file mode 100644 index 0000000..232f37a --- /dev/null +++ b/lua/tests/gmod/unit/libraries/bit/tohex.lua @@ -0,0 +1,37 @@ +--- @type GLuaTest_TestGroup +return { + groupName = "bit.tohex", + cases = { + { + name = "Should be a function", + func = function() + expect( bit.tohex ).to.beA( "function" ) + end + }, + + { + name = "psotive numbers", + func = function() + expect( bit.tohex( 255 ) ).to.equal( "000000ff" ) + expect( bit.tohex( 255, 4 ) ).to.equal( "00ff" ) + end + }, + + { + name = "negative numbers", + func = function() + expect( bit.tohex( -1 ) ).to.equal( "ffffffff" ) + expect( bit.tohex( -2 ) ).to.equal( "fffffffe" ) + end + }, + + { + name = "Fails on invalid input", + func = function() + expect( bit.tohex, nil ).to.err() + expect( bit.tohex, "abc" ).to.err() + expect( bit.tohex, {} ).to.err() + end + }, + } +} \ No newline at end of file From f3d36562cf1421820423da22fab53f12eb23090f Mon Sep 17 00:00:00 2001 From: Lemon <66844236+FirstLemon@users.noreply.github.com> Date: Wed, 1 Oct 2025 10:37:24 +0200 Subject: [PATCH 2/2] bit: cleanup and fix - fixed formatting issues - hopefully made the names better - corrected the tests a bit --- lua/tests/gmod/unit/libraries/bit/arshift.lua | 19 ++++++---- lua/tests/gmod/unit/libraries/bit/band.lua | 26 ++++++++------ lua/tests/gmod/unit/libraries/bit/bnot.lua | 19 ++++++---- lua/tests/gmod/unit/libraries/bit/bor.lua | 26 ++++++++------ lua/tests/gmod/unit/libraries/bit/bswap.lua | 20 ++++------- lua/tests/gmod/unit/libraries/bit/bxor.lua | 28 ++++++++------- lua/tests/gmod/unit/libraries/bit/lshift.lua | 27 +++++++------- lua/tests/gmod/unit/libraries/bit/rol.lua | 19 ++++++---- lua/tests/gmod/unit/libraries/bit/ror.lua | 15 +++++--- lua/tests/gmod/unit/libraries/bit/rshift.lua | 19 ++++++---- lua/tests/gmod/unit/libraries/bit/tobit.lua | 36 ++++++++----------- lua/tests/gmod/unit/libraries/bit/tohex.lua | 19 ++++++---- 12 files changed, 148 insertions(+), 125 deletions(-) diff --git a/lua/tests/gmod/unit/libraries/bit/arshift.lua b/lua/tests/gmod/unit/libraries/bit/arshift.lua index 293df9a..82826c0 100644 --- a/lua/tests/gmod/unit/libraries/bit/arshift.lua +++ b/lua/tests/gmod/unit/libraries/bit/arshift.lua @@ -3,14 +3,14 @@ return { groupName = "bit.arshift", cases = { { - name = "Should be a function", + name = "Functions exists", func = function() expect( bit.arshift ).to.beA( "function" ) end }, { - name = "Should correctly shift positive numbers", + name = "Correctly shifts positive numbers", func = function() expect( bit.arshift( 8, 1 ) ).to.equal( 4 ) expect( bit.arshift( 16, 2 ) ).to.equal( 4 ) @@ -21,7 +21,7 @@ return { }, { - name = "Returns correct values for negative arhithmetic shifting", + name = "Correctly shifts negative numbers", func = function() expect( bit.arshift( -8, 1 ) ).to.equal( -4 ) expect( bit.arshift( -16, 2 ) ).to.equal( -4 ) @@ -31,11 +31,16 @@ return { }, { - name = "Fails on invalid input", + name = "Throws error when not given a number", func = function() - expect( bit.arshift, nil, nil ).to.err() - expect( bit.arshift, "abc", "def" ).to.err() - expect( bit.arshift, {}, {} ).to.err() + expect( bit.arshift, nil, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got nil)]] ) + expect( bit.arshift, 1, nil ).to.errWith( [[bad argument #2 to '?' (number expected, got no value)]] ) + + expect( bit.arshift, "abc", 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.arshift, 1, "def" ).to.errWith( [[bad argument #2 to '?' (number expected, got string)]] ) + + expect( bit.arshift, {}, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) + expect( bit.arshift, 1, {} ).to.errWith( [[bad argument #2 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/band.lua b/lua/tests/gmod/unit/libraries/bit/band.lua index 453050d..c7b3b56 100644 --- a/lua/tests/gmod/unit/libraries/bit/band.lua +++ b/lua/tests/gmod/unit/libraries/bit/band.lua @@ -3,33 +3,34 @@ return { groupName = "bit.band", cases = { { - name = "Should be a function", + name = "Function exists", func = function() expect( bit.band ).to.beA( "function" ) end }, { - name = "Should handle positive numbers correctly", + name = "Returns correct values", func = function() expect( bit.band( 8, 8 ) ).to.equal( 8 ) + expect( bit.band( 8, 1 ) ).to.equal( 0 ) expect( bit.band( 42, 17 ) ).to.equal( 0 ) - expect( bit.band( 13, 7 ) ).to.equal( 5 ) + expect( bit.band( 0, 0 ) ).to.equal( 0 ) end }, { - name = "Should handle negative numbers correctly", + name = "Returns correct values with negative inputs", func = function() expect( bit.band( -8, 8 ) ).to.equal( 8 ) - expect( bit.band( -10, -12 ) ).to.equal( -12 ) + expect( bit.band( -8, 1 ) ).to.equal( 0 ) end }, { name = "Functions properly with more than 2 args", func = function() - expect( bit.band( 15, 67, 13 ) ).to.equal( 1 ) + expect( bit.band( 0, 0, 0 ) ).to.equal( 0 ) expect( bit.band( 300, 200, 300 ) ).to.equal( 8 ) expect( bit.band( 1, 2, 4, 8, 16, 32, 64 ) ).to.equal( 0 ) end @@ -43,11 +44,16 @@ return { }, { - name = "Fails on invalid input", + name = "Throws error when not given a number", func = function() - expect( bit.band, nil, nil ).to.err() - expect( bit.band, "abc", "def" ).to.err() - expect( bit.band, {}, {} ).to.err() + expect( bit.band, nil, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got nil)]] ) + expect( bit.band, 1, nil ).toNot.err() + + expect( bit.band, "abc", 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.band, 1, "def" ).to.errWith( [[bad argument #2 to '?' (number expected, got string)]] ) + + expect( bit.band, {}, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) + expect( bit.band, 1, {} ).to.errWith( [[bad argument #2 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/bnot.lua b/lua/tests/gmod/unit/libraries/bit/bnot.lua index 463465b..fdbf7fb 100644 --- a/lua/tests/gmod/unit/libraries/bit/bnot.lua +++ b/lua/tests/gmod/unit/libraries/bit/bnot.lua @@ -3,14 +3,14 @@ return { groupName = "bit.bnot", cases = { { - name = "Should be a function", + name = "Function exists", func = function() expect( bit.bnot ).to.beA( "function" ) end }, { - name = "Should correctly invert positive and negative numbers", + name = "Correctly inverts input number", func = function() expect( bit.bnot( 8 ) ).to.equal( -9 ) expect( bit.bnot( 32 ) ).to.equal( -33 ) @@ -20,22 +20,27 @@ return { }, { - name = "Should handle edge cases correctly", + name = "Correctly inverts 0 and -1", func = function() expect( bit.bnot( 0 ) ).to.equal( -1 ) expect( bit.bnot( -1 ) ).to.equal( 0 ) + end + }, + { + name = "Correctly handles min and max values", + func = function() expect( bit.bnot( 2147483647 ) ).to.equal( -2147483648 ) expect( bit.bnot( -2147483648 ) ).to.equal( 2147483647 ) end }, { - name = "Fails on invalid input", + name = "Throws error when not given a number", func = function() - expect( bit.bnot, nil ).to.err() - expect( bit.bnot, "abc" ).to.err() - expect( bit.bnot, {} ).to.err() + expect( bit.bnot, nil ).to.errWith( [[bad argument #1 to '?' (number expected, got no value)]] ) + expect( bit.bnot, "abc" ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.bnot, {} ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/bor.lua b/lua/tests/gmod/unit/libraries/bit/bor.lua index 6f4272f..2d974ee 100644 --- a/lua/tests/gmod/unit/libraries/bit/bor.lua +++ b/lua/tests/gmod/unit/libraries/bit/bor.lua @@ -3,14 +3,14 @@ return { groupName = "bit.bor", cases = { { - name = "Should be a function", + name = "Function exists", func = function() expect( bit.bor ).to.beA( "function" ) end }, { - name = "Should handle positive numbers correctly", + name = "Correctly handles positive OR operations", func = function() expect( bit.bor( 8, 8 ) ).to.equal( 8 ) expect( bit.bor( 8, 1 ) ).to.equal( 9 ) @@ -19,7 +19,7 @@ return { }, { - name = "Should handle negative numbers correctly", + name = "Correctly handles negative OR operations", func = function() expect( bit.bor( -1, 0 ) ).to.equal( -1 ) expect( bit.bor( -8, 1 ) ).to.equal( -7 ) @@ -28,22 +28,21 @@ return { }, { - name = "Should handle zero values correctly", + name = "Correctly handles or operation with 0", func = function() expect( bit.bor( 0, 69 ) ).to.equal( 69 ) - expect( bit.bor( -42, 0 ) ).to.equal( -42 ) end }, { - name = "Returns correct value with multiple args", + name = "Correctly returns result with mutliple args", func = function() expect( bit.bor( 1, 2, 4, 8 ) ).to.equal( 15 ) end }, { - name = "Handles Min and max values", + name = "Correctly handles min and max values", func = function() expect( bit.bor( 2147483647, 2147483648 ) ).to.equal( -1 ) expect( bit.bor( -2147483648, 0 ) ).to.equal( -2147483648 ) @@ -51,11 +50,16 @@ return { }, { - name = "Fails on invalid input", + name = "Throws error when not given a number", func = function() - expect( bit.bor, nil, nil ).to.err() - expect( bit.bor, "abc", "def" ).to.err() - expect( bit.bor, {}, {} ).to.err() + expect( bit.bor, nil, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got nil)]] ) + expect( bit.bor, 1, nil ).toNot.err() + + expect( bit.bor, "abc", 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.bor, 1, "def" ).to.errWith( [[bad argument #2 to '?' (number expected, got string)]] ) + + expect( bit.bor, {}, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) + expect( bit.bor, 1, {} ).to.errWith( [[bad argument #2 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/bswap.lua b/lua/tests/gmod/unit/libraries/bit/bswap.lua index fdd4fa2..f85c137 100644 --- a/lua/tests/gmod/unit/libraries/bit/bswap.lua +++ b/lua/tests/gmod/unit/libraries/bit/bswap.lua @@ -3,14 +3,14 @@ return { groupName = "bit.bswap", cases = { { - name = "Should be a function", + name = "Functions exists", func = function() expect( bit.bswap ).to.beA( "function" ) end }, { - name = "positive number byte swap", + name = "Correctly returns swapped value", func = function() expect( bit.bswap( 327 ) ).to.equal( 1191247872 ) expect( bit.bswap( 8 ) ).to.equal( 134217728 ) @@ -18,15 +18,7 @@ return { }, { - name = "Negative number byte swap", - func = function() - expect( bit.bswap( -8 ) ).to.equal( -117440513 ) - expect( bit.bswap( -100 ) ).to.equal( -1660944385 ) - end - }, - - { - name = "Swapping 0 and -1 returns the correct value", + name = "Correctly handles swapping 0 and -1", func = function() expect( bit.bswap( 0 ) ).to.equal( 0 ) expect( bit.bswap( -1 ) ).to.equal( -1 ) @@ -36,9 +28,9 @@ return { { name = "Fails on invalid input", func = function() - expect( bit.bswap, nil ).to.err() - expect( bit.bswap, "abc" ).to.err() - expect( bit.bswap, {} ).to.err() + expect( bit.bswap, nil ).to.errWith( [[bad argument #1 to '?' (number expected, got no value)]] ) + expect( bit.bswap, "abc" ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.bswap, {} ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/bxor.lua b/lua/tests/gmod/unit/libraries/bit/bxor.lua index 1650fd5..63c0291 100644 --- a/lua/tests/gmod/unit/libraries/bit/bxor.lua +++ b/lua/tests/gmod/unit/libraries/bit/bxor.lua @@ -3,53 +3,55 @@ return { groupName = "bit.bxor", cases = { { - name = "Should be a function", + name = "Functions exists", func = function() expect( bit.bxor ).to.beA( "function" ) end }, { - name = "Positive XOR operation", + name = "Correctly handles positive XOR operations", func = function() expect( bit.bxor( 19, 82 ) ).to.equal( 65 ) expect( bit.bxor( 327, 63 ) ).to.equal( 376 ) expect( bit.bxor( 234, 0 ) ).to.equal( 234 ) - expect( bit.bxor( 32, 32 ) ).to.equal( 0 ) end }, { - name = "Negative XOR operation", + name = "Correctly handles negative XOR operations", func = function() expect( bit.bxor( -99, -55 ) ).to.equal( 84 ) expect( bit.bxor( -420, -67 ) ).to.equal( 481 ) expect( bit.bxor( -32, 0 ) ).to.equal( -32 ) - expect( bit.bxor( 42, -1 ) ).to.equal( -43 ) end }, { - name = "Handles min and max 32-bit integers correctly", + name = "Correctly handles same number input", func = function() - expect( bit.bxor( 2147483647, -2147483648 ) ).to.equal( -1 ) - expect( bit.bxor( 2147483647, 1 ) ).to.equal( 2147483646 ) + expect( bit.bxor( 32, 32 ) ).to.equal( 0 ) end }, { - name = "Handles multiple arguments correctly", + name = "Correctly handles multiple args as input", func = function() expect( bit.bxor( 1, 2, 3, 4, 5 ) ).to.equal( 1 ) end }, { - name = "Fails on invalid input", + name = "Throws error when not given a number", func = function() - expect( bit.bxor, nil, nil ).to.err() - expect( bit.bxor, "abc", "def" ).to.err() - expect( bit.bxor, {}, {} ).to.err() + expect( bit.bxor, nil, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got nil)]] ) + expect( bit.bxor, 1, nil ).toNot.err() + + expect( bit.bxor, "abc", 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.bxor, 1, "def" ).to.errWith( [[bad argument #2 to '?' (number expected, got string)]] ) + + expect( bit.bxor, {}, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) + expect( bit.bxor, 1, {} ).to.errWith( [[bad argument #2 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/lshift.lua b/lua/tests/gmod/unit/libraries/bit/lshift.lua index 2b0d55f..980d121 100644 --- a/lua/tests/gmod/unit/libraries/bit/lshift.lua +++ b/lua/tests/gmod/unit/libraries/bit/lshift.lua @@ -3,14 +3,14 @@ return { groupName = "bit.lshift", cases = { { - name = "Should be a function", + name = "Functions exists", func = function() expect( bit.lshift ).to.beA( "function" ) end }, { - name = "Should correctly shift positive numbers", + name = "Correctly lshifts numbers", func = function() expect( bit.lshift( 15, 4 ) ).to.equal( 240 ) expect( bit.lshift( 96, 4 ) ).to.equal( 1536 ) @@ -18,18 +18,11 @@ return { end }, - { - name = "Should correctly shift negative numbers", - func = function() - expect( bit.lshift( -8, 1 ) ).to.equal( -16 ) - end - }, - { name = "Values are getting clamped over the signed 32-bit int limit", func = function() expect( bit.lshift( 4294967295, 1 ) ).to.equal( -2 ) - expect( bit.lshift( 1, 31 ) ).to.equal( -2147483648 ) + expect( bit.lshift( -1, 1 ) ).to.equal( -2 ) end }, @@ -37,16 +30,20 @@ return { name = "Shifting 0 times should return the same value", func = function() expect( bit.lshift( 1, 0 ) ).to.equal( 1 ) - expect( bit.lshift( 12345678, 0 ) ).to.equal( 12345678 ) end }, { - name = "Fails on invalid input", + name = "Throws error when not given a number", func = function() - expect( bit.lshift, nil, nil ).to.err() - expect( bit.lshift, "abc", "def" ).to.err() - expect( bit.lshift, {}, {} ).to.err() + expect( bit.lshift, nil, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got nil)]] ) + expect( bit.lshift, 1, nil ).to.errWith( [[bad argument #2 to '?' (number expected, got no value)]] ) + + expect( bit.lshift, "abc", 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.lshift, 1, "def" ).to.errWith( [[bad argument #2 to '?' (number expected, got string)]] ) + + expect( bit.lshift, {}, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) + expect( bit.lshift, 1, {} ).to.errWith( [[bad argument #2 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/rol.lua b/lua/tests/gmod/unit/libraries/bit/rol.lua index c3c1130..76288f1 100644 --- a/lua/tests/gmod/unit/libraries/bit/rol.lua +++ b/lua/tests/gmod/unit/libraries/bit/rol.lua @@ -3,7 +3,7 @@ return { groupName = "bit.rol", cases = { { - name = "Should be a function", + name = "Function exists", func = function() expect( bit.rol ).to.beA( "function" ) end @@ -35,19 +35,24 @@ return { }, { - name = "Functions properly when rotating by 32", + name = "Functions properly when rotating over the limit", func = function() expect( bit.rol( 1, 32 ) ).to.equal( 1 ) - expect( bit.rol( 16, 32 ) ).to.equal( 16 ) + expect( bit.rol( 16, 16 ) ).to.equal( 1048576 ) end }, { - name = "Fails on invalid input", + name = "Throws error when not given a number", func = function() - expect( bit.rol, nil, nil ).to.err() - expect( bit.rol, "abc", "def" ).to.err() - expect( bit.rol, {}, {} ).to.err() + expect( bit.rol, nil, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got nil)]] ) + expect( bit.rol, 1, nil ).to.errWith( [[bad argument #2 to '?' (number expected, got no value)]] ) + + expect( bit.rol, "abc", 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.rol, 1, "def" ).to.errWith( [[bad argument #2 to '?' (number expected, got string)]] ) + + expect( bit.rol, {}, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) + expect( bit.rol, 1, {} ).to.errWith( [[bad argument #2 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/ror.lua b/lua/tests/gmod/unit/libraries/bit/ror.lua index f11f01a..2b5168c 100644 --- a/lua/tests/gmod/unit/libraries/bit/ror.lua +++ b/lua/tests/gmod/unit/libraries/bit/ror.lua @@ -3,7 +3,7 @@ return { groupName = "bit.ror", cases = { { - name = "Should be a function", + name = "Function exists", func = function() expect( bit.ror ).to.beA( "function" ) end @@ -43,11 +43,16 @@ return { }, { - name = "Fails on invalid input", + name = "Throws error when not given a number", func = function() - expect( bit.ror, nil, nil ).to.err() - expect( bit.ror, "abc", "def" ).to.err() - expect( bit.ror, {}, {} ).to.err() + expect( bit.ror, nil, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got nil)]] ) + expect( bit.ror, 1, nil ).to.errWith( [[bad argument #2 to '?' (number expected, got no value)]] ) + + expect( bit.ror, "abc", 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.ror, 1, "def" ).to.errWith( [[bad argument #2 to '?' (number expected, got string)]] ) + + expect( bit.ror, {}, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) + expect( bit.ror, 1, {} ).to.errWith( [[bad argument #2 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/rshift.lua b/lua/tests/gmod/unit/libraries/bit/rshift.lua index 4e5cbe8..ec548d5 100644 --- a/lua/tests/gmod/unit/libraries/bit/rshift.lua +++ b/lua/tests/gmod/unit/libraries/bit/rshift.lua @@ -3,7 +3,7 @@ return { groupName = "bit.rshift", cases = { { - name = "Should be a function", + name = "Functions exists", func = function() expect( bit.rshift ).to.beA( "function" ) end @@ -26,25 +26,30 @@ return { }, { - name = "Shifting 0 should remain 0", + name = "Correctly handles shifting the number 0", func = function() expect( bit.rshift( 0, 1 ) ).to.equal( 0 ) end }, { - name = "Shifting 0 times", + name = "Correctly handles shifting a number 0 times", func = function() expect( bit.rshift( 312, 0 ) ).to.equal( 312 ) end }, { - name = "Fails on invalid input", + name = "Throws error when not given a number", func = function() - expect( bit.rshift, nil, nil ).to.err() - expect( bit.rshift, "abc", "def" ).to.err() - expect( bit.rshift, {}, {} ).to.err() + expect( bit.rshift, nil, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got nil)]] ) + expect( bit.rshift, 1, nil ).to.errWith( [[bad argument #2 to '?' (number expected, got no value)]] ) + + expect( bit.rshift, "abc", 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.rshift, 1, "def" ).to.errWith( [[bad argument #2 to '?' (number expected, got string)]] ) + + expect( bit.rshift, {}, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) + expect( bit.rshift, 1, {} ).to.errWith( [[bad argument #2 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/tobit.lua b/lua/tests/gmod/unit/libraries/bit/tobit.lua index 238eeac..ebe103c 100644 --- a/lua/tests/gmod/unit/libraries/bit/tobit.lua +++ b/lua/tests/gmod/unit/libraries/bit/tobit.lua @@ -3,50 +3,42 @@ return { groupName = "bit.tobit", cases = { { - name = "Should be a function", + name = "Functions exists", func = function() expect( bit.tobit ).to.beA( "function" ) end }, { - name = "Should return unchanged values", + name = "Correctly returns unchanged values", func = function() - expect( bit.tobit( 1 ) ).to.equal( 1 ) - expect( bit.tobit( -1 ) ).to.equal( -1 ) + expect( bit.tobit( 1 ) ).to.equal(1) + expect( bit.tobit( -1 ) ).to.equal(-1) end }, { - name = "Should work correctly on positive boundary values", + name = "Behaves correctly when handling large numbers", func = function() - expect( bit.tobit( 2147483647 ) ).to.equal( 2147483647 ) - expect( bit.tobit( 2147483648 ) ).to.equal( -2147483648 ) + expect( bit.tobit( 2147483647 ) ).to.equal(2147483647) + expect( bit.tobit( 2147483648 ) ).to.equal(-2147483648) end }, { - name = "Should work correctly on negative boundary values", + name = "Handles Non-integer values", func = function() - expect( bit.tobit( -2147483647 ) ).to.equal( -2147483647 ) - expect( bit.tobit( -2147483648 ) ).to.equal( -2147483648 ) + expect( bit.tobit( 1.1 ) ).to.equal(1) + expect( bit.tobit( -1 ) ).to.equal(-1) end }, { - name = "Handles float values by truncating them", + name = "Throws error when not given a number", func = function() - expect( bit.tobit( 1.123 ) ).to.equal( 1 ) - expect( bit.tobit( -1.123 ) ).to.equal( -1 ) - end - }, - - { - name = "Fails on invalid input", - func = function() - expect( bit.tobit, nil ).to.err() - expect( bit.tobit, "abc" ).to.err() - expect( bit.tobit, {} ).to.err() + expect( bit.tobit, nil ).to.errWith( [[bad argument #1 to '?' (number expected, got no value)]] ) + expect( bit.tobit, "abc" ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.tobit, {} ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) end }, } diff --git a/lua/tests/gmod/unit/libraries/bit/tohex.lua b/lua/tests/gmod/unit/libraries/bit/tohex.lua index 232f37a..fa9d233 100644 --- a/lua/tests/gmod/unit/libraries/bit/tohex.lua +++ b/lua/tests/gmod/unit/libraries/bit/tohex.lua @@ -3,14 +3,14 @@ return { groupName = "bit.tohex", cases = { { - name = "Should be a function", + name = "Functions exists", func = function() expect( bit.tohex ).to.beA( "function" ) end }, { - name = "psotive numbers", + name = "Correctly handles positive numbers", func = function() expect( bit.tohex( 255 ) ).to.equal( "000000ff" ) expect( bit.tohex( 255, 4 ) ).to.equal( "00ff" ) @@ -18,7 +18,7 @@ return { }, { - name = "negative numbers", + name = "Correctly handles negative numbers", func = function() expect( bit.tohex( -1 ) ).to.equal( "ffffffff" ) expect( bit.tohex( -2 ) ).to.equal( "fffffffe" ) @@ -26,11 +26,16 @@ return { }, { - name = "Fails on invalid input", + name = "Throws error when not given a number", func = function() - expect( bit.tohex, nil ).to.err() - expect( bit.tohex, "abc" ).to.err() - expect( bit.tohex, {} ).to.err() + expect( bit.tohex, nil, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got nil)]] ) + expect( bit.tohex, 1, nil ).toNot.err() + + expect( bit.tohex, "abc", 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got string)]] ) + expect( bit.tohex, 1, "def" ).to.errWith( [[bad argument #2 to '?' (number expected, got string)]] ) + + expect( bit.tohex, {}, 1 ).to.errWith( [[bad argument #1 to '?' (number expected, got table)]] ) + expect( bit.tohex, 1, {} ).to.errWith( [[bad argument #2 to '?' (number expected, got table)]] ) end }, }