Module:Template invocation/testcases
Appearance
From Wikipedia, the free encyclopedia
-- Unit tests for [[Module:Template invocation]]. Click talk page to run tests. localScribuntoUnit=require('Module:ScribuntoUnit') localp=ScribuntoUnit:new() localprotect=require('Module:Protect') localfunctionnw(o) returnmw.text.nowiki(tostring(o)) end localfunctiontest(a,expected) localmTemplateInvocation=require('Module:Template invocation') localmTemplateInvocation2=require('Module:Template invocation/sandbox') localliveRes=protect(mTemplateInvocation.invocation)('foo',a) localsandboxRes=protect(mTemplateInvocation2.invocation)('foo',a) localmessage='Expected '..nw(expected)..'. Got ' p:assertEquals(expected,liveRes,message..nw(liveRes)..' from live module.') p:assertEquals(expected,sandboxRes,message..nw(sandboxRes)..' from sandbox.') end functionp:test_hello() locala={'bar','baz',abc='def'};a[6]=666;a[7]=777;a['7']='777s';a[3]=333;a['4']='444s' returntest(a,'{{foo|bar|baz|333|6=666 |7=777 |4=444s |7=777s |abc=def}}') end functionp:test_equals_sign() locala={'bar','baz','{{=}}'} returntest(a,'{{foo|bar|baz|3={{=}}}}') end functionp:test_numbered() locala={} a[1]='aaa' a[2]='bbb' a[5]='eee' returntest(a,'{{foo|aaa|bbb|5=eee}}') end returnp