Skip to content

Commit

Permalink
chore: missing push develop into latest merge main (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoDornelles authored Jul 18, 2024
1 parent 9af3e6e commit 59ac4ef
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
16 changes: 16 additions & 0 deletions src/cli/fs.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
local function ls(src_path)
local ls_cmd = io.popen('ls -1 '..src_path)
local ls_files = {}

if ls_cmd then
repeat
local line = ls_cmd:read()
ls_files[#ls_files + 1] = line
until not line
ls_cmd:close()
end

return ls_files
end

local function clear(src_path)
if os.execute('rm --version > /dev/null 2> /dev//null') then
os.execute('mkdir -p '..src_path)
Expand Down Expand Up @@ -195,6 +210,7 @@ local function bundler(src_path, src_file, dest_file)
end

local P = {
ls = ls,
move = move,
moveLua = moveLua,
bundler = bundler,
Expand Down
10 changes: 8 additions & 2 deletions src/cli/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,16 @@ elseif command == 'bundler' then
zeebo_fs.bundler(path, file, dist..file)
elseif command == 'test-self' then
coverage = coverage and '-lluacov' or ''
local ok = os.execute('lua '..coverage..' ./tests/test_lib_common_math.lua')
local ok = ok and os.execute('lua '..coverage..' ./tests/test_shared_args.lua')
local files = zeebo_fs.ls('./tests')
local index = 1
local ok = true
while index <= #files do
ok = ok and os.execute('lua '..coverage..' ./tests/'..files[index])
index = index + 1
end
if #coverage > 0 then
os.execute('luacov src')
os.execute('tail -n '..tostring(#files + 5)..' luacov.report.out')
end
if not ok then
os.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/common/math.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ local function map(value, in_min, in_max, out_min, out_max)
return (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
end

--! @shor maximum
--! @short maximum
--! @todo document this
local function max(...)
local args = {...}
Expand Down
11 changes: 11 additions & 0 deletions tests/test_lib_common_math.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ function test_dis()
luaunit.assertEquals(zeebo_math.dis(0, 0, 3, 4), 5)
end

function test_dis2()
luaunit.assertEquals(zeebo_math.dis2(0, 0, 3, 4), 25)
end

function test_abs()
luaunit.assertEquals(zeebo_math.abs(-5), 5)
luaunit.assertEquals(zeebo_math.abs(10), 10)
Expand Down Expand Up @@ -51,6 +55,13 @@ function test_cycle()
luaunit.assertEquals(zeebo_math.cycle(15, 10), 0.5)
end

function test_min()
luaunit.assertEquals(zeebo_math.min(1, 2, 3, 4, 5), 1)
luaunit.assertEquals(zeebo_math.min(10, -5, 3, 0), -5)
luaunit.assertEquals(zeebo_math.min(-1, -2, -3), -3)
luaunit.assertEquals(zeebo_math.min({1, 2, 3, 4, 5}), 1)
end

function test_max()
luaunit.assertEquals(zeebo_math.max(1, 2, 3, 4, 5), 5)
luaunit.assertEquals(zeebo_math.max(10, -5, 3, 0), 10)
Expand Down

0 comments on commit 59ac4ef

Please sign in to comment.