Module:IPA/testcases

-- Unit tests for [[Module:IPA]]. Click talk page to run tests.
local p = require('Module:UnitTests')

local function getStripMarker(tag)
	return string.format(
		'%s\'"`UNIQ--%s-00000000-QINU`"\'%s',
		string.char(0x7f),
		tag,
		string.char(0x7f)
	)
end

function p:test_all()
	self:preprocess_equals_many('{{IPA/sandbox|', '|debug=yes}}', {
		{
			'foo',
			'<span class="IPA nowrap" lang="und-Latn-fonipa" title="Representation in the International Phonetic Alphabet (IPA)">foo</span>[[:Category:Pages with plain IPA]]'
		},
		{
			'foo|lang=en|class=foo bar|tooltip=Random tooltip',
			'<span class="IPA foo bar nowrap" lang="en-Latn-fonipa" title="Random tooltip">foo</span>[[:Category:Pages with plain IPA]]'
		},
		{
			'foo|bar|tooltip=',
			'<span style="color:#d33">Error: {{[[Template:IPA|IPA]]}}: unrecognized language code: foo</span>[[:Category:IPA template errors]]'
		},
		{
			'foo bar|tooltip=',
			'<span class="IPA nowrap" lang="und-Latn-fonipa">foo<span class="wrap"> </span>bar</span>[[:Category:Pages with plain IPA]]'
		},
		{
			'foo bar|wrap=none|tooltip=',
			'<span class="IPA nowrap" lang="und-Latn-fonipa">foo bar</span>[[:Category:Pages with plain IPA]]'
		},
		{
			'foo bar|wrap=all|tooltip=',
			'<span class="IPA" lang="und-Latn-fonipa">foo bar</span>[[:Category:Pages with plain IPA]]'
		},
		{
			'1=<i style="text-decoration: underline;">foo bar</i>|tooltip=',
			'<span class="IPA nowrap" lang="und-Latn-fonipa"><i style="text-decoration: underline;">foo<span class="wrap"> </span>bar</i></span>[[:Category:Pages with plain IPA]]'
		},
		{
			'[[foo bar]] [[foo bar|baz qux]]|tooltip=',
			'<span class="IPA nowrap" lang="und-Latn-fonipa">[[foo bar|foo<span class="wrap"> </span>bar]]<span class="wrap"> </span>[[foo bar|baz<span class="wrap"> </span>qux]]</span>[[:Category:Pages with plain IPA]]'
		},
		{
			'foo|audio=Example.ogg|tooltip=',
			'<span class="IPA nowrap" lang="und-Latn-fonipa">foo</span> ' .. getStripMarker('phonos') .. '[[:Category:Pages with plain IPA]][[:Category:Pages including recorded pronunciations]]'
		},
		{
			'fr|foo|-|Example.ogg',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">French pronunciation:</span> <span class="IPA nowrap" lang="fr-Latn-fonipa">[[Help:IPA/French|&#91;foo&#93;]]</span> ' .. getStripMarker('phonos') .. '[[:Category:Pages with French IPA]][[:Category:Pages including recorded pronunciations]]'
		},
		{
			'fra|foo|lang',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">French:</span> <span class="IPA nowrap" lang="fr-Latn-fonipa">[[Help:IPA/French|&#91;foo&#93;]]</span>[[:Category:Pages with French IPA]]'
		},
		{
			'fr|foo|',
			'<span class="IPA nowrap" lang="fr-Latn-fonipa">[[Help:IPA/French|&#91;foo&#93;]]</span>[[:Category:Pages with French IPA]]'
		},
		{
			'fr|foo|label=',
			'<span class="IPA nowrap" lang="fr-Latn-fonipa">[[Help:IPA/French|&#91;foo&#93;]]</span>[[:Category:Pages with French IPA]]'
		},
		{
			'fr|foo|label=Random label:|small=no',
			 '<span class="IPA-label">Random label:</span> <span class="IPA nowrap" lang="fr-Latn-fonipa">[[Help:IPA/French|&#91;foo&#93;]]</span>[[:Category:Pages with French IPA]]'
		},
		{
			'fr|foo|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[French language|French]] pronunciation:</span> <span class="IPA nowrap" lang="fr-Latn-fonipa">[[Help:IPA/French|&#91;foo&#93;]]</span>[[:Category:Pages with French IPA]]'
		},
		{
			'fr|foo|generic=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">French pronunciation:</span> <span class="IPA nowrap" lang="fr-Latn-fonipa">[[Help:IPA|&#91;foo&#93;]]</span>[[:Category:Pages with French IPA]]'
		},
		{
			'en|foo|generic=yes',
			'<span class="IPA nowrap" lang="en-Latn-fonipa">[[Help:IPA|&#91;foo&#93;]]</span>[[:Category:Pages with English IPA]]'
		},
		{
			'en-AU|foo|lang',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">Australian English:</span> <span class="IPA nowrap" lang="en-Latn-AU-fonipa">[[Help:IPA|&#91;foo&#93;]]</span>[[:Category:Pages with Australian English IPA]]'
		},
		{
			'ace|foo',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">Acehnese pronunciation:</span> <span class="IPA nowrap" lang="ace-Latn-fonipa">[[Help:IPA|&#91;foo&#93;]]</span>[[:Category:Pages with Acehnese IPA]]'
		},
		{
			'en|foo',
			'<span class="IPA nowrap" lang="en-Latn-fonipa">[[Help:IPA/English|/foo/]]</span>[[:Category:Pages with English IPA]]'
		},
		{
			'en-uk|foo',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">UK:</span> <span class="IPA nowrap" lang="en-Latn-GB-fonipa">[[Help:IPA/English|/foo/]]</span>[[:Category:Pages with British English IPA]]'
		},
		{
			'en-uk|foo|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[British English language|UK]]:</span> <span class="IPA nowrap" lang="en-Latn-GB-fonipa">[[Help:IPA/English|/foo/]]</span>[[:Category:Pages with British English IPA]]'
		},
		{
			'sv-FI|foo|lang',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">Finland Swedish:</span> <span class="IPA nowrap" lang="sv-Latn-FI-fonipa">[[Help:IPA/Swedish|&#91;foo&#93;]]</span>[[:Category:Pages with Finland Swedish IPA]]'
		},
		{
			'ca-valencia|foo|lang|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[Valencian language|Valencian]]:</span> <span class="IPA nowrap" lang="ca-Latn-valencia-fonipa">[[Help:IPA/Catalan|&#91;foo&#93;]]</span>[[:Category:Pages with Valencian IPA]]'
		},
		{
			'grc-x-attic|foo|lang|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[Attic Greek language|Attic Greek]]:</span> <span class="IPA nowrap" lang="grc-Latn-fonipa">[[Help:IPA/Greek|&#91;foo&#93;]]</span>[[:Category:Pages with Attic Greek IPA]]'
		},
		{
			'grc-x-aeolic|foo|lang|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[Aeolic Greek language|Aeolic Greek]]:</span> <span class="IPA nowrap" lang="grc-Latn-fonipa">[[Help:IPA|&#91;foo&#93;]]</span>[[:Category:Pages with Aeolic Greek IPA]]'
		},
		{
			'nan-TW|foo|lang|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[Taiwanese Hokkien language|Taiwanese Hokkien]]:</span> <span class="IPA nowrap" lang="nan-Latn-TW-fonipa">[[Help:IPA/Taiwanese Hokkien|&#91;foo&#93;]]</span>[[:Category:Pages with Taiwanese Hokkien IPA]]'
		},
		{
			'nl-BE|foo|lang|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[Flemish language|Flemish]]:</span> <span class="IPA nowrap" lang="nl-Latn-BE-fonipa">[[Help:IPA/Dutch|&#91;foo&#93;]]</span>[[:Category:Pages with Flemish IPA]]'
		},
		{
			'myn|foo|lang',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">Mayan:</span> <span class="IPA nowrap" lang="myn-Latn-fonipa">[[Help:IPA/Mayan|&#91;foo&#93;]]</span>[[:Category:Pages with Mayan languages IPA]]'
		},
		{
			'myn|foo|lang|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[Mayan languages|Mayan]]:</span> <span class="IPA nowrap" lang="myn-Latn-fonipa">[[Help:IPA/Mayan|&#91;foo&#93;]]</span>[[:Category:Pages with Mayan languages IPA]]'
		},
		{
			'aus|foo|lang|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[Australian languages|Aboriginal]]:</span> <span class="IPA nowrap" lang="aus-Latn-fonipa">[[Help:IPA/Australian languages|&#91;foo&#93;]]</span>[[:Category:Pages with Australian languages IPA]]'
		},
		{
			'mnr|foo|lang|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[Mono language (California)|Mono]]:</span> <span class="IPA nowrap" lang="mnr-Latn-fonipa">[[Help:IPA|&#91;foo&#93;]]</span>[[:Category:Pages with Mono (USA) IPA]]'
		},
		{
			'ga-GB|foo|lang|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[Ulster Irish language|Ulster Irish]]:</span> <span class="IPA nowrap" lang="ga-Latn-fonipa">[[Help:IPA/Irish|&#91;foo&#93;]]</span>[[:Category:Pages with Ulster Irish IPA]]'
		},
		{
			'ga-x-ulster|foo|lang|link=yes',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">[[Ulster Irish language|Ulster Irish]]:</span> <span class="IPA nowrap" lang="ga-Latn-fonipa">[[Help:IPA/Irish|&#91;foo&#93;]]</span>[[:Category:Pages with Ulster Irish IPA]]'
		},
		{
			'und|foo',
			getStripMarker('templatestyles') .. '<span class="IPA-label IPA-label-small">IPA:</span> <span class="IPA nowrap" lang="und-Latn-fonipa">[[Help:IPA|&#91;foo&#93;]]</span>[[:Category:Pages with undetermined IPA]]'
		},
		{
			'foo|lang=pt-BR',
			'<span class="IPA nowrap" lang="pt-Latn-BR-fonipa" title="Representation in the International Phonetic Alphabet (IPA)">foo</span>[[:Category:Pages with plain IPA]]'
		},
		{
			'foo|lang=grc-x-attic',
			'<span class="IPA nowrap" lang="grc-Latn-fonipa" title="Representation in the International Phonetic Alphabet (IPA)">foo</span>[[:Category:Pages with plain IPA]]'
		},
		{
			'en|',
			'<span class="IPA nowrap" lang="und-Latn-fonipa" title="Representation in the International Phonetic Alphabet (IPA)">en</span>[[:Category:Pages with plain IPA]]'
		},
	}, { combined = true, stripmarker = true })
	-- self:preprocess_equals_preprocess_many('{{IPA-cs|', '}}', '{{IPA|cs|', '}}', {
	-- 	{ 'foo' },
	-- 	{ 'foo|lang' },
	-- 	{ 'foo|-|Example.ogg' },
	-- 	{ 'foo|' },
	-- }, { combined = true, stripmarker = true })
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.

  1. 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:
  2. 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.
  3. 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.
  4. 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.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.