Module:Type in location/testcases
| This is the test cases page for the module Module:Type in location. Results of the test cases. |
local p = require('Module:UnitTests')
function p:testMain()
-- empty
self:preprocess_equals('{{#invoke:Type in location|generateDesc}}',
'')
-- just type
self:preprocess_equals('{{#invoke:Type in location|generateDesc|Airport}}',
'Airport')
-- junk type
self:preprocess_equals('{{#invoke:Type in location|generateDesc|<b></b>}}',
'')
-- just location
self:preprocess_equals('{{#invoke:Type in location|generateDesc||London}}',
'')
-- type and location
self:preprocess_equals('{{#invoke:Type in location|generateDesc|Airport|London}}',
'Airport in London')
-- type and wlink location
self:preprocess_equals('{{#invoke:Type in location|generateDesc|Airport|[[Dayton, Ohio]]}}',
'Airport in Dayton, Ohio')
-- type and complex location
self:preprocess_equals('{{#invoke:Type in location|generateDesc|Radio station|[[Natchitoches, Louisiana]], United States}}',
'Radio station in Louisiana, United States')
-- type and complex location with piping
self:preprocess_equals('{{#invoke:Type in location|generateDesc|Radio station|[[Natchitoches, Louisiana|Natchitoches]], [[Louisiana]]}}',
'Radio station in Natchitoches, Louisiana')
-- type and very messy location
self:preprocess_equals('{{#invoke:Type in location|generateDesc|Radio station| Special place, Dayton,, Ohio, ABC123}}',
'Radio station in Dayton, Ohio')
-- type and location with flag
self:preprocess_equals('{{#invoke:Type in location|generateDesc|Shopping mall|[[Gateshead]], [[United Kingdom]] {{flagicon|United Kingdom}}}}',
'Shopping mall in Gateshead, United Kingdom')
-- type and location with postal code
self:preprocess_equals('{{#invoke:Type in location|generateDesc|[[Historic house museum]]|Oxford Road, [[Gomersal]], [[West Yorkshire]], England<br/>BD19 4JP}}',
'Historic house museum in West Yorkshire, England')
-- check pattern succeeds
self:preprocess_equals('{{#invoke:Type in location|generateDesc|[[Natural history museum]]|[[Philadelphia]]|check-patterns = [Mm]useum;[Hh]all;[Gg]allery;[Cc]enter}}',
'Natural history museum in Philadelphia')
-- check pattern fails
self:preprocess_equals('{{#invoke:Type in location|generateDesc|Historic house|Oxford Road, [[Gomersal]], [[West Yorkshire]], England<br/>BD19 4JP|check-patterns = [Mm]useum;[Hh]all;[Gg]allery;[Cc]enter}}',
'')
-- test lc matching
self:preprocess_equals('{{#invoke:Type in location|generateDesc|Power plant cooling/recreational [[Reservoir (water)|Reservoir]]|Central [[Austin, Texas|Austin]], [[Texas]],<br />[[United States]]|check-patterns=basin;bay;bight;channel;estuary;gulf;lagoon;lake;loch;moraine;ocean;reservoir;river;sea;sound;strait|invalidadd=body of water}}',
'Power plant cooling/recreational Reservoir in Texas, United States')
-- test invalidadd
self:preprocess_equals('{{#invoke:Type in location|generateDesc|[[Geothermal (geology)|geothermal]]|[[Wai-O-Tapu| Waiotapu]], [[North Island]]|check-patterns=basin;bay;bight;channel;estuary;gulf;lagoon;lake;loch;moraine;ocean;reservoir;river;sea;sound;strait|invalidadd=body of water}}',
'Geothermal body of water in Waiotapu, North Island')
-- ubl location
self:preprocess_equals('{{#invoke:Type in location|generateDesc|Bridge|{{ublist|[[Dandong]], [[Liaoning]], China|[[Sinŭiju]], [[North P\'yŏngan]], North Korea}}}}',
'Bridge')
end
function p:testSandbox()
-- empty
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc}}',
'')
-- just type
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|Airport}}',
'Airport')
-- junk type
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|<b></b>}}',
'')
-- just location
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc||London}}',
'')
-- type and location
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|Airport|London}}',
'Airport in London')
-- type and wlink location
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|Airport|[[Dayton, Ohio]]}}',
'Airport in Dayton, Ohio')
-- type and complex location
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|Radio station|[[Natchitoches, Louisiana]], United States}}',
'Radio station in Louisiana, United States')
-- type and complex location with piping
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|Radio station|[[Natchitoches, Louisiana|Natchitoches]], [[Louisiana]]}}',
'Radio station in Natchitoches, Louisiana')
-- type and very messy location
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|Radio station| Special place, Dayton,, Ohio, ABC123}}',
'Radio station in Dayton, Ohio')
-- type and location with flag
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|Shopping mall|[[Gateshead]], [[United Kingdom]] {{flagicon|United Kingdom}}}}',
'Shopping mall in Gateshead, United Kingdom')
-- type and location with postal code
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|[[Historic house museum]]|Oxford Road, [[Gomersal]], [[West Yorkshire]], England<br/>BD19 4JP}}',
'Historic house museum in West Yorkshire, England')
-- check pattern succeeds
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|[[Natural history museum]]|[[Philadelphia]]|check-patterns = [Mm]useum;[Hh]all;[Gg]allery;[Cc]enter}}',
'Natural history museum in Philadelphia')
-- check pattern fails
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|Historic house|Oxford Road, [[Gomersal]], [[West Yorkshire]], England<br/>BD19 4JP|check-patterns = [Mm]useum;[Hh]all;[Gg]allery;[Cc]enter}}',
'')
-- test lc matching
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|Power plant cooling/recreational [[Reservoir (water)|Reservoir]]|Central [[Austin, Texas|Austin]], [[Texas]],<br />[[United States]]|check-patterns=basin;bay;bight;channel;estuary;gulf;lagoon;lake;loch;moraine;ocean;reservoir;river;sea;sound;strait|invalidadd=body of water}}',
'Power plant cooling/recreational Reservoir in Texas, United States')
-- test invalidadd
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|[[Geothermal (geology)|geothermal]]|[[Wai-O-Tapu| Waiotapu]], [[North Island]]|check-patterns=basin;bay;bight;channel;estuary;gulf;lagoon;lake;loch;moraine;ocean;reservoir;river;sea;sound;strait|invalidadd=body of water}}',
'Geothermal body of water in Waiotapu, North Island')
-- ubl location
self:preprocess_equals('{{#invoke:Type in location/sandbox|generateDesc|Bridge|{{ublist|[[Dandong]], [[Liaoning]], China|[[Sinŭiju]], [[North P\'yŏngan]], North Korea}}}}',
'Bridge')
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.