Modul:Luafunktionstest: Unterschied zwischen den Versionen

Aus SchnuppTrupp
Wechseln zu: Navigation, Suche
(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.hello()
+
function p.arithmetic()
return "Hello, world!"
+
    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
 
return p
 

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