Module:User:Equinox/LuaTest

-- testing: from: https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual

-- see also: https://en.wiktionary.org/wiki/Wiktionary:Grease_pit/2018/August#Lua

local p = {} -- p stands for package

function p.hello( frame ) return "Hello, world! I hate you, is this going to be like Linux all over again" end

function p.returnNonString( frame ) return 4 end

function p.dontReturnAnything( frame ) end

function p.myFirstLuaLoopEver( frame ) x = 0 for i=-7,39,4 do x = x + i end return x end

function p.zeroDivide( frame ) return 9/0 end

function p.throw( frame ) error("L Break into program, 0:1") end

function p.catch( frame ) if pcall(p.throw(frame)) then return 0 else return "you dun goofed boyo" end end

function p.infiniteRecurse( frame ) return p.infiniteRecurse(frame) end

function p.grabEntry( frame ) return mw.title.new("hagberry"):getContent end

return p