Difference between revisions of "Module:Delink/testcases"

From blackwiki
Jump to navigation Jump to search
blackwiki>Mr. Stradivarius
m (Undid revision 548523600 by Mr. Stradivarius (talk) nope, didn't work)
m (70 revisions imported)
 
(35 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
local p = require('Module:UnitTests')
 
local p = require('Module:UnitTests')
  
function p:test_basic()
+
function p:test01_basic()
    self:preprocess_equals('{{#invoke:Delink|delink|[[Apple]]}}', 'Apple')
+
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
    self:preprocess_equals('{{#invoke:Delink|delink|[[Orange]]s are dissimilar to [[Apple]]s}}', 'Oranges are dissimilar to Apples')
+
{ '[[Apple]]', 'Apple'},
  self:preprocess_equals('{{#invoke:Delink|delink|[[Apple]]s and [[orange]]s and [[fruit salad|other kinds of fruit]]}}', 'Apples and oranges and other kinds of fruit')
+
{ '[[Orange]]s are dissimilar to [[Apple]]s', 'Oranges are dissimilar to Apples'},
    self:preprocess_equals('{{#invoke:Delink|delink|All [[Gone]] [[wikt:to|]] [[Bed]] [[Now]]}}', 'All Gone to Bed Now')
+
{ '[[Apple]]s and [[orange]]s and [[fruit salad|other kinds of fruit]]', 'Apples and oranges and other kinds of fruit'},
    self:preprocess_equals('{{#invoke:Delink|delink|[[Survey]] of [http://books.google.com Google Books] on [[UK|Britain]]}}', 'Survey of Google Books on Britain')
+
{ 'All [[Gone]] [[wikt:to|]] [[Bed]] [[Now]]', 'All Gone to Bed Now'},
 +
{ '[[Survey]] of [http://books.google.com Google Books] on [[UK|Britain]]', 'Survey of Google Books on Britain'}
 +
}, {nowiki='yes'})
 
end
 
end
  
function p:test_cats_and_interwikis()
+
function p:test02_cats_and_interwikis()
    self:preprocess_equals('{{#invoke:Delink|delink|[[Category:Foo]]}}', '')
+
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
    self:preprocess_equals('{{#invoke:Delink|delink|[[es:Foo]]}}', '')
+
{ '[[Category:Foo]]', ''},
    self:preprocess_equals('{{#invoke:Delink|delink|[[wikt:Foo]]}}', 'wikt:Foo')
+
{ '[[category:Foo]]', ''},
    self:preprocess_equals('{{#invoke:Delink|delink|[[es:Wikipedia:Políticas]]}}', '')
+
{ '[[Image:Foo]]', ''},
    self:preprocess_equals('{{#invoke:Delink|delink|[[abcd:efgh:ijkl]]}}', 'abcd:efgh:ijkl')
+
{ '[[es:Foo]]', ''},
    self:preprocess_equals('{{#invoke:Delink|delink|[[cbk-zam:abcd:efgh]]}}', '')
+
{ '[[wikt:Foo]]', 'wikt:Foo'},
 +
{ '[[es:Wikipedia:Políticas]]', ''},
 +
{ '[[abcd:efgh:ijkl]]', 'abcd:efgh:ijkl'},
 +
{ '[[cbk-zam:abcd:efgh]]', ''},
 +
{ '[[meatball:WikiPedia]]', 'meatball:WikiPedia' },
 +
}, {nowiki='yes'})
 
end
 
end
   
+
 
function p:test_colontrick()
+
function p:test03_colontrick()
    self:preprocess_equals('{{#invoke:Delink|delink|[[:Category:Foo]]}}', 'Category:Foo')
+
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
    self:preprocess_equals('{{#invoke:Delink|delink|[[:es:Foo]]}}', 'es:Foo')
+
{ '[[:Category:Foo]]', 'Category:Foo'},
    self:preprocess_equals('{{#invoke:Delink|delink|[[:wikt:Foo]]}}', 'wikt:Foo')
+
{ '[[:es:Foo]]', 'es:Foo'},
    self:preprocess_equals('{{#invoke:Delink|delink|[[:es:Wikipedia:Políticas]]}}', 'es:Wikipedia:Políticas')
+
{ '[[:wikt:Foo]]', 'wikt:Foo'},
    self:preprocess_equals('{{#invoke:Delink|delink|[[:abcd:efgh:ijkl]]}}', 'abcd:efgh:ijkl')
+
{ '[[:es:Wikipedia:Políticas]]', 'es:Wikipedia:Políticas'},
    self:preprocess_equals('{{#invoke:Delink|delink|[[:cbk-zam:abcd:efgh]]}}', 'cbk-zam:abcd:efgh')
+
{ '[[:abcd:efgh:ijkl]]', 'abcd:efgh:ijkl'},
 +
{ '[[:cbk-zam:abcd:efgh]]', 'cbk-zam:abcd:efgh'},
 +
{ '[[:meatball:WikiPedia]]', 'meatball:WikiPedia'},
 +
}, {nowiki='yes'})
 +
end
 +
 
 +
function p:test04_pipetrick()
 +
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
 +
{ '[[Pipe (computing)|]]', 'Pipe'},
 +
{ '[[Boston, Massachusetts|]]', 'Boston'},
 +
{ '[[Wikipedia:Verifiability|]]', 'Verifiability'},
 +
{ '[[User:Example|]]', 'Example'},
 +
{ '[[Template:Welcome|]]', 'Welcome'},
 +
{ '[[Yours, Mine and Ours (1968 film)|]]', 'Yours, Mine and Ours'},
 +
{ '[[:es:Wikipedia:Políticas|]]', 'Wikipedia:Políticas'},
 +
{ '[[Il Buono, il Brutto, il Cattivo|]]', 'Il Buono'},
 +
{ '[[Wikipedia:Manual of Style (Persian)|]]', 'Manual of Style'},
 +
{ '[[Wikipedia:Manual of Style(Persian)|]]', 'Manual of Style'},
 +
{ '[[foo|bar|]]', 'bar|'},
 +
{ '[[foo||]]', '|'},
 +
{ 'xx[[foo bar  (baz)|]]xx', 'xxfoo bar xx'},
 +
}, {nowiki='yes'})
 +
