Module:es-headword/testcases

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 "" .. word .. "" 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", {["ms"] = "ponzoñoso", ["mp"] = "ponzoñosos", ["fs"] = "ponzoñosa", ["fp"] = "ponzoñosas"}}, "ending in -a", {"química", {["ms"] = "químico", ["mp"] = "químicos", ["fs"] = "química", ["fp"] = "químicas"}, "f"}, "ending in -e", {"tolerable", {["ms"] = "tolerable", ["mp"] = "tolerables", ["fs"] = "tolerable", ["fp"] = "tolerables"}}, "ending in -ista", {"culturalista", {["ms"] = "culturalista", ["mp"] = "culturalistas", ["fs"] = "culturalista", ["fp"] = "culturalistas"}}, "ending in -z", {"feliz", {["ms"] = "feliz", ["mp"] = "felices", ["fs"] = "feliz", ["fp"] = "felices"}}, "ending in -or", {"ahorrador", {["ms"] = "ahorrador", ["mp"] = "ahorradores", ["fs"] = "ahorradora", ["fp"] = "ahorradoras"}, "m"}, {"ahorradora", {["ms"] = "ahorrador", ["mp"] = "ahorradores", ["fs"] = "ahorradora", ["fp"] = "ahorradoras"}, "f"}, {"superior", {["ms"] = "superior", ["mp"] = "superiores", ["fs"] = "superior", ["fp"] = "superiores"}, "m"}, "ending in -ón", {"alegrón", {["ms"] = "alegrón", ["mp"] = "alegrones", ["fs"] = "alegrón", ["fp"] = "alegrones"}}, "ending in -ín", {"cantarín", {["ms"] = "cantarín", ["mp"] = "cantarines", ["fs"] = "cantarina", ["fp"] = "cantarinas"}}, "ending in -l", {"aluvial", {["ms"] = "aluvial", ["mp"] = "aluviales", ["fs"] = "aluvial", ["fp"] = "aluviales"}}, {"civil", {["ms"] = "civil", ["mp"] = "civiles", ["fs"] = "civil", ["fp"] = "civiles"}}, "ending in -ar", {"auxiliar", {["ms"]= "auxiliar", ["mp"] = "auxiliares", ["fs"] = "auxiliar", ["fp"] = "auxiliares"}}, "ending in -és", {"francés", {["ms"] = "francés", ["mp"] = "franceses", ["fs"] = "francesa", ["fp"] = "francesas"}}, "ending in -án", {"alemán", {["ms"] = "alemán", ["mp"] = "alemanes", ["fs"] = "alemana", ["fp"] = "alemanas"}} }	tests:iterate(examples, "check_adjective_forms") end return tests