Modul:BananaParam/testniprimeri

Iz Wikipedije, proste enciklopedije
Jump to navigation Jump to search
-- Test za [[Modul:BananaParam]]. Za rezultate klikni na pogovorno stran.
local p = require('Modul:UnitTests')
 
function p:test_hello_world()
    self:preprocess_equals('{{#invoke:BananaParam|hello_world}}', 'Hello, world!')
end
 
function p:test_hello()
    self:preprocess_equals('{{#invoke:BananaParam|hello|Fred}}', 'Hello, Fred!')
end
 
function p:test_add()
    self:preprocess_equals('{{#invoke:BananaParam|add|5|3}}', '8')
end
 
function p:test_count_fruit()
    self:preprocess_equals('{{#invoke:BananaParam|count_fruit|bananas=5|apples=3}}', 'I have 5 bananas and 3 apples')
end

function p:test_has_fruit()
    self:preprocess_equals('{{#invoke:BananaParam|has_fruit|Fred|bananas=5|cherries=7}}', 'Fred has: 5 bananas 7 cherries')
end
 
function p:test_custom_fruit()
    self:preprocess_equals('{{#invoke:BananaParam|custom_fruit|pineapples=10|kiwis=5}}', 'I have: 5 kiwis 10 pineapples')
end
 
function p:test_custom_fruit_2()
    self:preprocess_equals('{{#invoke:BananaParam|custom_fruit_2|Fred|pineapples=10|kiwis=5}}', 'Fred has: 5 kiwis 10 pineapples')
end

function p:test_hello_world_extraneous()
    self:preprocess_equals('{{#invoke:BananaParam|hello_world|extra}}', 'Hello, world!')
end
 
function p:test_hello_noone()
    self:preprocess_equals('{{#invoke:BananaParam|hello|}}', 'Hello, !')
end
 
function p:test_add_backwards()
    self:preprocess_equals('{{#invoke:BananaParam|add|2=5|1=3}}', '8')
end
 
function p:test_count_fruit_otherorder()
    self:preprocess_equals('{{#invoke:BananaParam|count_fruit|apples=3|bananas=5}}', 'I have 5 bananas and 3 apples')
end

function p:test_has_fruit_alternateorder()
    self:preprocess_equals('{{#invoke:BananaParam|has_fruit|cherries=7|1=Fred|bananas=5}}', 'Fred has: 5 bananas 7 cherries')
end
 
function p:test_custom_fruit_otherorder()
    self:preprocess_equals('{{#invoke:BananaParam|custom_fruit|kiwis=5|pineapples=10}}', 'I have: 10 pineapples 5 kiwis')
end
 
function p:test_custom_fruit_2_alternateorder()
    self:preprocess_equals('{{#invoke:BananaParam|custom_fruit_2|kiwis=5|1=Fred|pineapples=10}}', 'Fred has: 10 pineapples 5 kiwis')
end

return p