localp=require('Módulo:UnitTests')locallang_data=mw.loadData('Módulo:Lang/data');-- language name override and transliteration tool-tip tableslocallang_table=lang_data.lang_name_table.lang;locallang_es_table=lang_data.lang_name_table.lang_es;localoverride_table=lang_data.override;localcode_mask='^[j-p]%l%l';-- used to limit number of tests--[[--------------------------< T E S T _ P A T T E R N S _ G E T >--------------------------------------------build a table of test patterns where each entry in the table is a table with two members: {"<name>", "<tag>"}]]localfunctiontest_patterns_get()localtpats={}-- collect test patterns herelocalcomplete={}fork,vinpairs(lang_table)docomplete[k]=vendfork,vinpairs(lang_es_table)docomplete[k]=vendfortag,namesinpairs(complete)dolocalpattern={};-- here we assemble the test pattern for <name>-- if 2 == tag:len() then -- no limits for two-character codesiftag:find(code_mask)then-- if tag within limits (three-character codes)ifoverride_table[tag]thentable.insert(pattern,override_table[tag][1]);-- add first <name> only to the patterntable.insert(pattern,tag);-- add the 'expected result' <tag>elseiflang_es_table[tag]thentable.insert(pattern,lang_es_table[tag][1]);-- add first <name> only to the patterntable.insert(pattern,tag);-- add the 'expected result' <tag>elsetable.insert(pattern,names[1]);-- add first <name> only to the patterntable.insert(pattern,tag);-- add the 'expected result' <tag>endtable.insert(tpats,pattern);-- accumulate in list of patternsendendlocalfunctioncomp(a,b)-- local function used by table.sort()returna[2]<b[2];-- ascending sort by code (because test limits are by code)endtable.sort(tpats,comp);-- make the list prettyreturntpats;-- and doneendlocaltest_patterns=test_patterns_get();--[[--------------------------< T E S T _ T A G _ F R O M _ N A M E >------------------------------------------]]functionp:test_tag_from_name_iso_639_3_2()self:preprocess_equals_preprocess_many('{{#invoke:Lang/zona de pruebas|tag_from_name|','}}','','',test_patterns,{nowiki=1})end;returnp
Marcha 30, 2024
módulo, lang, tests, from, name, este, módulo, tiene, página, documentación, crear, módulo, lang, tests, from, name, código, discusión, tests, comprobar, tests, subpáginas, enlaces, local, require, módulo, unittests, local, lang, data, loaddata, módulo, lang, . Este modulo no tiene pagina de documentacion crear Modulo Lang tests ISO 639 3 2 tag from name codigo doc discusion tests comprobar tests subpaginas enlaces local p require Modulo UnitTests local lang data mw loadData Modulo Lang data language name override and transliteration tool tip tables local lang table lang data lang name table lang local lang es table lang data lang name table lang es local override table lang data override local code mask j p l l used to limit number of tests lt T E S T P A T T E R N S G E T gt build a table of test patterns where each entry in the table is a table with two members lt name gt lt tag gt local function test patterns get local tpats collect test patterns here local complete for k v in pairs lang table do complete k v end for k v in pairs lang es table do complete k v end for tag names in pairs complete do local pattern here we assemble the test pattern for lt name gt if 2 tag len then no limits for two character codes if tag find code mask then if tag within limits three character codes if override table tag then table insert pattern override table tag 1 add first lt name gt only to the pattern table insert pattern tag add the expected result lt tag gt elseif lang es table tag then table insert pattern lang es table tag 1 add first lt name gt only to the pattern table insert pattern tag add the expected result lt tag gt else table insert pattern names 1 add first lt name gt only to the pattern table insert pattern tag add the expected result lt tag gt end table insert tpats pattern accumulate in list of patterns end end local function comp a b local function used by table sort return a 2 lt b 2 ascending sort by code because test limits are by code end table sort tpats comp make the list pretty return tpats and done end local test patterns test patterns get lt T E S T T A G F R O M N A M E gt function p test tag from name iso 639 3 2 self preprocess equals preprocess many invoke Lang zona de pruebas tag from name test patterns nowiki 1 end return p Obtenido de https es wikipedia org w index php title Modulo Lang tests ISO 639 3 2 tag from name amp oldid 133188796, wikipedia, wiki, leyendo, leer, libro, biblioteca,