end
 +
 
 +
function p:test05_reverse_pipetrick()
 +
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
 +
{ '[[|foo]]', 'foo'},
 +
{ '[[|multiple|pipes]]', '[[|multiple|pipes]]'},
 +
{ '[[|foo (bar)]]', 'foo (bar)'},
 +
{ '[[|foo, bar (baz)]]', 'foo, bar (baz)'},
 +
{ '[[|simultaneous pipe trick|]]', '[[|simultaneous pipe trick|]]'},
 +
}, {nowiki='yes'})
 +
end
 +
 
 +
function p:test06_badlinks()
 +
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
 +
{ '[[<]]', '[[<]]'},
 +
{ '[[Category:<]]', '[[Category:<]]'},
 +
{ '[[:Category:<]]', '[[:Category:<]]'},
 +
{ '[[:Category:<|Foo]]', '[[:Category:<|Foo]]'},
 +
{ '[[:Category:<|]]', '[[:Category:<|]]'},
 +
{ '[[:Category:Foo|<]]', '<'},
 +
{ '[[Category:Foo|<]]', ''},
 +
{ '[[Foo:Bar|<]]', '<'},
 +
{ '[[Foo:Bar:>]]', '[[Foo:Bar:>]]'},
 +
{ '[[es:Wikipedia:<]]', '[[es:Wikipedia:<]]'},
 +
{ '[[es:Wikipedia:Foo|<]]', ''},
 +
{ '[[:es:Wikipedia:<]]', '[[:es:Wikipedia:<]]'},
 +
{ '[[:es:Wikipedia:Foo|<]]', '<'},
 +
{ '[[Foo:Bar:Foo#>]]', 'Foo:Bar:Foo#>'},
 +
{ '[[Foo:Bar:Foo>#Baz]]', '[[Foo:Bar:Foo>#Baz]]'},
 +
{ '[[Foo#Bar>#Baz]]', 'Foo#Bar>#Baz'},
 +
{ '[[Foo>#Bar#Baz]]', '[[Foo>#Bar#Baz]]'},
 +
{ '[[wikt:es:asdf:&#x0000;Template:title#Fragment]]', '[[wikt:es:asdf:&#x0000;Template:title#Fragment]]'},
 +
{ '[[foo]]', '[[foo]]'}, -- ASCII delete character
 +
}, {nowiki='yes'})
 +
end
 +
 
 +
function p:test07_URI_slashes()
 +
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
 +
{ '[/foo]', '[/foo]'},
 +
{ '[/foo bar]', '[/foo bar]'},
 +
{ '[//foo]', ''},
 +
{ '[//foo bar]', 'bar'},
 +
{ '[///foo]', ''},
 +
{ '[///foo bar]', 'bar'},
 +
{ '[////foo]', ''},
 +
{ '[////foo bar]', 'bar'},
 +
{ '[///////////////////////////////////foo]', ''},
 +
{ '[///////////////////////////////////foo bar]', 'bar'},
 +
}, {nowiki='yes'})
 +
end
 +
 
 +
function p:test08_URI_prefixes()
 +
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
 +
{ '[://foo]', '[://foo]'},
 +
{ '[:://foo]', '[:://foo]'},
 +
{ '[abcd://]', '[abcd://]'},
 +
{ '[abcd://foo]', '[abcd://foo]'},
 +
{ '[http://]', '[http://]'},
 +
{ '[http://foo]', ''},
 +
{ '[https://]', '[https://]'},
 +
{ '[https://foo]', ''},
 +
{ '[ftp://]', '[ftp://]'},
 +
{ '[ftp://foo]', ''},
 +
{ '[gopher://]', '[gopher://]'},
 +
{ '[gopher://foo]', ''},
 +
{ '[mailto:]', '[mailto:]'},
 +
{ '[mailto:foo]', ''},
 +
{ '[news]', '[news]'},
 +
{ '[news at ten]', '[news at ten]'},
 +
{ '[news:]', '[news:]'},
 +
{ '[news: at ten]', '[news: at ten]'},
 +
{ '[news:/]', ''},
 +
{ '[news:/ at ten]', 'at ten'},
 +
{ '[news://]', ''},
 +
{ '[news://foo]', ''},
 +
{ '[news://foo at ten]', 'at ten'},
 +
{ '[irc://]', '[irc://]'},
 +
{ '[irc://foo]', ''},
 +
}, {nowiki='yes'})
 +
end
 +
 
 +
function p:test09_URI_special_characters()
 +
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
 +
{ '[:http://foo]', '[:http://foo]'},
 +
{ '[http://<foo]', '<foo'},
 +
{ '[http://foo"bar]', '"bar'},
 +
{ '[http://"foo]', '[http://"foo]'},
 +
{ '[http://>foo]', '>foo'},
 +
{ '[http://foo<bar]', '<bar'},
 +
{ '[http://foo>bar]', '>bar'},
 +
{ '[http:// foo]', '[http:// foo]'},
 +
}, {nowiki='yes'})
 +
end
 +
 
 +
function p:test10_nesting()
 +
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
 +
{ 'text[[<s name=]]>stricken</s>more text]]', 'text[[<s name=]]>stricken</s>more text]]'},
 +
{ 'text[[<s>stricken</s>more text]]', 'text[[<s>stricken</s>more text]]'},
 +
{ '[[outer[[inner]]outer]]', '[[outerinnerouter]]'},
 +
{ '[http://outer outer [[inner]] outer]', 'outer inner outer'},
 +
{ '[[outer[http://inner inner]outer]]', '[[outerinnerouter]]'},
 +
{ '[[outer[http://inner]outer]]]', '[[outerouter]]]'},
 +
}, {nowiki='yes'})
 +
end
 +
 
 +
function p:test11_multiple_pipes()
 +
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
 +
{ '[[foo|bar|baz]]', 'bar|baz'},
 +
{ '[[foo|bar|baz|]]', 'bar|baz|'},
 +
{ '[[|foo|bar|baz]]', '[[|foo|bar|baz]]'},
 +
{ '[[|foo|bar|baz|]]', '[[|foo|bar|baz|]]'},
 +
{ '[[foo|bar|baz||]]', 'bar|baz||'},
 +
{ '[[||foobarbaz]]', '[[||foobarbaz]]'},
 +
{ '[[foobarbaz||]]', '|'},
 +
}, {nowiki='yes'})
 +
