local tests = require("Module:UnitTests")
local make_plural_noun = require("Module:es-headword").make_plural_noun
local adjective_forms = require("Module:es-headword").adjective_forms
local function link(word)
return "]"
end
function tests:check_noun_plurals(singular, expected_plural, gender)
local r = make_plural_noun(singular, gender)
local test = r.pl
if r.pl2 then test = test .. ", " .. r.pl2 end
self:equals(link(singular),
test,
expected_plural)
end
function tests:check_adjective_forms(singular, expected_forms, gender)
local forms = adjective_forms(singular, gender)
self:equals(link(singular),
forms.ms .. ", " .. forms.mp .. ", " .. forms.fs .. ", " .. forms.fp,
expected_forms.ms .. ", " .. expected_forms.mp .. ", " .. expected_forms.fs .. ", " .. expected_forms.fp)
end
function tests:test_noun_plurals()
local examples = {
"nouns ending in unstressed vowel or á, é, ó",
{"pera", "peras"},
{"bota", "botas"},
{"sonido", "sonidos"},
{"panti", "pantis"},
{"café", "cafés"},
{"papá", "papás"},
{"buró", "burós"},
"nouns ending in í or ú",
{"tisú", "tisús, tisúes"},
{"tabú", "tabús, tabúes"},
{"israelí", "israelís, israelíes"},
{"marroquí", "marroquís, marroquíes"},
"nouns ending in a vowel + y, l, r, n, d, j, or ch",
{"rey", "reyes"},
{"panel", "paneles"},
{"color", "colores"},
{"alféizar", "alféizares"},
{"can", "canes"},
{"césped", "céspedes"},
{"reloj", "relojes"},
{"sándwich", "sándwiches"},
{"orden", "órdenes"},
{"volumen", "volúmenes"},
{"brasil", "brasiles"},
{"níquel", "níqueles"}, -- maybe shouldn't have a plural, but ...
{"íleon", "íleones"},
"single syllable, ending in s or x",
{"mes", "meses"},
{"fax", "faxes"},
"nouns ending in a vowel + z",
{"luz", "luces"},
{"lápiz", "lápices"},
{"actriz", "actrices"},
{"voz", "voces"},
{"maíz", "maíces"},
"noun ending in tz",
{"kibbutz", "kibbutz"},
"nouns ending in a stressed vowel + consonant",
{"botón", "botones"},
{"compás", "compases"},
{"acreditación", "acreditaciones"},
{"champiñón", "champiñones"},
{"tahúr", "tahúres"},
"nouns ending in a consonant cluster",
{"iceberg", "icebergs"},
"nouns ending in a vowel + a consonant other than l, r, n, d, z, j, s, x, or ch",
{"esnob", "esnobs"},
{"zigzag", "zigzags"},
{"crac", "cracs"},
{"mamut", "mamuts"},
"nouns ending in s or x with more than 1 syllable, last syllable unstressed",
{"análisis", "análisis"},
{"jueves", "jueves"},
{"lunes", "lunes"},
{"tórax", "tórax"},
{"cóccix", "cóccix"},
{"ibex", "ibex"},
{"carcax", "carcax"},
{"bíceps", "bíceps"},
"nouns ending in l, r, n, d, z, j, 3 or more syllables, accented on third to last syllable",
{"polisíndeton", "polisíndeton"},
"noun + adjective",
{"número arábigo", "números arábigos", "m"},
{"fórmula química", "fórmulas químicas", "f"},
{"accidente cerebrovascular", "accidentes cerebrovasculares", "m"},
{"arándano azul", "arándanos azules", "m"},
{"avión común", "aviones comunes", "m"},
{"católica romana", "católicas romanas", "f"},
"noun + prepositional phrase (de, del)",
{"hombre de letras", "hombres de letras"},
{"hombre del mundo", "hombres del mundo"},
{"acero al carbono", "aceros al carbono"},
"other",
{"esmoquin", "esmóquines"},
{"guion", "guiones"},
{"ciempiés", "ciempiés"}
}
tests:iterate(examples, "check_noun_plurals")
end
function tests:test_adjective_forms()
local examples = {
"ending in -o",
{"ponzoñoso", { = "ponzoñoso", = "ponzoñosos", = "ponzoñosa", = "ponzoñosas"}},
"ending in -a",
{"química", { = "químico", = "químicos", = "química", = "químicas"}, "f"},
"ending in -e",
{"tolerable", { = "tolerable", = "tolerables", = "tolerable", = "tolerables"}},
"ending in -ista",
{"culturalista", { = "culturalista", = "culturalistas", = "culturalista", = "culturalistas"}},
"ending in -z",
{"feliz", { = "feliz", = "felices", = "feliz", = "felices"}},
"ending in -or",
{"ahorrador", { = "ahorrador", = "ahorradores", = "ahorradora", = "ahorradoras"}, "m"},
{"ahorradora", { = "ahorrador", = "ahorradores", = "ahorradora", = "ahorradoras"}, "f"},
{"superior", { = "superior", = "superiores", = "superior", = "superiores"}, "m"},
"ending in -ón",
{"alegrón", { = "alegrón", = "alegrones", = "alegrón", = "alegrones"}},
"ending in -ín",
{"cantarín", { = "cantarín", = "cantarines", = "cantarina", = "cantarinas"}},
"ending in -l",
{"aluvial", { = "aluvial", = "aluviales", = "aluvial", = "aluviales"}},
{"civil", { = "civil", = "civiles", = "civil", = "civiles"}},
"ending in -ar",
{"auxiliar", {= "auxiliar", = "auxiliares", = "auxiliar", = "auxiliares"}},
"ending in -és",
{"francés", { = "francés", = "franceses", = "francesa", = "francesas"}},
"ending in -án",
{"alemán", { = "alemán", = "alemanes", = "alemana", = "alemanas"}}
}
tests:iterate(examples, "check_adjective_forms")
end
return tests