Module:Math/testcases
Appearance
![]() | This is the test cases page for the module Module:Math. Results of the test cases. |
-- Unit tests for [[Module:Math]]. Click talk page to run tests.
local p = require('Module:UnitTests')
function p:test_random()
self:preprocess_equals_many ('{{#Invoke:math/sandbox|random', '}}', {
{'', '0.00047147460303804'},
{'|10','8'},
{'|1|2','2'},
})
end
function p:test_max()
self:preprocess_equals_many ('{{#Invoke:math/sandbox|max|', '}}', {
{'',''},
{'5|6|9', '9'},
{'-5|-6|-9', '-5'},
})
end
function p:test_average()
self:preprocess_equals_many ('{{#Invoke:math/sandbox|average|', '}}', {
{'5|6|7', '6'},
{'-7', '-7'},
{'10000000001|10000000002|10000000003', '10000000002'},
})
end
function p:test_min()
self:preprocess_equals_many ('{{#Invoke:math/sandbox|min|', '}}', {
{'',''},
{'1|2|3','1'},
{'-1|-2|-3','-3'},
})
end
function p:test_order()
self:preprocess_equals_many ('{{#Invoke:math/sandbox|order|', '}}', {
{'2','0'},
{'20','1'},
{'200','2'},
{'x = 5','0'},
{'string','<strong class="error">Formatting error: Order of magnitude input appears non-numeric</strong>'},
})
end
function p:test_precison()
self:preprocess_equals_many ('{{#Invoke:math/sandbox|precision|', '}}', {
{'1.9856', '4'},
{'1.1', '1'},
{'1.9999999999', '10'},
{'x = 1.9888', '4'},
{'letra', '<strong class="error">Formatting error: Precision input appears non-numeric</strong>'},
})
end
function p:test_round()
self:preprocess_equals_many ('{{#Invoke:math/sandbox|round|', '}}', {
{'1.99999', '2'},
{'1.99999|0', '2'},
{'1.94|1', '1.9'},
{'15|-1', '20'},
{'value = 2.99999|precision = 2', '3'},
})
end
function p:test_precison_format()
self:preprocess_equals('{{#Invoke:math/sandbox|precision_format|10|2}}', '10.00')
end
return p