From cdd7f3f8fdaa096b9a47c999346996a1e4ee5c69 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sun, 15 Oct 2023 13:55:02 +0100 Subject: [PATCH] Create leap year exercise --- basic/leap_year.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 basic/leap_year.lua diff --git a/basic/leap_year.lua b/basic/leap_year.lua new file mode 100644 index 0000000..582e9fb --- /dev/null +++ b/basic/leap_year.lua @@ -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())