Difference between revisions of "Module:Math/testcases"
Jump to navigation
Jump to search
blackwiki>Jarekt (←Created page with '-- Unit tests for Module:Math. Click talk page to run tests. local p = require('Module:UnitTests') function p:test_random() self:preprocess_equals_ma...') |
blackwiki>Mr. Stradivarius (test module sandbox) |
||
| Line 4: | Line 4: | ||
function p:test_random() | function p:test_random() | ||
| − | self:preprocess_equals_many ('{{#Invoke:math|random', '}}', { | + | self:preprocess_equals_many ('{{#Invoke:math/sandbox|random', '}}', { |
{'', '0.00047147460303804'}, | {'', '0.00047147460303804'}, | ||
{'|10','8'}, | {'|10','8'}, | ||
| Line 12: | Line 12: | ||
function p:test_max() | function p:test_max() | ||
| − | self:preprocess_equals_many ('{{#Invoke:math|max|', '}}', { | + | self:preprocess_equals_many ('{{#Invoke:math/sandbox|max|', '}}', { |
{'',''}, | {'',''}, | ||
{'5|6|9', '9'}, | {'5|6|9', '9'}, | ||
| Line 20: | Line 20: | ||
function p:test_average() | function p:test_average() | ||
| − | self:preprocess_equals_many ('{{#Invoke:math|average|', '}}', { | + | self:preprocess_equals_many ('{{#Invoke:math/sandbox|average|', '}}', { |
{'5|6|7', '6'}, | {'5|6|7', '6'}, | ||
{'-7', '-7'}, | {'-7', '-7'}, | ||
| Line 28: | Line 28: | ||
function p:test_min() | function p:test_min() | ||
| − | self:preprocess_equals_many ('{{#Invoke:math|min|', '}}', { | + | self:preprocess_equals_many ('{{#Invoke:math/sandbox|min|', '}}', { |
{'',''}, | {'',''}, | ||
{'1|2|3','1'}, | {'1|2|3','1'}, | ||
| Line 36: | Line 36: | ||
function p:test_order() | function p:test_order() | ||
| − | self:preprocess_equals_many ('{{#Invoke:math|order|', '}}', { | + | self:preprocess_equals_many ('{{#Invoke:math/sandbox|order|', '}}', { |
{'2','0'}, | {'2','0'}, | ||
{'20','1'}, | {'20','1'}, | ||
| Line 46: | Line 46: | ||
function p:test_precison() | function p:test_precison() | ||
| − | self:preprocess_equals_many ('{{#Invoke:math|precision|', '}}', { | + | self:preprocess_equals_many ('{{#Invoke:math/sandbox|precision|', '}}', { |
{'1.9856', '4'}, | {'1.9856', '4'}, | ||
{'1.1', '1'}, | {'1.1', '1'}, | ||
| Line 56: | Line 56: | ||
function p:test_round() | function p:test_round() | ||
| − | self:preprocess_equals_many ('{{#Invoke:math|round|', '}}', { | + | self:preprocess_equals_many ('{{#Invoke:math/sandbox|round|', '}}', { |
{'1.99999', '2'}, | {'1.99999', '2'}, | ||
{'1.99999|0', '2'}, | {'1.99999|0', '2'}, | ||
| Line 66: | Line 66: | ||
function p:test_precison_format() | function p:test_precison_format() | ||
| − | self:preprocess_equals('{{#Invoke:math|precision_format|10|2}}', '10.00') | + | self:preprocess_equals('{{#Invoke:math/sandbox|precision_format|10|2}}', '10.00') |
end | end | ||
return p | return p | ||
Revision as of 03:30, 5 December 2013
Documentation for this module may be created at Module:Math/testcases/doc
-- 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