Module:palindromes/testcases

7 of 82 tests failed. (refresh)

TextExpectedActual
test_palindrome_ar:
Passedواحدfalsefalse
Passedترجمfalsefalse
Passedرfalsefalse
Passedنونtruetrue
Passedبابtruetrue
Passedتحتtruetrue
Passedيرىtruetrue
Passedآباءtruetrue
Passedأشاءtruetrue
Passedيجئtruetrue
Passedأناtruetrue
Passedهمةtruetrue
Passedوضؤtruetrue
TextExpectedActual
test_palindrome_bho:
Failedनूनfalsetrue
Failedननूनtruefalse
Failedनूनूtruefalse
Failedप्रतंप्रtruefalse
TextExpectedActual
test_palindrome_cs:
Passedtázattruetrue
TextExpectedActual
test_palindrome_el:
Passedσορόςtruetrue
Passedαλλάtruetrue
TextExpectedActual
test_palindrome_en:
Passedafalsefalse
Passedabfalsefalse
Passedaafalsefalse
Passedabatruetrue
Passeda.afalsefalse
Passedabcfalsefalse
PassedAAAfalsefalse
Passedpalindromemordnilaptruetrue
Passednon-falsefalse
Passed-n-falsefalse
PassedI, man, am regal - a German am Itruetrue
PassedNever odd or eventruetrue
PassedIf I had a hi-fitruetrue
PassedMadam, I'm Adamtruetrue
PassedToo hot to hoottruetrue
PassedNo lemons, no melontruetrue
PassedToo bad I hid a boottruetrue
PassedLisa Bonet ate no basiltruetrue
PassedWarsaw was rawtruetrue
PassedWas it a car or a cat I saw?truetrue
PassedRise to vote, sirtruetrue
PassedDo geese see god?truetrue
Passed"Do nine men interpret?" "Nine men," I nodtruetrue
PassedRats live on no evil startruetrue
PassedWon't lovers revolt now?truetrue
PassedRace fast, safe cartruetrue
PassedPa's a saptruetrue
PassedMa is as selfless as I amtruetrue
PassedMay a moody baby doom a yam?truetrue
PassedAh, Satan sees Natashatruetrue
PassedNo devil lived ontruetrue
PassedLonely Tylenoltruetrue
PassedNot a banana batontruetrue
PassedNo "x" in "Nixon"truetrue
PassedO, stone, be not sotruetrue
PassedO Geronimo, no minor egotruetrue
Passed"Naomi," I moantruetrue
Passed"A Toyota's a Toyota"truetrue
PassedA dog, a panic in a pagodatruetrue
PassedOh no! Don Ho!truetrue
PassedNurse, I spy gypsies - run!truetrue
PassedSenile felinestruetrue
PassedNow I see bees I wontruetrue
PassedUFO tofutruetrue
PassedWe panic in a pewtruetrue
PassedOozy rat in a sanitary zootruetrue
PassedGod! A red nugget! A fat egg under a dog!truetrue
PassedGo hang a salami, I'm a lasagna hogtruetrue
Passedà latruetrue
TextExpectedActual
test_palindrome_grc:
PassedΝΙΨΟΝ ΑΝΟΜΗΜΑΤΑ ΜΗ ΜΟΝΑΝ ΟΨΙΝtruetrue
PassedΝίψον ἀνομήματα, μὴ μόναν ὄψινtruetrue
TextExpectedActual
test_palindrome_he:
Passedףרשנו רעבתן שבדבש ןתבער ונשרףtruetrue
Passedפרשנו רעבתן שבדבש נתבער ונשרףtruetrue
Passedﭏ׳װױײ ט ייי־ווול״א׳truetrue
TextExpectedActual
test_palindrome_hu:
Passedszusztruetrue
Failedkérektruefalse
Failedkeréktruefalse
Passedcsúcstruetrue
TextExpectedActual
test_palindrome_ja:
Passedいかにもにがいtruetrue
Passedakkafalsefalse
Failedakkafalsetrue
TextExpectedActual
test_palindrome_ota:
Passedقاپاقtruetrue

local tests = require('Module:UnitTests')
local m_palindromes = require('Module:palindromes')
local m_languages = require("Module:languages")

local function check_palindrome(word, expected, langcode, sc_code)
		sc = sc_code and require('Module:scripts').getByCode(sc_code) or nil
		tests:equals(
			word,
			m_palindromes.is_palindrome(word, m_languages.getByCode(langcode), sc),
			expected
		)
	end