end
 +
 
 +
function p:test12_http_links()
 +
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
 +
{ '[http]', '[http]'},
 +
{ '[http:foo]', '[http:foo]'},
 +
{ '[http:]', '[http:]'},
 +
{ '[http:foo]', '[http:foo]'},
 +
{ '[http:/]', '[http:/]'},
 +
{ '[http:/foo]', '[http:/foo]'},
 +
{ '[http://]', '[http://]'},
 +
{ '[http://foo]', ''},
 +
}, {nowiki='yes'})
 
end
 
end
  
function p:test_pipetrick()
+
function p:test13_whitespace()
    self:preprocess_equals('{{#invoke:Delink|delink|[[Pipe (computing)|]]}}', 'Pipe')
+
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
    self:preprocess_equals('{{#invoke:Delink|delink|[[Boston, Massachusetts|]]}}', 'Boston')
+
{ 'xx[[   fruit salad  |   many kinds of fruit  ]]xx', 'xx many kinds of fruit xx'},
    self:preprocess_equals('{{#invoke:Delink|delink|[[Wikipedia:Verifiability|]]}}', 'Verifiability')
+
{ '[http://www.example.com        example]', 'example'},
    self:preprocess_equals('{{#invoke:Delink|delink|[[User:Example|]]}}', 'Example')
+
{ [=[[[link with
    self:preprocess_equals('{{#invoke:Delink|delink|[[Template:Welcome|]]}}', 'Welcome')
+
a line break in]]]=], '[[link with a line break in]]'},
    self:preprocess_equals('{{#invoke:Delink|delink|[[Yours, Mine and Ours (1968 film)|]]}}', 'Yours, Mine and Ours')
+
{ [=[[[link with
    self:preprocess_equals('{{#invoke:Delink|delink|[[:es:Wikipedia:Políticas|]]}}', 'Wikipedia:Políticas')
+
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[Il Buono, il Brutto, il Cattivo|]]}}', 'Il Buono')
+
two line breaks in]]]=], [=[[[link with
    self:preprocess_equals('{{#invoke:Delink|delink|[[Wikipedia:Manual of Style (Persian)|]]}}', 'Manual of Style')
+
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[Wikipedia:Manual of Style(Persian)|]]}}', 'Manual of Style')
+
two line breaks in]]]=] },
    self:preprocess_equals('{{#invoke:Delink|delink|[[foo|bar|]]}}', 'bar|')
+
{ [=[an [http://www.example.com
 +
example].]=], 'an [http://www.example.com example].'},
 +
{ [=[an [http://www.example.com
 +
 
 +
example].]=], [=[an [http://www.example.com
 +
 
 +
example].]=] },
 +
{ '[http://www.example.com HTML line breaks] between<br>two [http://www.example.com links]', 'HTML line breaks between two links'},
 +
{ '[http://www.example.com HTML line break<br />within<br/>a link]', 'HTML line break within a link'},
 +
{ '[http://www.example.com Double HTML line break<br /><br  />within a link]', [=[Double HTML line break
 +
 
 +
within a link]=]},
 +
{ '[http://www.example.com non-breaking spaces]', 'non-breaking spaces'},
 +
{ '[http://www.example.com tab characters]', 'tab characters'},
 +
{ '[http://www.example.com    multiple    non-breaking      spaces]', 'multiple non-breaking spaces'},
 +
{ '[http://www.example.com    multiple    tab      characters]', 'multiple tab characters'},
 +
}, {nowiki='yes'})
 
end
 
end
  
function p:test_reverse_pipetrick()
+
function p:test14_full_paragraphs()
    self:preprocess_equals('{{#invoke:Delink|delink|[[|foo]]}}', 'foo')
+
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
    self:preprocess_equals('{{#invoke:Delink|delink|[[|multiple|pipes]]}}', '[[|multiple|pipes]]')
