From 8d49972da37020951489f75ce5897656fa9aa4e2 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Tue, 19 Sep 2006 15:54:31 +0000 Subject: [PATCH] Moved tests here from ../test.pl --- t/default-links.pl | 128 +++++++++++++++++++++++++++++++++++++++++++++ t/usemod-options.t | 32 ++++++++++++ t/usemod.t | 98 ++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+) create mode 100755 t/default-links.pl create mode 100755 t/usemod-options.t create mode 100755 t/usemod.t diff --git a/t/default-links.pl b/t/default-links.pl new file mode 100755 index 00000000..825fced1 --- /dev/null +++ b/t/default-links.pl @@ -0,0 +1,128 @@ +require 't/test.pl'; +package OddMuse; +use Test::More tests => 53; + +clear_pages(); + +$AllNetworkFiles = 1; + +update_page('HomePage', "This page exists."); +update_page('InterMap', " Oddmuse http://www.emacswiki.org/cgi-bin/oddmuse.pl?\n PlanetMath http://planetmath.org/encyclopedia/%s.html", 'required', 0, 1); +$InterInit = 0; +$BracketWiki = 0; # old default +InitVariables(); + +xpath_run_tests(split('\n',<<'EOT')); +file://home/foo/tutorial.pdf +//a[@class="url file"][@href="file://home/foo/tutorial.pdf"][text()="file://home/foo/tutorial.pdf"] +file:///home/foo/tutorial.pdf +//a[@class="url file"][@href="file:///home/foo/tutorial.pdf"][text()="file:///home/foo/tutorial.pdf"] +image inline: [[image:HomePage]] +//a[@class="image"][@href="http://localhost/test.pl/HomePage"]/img[@class="upload"][@src="http://localhost/test.pl/download/HomePage"][@alt="HomePage"] +image inline: [[image:OtherPage]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage;upload=1"][text()="?"] +traditional local link: HomePage +//a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="HomePage"] +traditional local link: OtherPage +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"] +traditional local link with extra brackets: [HomePage] +//a[@class="local number"][@title="HomePage"][@href="http://localhost/test.pl/HomePage"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +traditional local link with extra brackets: [OtherPage] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"] +traditional local link with other text: [HomePage homepage] +//a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="HomePage"] +traditional local link with other text: [OtherPage other page] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"] +free link: [[home page]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"] +free link: [[other page]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"] +free link with extra brackets: [[[home page]]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"] +free link with extra brackets: [[[other page]]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"] +free link with other text: [[home page|da homepage]] +//text()[string()="free link with other text: [[home page|da homepage]]"] +free link with other text: [[other page|da other homepage]] +//text()[string()="free link with other text: [[other page|da other homepage]]"] +URL: http://www.oddmuse.org/ +//a[@class="url http"][@href="http://www.oddmuse.org/"][text()="http://www.oddmuse.org/"] +URL in text http://www.oddmuse.org/ like this +//text()[string()="URL in text "]/following-sibling::a[@class="url http"][@href="http://www.oddmuse.org/"][text()="http://www.oddmuse.org/"]/following-sibling::text()[string()=" like this"] +URL in brackets: [http://www.oddmuse.org/] +//a[@class="url http number"][@href="http://www.oddmuse.org/"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +URL in brackets with other text: [http://www.oddmuse.org/ oddmuse] +//a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"] +URL abbreviation: Oddmuse:Link_Pattern +//a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::text()[string()=":"]/following-sibling::span[@class="page"][text()="Link_Pattern"] +URL abbreviation with extra brackets: [Oddmuse:Link_Pattern] +//a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +URL abbreviation with other text: [Oddmuse:Link_Pattern link patterns] +//a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"][text()="link patterns"] +URL abbreviation with meta characters: Oddmuse:Link+Pattern +//a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link+Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::text()[string()=":"]/following-sibling::span[@class="page"][text()="Link+Pattern"] +URL abbreviation with meta characters and extra brackets: [Oddmuse:Link+Pattern] +//a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link+Pattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +URL abbreviation with meta characters and other text: [Oddmuse:Link+Pattern link patterns] +//a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link+Pattern"][text()="link patterns"] +free URL abbreviation: [[Oddmuse:Link Pattern]] +//a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::text()[string()=":"]/following-sibling::span[@class="page"][text()="Link Pattern"] +free URL abbreviation with extra brackets: [[[Oddmuse:Link Pattern]]] +//a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +free URL abbreviation with other text: [[Oddmuse:Link Pattern|link patterns]] +//a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"][text()="link patterns"] +free URL abbreviation with meta characters: [[Oddmuse:Link+Pattern]] +//a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%2bPattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::text()[string()=":"]/following-sibling::span[@class="page"][text()="Link+Pattern"] +free URL abbreviation with meta characters and extra brackets: [[[Oddmuse:Link+Pattern]]] +//a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%2bPattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +free URL abbreviation with meta characters and other text: [[Oddmuse:Link+Pattern|link patterns]] +//a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%2bPattern"][text()="link patterns"] +EOT + +$AllNetworkFiles = 0; +$BracketWiki = 1; + +xpath_run_tests(split('\n',<<'EOT')); +traditional local link: HomePage +//a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="HomePage"] +traditional local link: OtherPage +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"] +traditional local link with extra brackets: [HomePage] +//a[@class="local number"][@title="HomePage"][@href="http://localhost/test.pl/HomePage"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +traditional local link with extra brackets: [OtherPage] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"] +traditional local link with other text: [HomePage homepage] +//a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="homepage"] +traditional local link with other text: [OtherPage other page] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"] +free link: [[home page]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"] +free link: [[other page]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"] +free link with extra brackets: [[[home page]]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"] +free link with extra brackets: [[[other page]]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"] +free link with other text: [[home page|da homepage]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"] +free link with other text: [[other page|da other homepage]] +//a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"] +URL: http://www.oddmuse.org/ +//a[@class="url http"][@href="http://www.oddmuse.org/"][text()="http://www.oddmuse.org/"] +URL in brackets: [http://www.oddmuse.org/] +//a[@class="url http number"][@href="http://www.oddmuse.org/"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +URL in brackets with other text: [http://www.oddmuse.org/ oddmuse] +//a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"] +URL abbreviation: Oddmuse:Link_Pattern +//a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::text()[string()=":"]/following-sibling::span[@class="page"][text()="Link_Pattern"] +URL abbreviation with extra brackets: [Oddmuse:Link_Pattern] +//a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +URL abbreviation with other text: [Oddmuse:Link_Pattern link patterns] +//a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"][text()="link patterns"] +free URL abbreviation: [[Oddmuse:Link Pattern]] +//a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::text()[string()=":"]/following-sibling::span[@class="page"][text()="Link Pattern"] +free URL abbreviation with extra brackets: [[[Oddmuse:Link Pattern]]] +//a[@class="inter Oddmuse number"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"]/span/span[@class="bracket"][text()="["]/following-sibling::text()[string()="1"]/following-sibling::span[@class="bracket"][text()="]"] +free URL abbreviation with other text: [[Oddmuse:Link Pattern|link pattern]] +//a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"][text()="link pattern"] +EOT diff --git a/t/usemod-options.t b/t/usemod-options.t new file mode 100755 index 00000000..e5c27302 --- /dev/null +++ b/t/usemod-options.t @@ -0,0 +1,32 @@ +require 't/test.pl'; +package OddMuse; +use Test::More tests => 7; + +clear_pages(); + +add_module('usemod.pl'); + +InitVariables(); + +$UseModSpaceRequired = 0; +$UseModMarkupInTitles = 1; + +run_tests(split('\n',<<'EOT')); +*one\n**two + +#one\n##two +
  1. one
    1. two
