Jump to content

Module:ar-nominals/testcases

From Wiktionary, the free dictionary

This is the unit-testing module for Module:ar-nominals.

3 of 52 tests failed. (refresh)

TextExpectedActualDiffers at
test_decl_arabic:
Passedsfp for مرْآةمرْ￰َيَات/�مرْ￰َيَات/�
Passedsfp for مراةمرَيَات/�مرَيَات/�
Passedsfp for مَرَاة (marāh)مَرَيَات/marayātمَرَيَات/marayāt
Passedsfp for مُسْتَشْفًى (mustašfan)مُسْتَشْفَيَات/mustašfayātمُسْتَشْفَيَات/mustašfayāt
Passedsfp for كَاتٍ (kātin)كَاتِيَات/kātiyātكَاتِيَات/kātiyāt
Passedsfp for ذِكْرَى (ḏikrā)ذِكْرَيَات/ḏikrayātذِكْرَيَات/ḏikrayāt
Passedsfp for دُنْيَا (dunyā)دُنْيَيَات/dunyayātدُنْيَيَات/dunyayāt
Passedsfp for كَامِيرَا (kāmīrā)كَامِيرَات/kāmīrātكَامِيرَات/kāmīrāt
Passedsfp for كُبْء (kubʔ)كُبْ￰َات/kubʔātكُبْ￰َات/kubʔāt
Passedsfp for كُوب (kūb)كُوبَات/kūbātكُوبَات/kūbāt
Passedsmp for كَاتٍ (kātin)كَاتُون/kātūnكَاتُون/kātūn
Passedsmp for كَتَأ (kataʔ)كَتَ￰ُون/kataʔūnكَتَ￰ُون/kataʔūn
Passedsmp for كَتِئ (katiʔ)كَتِ￰ُون/katiʔūnكَتِ￰ُون/katiʔūn
Passedsmp for كُبْء (kubʔ)كُبْ￰ُون/kubʔūnكُبْ￰ُون/kubʔūn
Passedsmp for مُسْلِم (muslim)مُسْلِمُون/muslimūnمُسْلِمُون/muslimūn
Passedawnp for كَتًى (katan)كَتَوْن/katawnكَتَوْن/katawn
Passedsingular دُنْيَا (dunyā)invinv
Passedplural هَدَايَا (hadāyā)invinv
Passedsingular ذِكْرَى (ḏikrā)invinv
Failedsingular لِيبِيَا (lībiyā)invlwinv1
Passedsingular كَامِيرَا (kāmīrā)lwinvlwinv
Passedplural لَيَالٍ (layālin)diindiin
Passedplural مَآسٍ (maʔāsin)diindiin
Passedplural أَيْدٍ (ʔaydin)triintriin
Passedsingular وَادٍ (wādin)triintriin
Passedsingular مُسْتَشْفًى (mustašfan)anan
Passedsingular عَصًا (ʕaṣan)anan
Passedplural أَدْنَوْن (ʔadnawn)awnpawnp
Passedplural أَدْنَوْنَ (ʔadnawna)awnpawnp
Passedplural مُسْلِمُون (muslimūn)smpsmp
Passedplural مُسْلِمُونَ (muslimūna)smpsmp
Passedsingular مُسْلِمَة (muslima)tritri
Passedsingular مُسْلِمَةٌ (muslimatun)tritri
Passedplural مُسْلِمَات (muslimāt)sfpsfp
Passedplural مُسْلِمَاتٌ (muslimātun)sfpsfp
Passedplural فَوَاكِه (fawākih)didi
Passedplural فَوَاكِهُ (fawākihu)didi
Passedplural مَفَاتِيح (mafātīḥ)didi
Passedplural مَقَامّ (maqāmm)didi
Passedplural مَقَامُّ (maqāmmu)didi
Passedplural وُزَرَاء (wuzarāʔ)didi
Passedplural أَصْدِقَاء (ʔaṣdiqāʔ)didi
Passedplural أَقِلَّاء (ʔaqillāʔ)didi
Failedsingular كَسْلَان (kaslān)ditri1
Passedsingular قَمْرَاء (qamrāʔ)didi
Failedsingular لَفَّاء (laffāʔ)ditri1
Passedsingular أَحْمَر (ʔaḥmar)didi
Passedsingular أَلَفّ (ʔalaff)didi
Passedsingular آلَم (ʔālam)didi
Passedsingular كِتَاب (kitāb)tritri
Passedplural كُتُب (kutub)tritri
Passedplural أَفْلَام (ʔaflām)tritri

-- Unit tests for [[Module:ar-nominals]]. Refresh page to run tests.
local tests = require('Module:UnitTests')
local ar_nominals = require('Module:ar-nominals')

local full_link = require('Module:links').full_link
local Arabic = require("Module:languages").getByCode("ar")
local rsub = mw.ustring.gsub
local u = mw.ustring.char

local BOGUS_CHAR = u(0xFFFD)
local HAMZA_PH = u(0xFFF0)

local function link(form)
	return full_link{term = form, lang = Arabic}
end

local function canon_hamza(form)
	form = rsub(form, "آ", HAMZA_PH .. "َا")
	form = rsub(form, "[ءأئؤ]", HAMZA_PH)
	return form
end

