Create leap year exercise

This commit is contained in:
Camden Dixie O'Brien 2023-10-15 13:55:02 +01:00
parent 225a8fb8c1
commit cdd7f3f8fd

26
basic/leap_year.lua Normal file
View File

@ -0,0 +1,26 @@
function leap_year(year)
-- Your solution here
end
-- Tests -----------------------------------------------------------------------
package.path = package.path .. ";../luaunit/?.lua"
local luaunit = require("luaunit")
function test_2004_is_leap_year()
luaunit.assertTrue(leap_year(2004))
end
function test_1993_is_not_leap_year()
luaunit.assertFalse(leap_year(1993))
end
function test_1900_is_not_leap_year()
luaunit.assertFalse(leap_year(1900))
end
function test_2000_is_leap_year()
luaunit.assertTrue(leap_year(2000))
end
os.exit(luaunit.LuaUnit.run())