From 467ca0446abcf9063bc18e4e126f6ed7deb420c3 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Mon, 11 Dec 2023 12:09:58 +0000 Subject: [PATCH] Write palindrome exercise --- palindromes.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 palindromes.lua diff --git a/palindromes.lua b/palindromes.lua new file mode 100644 index 0000000..e94d656 --- /dev/null +++ b/palindromes.lua @@ -0,0 +1,34 @@ +-- Solution -------------------------------------------------------------------- +function is_palindrome(str) + -- Your implementation here +end + +-- Tests ----------------------------------------------------------------------- + +local luaunit = require("luaunit.luaunit") + +function test_foo_is_not_palindrome() + luaunit.assertFalse(is_palindrome("foo")) +end + +function test_wow_is_palindrome() + luaunit.assertTrue(is_palindrome("wow")) +end + +function test_toast_is_not_palindrome() + luaunit.assertFalse(is_palindrome("toast")) +end + +function test_Racecar_is_palindrome() + luaunit.assertTrue(is_palindrome("Race car")) +end + +function test_Do_geese_see_God_is_palindrome() + luaunit.assertTrue(is_palindrome("Do geese see God?")) +end + +function test_No_lemons_no_melon_is_palindrome() + luaunit.assertTrue(is_palindrome("No lemons, no melon.")) +end + +os.exit(luaunit.LuaUnit.run())