Documentation for this module may be created at Module:mr-translit/testcases/doc

-- Unit tests for [[Module:mr-translit]]. Refresh page to run tests.
local tests = require('Module:UnitTests')
local mr_translit = require('Module:mr-translit')

--TO DO
function tests:do_test_translit(deva, roman, comment)
	self:equals(
		'<span class="Deva" lang="mr">[[' .. deva .. '#Marathi|' .. deva .. ']]</span>',
		mr_translit.tr(deva, 'mr', 'Deva'),
		roman,
		{ comment = comment })
end

function tests:test_translit_marathi()
	local examples = {
	--Weird schwa dropping (need to fix!)
		{ 'दगड', 'dagaḍ', 'weird schwa dropping in first syllable of words beginning with d (should be impossible!)'}, 
		{ 'दहशत', 'dahśat'},  
		{ 'दहशत', 'dahśat'}, 
		{ 'दऱ्या', 'daryā' }, --‘दऱ्या’ is the plural of ‘दरी’
		{ 'दहा', 'dahā'}, 
		{ 'दही', 'dahī'}, 
		{ 'दचकणे', 'dacakṇe'}, 
	--Final clusters/geminates (need to fix!)
		{ 'खुद्द', 'khudda', 'geminates/clusters finally force a schwa'}, 
		{ 'शुद्ध', 'śuddha' }, 
		{ 'घट्ट', 'ghaṭṭa' }, 
		{ 'भिन्न', 'bhinna' }, 
		{ 'मार्ग', 'mārga' }, 
		{ 'कर्म', 'karma' }, 
		{ 'शब्द', 'śabda' }, 
		{ 'पत्र', 'patra' }, 
		{ 'वृक्ष', 'vrukṣa' }, 
		{ 'महाराष्ट्र', 'mahārāṣṭra' }, 


	--Fundamental tests
		{ 'भारत', 'bhārat' }, 
		{ 'मराठी', 'marāṭhī' }, 
		{ 'हृदय', 'hruday' }, 
	
	--Homorganic nasal assimilation 
		{ 'गंगा', 'gaṅgā', "anusvara before ग' is its homorganic nasal ('ṅ')" },
		{ 'लंड', 'laṇḍa' }, --anusvara before 'ड' is its homorganic nasal ('ṇ') 
		{ 'कंबल', 'kambal' }, --anusvara before 'ब' is its homorganic nasal ('m')
	
	--The following two categories could be problematic since they could interfere with cases without schwa deletion
	--such as English borrowings (ऑगस्ट)
	--Word-final consonant clusters with no schwa deletion
		{ 'रक्त', 'rakta' }, 
		{ 'काव्य', 'kāvya' }, --य-final is a subcase
	
	--Word-final nasal assimilation consonant clusters with no schwa deletion (where nasal is न)
		{ 'मंद', 'manda' }, --Sanskrit borrowing
		{ 'उंच़', 'unċa', 'phonological ċ'}, 
	
	--Tests individual letters
		{ 'कृपा', 'krupā', [=[‘ऋ’ is ‘ru’]=] },
		{ 'ज्ञान', 'dnyān' }, --‘ज्ञ’ is ‘dny’ (even word initially such as Dnyaneshwar)
	
	--Eyelash र
		{ 'ऱ्हास', 'rhās' }, 
		{ 'दऱ्या', 'daryā' }, --‘दऱ्या’ is the plural of ‘दरी’
		{ 'दर्या', 'daryā' }, 
	
	--Ensures औ and ऐ remain diphthongs
		{ 'कैरी', 'kairī' }, --‘ऐ’ is a diphthong
		{ 'हौस', 'haus' }, --‘औ’ is a diphthong
	
	--Anusvāra before र, श, ष, स: Provincial Class
		{ 'संरक्षण', 'saurakṣaṇ' }, --Anusvāra transliterated before र is ‘u’
		{ 'संशय', 'sauśay' }, 
		{ 'दंष्ट्र', 'dauṣṭra' }, --Word-final ‘a’
		{ 'हंस', 'haus' }, 
	
	--Anusvāra before य, ल, व: Classical Class
		{ 'संयोग', 'saiyog' }, --Anusvāra transliterated before य is ‘i’
		{ 'संलग्न', 'sallagna' }, --Anusvāra transliterated before ल is ‘u’ + Word-final ‘a’
		{ 'संवाद', 'sauvād' }, --Anusvāra is transliterated before व is ‘u’
	
	--Anusvāra: Other
		{ 'सिंह', 'siuha' }, --Anusvāra before ‘ह’ and after ‘इ’ + Word-final ‘a’
		{ 'संहार', 'sauhār' }, --Anusvāra before ‘ह’
		{ 'संज्ञा', 'sandnyā' }, --Anusvāra before ‘ज्ञ’
		{ 'माझं', 'mājha' }, --Anusvara to stop schwa dropping
	
	--English borrowings
		{ 'बॅट', 'bĕṭ' }, --‘ ॅ‘ is IPA /æ/ (बॅट = bat)
		{ 'बँक', 'bĕṅk' }, -- ‘ँ’ = ‘ॅ’ + ‘ं’, chandrabindu is never used as in Hindi
	                                      --Rurally ‘ॅ’ is ‘yā’, so बँक becomes ‘byāṅk’
		{ 'ॲप', 'ĕp' }, --Independent form of ‘ ॅ‘ (ॲप = app)
		{ 'ऍप', 'ĕp' }, --Another independent form of ‘ ॅ‘ (ऍप = app)
		{ 'कॉट', 'kŏṭ' }, --‘ॉ‘ is IPA /ɔ/ (कॉट = cot), RP ‘ɒ’ and ‘ɔ’ are both represented with ‘ॉ‘
	                                      --Rurally ‘ॉ‘ is ‘ā’, so डॉकटर becomes ‘ḍākṭar’
		{ 'हाँग काँग', 'hŏṅg kŏṅg' }, --‘ॉ’ = ‘ॉ’ + ‘ं (हाँग काँग = Hong Kong)
		{ 'ऑस्ट्रेलिया', 'ŏsṭreliyā' }, --Independent form of ‘ ॉ‘ (ऑस्ट्रेलिया = Australia)
	    
	--The remaining tests concern: c and ċ, j and j̈, jh and j̈h
	--य denotes palatalisation and has no independent realisation (Perhaps this should be in Mod:mr-IPA instead)
		{ 'च्या', 'cā' }, --‘ċ’ palatalised to ‘c’ in genitive oblique
		{ 'तुझ्या', 'tujhā' }, --‘j̈h’ palatalised to ‘jh’ in genitive oblique
	
	--च word-initial minimal pair
		{ 'च़ार', 'ċār' }, --Word-initial voiceless alveolar affricate, ‘चार’ means ‘four’
		{ 'चार', 'cār' }, --Word-initial voiceless palato-alveolar affricate, ‘चार’ means ‘graze’ or ‘young green grass’
	
	--च word-medial minimal pair
		{ 'काच़ा', 'kāċā' }, --Word-medial voiceless alveolar affricate, ‘काचा’ is the plural form of ‘काच’ kāċ, which means ‘glass’
		{ 'काचा', 'kācā' }, --Word-medial voiceless palato-affricate, ‘काचा’ means ‘button-hole’ or ‘tuck’
	
	--च word-initial and word-medial minimal pair
		{ 'च़राच़र', 'ċarāċar' }, --Word-medial voiceless alveolar affricate, ‘चराचर’ is an onomatopoeia that means ‘tearing sound’ or ‘rapidly’
		{ 'चराचर', 'carācar' }, --Word-medial voiceless palato-affricate, ‘चराचर’ means ‘every created thing, animate or inanimate‘
	
	--ज word-initial minimal pair
		{ 'ज़प', 'j̈ap' }, --Word-initial voiced alveolar affricate, ‘जप’ is an imperative that means ‘be careful’
		{ 'जप', 'jap' }, --Word-initial voiced palato-affricate, ‘जप’ means ‘counting beads’
	
	--ज alveolar affricate word-medial
		{ 'मोज़णे', 'moj̈ṇe' }, --Word-medial voiced alveolar affricate
	
	--ज alveolar affricate word-final
		{ 'लाज़', 'lāj̈' }, --Word-final voiced alveolar affricate
		
	--झ word-initial and word-medial two minimal pairs
		{ 'झ़कझ़क', 'j̈hakj̈hak' }, --Word-initial and word-medial breathy-voiced alveolar affricate, means ‘bright light’
		{ 'झकझक', 'jhakjhak' }, --Word-initial and word-medial breathy-voiced palato-alveolar affricate, means ‘complaining’
		{ 'झ़ापड', 'j̈hāpaḍ' }, --Word-initial and word-medial breathy-voiced alveolar affricate, means ‘drowsiness’
		{ 'झापड', 'jhāpaḍ' }, --Word-initial and word-medial breathy-voiced palato-alveolar affricate, means ‘slap’
	
	--One alveolar affricate and one palato-alveolar affricate in a single word
		{ 'झीज़', 'jhīj̈' }, --‘झीज’ means ‘erosion’, see Wiktionary entry for ‘झिजणे’
		{ 'चीज़', 'cīj̈' }, --‘चीज’ means ‘thing’, see Wiktionary entry for ‘चीज़’
	
	--anusvar word final, e.g. as a neuter plural marker -> nasalisation of vowel
		{ 'अंग', 'aṅga'},
		{ 'अंगे', 'aṅge'},
		{ 'अंगं', 'aṅga'},
	}
	
	self:iterate(examples, 'do_test_translit')
end
 
return tests