+
{
    self:preprocess_equals('{{#invoke:Delink|delink|[[|foo (bar)]]}}', 'foo (bar)')
+
[==[He then studied at [[Saint Patrick Seminary, Menlo Park|St. Patrick's Seminary]] in [[Menlo Park, California|Menlo Park]]. He was [[Holy Orders|ordained]] to the [[Priesthood (Catholic Church)|priesthood]] on June 10, 1933.<ref name=hierarchy>{{cite news|work=Catholic-Hierarchy.org|title=Bishop Merlin Joseph Guilfoyle|url=http://www.catholic-hierarchy.org/bishop/bguimj.html}}</ref> In 1937, he earned a [[Doctor of Canon Law]] from the [[The Catholic University of America|Catholic University of America]] in [[Washington, D.C.]]<ref name=curtis/> He became a [[Monsignor|Domestic Prelate]] in 1949, and was co-founder and [[chaplain]] of [http://www.stthomasmore-sf.org/ St. Thomas More Society].]==],
    self:preprocess_equals('{{#invoke:Delink|delink|[[|foo, bar (baz)]]}}', 'foo, bar (baz)')
+
[==[He then studied at St. Patrick's Seminary in Menlo Park. He was ordained to the priesthood on June 10, 1933. In 1937, he earned a Doctor of Canon Law from the Catholic University of America in Washington, D.C. He became a Domestic Prelate in 1949, and was co-founder and chaplain of St. Thomas More Society.]==],
    self:preprocess_equals('{{#invoke:Delink|delink|[[|simultaneous pipe trick|]]}}', '[[|simultaneous pipe trick|]]')
+
},
 +
})
 
end
 
end
  
function p:test_badlinks()
+
function p:test15_full_paragraphs_removing_ref_strip_markers()
    self:preprocess_equals('{{#invoke:Delink|delink|[[<]]}}', '[[<]]')
+
self:preprocess_equals_many('{{delink/sandbox|refs=yes|', '}}', {
    self:preprocess_equals('{{#invoke:Delink|delink|[[Category:<]]}}', '[[Category:<]]')
+
{
    self:preprocess_equals('{{#invoke:Delink|delink|[[:Category:<]]}}', '[[:Category:<]]')
+
[==[He then studied at [[Saint Patrick Seminary, Menlo Park|St. Patrick's Seminary]] in [[Menlo Park, California|Menlo Park]]. He was [[Holy Orders|ordained]] to the [[Priesthood (Catholic Church)|priesthood]] on June 10, 1933.<ref name=hierarchy>{{cite news|work=Catholic-Hierarchy.org|title=Bishop Merlin Joseph Guilfoyle|url=http://www.catholic-hierarchy.org/bishop/bguimj.html}}</ref> In 1937, he earned a [[Doctor of Canon Law]] from the [[The Catholic University of America|Catholic University of America]] in [[Washington, D.C.]]<ref name=curtis/> He became a [[Monsignor|Domestic Prelate]] in 1949, and was co-founder and [[chaplain]] of [http://www.stthomasmore-sf.org/ St. Thomas More Society].]==],
    self:preprocess_equals('{{#invoke:Delink|delink|[[:Category:<|Foo]]}}', '[[:Category:<|Foo]]')
+
[==[He then studied at St. Patrick's Seminary in Menlo Park. He was ordained to the priesthood on June 10, 1933. In 1937, he earned a Doctor of Canon Law from the Catholic University of America in Washington, D.C. He became a Domestic Prelate in 1949, and was co-founder and chaplain of St. Thomas More Society.]==],
    self:preprocess_equals('{{#invoke:Delink|delink|[[:Category:<|]]}}', '[[:Category:<|]]')
+
},
    self:preprocess_equals('{{#invoke:Delink|delink|[[:Category:Foo|<]]}}', '<')
+
})
    self:preprocess_equals('{{#invoke:Delink|delink|[[Category:Foo|<]]}}', '')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[Foo:Bar|<]]}}', '<')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[Foo:Bar:>]]}}', '[[Foo:Bar:>]]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[es:Wikipedia:<]]}}', '[[es:Wikipedia:<]]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[es:Wikipedia:Foo|<]]}}', '')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[:es:Wikipedia:<]]}}', '[[:es:Wikipedia:<]]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[:es:Wikipedia:Foo|<]]}}', '<')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[Foo:Bar:Foo#>]]}}', 'Foo:Bar:Foo#>')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[Foo:Bar:Foo>#Baz]]}}', '[[Foo:Bar:Foo>#Baz]]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[Foo#Bar>#Baz]]}}', 'Foo#Bar>#Baz')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[Foo>#Bar#Baz]]}}', '[[Foo>#Bar#Baz]]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[[wikt:es:asdf:&#x0000;Template:title#Fragment]]}}', '[[wikt:es:asdf:&#x0000;Template:title#Fragment]]')
 
 
end
 
end
  
function p:test_URI_slashes()
+
function p:test16_html_comments()
    self:preprocess_equals('{{#invoke:Delink|delink|[/foo]}}', '[/foo]')
+
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
    self:preprocess_equals('{{#invoke:Delink|delink|[/foo bar]}}', '[/foo bar]')
+
{ '[[foo<!--bar]]-->baz]]', 'foobaz'},
    self:preprocess_equals('{{#invoke:Delink|delink|[//foo]}}', '')
+
{ 'foo<!--bar-->baz', 'foobaz'},
    self:preprocess_equals('{{#invoke:Delink|delink|[//foo bar]}}', 'bar')
+
{ 'foo<!--bar<!--baz-->bat-->bam', 'foobat-->bam'},
    self:preprocess_equals('{{#invoke:Delink|delink|[///foo]}}', '')
+
{ 'foo[http://abcd<!--bar-->efgh]baz', 'foobaz'},
    self:preprocess_equals('{{#invoke:Delink|delink|[///foo bar]}}', 'bar')
+
{ 'foo[http://abcd<!--barefgh]baz-->bat', 'foo[http://abcdbat'},
    self:preprocess_equals('{{#invoke:Delink|delink|[////foo]}}', '')
+
{ 'foo[http://ab[[cd]]<!--barefgh]baz-->bat', 'foo[http://abcdbat'},
    self:preprocess_equals('{{#invoke:Delink|delink|[////foo bar]}}', 'bar')
+
{ 'foo[http://ab{{!((}}cd<!--bar]]efgh]baz-->bat', 'foo[http://ab[[cdbat'},
    self:preprocess_equals('{{#invoke:Delink|delink|[///////////////////////////////////foo]}}', '')
+
{ 'foo[[bar<!--baz-->]]bam', 'foobarbam'},
    self:preprocess_equals('{{#invoke:Delink|delink|[///////////////////////////////////foo bar]}}', 'bar')
+
}, {nowiki='yes'})
 
end
 
end
  
function p:test_URI_prefixes()
+
function p:test17_nowiki()
    self:preprocess_equals('{{#invoke:Delink|delink|[://foo]}}', '[://foo]')
+
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
    self:preprocess_equals('{{#invoke:Delink|delink|[:://foo]}}', '[:://foo]')
+
{ '<nowiki>[[foo]]</nowiki>', '[[foo]]'},
    self:preprocess_equals('{{#invoke:Delink|delink|[abcd://]}}', '[abcd://]')
+
{ '[[foo]]<nowiki>[[bar]]</nowiki>[[baz]]', 'foo[[bar]]baz'},
    self:preprocess_equals('{{#invoke:Delink|delink|[abcd://foo]}}', '[abcd://foo]')
+
{ '<nowiki>[http://www.example.com foo]</nowiki>', '[http://www.example.com foo]'},
    self:preprocess_equals('{{#invoke:Delink|delink|[http://]}}', '[http://]')
+
{ '{{!((}}foo<nowiki>bar]]</nowiki>', '[[foobar]]'},
    self:preprocess_equals('{{#invoke:Delink|delink|[http://foo]}}', '')
+
{ '<nowiki>[[foo</nowiki>bar]]', '[[foobar]]'},
    self:preprocess_equals('{{#invoke:Delink|delink|[https://]}}', '[https://]')
+
{ '[http://www.exa<nowiki>mple.com foo]</nowiki>', '[http://www.example.com foo]'},
    self:preprocess_equals('{{#invoke:Delink|delink|[https://foo]}}', '')
