Module:For/testcases

--

-- @todo Don't hardcode i18n messages and the page name. Dunno how to do that. -- @todo DRY up test cases, since `_main` and `main` are nearly identical. -- @todo Make tests truly exhaustive (e.g. '_b_cd_'). -- @todo Fix `main` tests, since they probably won't work on the parent frame.

local inputs = { ['nil'] = { [''] = {nil, nil, nil, nil, nil, nil}, ['a'] = {'a', nil, nil, nil, nil, nil}, ['ab'] = {'a', 'b', nil, nil, nil, nil}, ['abc'] = {'a', 'b', 'c', nil, nil, nil}, ['abcd'] = {'a', 'b', 'c', 'd', nil, nil}, ['abcde'] = {'a', 'b', 'c', 'd', 'e', nil} },   ['empty string'] = { [] = {, , , , , },       ['a'] = {'a', , , , , }, ['ab'] = {'a', 'b', , , , }, ['abc'] = {'a', 'b', 'c', , , ''}, ['abcd'] = {'a', 'b', 'c', 'd', , }, ['abcde'] = {'a', 'b', 'c', 'd', 'e', ''} },   ['whitespace only'] = { [''] = {'\n \t', '\n \t', '\n \t', '\n \t', '\n \t', '\n \t'}, ['a'] = {'a', '\n \t', '\n \t', '\n \t', '\n \t', '\n \t'}, ['ab'] = {'a', 'b', '\n \t', '\n \t', '\n \t', '\n \t'}, ['abc'] = {'a', 'b', 'c', '\n \t', '\n \t', '\n \t'}, ['abcd'] = {'a', 'b', 'c', 'd', '\n \t', '\n \t'}, ['abcde'] = {'a', 'b', 'c', 'd', 'e', '\n \t'} } }

local outputs = { [''] = table.concat{ '', '' },   ['a'] = table.concat{ '', '', ' ',                   '', 'For a, see For/testcases (disambiguation).', '', ' ',           '', '' },   ['ab'] = table.concat{ '', '', ' ',                   '', 'For a, see b.', '', ' ',           '', '' },   ['abc'] = table.concat{ '', '', ' ',                   '', 'For a, see b or c.', '</i>', ' ',           '</dd>', '</dl>' },   ['abcd'] = table.concat{ '', '', ' ',                   '', 'For a, see b or c.', '</i>', ' ',           '</dd>', '', ' ',                   '', 'For d, see For/testcases (disambiguation).', '</i>', ' ',           '</dd>', '</dl>' },   ['abcde'] = table.concat{ '', '', ' ',                   '', 'For a, see b or c.', '</i>', ' ',           '</dd>', '', ' ',                   '', 'For d, see e.', '</i>', ' ',           '</dd>', '</dl>' } }

return { _main = { options = { mode = 'method', nowiki = true },       tests = { {               inputs['nil'][''], outputs[''] },           {                inputs['nil']['a'], outputs['a'] },           {                inputs['nil']['ab'], outputs['ab'] },           {                inputs['nil']['abc'], outputs['abc'] },           {                inputs['nil']['abcd'], outputs['abcd'] },           {                inputs['nil']['abcde'], outputs['abcde'] },

{               inputs['empty string'][''], outputs[''] },           {                inputs['empty string']['a'], outputs['a'] },           {                inputs['empty string']['ab'], outputs['ab'] },           {                inputs['empty string']['abc'], outputs['abc'] },           {                inputs['empty string']['abcd'], outputs['abcd'] },           {                inputs['empty string']['abcde'], outputs['abcde'] },

{               inputs['whitespace only'][''], outputs[''] },           {                inputs['whitespace only']['a'], outputs['a'] },           {                inputs['whitespace only']['ab'], outputs['ab'] },           {                inputs['whitespace only']['abc'], outputs['abc'] },           {                inputs['whitespace only']['abcd'], outputs['abcd'] },           {                inputs['whitespace only']['abcde'], outputs['abcde'] }       }    },    main = { options = { mode = 'invocation', nowiki = true },       tests = { {               table.concat(inputs['nil'][''], '|'), outputs[''] },           {                table.concat(inputs['nil']['a'], '|'), outputs['a'] },           {                table.concat(inputs['nil']['ab'], '|'), outputs['ab'] },           {                table.concat(inputs['nil']['abc'], '|'), outputs['abc'] },           {                table.concat(inputs['nil']['abcd'], '|'), outputs['abcd'] },           {                table.concat(inputs['nil']['abcde'], '|'), outputs['abcde'] },

{               table.concat(inputs['empty string'][''], '|'), outputs[''] },           {                table.concat(inputs['empty string']['a'], '|'), outputs['a'] },           {                table.concat(inputs['empty string']['ab'], '|'), outputs['ab'] },           {                table.concat(inputs['empty string']['abc'], '|'), outputs['abc'] },           {                table.concat(inputs['empty string']['abcd'], '|'), outputs['abcd'] },           {                table.concat(inputs['empty string']['abcde'], '|'), outputs['abcde'] },

{               table.concat(inputs['whitespace only'][''], '|'), outputs[''] },           {                table.concat(inputs['whitespace only']['a'], '|'), outputs['a'] },           {                table.concat(inputs['whitespace only']['ab'], '|'), outputs['ab'] },           {                table.concat(inputs['whitespace only']['abc'], '|'), outputs['abc'] },           {                table.concat(inputs['whitespace only']['abcd'], '|'), outputs['abcd'] },           {                table.concat(inputs['whitespace only']['abcde'], '|'), outputs['abcde'] }       }    } }