Create leap year exercise
This commit is contained in:
parent
225a8fb8c1
commit
cdd7f3f8fd
26
basic/leap_year.lua
Normal file
26
basic/leap_year.lua
Normal 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())
|
Loading…
x
Reference in New Issue
Block a user