+
}, {nowiki='yes'})
    self:preprocess_equals('{{#invoke:Delink|delink|[ftp://]}}', '[ftp://]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[ftp://foo]}}', '')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[gopher://]}}', '[gopher://]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[gopher://foo]}}', '')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[mailto:]}}', '[mailto:]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[mailto:foo]}}', '')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[news]}}', '[news]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[news at ten]}}', '[news at ten]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[news:]}}', '[news:]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[news: at ten]}}', '[news: at ten]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[news:/]}}', '')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[news:/ at ten]}}', 'at ten')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[news://]}}', '')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[news://foo]}}', '')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[news://foo at ten]}}', 'at ten')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[irc://]}}', '[irc://]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[irc://foo]}}', '')
 
 
end
 
end
  
function p:test_URI_special_characters()
+
function p:test18_decoding()
    self:preprocess_equals('{{#invoke:Delink|delink|[:http://foo]}}', '[:http://foo]')
+
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
    self:preprocess_equals('{{#invoke:Delink|delink|[http://<foo]}}', '<foo')
+
{ '[[foo%25 bar]]', 'foo% bar'},
    self:preprocess_equals('{{#invoke:Delink|delink|[http://foo"bar]}}', '"bar')
+
{ '[[foo%25bar]]', '[[foo%25bar]]'},
    self:preprocess_equals('{{#invoke:Delink|delink|[http://"foo]}}', '[http://"foo]')
+
{ '[[foo%24bar]]', 'foo$bar'},
    self:preprocess_equals('{{#invoke:Delink|delink|[http://>foo]}}', '>foo')
+
{ '[[foo%88bar]]', '[[foo%88bar]]'},
    self:preprocess_equals('{{#invoke:Delink|delink|[http://foo<bar]}}', '<bar')
+
{ '[[foo%6Abar]]', 'foojbar'},
    self:preprocess_equals('{{#invoke:Delink|delink|[http://foo>bar]}}', '>bar')
+
{ '[[foo%11bar]]', '[[foo%11bar]]'},
    self:preprocess_equals('{{#invoke:Delink|delink|[http:// foo]}}', '[http:// foo]')
+
{ '[[foo&amp;bar]]', 'foo&bar'},
 +
{ '[[foo%25bar]]', '[[foo%25bar]]'},
 +
{ '[[foo&a%6Amp;bar]]', '[[foo&a%6Amp;bar]]'},
 +
{ '[[foo&%61mp;bar]]', 'foo&bar'},
 +
{ '[[foo&%62mp;bar]]', '[[foo&%62mp;bar]]'},
 +
{ '[[foo&#x25;bar]]', '[[foo&#x25;bar]]'},
 +
{ '[[foo&#x25;62bar]]', '[[foo&#x25;62bar]]'},
 +
{ '[[foo&#x0000;bar]]', '[[foo&#x0000;bar]]'},
 +
{ '[[foo&#x00000;bar]]', '[[foo&#x00000;bar]]'},
 +
{ '[[foo&#x22;bar]]', 'foo"bar'},
 +
{ '[[foo&#x0000022;bar]]', 'foo"bar'},
 +
{ '[[foo&amp;amp;bar]]', '[[foo&amp;amp;bar]]'},
 +
}, {nowiki='yes'})
 
end
 
end
  
function p:test_nesting()
+
function p:test19_URL_decoding()
    self:preprocess_equals_preprocess('{{#invoke:Delink|delink|text[[<s name=]]>stricken</s>more text]]}}', 'text[[<s name=]]>stricken</s>more text]]')
+
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
    self:preprocess_equals_preprocess('{{#invoke:Delink|delink|text[[<s>stricken</s>more text]]}}', 'text[[<s>stricken</s>more text]]')
+
{ '[http://www.example.com foo%25 bar]', 'foo%25 bar'},
    self:preprocess_equals_preprocess('{{#invoke:Delink|delink|[[outer[[inner]]outer]]}}', '[[outerinnerouter]]')
+
{ '[http://www.example.com foo%25bar]', 'foo%25bar'},
    self:preprocess_equals_preprocess('{{#invoke:Delink|delink|[http://outer outer [[inner]] outer]}}', 'outer inner outer')
+
{ '[http://www.example.com foo%24bar]', 'foo%24bar'},
    self:preprocess_equals_preprocess('{{#invoke:Delink|delink|[[outer[http://inner inner]outer]]}}', '[[outerinnerouter]]')
+
{ '[http://www.example.com foo%88bar]', 'foo%88bar'},
    self:preprocess_equals_preprocess('{{#invoke:Delink|delink|[[outer[http://inner]outer]]]}}', '[[outerouter]]]')
+
{ '[http://www.example.com foo%6Abar]', 'foo%6Abar'},
 +
{ '[http://www.example.com foo%11bar]', 'foo%11bar'},
 +
{ '[http://www.example.com foo&amp;bar]', 'foo&bar'},
 +
{ '[http://www.example.com foo%25bar]', 'foo%25bar'},
 +
{ '[http://www.example.com foo&a%6Amp;bar]', 'foo&a%6Amp;bar'},
 +
{ '[http://www.example.com foo&%61mp;bar]', 'foo&%61mp;bar'},
 +
{ '[http://www.example.com foo&%62mp;bar]', 'foo&%62mp;bar'},
 +
{ '[http://www.example.com foo&#x25;bar]', 'foo%bar'},
 +
{ '[http://www.example.com foo&#x25;62bar]', 'foo%62bar'},
 +
{ '[http://www.example.com foo&#x0000;bar]', 'foo&#x0000;bar'},
 +
{ '[http://www.example.com foo&#x00000;bar]', 'foo&#x00000;bar'},
 +
{ '[http://www.example.com foo&#x22;bar]', 'foo"bar'},
 +
{ '[http://www.example.com foo&#x0000022;bar]', 'foo"bar'},
 +
}, {nowiki='yes'})
 
end
 
end
  
function p:test_http_links()
+
function p:test20_no_link()
    self:preprocess_equals('{{#invoke:Delink|delink|[http]}}', '[http]')
