lua-exercises/anagrams.lua

40 lines
1.0 KiB
Lua

-- Solution --------------------------------------------------------------------
function is_anagram(str1, str2)
-- Your implementation here
end
-- Tests -----------------------------------------------------------------------
local luaunit = require("luaunit.luaunit")
function test_listen_is_anagram_of_silent()
luaunit.assertTrue(is_anagram("listen", "silent"))
end
function test_astronomers_is_anagram_of_moon_starers()
luaunit.assertTrue(is_anagram("astronomers", "moon starers"))
end
function test_dormitory_is_anagram_of_dirty_room()
luaunit.assertTrue(is_anagram("dormitory", "dirty room"))
end
function test_foo_is_not_anagram_of_bar()
luaunit.assertFalse(is_anagram("foo", "bar"))
end
function test_foo_is_not_anagram_of_of()
luaunit.assertFalse(is_anagram("foo", "of"))
end
function test_bar_is_not_anagram_of_barn()
luaunit.assertFalse(is_anagram("bar", "barn"))
end
function test_barn_is_not_anagram_of_bar()
luaunit.assertFalse(is_anagram("barn", "bar"))
end
os.exit(luaunit.LuaUnit.run())