39 lines
1.0 KiB
Lua
39 lines
1.0 KiB
Lua
-- Implement is_palindrome(), which should return whether the passed
|
|
-- string is palindromic (i.e the same forwards as it is backwards).
|
|
-- Ignore non-letters and case.
|
|
--
|
|
-- 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())
|