+
self:preprocess_equals_many('{{delink/sandbox|', '}}', {
    self:preprocess_equals('{{#invoke:Delink|delink|[http:foo]}}', '[http:foo]')
+
{ '#Foo', '#Foo' },
    self:preprocess_equals('{{#invoke:Delink|delink|[http:]}}', '[http:]')
+
{ 'Foo#Bar', 'Foo#Bar' },
    self:preprocess_equals('{{#invoke:Delink|delink|[http:foo]}}', '[http:foo]')
+
}, {nowiki='yes'})
    self:preprocess_equals('{{#invoke:Delink|delink|[http:/]}}', '[http:/]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[http:/foo]}}', '[http:/foo]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[http://]}}', '[http://]')
 
    self:preprocess_equals('{{#invoke:Delink|delink|[http://foo]}}', '')
 
 
end
 
end
  
 
return p
 
return p

Latest revision as of 16:03, 26 September 2020

Documentation for this module may be created at Module:Delink/testcases/doc

local p = require('Module:UnitTests')

function p:test01_basic()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[[Apple]]', 'Apple'},
		{ '[[Orange]]s are dissimilar to [[Apple]]s', 'Oranges are dissimilar to Apples'},
		{ '[[Apple]]s and [[orange]]s and [[fruit salad|other kinds of fruit]]', 'Apples and oranges and other kinds of fruit'},
		{ 'All [[Gone]] [[wikt:to|]] [[Bed]] [[Now]]', 'All Gone to Bed Now'},
		{ '[[Survey]] of [http://books.google.com Google Books] on [[UK|Britain]]', 'Survey of Google Books on Britain'}
	}, {nowiki='yes'})
end

function p:test02_cats_and_interwikis()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[[Category:Foo]]', ''},
		{ '[[category:Foo]]', ''},
		{ '[[Image:Foo]]', ''},
		{ '[[es:Foo]]', ''},
		{ '[[wikt:Foo]]', 'wikt:Foo'},
		{ '[[es:Wikipedia:Políticas]]', ''},
		{ '[[abcd:efgh:ijkl]]', 'abcd:efgh:ijkl'},
		{ '[[cbk-zam:abcd:efgh]]', ''},
		{ '[[meatball:WikiPedia]]', 'meatball:WikiPedia' },
	}, {nowiki='yes'})
end

function p:test03_colontrick()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[[:Category:Foo]]', 'Category:Foo'},
		{ '[[:es:Foo]]', 'es:Foo'},
		{ '[[:wikt:Foo]]', 'wikt:Foo'},
		{ '[[:es:Wikipedia:Políticas]]', 'es:Wikipedia:Políticas'},
		{ '[[:abcd:efgh:ijkl]]', 'abcd:efgh:ijkl'},
		{ '[[:cbk-zam:abcd:efgh]]', 'cbk-zam:abcd:efgh'},
		{ '[[:meatball:WikiPedia]]', 'meatball:WikiPedia'},
	}, {nowiki='yes'})
end

function p:test04_pipetrick()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[[Pipe (computing)|]]', 'Pipe'},
		{ '[[Boston, Massachusetts|]]', 'Boston'},
		{ '[[Wikipedia:Verifiability|]]', 'Verifiability'},
		{ '[[User:Example|]]', 'Example'},
		{ '[[Template:Welcome|]]', 'Welcome'},
		{ '[[Yours, Mine and Ours (1968 film)|]]', 'Yours, Mine and Ours'},
		{ '[[:es:Wikipedia:Políticas|]]', 'Wikipedia:Políticas'},
		{ '[[Il Buono, il Brutto, il Cattivo|]]', 'Il Buono'},
		{ '[[Wikipedia:Manual of Style (Persian)|]]', 'Manual of Style'},
		{ '[[Wikipedia:Manual of Style(Persian)|]]', 'Manual of Style'},
		{ '[[foo|bar|]]', 'bar|'},
		{ '[[foo||]]', '|'},
		{ 'xx[[foo bar   (baz)|]]xx', 'xxfoo bar xx'},
	}, {nowiki='yes'})
end

function p:test05_reverse_pipetrick()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[[|foo]]', 'foo'},
		{ '[[|multiple|pipes]]', '[[|multiple|pipes]]'},
		{ '[[|foo (bar)]]', 'foo (bar)'},
		{ '[[|foo, bar (baz)]]', 'foo, bar (baz)'},
		{ '[[|simultaneous pipe trick|]]', '[[|simultaneous pipe trick|]]'},
	}, {nowiki='yes'})
end

function p:test06_badlinks()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[[<]]', '[[<]]'},
		{ '[[Category:<]]', '[[Category:<]]'},
		{ '[[:Category:<]]', '[[:Category:<]]'},
		{ '[[:Category:<|Foo]]', '[[:Category:<|Foo]]'},
		{ '[[:Category:<|]]', '[[:Category:<|]]'},
		{ '[[:Category:Foo|<]]', '<'},
		{ '[[Category:Foo|<]]', ''},
		{ '[[Foo:Bar|<]]', '<'},
		{ '[[Foo:Bar:>]]', '[[Foo:Bar:>]]'},
		{ '[[es:Wikipedia:<]]', '[[es:Wikipedia:<]]'},
		{ '[[es:Wikipedia:Foo|<]]', ''},
		{ '[[:es:Wikipedia:<]]', '[[:es:Wikipedia:<]]'},
		{ '[[:es:Wikipedia:Foo|<]]', '<'},
		{ '[[Foo:Bar:Foo#>]]', 'Foo:Bar:Foo#>'},
		{ '[[Foo:Bar:Foo>#Baz]]', '[[Foo:Bar:Foo>#Baz]]'},
		{ '[[Foo#Bar>#Baz]]', 'Foo#Bar>#Baz'},
		{ '[[Foo>#Bar#Baz]]', '[[Foo>#Bar#Baz]]'},
		{ '[[wikt:es:asdf:&#x0000;Template:title#Fragment]]', '[[wikt:es:asdf:&#x0000;Template:title#Fragment]]'},
		{ '[[foo]]', '[[foo]]'}, -- ASCII delete character
	}, {nowiki='yes'})
end

