Module:ScriptUtil/testcases

local ScriptUtil = require('Module:ScriptUtil') local ScribuntoUnit = require('Module:ScribuntoUnit') local suite = ScribuntoUnit:new

local Template = ScriptUtil.Template

function suite:testTemplate_RoundTrip_NoParamTemplate self:assertEquals(		"",		Template.new("SomeTemplateName"):toWikitext	) end

function suite:testTemplate_RoundTrip_UnnamedParams self:assertEquals(   	"",    	Template.newFromWikitext(""):toWikitext	) end

function suite:testTemplate_RoundTrip_EmptyNameParams self:assertEquals(   	"",    	Template.newFromWikitext(""):toWikitext	) end

function suite:testTemplate_RoundTrip_NestedTemplates self:assertEquals(   	"",    	Template.newFromWikitext(""):toWikitext	) end

function suite:testTemplate_RoundTrip_NestedTemplateWithUnamedParam self:assertEquals(   	"",    	Template.newFromWikitext(""):toWikitext	) end

function suite:testTemplate_RoundTrip_NestedTemplateWithNamedParam self:assertEquals(   	"",    	Template.newFromWikitext(""):toWikitext	) end

function suite:testTemplate_Error_NoTitle self:assertThrows( function   	Template.new    end ) end

function suite:testTemplate_Error_NotATemplate self:assertThrows( function   	Template.newFromWikitext("regular text")    end ) end function suite:testTemplate_AllParamNamesAreStrings local t = Template.new("TemplateName") t:setArg("1",9) t:setArg(1,10) self:assertEquals(   	"",    	t:toWikitext	) end

function suite:testTemplate_SetParamTwice local t = Template.new("TemplateName") t:setArg("some param",9) t:setArg("some param",10) self:assertEquals(   	"",    	t:toWikitext	) end

function suite:testTemplate_RoundTrip_MiscWikiParser1 self:assertThrows( function   	Template.newFromWikitext("{{SomeTemplate|}"):toWikitext    end ) end

function suite:testTemplate_RoundTrip_MiscWikiParser2 self:assertEquals(   	"",    	Template.newFromWikitext("{{SomeTemplate|{{SomeOtherTemplate}}}}}"):toWikitext	) end

function suite:testTemplate_RoundTrip_MiscWikiParser3 self:assertEquals(   	"{{SomeTemplate|a} }}",    	Template.newFromWikitext("{{SomeTemplate|a} }}"):toWikitext	) end

function suite:testTemplate_RoundTrip_MiscPreserveNameType self:assertEquals(   	"",    	Template.newFromWikitext(""):toWikitext    ) end

return suite