Modul:Luafunktionstest: Unterschied zwischen den Versionen
Aus SchnuppTrupp
(Die Seite wurde neu angelegt: „-- For unit tests, see Module:Bananas/testcases local p = {} function p.hello() return "Hello, world!" end return p“) |
|||
Zeile 2: | Zeile 2: | ||
local p = {} | local p = {} | ||
− | function p. | + | function p.arithmetic() |
− | + | local a | |
+ | local b | ||
+ | local result | ||
+ | |||
+ | result = ';Arithmetic\n' | ||
+ | result = result .. ':a is ' .. a .. '\n' | ||
+ | result = result .. ':b is ' .. b .. '\n' | ||
+ | result = result .. ':a + b is ' .. a + b .. '\n' | ||
+ | result = result .. ':a - b is ' .. a - b .. '\n' | ||
+ | result = result .. ':a * b is ' .. a * b .. '\n' | ||
+ | result = result .. ':a / b is ' .. a / b .. '\n' | ||
+ | result = result .. ':a % b is ' .. a % b .. '\n' | ||
+ | result = result .. ':a ^ b is ' .. a ^ b .. '\n' | ||
+ | result = result .. ':-a is ' .. -a .. '\n' | ||
+ | |||
+ | return result | ||
end | end | ||
− | |||
− |
Version vom 2. Januar 2017, 19:42 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Luafunktionstest/Doku erstellt werden
-- For unit tests, see [[Module:Bananas/testcases]] local p = {} function p.arithmetic() local a local b local result result = ';Arithmetic\n' result = result .. ':a is ' .. a .. '\n' result = result .. ':b is ' .. b .. '\n' result = result .. ':a + b is ' .. a + b .. '\n' result = result .. ':a - b is ' .. a - b .. '\n' result = result .. ':a * b is ' .. a * b .. '\n' result = result .. ':a / b is ' .. a / b .. '\n' result = result .. ':a % b is ' .. a % b .. '\n' result = result .. ':a ^ b is ' .. a ^ b .. '\n' result = result .. ':-a is ' .. -a .. '\n' return result end