function tests:check_gen_plural(sg, form, outform)
	-- For given singular, detect the declension type ...
	local sgform, sgtype = ar_nominals.stem_and_type(sg, "", "", false, "sg", "noun")
	-- .. then pass in when we need to generate the plural
	local oform, oclass = ar_nominals.stem_and_type(form, sgform, sgtype, false, "pl", "noun")
	return self:equals(form .. " for " .. link(sg), oform, canon_hamza(outform) .. "/" .. ((Arabic:transliterate(outform)) or BOGUS_CHAR))
end

function tests:check_detect(form, outclass, ispl)
	local oform, oclass = ar_nominals.stem_and_type(form, "", "", false, ispl and "pl" or "sg", "noun")
	return self:equals((ispl and "plural " or "singular ") .. link(form), oclass, outclass)
end

function tests:test_decl_arabic()
	local examples1 = {
		{ "مرْآة", "sfp", "مرْأَيَات" },
		{ "مراة", "sfp", "مرَيَات" },
		{ "مَرَاة", "sfp", "مَرَيَات" },
		{ "مُسْتَشْفًى", "sfp", "مُسْتَشْفَيَات" },
		{ "كَاتٍ", "sfp", "كَاتِيَات" },
		{ "ذِكْرَى", "sfp", "ذِكْرَيَات" },
		{ "دُنْيَا", "sfp", "دُنْيَيَات" },
		{ "كَامِيرَا", "sfp", "كَامِيرَات" },
		{ "كُبْء", "sfp", "كُبْآت" },
		{ "كُوب", "sfp", "كُوبَات" },
	
		{ "كَاتٍ", "smp", "كَاتُون" },
		{ "كَتَأ", "smp", "كَتَؤُون" },
		{ "كَتِئ", "smp", "كَتِئُون" },
		{ "كُبْء", "smp", "كُبْؤُون" },
		{ "مُسْلِم", "smp", "مُسْلِمُون" },
	
		{ "كَتًى", "awnp", "كَتَوْن" },
	}
	
	self:iterate(examples1, "check_gen_plural")

	local examples2 = {
		{ "دُنْيَا", "inv" }, -- dunyā "world"
		{ "هَدَايَا", "inv", true }, -- hadāyā "gifts"
		{ "ذِكْرَى", "inv" }, -- ḏikrā "remembrance"
		{ "لِيبِيَا", "inv" }, -- lībiyā "Libya"
		{ "كَامِيرَا", "lwinv" }, -- kāmērā "camera"
		{ "لَيَالٍ", "diin", true }, -- layālin "nights"
		{ "مَآسٍ", "diin", true }, -- maʾāsin "tragedies, dramas"
		{ "أَيْدٍ", "triin", true }, -- ʾaydin "hands"
		{ "وَادٍ", "triin" }, -- wādin "valley"
		{ "مُسْتَشْفًى", "an" }, -- mustašfan "hospital"
		{ "عَصًا", "an" }, -- ʿaṣan "stick"
		{ "أَدْنَوْن", "awnp", true }, -- ʾadnawn "nearer (masc. pl.)"
		{ "أَدْنَوْنَ", "awnp", true }, -- ʾadnawna "nearer (masc. pl.)"
		{ "مُسْلِمُون", "smp", true }, -- muslimūn "Muslims"
		{ "مُسْلِمُونَ", "smp", true }, -- muslimūna "Muslims"
		{ "مُسْلِمَة", "tri" }, -- muslima "Muslim (fem.)"
		{ "مُسْلِمَةٌ", "tri" }, -- muslimatun "Muslim (fem.)"
		{ "مُسْلِمَات", "sfp", true }, -- muslimāt "Muslims (fem.)"
		{ "مُسْلِمَاتٌ", "sfp", true }, -- muslimāti "Muslims (fem.)"
		{ "فَوَاكِه", "di", true }, -- fawākih "fruits"
		{ "فَوَاكِهُ", "di", true }, -- fawākihu "fruits"
		{ "مَفَاتِيح", "di", true }, -- mafātīḥ "keys"
		{ "مَقَامّ", "di", true }, -- maqāmm "brooms"
		{ "مَقَامُّ", "di", true }, -- maqāmmu "brooms"
		{ "وُزَرَاء", "di", true }, -- wuzarāʾ "ministers"
		{ "أَصْدِقَاء", "di", true }, -- ʾaṣdiqāʾ "friends"
		{ "أَقِلَّاء", "di", true }, -- ʾaqillāʾ "small (masc. pl.)"
		{ "كَسْلَان", "di" }, -- kaslān "lazy"
		{ "قَمْرَاء", "di" }, -- qamrāʾ "moon-white, moonlight"
		{ "لَفَّاء", "di" }, -- laffāʾ "plump (fem.)"
		{ "أَحْمَر", "di" }, -- ʾaḥmar "red"
		{ "أَلَفّ", "di" }, -- ʾalaff "plump"
		{ "آلَم", "di" }, -- ʾālam "more painful"
		{ "كِتَاب", "tri" }, -- kitāb "book"
		{ "كُتُب", "tri", true }, -- kutub "books"
		{ "أَفْلَام", "tri", true }, -- ʾaflām "films"
	}
	self:iterate(examples2, "check_detect")
end
 
return tests