Module:Wd/testcases/1

-- Unit tests for Module:Wd. Click talk page to run tests. local p = require('Module:UnitTests') local wdib = require('Module:WikidataIB') local wd = require('Module:Wd')

function p:test_live self:preprocess_equals('', wdib._getValue{'P395',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals(, ) self:preprocess_equals('', wdib._getValue{'P395',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals(, ) self:preprocess_equals(, ) self:preprocess_equals('', wdib._getValue{'P395',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P395',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P395',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals(, ) self:preprocess_equals('', wdib._getValue{'P395',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'} .. ' ') self:preprocess_equals('', wdib._getValue{'P395',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'} .. ' ') self:preprocess_equals('', wdib._getValue{'P31',qid='Q2',linked='false',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P31',qid='Q2',linked='false',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P31',qid='Q2',linked='false',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals(, ) self:preprocess_equals('', wdib._getValue{'P31',qid='P625',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P31',qid='P625',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P31',qid='P625',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals(, ) self:preprocess_equals('', wdib._getValue{'P31',qid='P625',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P31',qid='P625',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P31',qid='P625',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals(, ) self:preprocess_equals(, ) self:preprocess_equals(, ) self:preprocess_equals(, ) self:preprocess_equals('', wdib._getValue{'P1082',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', table.concat({wdib._getValue{'P1082',qid='Q55',noicon='true',osd='no',rank='p',fwd='ALL'}, wdib._getValue{'P1082',qid='Q55',noicon='true',osd='no',rank='n',fwd='ALL'}}, ', ')) self:preprocess_equals('', table.concat({wdib._getValue{'P1082',qid='Q55',qual='P585',noicon='true',osd='no',df='dmy',rank='p',fwd='ALL'}, wdib._getValue{'P1082',qid='Q55',qual='P585',noicon='true',osd='no',df='dmy',rank='n',fwd='ALL'}}, ', ')) self:preprocess_equals('', wdib._getValue{'P1082',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P1082',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}..'.') self:preprocess_equals('', table.concat({wdib._getValue{'P1082',qid='Q55',qual='P585',qo='true',sep='; ',noicon='true',osd='no',df='dmy',rank='p',fwd='ALL'}, wdib._getValue{'P1082',qid='Q55',qual='P585',qo='true',sep='; ',noicon='true',osd='no',df='dmy',rank='n',fwd='ALL'}}, '; ')) self:preprocess_equals('', wdib._getValue{'P1082',qid='Q55',qual='P585',qo='true',noicon='true',osd='no',df='dmy',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P1082',qid='Q55',qual='P585',qo='true',noicon='true',osd='no',df='mdy',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', ({mw.ustring.gsub(table.concat({wdib._getValue{'P1081',qid='Q55',noicon='true',osd='no',rank='p',fwd='ALL'}, wdib._getValue{'P1081',qid='Q55',noicon='true',osd='no',rank='n',fwd='ALL'}}, ', ')..',', '([.]%d%d),', '%10,')})[1]) self:preprocess_equals('', ({mw.ustring.gsub(table.concat({wdib._getValue{'P1081',qid='Q55',noicon='true',rank='p',fwd='ALL'}, wdib._getValue{'P1081',qid='Q55',noicon='true',rank='n',fwd='ALL'}}, ', ')..',', '([.]%d%d),', '%10,')})[1]) self:preprocess_equals('', ({string.gsub(wdib._getValue{'P2855',qid='Q55',qual='P518',qo='true',linked='false',noicon='true',osd='no',fwd='ALL'}, '^([^,]+).*$', '%1', 1)})[1]) self:preprocess_equals('', wdib._getValue{'P2855',qid='Q55',qual='P518',qo='true',linked='false',noicon='true',osd='no',fwd='ALL'}) self:preprocess_equals('', ({string.gsub(wdib._getValue{'P2855',qid='Q55',qual='P518',linked='false',noicon='true',osd='no',fwd='ALL'}, ' percent', '%%')})[1]) self:preprocess_equals('', ({string.gsub(wdib._getValue{'P2855',qid='Q55',qual='P518',sep='" + "',qsep='" / "',linked='false',noicon='true',osd='no',fwd='ALL'}, ' percent', '%%')})[1]) self:preprocess_equals(, table.concat({({string.gsub(wdib._getValue{'P35',qid='Q55',qual='P580',qsep='"; "',linked='false',noicon='true',osd='no',df='dmy',rank='p',fwd='ALL'}, ' – ', , 1)})[1], ({string.gsub(wdib._getValue{'P35',qid='Q55',qual='P580,P582',qsep='"; "',linked='false',noicon='true',osd='no',df='dmy',rank='n',fwd='ALL'}, ' – ', '; ')})[1]}, ', ')) self:preprocess_equals(, table.concat({({string.gsub(wdib._getValue{'P35',qid='Q55',qual='P580',qsep='" – "',linked='false',noicon='true',osd='no',df='dmy',rank='p',fwd='ALL'}, ' – ', , 1)})[1], ({string.gsub(wdib._getValue{'P35',qid='Q55',qual='P580,P582',qsep='" – "',linked='false',noicon='true',osd='no',df='dmy',rank='n',fwd='ALL'}, ' – ', ' – ')})[1]}, ', ')) self:preprocess_equals(, table.concat({({string.gsub(wdib._getValue{'P35',qid='Q55',qual='P580',qsep='" – "',linked='false',noicon='true',osd='no',df='dmy',rank='p',fwd='ALL'}, ' – ', , 1)})[1], ({string.gsub(wdib._getValue{'P35',qid='Q55',qual='P580,P582',qsep='" – "',linked='false',noicon='true',osd='no',df='dmy',rank='n',fwd='ALL'}, ' – ', ' – ')})[1]}, ', ')) self:preprocess_equals('', 'Beatrix of the Netherlands (1980-04-30 – 30 April 2013)') self:preprocess_equals(, ({string.gsub(({string.gsub(table.concat({wdib._getValue{'P38',qid='Q55',qual='P518',linked='false',noicon='true',osd='no',rank='p',fwd='ALL'}, wdib._getValue{'P38',qid='Q55',qual='P518',linked='false',noicon='true',osd='no',rank='n',fwd='ALL'}}, ', '), 'Dutch guilder[^,]*', , 1)})[1], ', ,', ',', 1)})[1]) self:preprocess_equals('', ({string.gsub(table.concat({wdib._getValue{'P38',qid='Q55',noicon='true',osd='no',rank='p',fwd='ALL'}, wdib._getValue{'P38',qid='Q55',noicon='true',osd='no',rank='n',fwd='ALL'}}, ', '), '([^|]+)|%1', '%1')})[1]) self:preprocess_equals('', ({string.gsub(table.concat({wdib._getValue{'P38',qid='Q55',sn='true',noicon='true',osd='no',rank='p',fwd='ALL'}, wdib._getValue{'P38',qid='Q55',sn='true',noicon='true',osd='no',rank='n',fwd='ALL'}}, ', '), '([^|]+)|%1', '%1')})[1]) self:preprocess_equals('', wdib.getQualifierValue{args={'P38',qid='Q55',qual='P518',pval='Q4917',linked='false',noicon='true',osd='no',fwd='ALL'}}) self:preprocess_equals('', wdib.getValueByQual{args={'P38',qid='Q55',qualID='P518',qvalue='Q27561',linked='false',noicon='true',osd='no',fwd='ALL'}}) self:preprocess_equals('', 'Dutch guilder') self:preprocess_equals('', 'Q788472') self:preprocess_equals('', 'Q788472') self:preprocess_equals('', wdib._getValue{'P1549',qid='Q55',noicon='true',osd='no',rank='best',fwd='ALL'}) self:preprocess_equals(, wdib.getValueByQual{args={'P1549',qid='Q55',qualID='P407',qvalue='Q36846',noicon='true',osd='no',fwd='ALL'}} or ) self:preprocess_equals('', wdib._getValue{'P2884',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', wdib._getValue{'P2884',qid='Q55',su='false',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}) self:preprocess_equals('', ({string.gsub(wdib._getValue{'P2884',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}, '^[^ ]+ (.+)$', '%1', 1)})[1]) self:preprocess_equals(, '%1', 1)})[1], '^.', string.upper, 1)})[1] .. ) self:preprocess_equals('', 'Q25250') self:preprocess_equals(, ({string.gsub(({string.gsub(({string.gsub(wdib._getValue{'P625',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}, "′", "'", 2)})[1], '″', '"', 2)})[1], ' ', ', ', 1)})[1])	self:preprocess_equals(, '.. ({mw.ustring.gsub(wdib._getValue{'P625',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}, '[°′″', '_')})[1] .. '_globe:earth ' .. ({string.gsub(({string.gsub(({string.gsub(wdib._getValue{'P625',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}, "′", "'", 2)})[1], '″', '"', 2)})[1], ' ', ', ', 1)})[1] .. ']') self:preprocess_equals('', ({mw.ustring.gsub(wdib._getValue{'P625',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}, '[°′″ ]', '/')})[1]) self:preprocess_equals(, ({string.gsub(({string.gsub(({string.gsub(wdib._getValue{'P625',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'}, "′", "'", 2)})[1], '″', '"', 2)})[1], ' ', ', ', 1)})[1])	self:preprocess_equals(, )	self:preprocess_equals(, wdib._getValue{'P41',qid='Q55',noicon='true',osd='no',rank='best',maxvals='1',fwd='ALL'})	self:preprocess_equals(, 'Statenvlag.svg')	self:preprocess_equals(, 'Prinsenvlag.svg')	self:preprocess_equals(, '\\frac{n^2 - 1}{n^2 + 2} = \\frac{4 \\pi}{3} N \\alpha')	self:preprocess_equals(,  .. mw.getCurrentFrame:callParserFunction{name='#property:P3896',args={from='Q6256'}} .. )	self:preprocess_equals(, wdib.getLabel{args={'Q4917'}})	self:preprocess_equals(, ({string.gsub(wdib.getLink{args={'Q4917'}}, ':([^|]+)|%1', '%1', 1)})[1]) self:preprocess_equals('', wdib.getLabel{args={'P38'}}) self:preprocess_equals(,  .. wdib.getLabel{args={'P38'}} .. '') self:preprocess_equals('', wdib.getLabel{args={'Q776'}}) self:preprocess_equals(, ({string.gsub(wdib.getLink{args={'Q776'}}, '%[%[:', 'Q776')	self:preprocess_equals(, wdib.getLabel{args={'P625'}})	self:preprocess_equals(, wdib.getLabel{args={'P625'}})	self:preprocess_equals(, wdib.getLabel{args={'P625'}})	self:preprocess_equals(, wdib.getLabel{args={'P625'}})	self:preprocess_equals(, wdib.getLabel{args={'P625'}})	self:preprocess_equals(, wdib.getLabel{args={'P625'}})	self:preprocess_equals(, wdib.getLabel{args={'P625'}})	self:preprocess_equals(, wdib.getLabel{args={'P625'}})	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, wdib.getSiteLink{args={qid='Q776'}})	self:preprocess_equals(,  .. wdib.getSiteLink{args={qid='Q776'}} .. )	self:preprocess_equals(, )	self:preprocess_equals(, wdib.getDescription{args={qid='Q55','wikidata'}})	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, )	self:preprocess_equals(, ({string.gsub(wdib.getAliases{args={qid='Q55',noicon='true',fwd='ALL'}}, '^([^,]+).*$', '%1', 1)})[1])	self:preprocess_equals(, wdib.getAliases{args={qid='Q55',noicon='true',fwd='ALL'}})	self:preprocess_equals(,  .. ({string.gsub(wdib.getAliases{args={qid='Q55',noicon='true',fwd='ALL'}}, '^([^,]+).*')	self:preprocess_equals(, )	self:preprocess_equals(, 'featured article badge')	self:preprocess_equals(, 'Q17437796')	self:preprocess_equals(, ) end, '%1', 1)})[1] .. )	self:preprocess_equals(, )	self:preprocess_equals(, 'featured article badge')	self:preprocess_equals(, 'Q17437796')	self:preprocess_equals(, '') end

return p