Module:Linguistic/testcases

Documentation for this module may be created at Module:Linguistic/testcases/doc

Code

-- Unit tests for [[Module:Linguistic]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_conjfromWiki()
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki | A | |lang=en  }}', 'A')
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki | | A | |lang=en  }}', 'A')
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki | A | B |lang=en}}', 'A and B')
	self:preprocess_equals_many('{{#invoke:Linguistic | conjfromWiki | A | B | C | D | E |lang=', '}}', {{'en', 'A, B, C, D and E'}, {'pl', 'A, B, C, D i E'}, {'no', 'A, B, C, D og E'}})
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki | A | B | C | D | E |lang=zh}}', 'A、B、C、D和E')
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki | A | B | C | D | E |lang=ja}}', 'A、B、C、DおよびE')
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki |אחת|שתיים|שלוש|lang=he}}', 'אחת, שתיים ושלוש')
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki | ا | ب | ت | ث | ج |lang=ar}}', 'ا، ب، ت، ث وج')
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki | A | | B |lang=en}}', 'A and B')
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki | A |3=B | C |lang=en}}', 'A, C and B')
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki | A | B | C |lang=en|type=comma}}', 'A, B, C')
	self:preprocess_equals('{{#invoke:Linguistic | conjfromWiki | A | B | C | D | E |lang=en|type=explicit or  }}', 'A or B or C or D or E')
end

function p:test_offromwiki__fr()
	self:preprocess_equals_preprocess_many(
		'Maître {{#invoke:Linguistic| offromwiki|lang=fr', '}}',
		'Maître {{Of/fr/old','}}', {
			{'|word=Alkmaar'}, 
			{'|word=Balaam  '}, 
			{'|word=Loutreuil'},
			{'|word=demi-figures féminines |determiner=1 |number=p|plural=1 |gender=f '}, 
			{'|word=Giovanelli Madonna |determiner=1 |gender=f '}, 
			{'|word=Starck Triptych |determiner=1 |gender=m '}, 
			{'|word=Osservanza |determiner=1 '}, 
	} )
end

function p:test_offromwiki__ca()
	self:preprocess_equals_preprocess_many(
		'Mestre {{#invoke:Linguistic| offromwiki|lang=ca', '}}',
		'Mestre {{Of/ca/old','}}', {
			{'|word=Alkmaar|1=Alkmaar '}, 
			{'|word=Balaam|1=Balaam'},
			{'|word=Ian|1=Ian'}, 
	} )
end

function p:test_noungroup()
	local noungroup = require('Module:Linguistic').noungroup
	self:equals('English', noungroup('somenoun', 'someadj', 'en'), 'someadj somenoun')
	self:equals('Arabic', noungroup('حديقة', 'جميلة', 'ar'), 'حديقة جميلة')
	self:equals('Latin', noungroup('hortus', 'pulcher', 'la'), 'hortus pulcher')
	self:equals('language without defined order', noungroup('somenoun', 'someadj', 'foolang'), 'somenoun (someadj)')
end

return p