+:one\n:two\n::one and two\n::two and three\n:three +
one
two
one and two
two and three
three
+;one:eins\n;two:zwei +
one
eins
two
zwei
+=='''title'''== +

title

+1 \+ 1 = 2 +1 \+ 1 = 2 +EOT + +xpath_run_tests(split('\n',<<'EOT')); +==[[Free Link]]== +//h2/text()[string()="[Free Link]"]/following-sibling::a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=Free_Link"][text()="?"] +EOT diff --git a/t/usemod.t b/t/usemod.t new file mode 100755 index 00000000..7d1f5923 --- /dev/null +++ b/t/usemod.t @@ -0,0 +1,98 @@ +require 't/test.pl'; +package OddMuse; +use Test::More tests => 43; + +clear_pages(); + +add_module('usemod.pl'); + +InitVariables(); + +run_tests(split('\n',<<'EOT')); +* ''one\n** two + +# one\n# two +
  1. one
  2. two
+* one\n# two +
  1. two
+# one\n\n#two +
  1. one

#two

+# one\n# two\n## one and two\n## two and three\n# three +
  1. one
  2. two
    1. one and two
    2. two and three
  3. three
+# one and #\n# two and # more +
  1. one and #
  2. two and # more
+: one\n: two\n:: one and two\n:: two and three\n: three +
one
two
one and two
two and three
three
+: one and :)\n: two and :) more +
one and :)
two and :) more
+: one\n\n:two +
one

:two

+; one:eins\n;two:zwei +
one
eins ;two:zwei
+; one:eins\n\n; two:zwei +
one
eins
two
zwei
+; a: b: c\n;; x: y: z +
a
b: c
x
y: z
+* foo bold\n* bar + +This is ''emphasized''. +This is emphasized. +This is '''strong'''. +This is strong. +This is ''longer emphasized'' text. +This is longer emphasized text. +This is '''longer strong''' text. +This is longer strong text. +This is '''''emphasized and bold''''' text. +This is emphasized and bold text. +This is ''emphasized '''and bold''''' text. +This is emphasized and bold text. +This is '''bold ''and emphasized''''' text. +This is bold and emphasized text. +This is ''emphasized text containing '''longer strong''' text''. +This is emphasized text containing longer strong text. +This is '''strong text containing ''emph'' text'''. +This is strong text containing emph text. +||one|| +
one
+||one|| +
one
+|| one ''two'' || +
one two
+|| one two || +
one two
+introduction\n\n||one||two||three||\n||||one two||three|| +introduction
onetwothree
one twothree
+||one||two||three||\n||||one two||three||\n\nfooter +
onetwothree
one twothree

footer

+||one||two||three||\n||||one two||three||\n\nfooter +
onetwothree
one twothree

footer

+|| one|| two|| three||\n|||| one two|| three||\n\nfooter +
onetwothree
one twothree

footer

+||one ||two ||three ||\n||||one two ||three ||\n\nfooter +
one two three
one two three

footer

+|| one || two || three ||\n|||| one two || three ||\n\nfooter +
one two three
one two three

footer

+introduction\n\n||one||two||three||\n||||one two||three||\n\nfooter +introduction
onetwothree
one twothree

footer

+ source +
 source
+ source\n etc\n +
 source\n etc
+ source\n \n etc\n +
 source\n \n etc
+ source\n \n etc\n\nother +
 source\n \n etc

other

+= title = +

title

+==title= +

title

+========fnord= +
fnord
+== nada\nnada == +== nada nada == + == nada == +
 == nada ==
+==[[Free Link]]== +

[[Free Link]]

+EOT