function tests:test_palindrome_en()
	
	check_palindrome('a', false, "en")
	check_palindrome('ab', false, "en")
	check_palindrome('aa', false, "en")
	check_palindrome('aba', true, "en")
	check_palindrome('a.a', false, "en")
	check_palindrome('abc', false, "en")
	check_palindrome('AAA', false, "en")
	check_palindrome('palindromemordnilap', true, "en")
	check_palindrome('non-', false, "en")
	
	-- unsure about these two cases:
		--check_palindrome('7/7', false, 'en')
		--check_palindrome('B & B', false, 'en')
	
	check_palindrome("-n-", false, "en")
	check_palindrome("I, man, am regal - a German am I", true, 'en')
	check_palindrome("Never odd or even", true, 'en')
	check_palindrome("If I had a hi-fi", true, 'en')
	check_palindrome("Madam, I\'m Adam", true, 'en')
	check_palindrome("Too hot to hoot", true, 'en')
	check_palindrome("No lemons, no melon", true, 'en')
	check_palindrome("Too bad I hid a boot", true, 'en')
	check_palindrome("Lisa Bonet ate no basil", true, 'en')
	check_palindrome("Warsaw was raw", true, 'en')
	check_palindrome("Was it a car or a cat I saw?", true, 'en')
	
	check_palindrome("Rise to vote, sir", true, 'en')
	check_palindrome("Do geese see god?", true, 'en')
	check_palindrome("\"Do nine men interpret?\" \"Nine men,\" I nod", true, 'en')
	check_palindrome("Rats live on no evil star", true, 'en')
	check_palindrome("Won\'t lovers revolt now?", true, 'en')
	check_palindrome("Race fast, safe car", true, 'en')
	check_palindrome("Pa\'s a sap", true, 'en')
	check_palindrome("Ma is as selfless as I am", true, 'en')
	check_palindrome("May a moody baby doom a yam?", true, 'en')
	
	check_palindrome("Ah, Satan sees Natasha", true, 'en')
	check_palindrome("No devil lived on", true, 'en')
	check_palindrome("Lonely Tylenol", true, 'en')
	check_palindrome("Not a banana baton", true, 'en')
	check_palindrome("No \"x\" in \"Nixon\"", true, 'en')
	check_palindrome("O, stone, be not so", true, 'en')
	check_palindrome("O Geronimo, no minor ego", true, 'en')
	check_palindrome("\"Naomi,\" I moan", true, 'en')
	check_palindrome("\"A Toyota\'s a Toyota\"", true, 'en')
	check_palindrome("A dog, a panic in a pagoda", true, 'en')
	
	check_palindrome("Oh no! Don Ho!", true, 'en')
	check_palindrome("Nurse, I spy gypsies - run!", true, 'en')
	check_palindrome("Senile felines", true, 'en')
	check_palindrome("Now I see bees I won", true, 'en')
	check_palindrome("UFO tofu", true, 'en')
	check_palindrome("We panic in a pew", true, 'en')
	check_palindrome("Oozy rat in a sanitary zoo", true, 'en')
	check_palindrome("God! A red nugget! A fat egg under a dog!", true, 'en')
	check_palindrome("Go hang a salami, I\'m a lasagna hog", true, 'en')
	check_palindrome("à la", true, 'en')

end

function tests:test_palindrome_he()
	
	check_palindrome("ףרשנו רעבתן שבדבש ןתבער ונשרף", true, "he")
	check_palindrome("פרשנו רעבתן שבדבש נתבער ונשרף", true, "he")
	check_palindrome("ﭏ׳װױײ ט ייי־ווול״א׳", true, "he")

end

function tests:test_palindrome_grc()
	
	check_palindrome("ΝΙΨΟΝ ΑΝΟΜΗΜΑΤΑ ΜΗ ΜΟΝΑΝ ΟΨΙΝ", true, 'grc')
	check_palindrome("Νίψον ἀνομήματα, μὴ μόναν ὄψιν", true, 'grc')

end

function tests:test_palindrome_hu()
	
	check_palindrome("szusz", true, 'hu')
	check_palindrome("kérek", true, 'hu')
	check_palindrome("kerék", true, 'hu')
	check_palindrome("csúcs", true, 'hu')
	
end

function tests:test_palindrome_el()
	
	check_palindrome("σορός", true, "el")
	check_palindrome("αλλά", true, "el")
	
end

function tests:test_palindrome_cs()
	
	check_palindrome("tázat", true, "cs")
	
end

function tests:test_palindrome_ota()
	
	check_palindrome("قاپاق", true, "ota")
	
end

function tests:test_palindrome_ja()
	
	check_palindrome("いかにもにがい", true, "ja")
	check_palindrome("akka", false, "ja", "Latn")
	check_palindrome("akka", false, "ja")
	
end

function tests:test_palindrome_ar()

	check_palindrome("واحد", false, "ar")
	check_palindrome("ترجم", false, "ar")
	check_palindrome("ر", false, "ar")
	check_palindrome("نون", true, "ar")
	check_palindrome("باب", true, "ar")
	check_palindrome("تحت", true, "ar")
	check_palindrome("يرى", true, "ar")
	check_palindrome("آباء", true, "ar")
	check_palindrome("أشاء", true, "ar")
	check_palindrome("يجئ", true, "ar")
	check_palindrome("أنا", true, "ar")
	check_palindrome("همة", true, "ar")
	check_palindrome("وضؤ", true, "ar")

end

function tests:test_palindrome_bho()
	check_palindrome("नून", false, "bho")
	check_palindrome("ननून", true, "bho")
	check_palindrome("नूनू", true, "bho")
	check_palindrome("प्रतंप्र", true, "bho")
	
end

return tests