function p:test07_URI_slashes()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[/foo]', '[/foo]'},
		{ '[/foo bar]', '[/foo bar]'},
		{ '[//foo]', ''},
		{ '[//foo bar]', 'bar'},
		{ '[///foo]', ''},
		{ '[///foo bar]', 'bar'},
		{ '[////foo]', ''},
		{ '[////foo bar]', 'bar'},
		{ '[///////////////////////////////////foo]', ''},
		{ '[///////////////////////////////////foo bar]', 'bar'},
	}, {nowiki='yes'})
end

function p:test08_URI_prefixes()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[://foo]', '[://foo]'},
		{ '[:://foo]', '[:://foo]'},
		{ '[abcd://]', '[abcd://]'},
		{ '[abcd://foo]', '[abcd://foo]'},
		{ '[http://]', '[http://]'},
		{ '[http://foo]', ''},
		{ '[https://]', '[https://]'},
		{ '[https://foo]', ''},
		{ '[ftp://]', '[ftp://]'},
		{ '[ftp://foo]', ''},
		{ '[gopher://]', '[gopher://]'},
		{ '[gopher://foo]', ''},
		{ '[mailto:]', '[mailto:]'},
		{ '[mailto:foo]', ''},
		{ '[news]', '[news]'},
		{ '[news at ten]', '[news at ten]'},
		{ '[news:]', '[news:]'},
		{ '[news: at ten]', '[news: at ten]'},
		{ '[news:/]', ''},
		{ '[news:/ at ten]', 'at ten'},
		{ '[news://]', ''},
		{ '[news://foo]', ''},
		{ '[news://foo at ten]', 'at ten'},
		{ '[irc://]', '[irc://]'},
		{ '[irc://foo]', ''},
	}, {nowiki='yes'})
end

function p:test09_URI_special_characters()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[:http://foo]', '[:http://foo]'},
		{ '[http://<foo]', '<foo'},
		{ '[http://foo"bar]', '"bar'},
		{ '[http://"foo]', '[http://"foo]'},
		{ '[http://>foo]', '>foo'},
		{ '[http://foo<bar]', '<bar'},
		{ '[http://foo>bar]', '>bar'},
		{ '[http:// foo]', '[http:// foo]'},
	}, {nowiki='yes'})
end

function p:test10_nesting()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ 'text[[<s name=]]>stricken</s>more text]]', 'text[[<s name=]]>stricken</s>more text]]'},
		{ 'text[[<s>stricken</s>more text]]', 'text[[<s>stricken</s>more text]]'},
		{ '[[outer[[inner]]outer]]', '[[outerinnerouter]]'},
		{ '[http://outer outer [[inner]] outer]', 'outer inner outer'},
		{ '[[outer[http://inner inner]outer]]', '[[outerinnerouter]]'},
		{ '[[outer[http://inner]outer]]]', '[[outerouter]]]'},
	}, {nowiki='yes'})
end

function p:test11_multiple_pipes()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[[foo|bar|baz]]', 'bar|baz'},
		{ '[[foo|bar|baz|]]', 'bar|baz|'},
		{ '[[|foo|bar|baz]]', '[[|foo|bar|baz]]'},
		{ '[[|foo|bar|baz|]]', '[[|foo|bar|baz|]]'},
		{ '[[foo|bar|baz||]]', 'bar|baz||'},
		{ '[[||foobarbaz]]', '[[||foobarbaz]]'},
		{ '[[foobarbaz||]]', '|'},
	}, {nowiki='yes'})
end

function p:test12_http_links()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[http]', '[http]'},
		{ '[http:foo]', '[http:foo]'},
		{ '[http:]', '[http:]'},
		{ '[http:foo]', '[http:foo]'},
		{ '[http:/]', '[http:/]'},
		{ '[http:/foo]', '[http:/foo]'},
		{ '[http://]', '[http://]'},
		{ '[http://foo]', ''},
	}, {nowiki='yes'})
end

function p:test13_whitespace()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ 'xx[[   fruit salad   |   many kinds of fruit   ]]xx', 'xx many kinds of fruit xx'},
		{ '[http://www.example.com        example]', 'example'},
		{ [=[[[link with
		a line break in]]]=], '[[link with a line break in]]'},
		{ [=[[[link with

		two line breaks in]]]=], [=[[[link with

 two line breaks in]]]=] },
		{ [=[an [http://www.example.com 
		example].]=], 'an [http://www.example.com example].'},
		{ [=[an [http://www.example.com

		example].]=], [=[an [http://www.example.com

 example].]=] },
		{ '[http://www.example.com HTML line breaks] between<br>two [http://www.example.com links]', 'HTML line breaks between two links'},
		{ '[http://www.example.com HTML line break<br />within<br/>a link]', 'HTML line break within a link'},
		{ '[http://www.example.com Double HTML line break<br /><br  />within a link]', [=[Double HTML line break

within a link]=]},
		{ '[http://www.example.com non-breaking spaces]', 'non-breaking spaces'},
		{ '[http://www.example.com tab characters]', 'tab characters'},
		{ '[http://www.example.com     multiple    non-breaking      spaces]', 'multiple non-breaking spaces'},
		{ '[http://www.example.com     multiple    tab      characters]', 'multiple tab characters'},
	}, {nowiki='yes'})
end

