Jump to content

Module talk:Lua call/testcases

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Pppery (talk | contribs) at 02:10, 17 March 2019 (Pppery moved page Module talk:LuaCall to Module:LuaCall/testcases: Fix misuse of talk namespace; will move actual comment to talk page). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

{{#invoke:LuaCall|main|a=test |b=7|string.rep(a,b)}}

test test test test test test test 

{{#invoke:LuaCall|main|pattern=(%a)|replace=%1.|string=I can't get no satisfaction|mw.ustring.gsub(string,pattern,replace)|reserved_return=1}}

I. c.a.n.'t. g.e.t. n.o. s.a.t.i.s.f.a.c.t.i.o.n.

{{#invoke:LuaCall|main|pattern=(%a)|replace=%1.|string=I can't get no satisfaction|mw.ustring.gsub(string,pattern,replace)|reserved_return=2}}

22

{{#invoke:LuaCall|main|value=1.4512|math.ceil(value)}}

2

{{#invoke:LuaCall|main|value=1.4512|math.modf(value)}}

1

{{#invoke:LuaCall|main|value=1.4512|math.modf(value)|reserved_return=2}}

0.4512

{{#invoke:LuaCall|main|value=... that the '''[[Privacy and Civil Liberties Oversight Board report on mass surveillance]]''' recommended against imposing a [[data retention]] requirement on U.S. phone companies?|string.len(value)}}

181

For comparison with n:Template:Evalx:

{{#invoke:LuaCall|main|value=abcd|start=2|end=3|string.sub(value,start,end)}}

bc

I sincerely hope that no one ever actually uses this

We don't provide loadstring() because we don't want people trying to embed Lua in pages or templates because that leads to unreadable messes. So this is fun (and impressive) like IOCCC entries, but there's no reason to use this any more than there is to use the old padleft hacks for string functions now that we have Scribunto. BJorsch (WMF) (talk) 18:14, 11 March 2014 (UTC)[reply]

I think the point of this is to avoid having to make a bunch of one-line modules (though I would yell about this appearing in an article). Jackmcbarn (talk) 15:48, 14 March 2014 (UTC)[reply]

call()

{{#invoke:LuaCall|call|mw.log|<pre>p</pre>, <ref>r</ref>, <nowiki>n</nowiki>, <code>c</code>, {{Ping|Ans}}, [[User:Ans]]}}

will display


'"`UNIQ--pre-0000000C-QINU`"', '"`UNIQ--ref-0000000D-QINU`"', '"`UNIQ--nowiki-0000000E-QINU`"', <code>c</code>, <span class="template-ping">@[[User:Ans|Ans]]:</span>, [[User:Ans]]

in Lua logs. --Ans (talk) 05:29, 15 March 2019 (UTC)[reply]

{{#invoke:LuaCall|call|mw.ustring.sub|<pre>p</pre>, <ref>r</ref>, <nowiki>n</nowiki>, <code>c</code>, {{Ping|Ans}}, [[User:Ans]]}}

will display

p

, [3], n, c, @Ans:, User:Ans

--Ans (talk) 05:50, 15 March 2019 (UTC)[reply]

  1. ^ r
  2. ^ r
  3. ^ r