-- Tests para [[Module:Math]]. El resultado está en la página de discusión.

local p = require('Module:UnitTests')

function p:test_random()
    self:preprocess_equals_many ('{{#Invoke:math|random', '}}', {
    {'', '0.00047147460303804'},
    {'|10','8'},
    {'|1|2','2'},
    })
end

function p:test_max()
    self:preprocess_equals_many ('{{#Invoke:math|max', '}}', {
    {'',''},
    {'|5|6|9', '9'},
    })
end
 
function p:test_min()
    self:preprocess_equals_many ('{{#Invoke:math|min', '}}', {
    {'',''},
    {'|1|2|3','1'},
    })
end

function p:test_order()
    self:preprocess_equals_many ('{{#Invoke:math|order|', '}}', {
    {'2','0'},
    {'x = 5','0'},
    {'letra','<strong class="error"><small>Error de formato: El orden de magnitud debe ser numérico</small></strong>'}
}, {nowiki = 'yes'})
end
 
function p:test_precison()
    self:preprocess_equals_many ('{{#Invoke:math|precision|', '}}', {
{'1.9856', '4'},
{'x = 1.9888', '4'},
{'letra', '<strong class="error"><small>Error de formato: El valor de precisión ha de ser numérico</small></strong>'}
}, {nowiki = 'yes'})
end

function p:test_round()
    self:preprocess_equals_many ('{{#Invoke:math|round|', '}}', {
{'1.99999|2', '2'},
{'value = 2.99999|precision = 2', '3'},
})
end

function p:test_precison_format()
    self:preprocess_equals('{{#Invoke:math|precision_format|10|2}}', '10,00')
end
 
return p