This module contains testcases for its parent module, Calculator.
See also
local userError = require('Dev:User error')
local missingOperand = userError('must provide 2 operands for $1')
return {
addition = {
options = {
mode = 'invocation',
preprocess = true
},
tests = {
{
nil,
(missingOperand:gsub('$1', 'addition'))
},
{ '1|2', '{{#expr:1 + 2}}' }
}
},
division = {
options = {
mode = 'invocation',
preprocess = true
},
tests = {
{
nil,
(missingOperand:gsub('$1', 'division'))
},
{ '4|2', '{{#expr:4 / 2}}' },
{ '4|2', '{{#expr:4 / 2}}' },
{ '5|3', '{{#expr:5 / 3}}' }
}
},
modulo = {
options = {
mode = 'invocation',
preprocess = true
},
tests = {
{
nil,
(missingOperand:gsub('$1', 'modulo'))
},
{ '4|2', '{{#expr:4 mod 2}}' },
{ '5|3', '{{#expr:5 mod 3}}' }
}
},
multiplication = {
options = {
mode = 'invocation',
preprocess = true
},
tests = {
{
nil,
(missingOperand:gsub('$1', 'multiplication'))
},
{ '10|10', '{{#expr:10 * 10}}' }
}
},
subtraction = {
options = {
mode = 'invocation',
preprocess = true
},
tests = {
{
nil,
(missingOperand:gsub('$1', 'subtraction'))
},
{ '2|1', '{{#expr:2 - 1}}' },
{ '1|2', '{{#expr:1 - 2}}' }
}
},
exponentation = {
options = {
mode = 'invocation',
preprocess = true
},
tests = {
{
nil,
(missingOperand:gsub('$1', 'exponentation'))
},
{ '2|1', '{{#expr:2 ^ 1}}' },
{ '5|9', '{{#expr:5 ^ 9}}' }
}
},
main = {
options = {
mode = 'invocation',
nowiki = true
},
tests = {
{ nil, 'you must specify a function to call', { ['err'] = true } }
}
}
}