function p:test14_full_paragraphs()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{
			[==[He then studied at [[Saint Patrick Seminary, Menlo Park|St. Patrick's Seminary]] in [[Menlo Park, California|Menlo Park]]. He was [[Holy Orders|ordained]] to the [[Priesthood (Catholic Church)|priesthood]] on June 10, 1933.<ref name=hierarchy>{{cite news|work=Catholic-Hierarchy.org|title=Bishop Merlin Joseph Guilfoyle|url=http://www.catholic-hierarchy.org/bishop/bguimj.html}}</ref> In 1937, he earned a [[Doctor of Canon Law]] from the [[The Catholic University of America|Catholic University of America]] in [[Washington, D.C.]]<ref name=curtis/> He became a [[Monsignor|Domestic Prelate]] in 1949, and was co-founder and [[chaplain]] of [http://www.stthomasmore-sf.org/ St. Thomas More Society].]==],
			[==[He then studied at St. Patrick's Seminary in Menlo Park. He was ordained to the priesthood on June 10, 1933. In 1937, he earned a Doctor of Canon Law from the Catholic University of America in Washington, D.C. He became a Domestic Prelate in 1949, and was co-founder and chaplain of St. Thomas More Society.]==],
		},
	})
end

function p:test15_full_paragraphs_removing_ref_strip_markers()
	self:preprocess_equals_many('{{delink/sandbox|refs=yes|', '}}', {
		{
			[==[He then studied at [[Saint Patrick Seminary, Menlo Park|St. Patrick's Seminary]] in [[Menlo Park, California|Menlo Park]]. He was [[Holy Orders|ordained]] to the [[Priesthood (Catholic Church)|priesthood]] on June 10, 1933.<ref name=hierarchy>{{cite news|work=Catholic-Hierarchy.org|title=Bishop Merlin Joseph Guilfoyle|url=http://www.catholic-hierarchy.org/bishop/bguimj.html}}</ref> In 1937, he earned a [[Doctor of Canon Law]] from the [[The Catholic University of America|Catholic University of America]] in [[Washington, D.C.]]<ref name=curtis/> He became a [[Monsignor|Domestic Prelate]] in 1949, and was co-founder and [[chaplain]] of [http://www.stthomasmore-sf.org/ St. Thomas More Society].]==],
			[==[He then studied at St. Patrick's Seminary in Menlo Park. He was ordained to the priesthood on June 10, 1933. In 1937, he earned a Doctor of Canon Law from the Catholic University of America in Washington, D.C. He became a Domestic Prelate in 1949, and was co-founder and chaplain of St. Thomas More Society.]==],
		},
	})
end

function p:test16_html_comments()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[[foo<!--bar]]-->baz]]', 'foobaz'},
		{ 'foo<!--bar-->baz', 'foobaz'},
		{ 'foo<!--bar<!--baz-->bat-->bam', 'foobat-->bam'},
		{ 'foo[http://abcd<!--bar-->efgh]baz', 'foobaz'},
		{ 'foo[http://abcd<!--barefgh]baz-->bat', 'foo[http://abcdbat'},
		{ 'foo[http://ab[[cd]]<!--barefgh]baz-->bat', 'foo[http://abcdbat'},
		{ 'foo[http://ab{{!((}}cd<!--bar]]efgh]baz-->bat', 'foo[http://ab[[cdbat'},
		{ 'foo[[bar<!--baz-->]]bam', 'foobarbam'},
	}, {nowiki='yes'})
end

function p:test17_nowiki()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '<nowiki>[[foo]]</nowiki>', '[[foo]]'},
		{ '[[foo]]<nowiki>[[bar]]</nowiki>[[baz]]', 'foo[[bar]]baz'},
		{ '<nowiki>[http://www.example.com foo]</nowiki>', '[http://www.example.com foo]'},
		{ '{{!((}}foo<nowiki>bar]]</nowiki>', '[[foobar]]'},
		{ '<nowiki>[[foo</nowiki>bar]]', '[[foobar]]'},
		{ '[http://www.exa<nowiki>mple.com foo]</nowiki>', '[http://www.example.com foo]'},
	}, {nowiki='yes'})
end

function p:test18_decoding()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[[foo%25 bar]]', 'foo% bar'},
		{ '[[foo%25bar]]', '[[foo%25bar]]'},
		{ '[[foo%24bar]]', 'foo$bar'},
		{ '[[foo%88bar]]', '[[foo%88bar]]'},
		{ '[[foo%6Abar]]', 'foojbar'},
		{ '[[foo%11bar]]', '[[foo%11bar]]'},
		{ '[[foo&amp;bar]]', 'foo&bar'},
		{ '[[foo%25bar]]', '[[foo%25bar]]'},
		{ '[[foo&a%6Amp;bar]]', '[[foo&a%6Amp;bar]]'},
		{ '[[foo&%61mp;bar]]', 'foo&bar'},
		{ '[[foo&%62mp;bar]]', '[[foo&%62mp;bar]]'},
		{ '[[foo&#x25;bar]]', '[[foo&#x25;bar]]'},
		{ '[[foo&#x25;62bar]]', '[[foo&#x25;62bar]]'},
		{ '[[foo&#x0000;bar]]', '[[foo&#x0000;bar]]'},
		{ '[[foo&#x00000;bar]]', '[[foo&#x00000;bar]]'},
		{ '[[foo&#x22;bar]]', 'foo"bar'},
		{ '[[foo&#x0000022;bar]]', 'foo"bar'},
		{ '[[foo&amp;amp;bar]]', '[[foo&amp;amp;bar]]'},
	}, {nowiki='yes'})
end

function p:test19_URL_decoding()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '[http://www.example.com foo%25 bar]', 'foo%25 bar'},
		{ '[http://www.example.com foo%25bar]', 'foo%25bar'},
		{ '[http://www.example.com foo%24bar]', 'foo%24bar'},
		{ '[http://www.example.com foo%88bar]', 'foo%88bar'},
		{ '[http://www.example.com foo%6Abar]', 'foo%6Abar'},
		{ '[http://www.example.com foo%11bar]', 'foo%11bar'},
		{ '[http://www.example.com foo&amp;bar]', 'foo&bar'},
		{ '[http://www.example.com foo%25bar]', 'foo%25bar'},
		{ '[http://www.example.com foo&a%6Amp;bar]', 'foo&a%6Amp;bar'},
		{ '[http://www.example.com foo&%61mp;bar]', 'foo&%61mp;bar'},
		{ '[http://www.example.com foo&%62mp;bar]', 'foo&%62mp;bar'},
		{ '[http://www.example.com foo&#x25;bar]', 'foo%bar'},
		{ '[http://www.example.com foo&#x25;62bar]', 'foo%62bar'},
		{ '[http://www.example.com foo&#x0000;bar]', 'foo&#x0000;bar'},
		{ '[http://www.example.com foo&#x00000;bar]', 'foo&#x00000;bar'},
		{ '[http://www.example.com foo&#x22;bar]', 'foo"bar'},
		{ '[http://www.example.com foo&#x0000022;bar]', 'foo"bar'},
	}, {nowiki='yes'})
end

function p:test20_no_link()
	self:preprocess_equals_many('{{delink/sandbox|', '}}', {
		{ '#Foo', '#Foo' },
		{ 'Foo#Bar', 'Foo#Bar' },
	}, {nowiki='yes'})
end

return p