default-links.t 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. # Copyright (C) 2006–2015 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. require 't/test.pl';
  16. package OddMuse;
  17. use Test::More tests => 63;
  18. $AllNetworkFiles = 1;
  19. update_page('HomePage', "This page exists.");
  20. update_page('InterMap', " Oddmuse http://www.emacswiki.org/cgi-bin/oddmuse.pl?\n PlanetMath http://planetmath.org/encyclopedia/%s.html", 'required', 0, 1);
  21. $InterInit = 0;
  22. $WikiLinks = 1; # old default
  23. $BracketWiki = 0; # old default
  24. InitVariables();
  25. xpath_run_tests(split('\n',<<'EOT'));
  26. [[1]]
  27. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=1"][text()="?"]
  28. [[0]]
  29. //div[text()="[[0]]"]
  30. [[0a]]
  31. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=0a"][text()="?"]
  32. [[foo bar]]
  33. //div[text()[.="[[foo_bar"]/following-sibling::a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=foo_bar"][text()="?"]/following-sibling::text()[.="]]"]]
  34. [[foo_bar]]
  35. //div[text()[.="[[foo_bar"]/following-sibling::a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=foo_bar"][text()="?"]/following-sibling::text()[.="]]"]]
  36. file://home/foo/tutorial.pdf
  37. //a[@class="url file"][@href="file://home/foo/tutorial.pdf"][text()="file://home/foo/tutorial.pdf"]
  38. file:///home/foo/tutorial.pdf
  39. //a[@class="url file"][@href="file:///home/foo/tutorial.pdf"][text()="file:///home/foo/tutorial.pdf"]
  40. image inline: [[image:HomePage]]
  41. //a[@class="image"][@href="http://localhost/test.pl/HomePage"]/img[@class="upload"][@src="http://localhost/test.pl/download/HomePage"][@alt="HomePage"]
  42. image inline: [[image:OtherPage]]
  43. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage;upload=1"][text()="?"]
  44. traditional local link: HomePage
  45. //a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="HomePage"]
  46. traditional local link: OtherPage
  47. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
  48. traditional local link with extra brackets: [HomePage]
  49. //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()="]"]
  50. traditional local link with extra brackets: [OtherPage]
  51. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
  52. traditional local link with other text: [HomePage homepage]
  53. //a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="HomePage"]
  54. traditional local link with other text: [OtherPage other page]
  55. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
  56. free link: [[home page]]
  57. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"]
  58. free link: [[other page]]
  59. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"]
  60. free link with extra brackets: [[[home page]]]
  61. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"]
  62. free link with extra brackets: [[[other page]]]
  63. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"]
  64. free link with other text: [[home page|da homepage]]
  65. //text()[string()="free link with other text: [[home page|da homepage]]"]
  66. free link with other text: [[other page|da other homepage]]
  67. //text()[string()="free link with other text: [[other page|da other homepage]]"]
  68. URL: http://www.oddmuse.org/
  69. //a[@class="url http"][@href="http://www.oddmuse.org/"][text()="http://www.oddmuse.org/"]
  70. URL with text: [http://www.oddmuse.org/ name]
  71. //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="name"]
  72. zero is text: [http://www.oddmuse.org/ 0]
  73. //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="0"]
  74. URL in text http://www.oddmuse.org/ like this
  75. //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"]
  76. URL in brackets: [http://www.oddmuse.org/]
  77. //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()="]"]
  78. URL in brackets with other text: [http://www.oddmuse.org/ oddmuse]
  79. //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"]
  80. URL in brackets with other text: [[http://www.oddmuse.org/ oddmuse]]
  81. //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"]
  82. URL in brackets with other text: [http://www.oddmuse.org/|oddmuse]
  83. //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"]
  84. URL in brackets with other text: [[http://www.oddmuse.org/|oddmuse]]
  85. //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"]
  86. URL abbreviation: Oddmuse:Link_Pattern
  87. //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="interpage"][text()="Link_Pattern"]
  88. URL abbreviation with extra brackets: [Oddmuse:Link_Pattern]
  89. //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()="]"]
  90. URL abbreviation with other text: [Oddmuse:Link_Pattern link patterns]
  91. //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"][text()="link patterns"]
  92. URL abbreviation with meta characters: Oddmuse:Link+Pattern
  93. //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link+Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="interpage"][text()="Link+Pattern"]
  94. URL abbreviation with meta characters and extra brackets: [Oddmuse:Link+Pattern]
  95. //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()="]"]
  96. URL abbreviation with meta characters and other text: [Oddmuse:Link+Pattern link patterns]
  97. //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link+Pattern"][text()="link patterns"]
  98. free URL abbreviation: [[Oddmuse:Link Pattern]]
  99. //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="interpage"][text()="Link Pattern"]
  100. free URL abbreviation with extra brackets: [[[Oddmuse:Link Pattern]]]
  101. //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()="]"]
  102. free URL abbreviation with other text: [[Oddmuse:Link Pattern|link patterns]]
  103. //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"][text()="link patterns"]
  104. free URL abbreviation with meta characters: [[Oddmuse:Link+Pattern]]
  105. //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%2bPattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="interpage"][text()="Link+Pattern"]
  106. free URL abbreviation with meta characters and extra brackets: [[[Oddmuse:Link+Pattern]]]
  107. //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()="]"]
  108. free URL abbreviation with meta characters and other text: [[Oddmuse:Link+Pattern|link patterns]]
  109. //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%2bPattern"][text()="link patterns"]
  110. EOT
  111. $AllNetworkFiles = 0;
  112. $BracketWiki = 1;
  113. xpath_run_tests(split('\n',<<'EOT'));
  114. traditional local link: HomePage
  115. //a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="HomePage"]
  116. traditional local link: OtherPage
  117. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
  118. traditional local link with extra brackets: [HomePage]
  119. //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()="]"]
  120. traditional local link with extra brackets: [OtherPage]
  121. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
  122. traditional local link with other text: [HomePage homepage]
  123. //a[@class="local"][@href="http://localhost/test.pl/HomePage"][text()="homepage"]
  124. traditional local link with other text: [OtherPage other page]
  125. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=OtherPage"][text()="?"]
  126. free link: [[home page]]
  127. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"]
  128. free link: [[other page]]
  129. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"]
  130. free link with extra brackets: [[[home page]]]
  131. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"]
  132. free link with extra brackets: [[[other page]]]
  133. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"]
  134. free link with other text: [[home page|da homepage]]
  135. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=home_page"][text()="?"]
  136. free link with other text: [[other page|da other homepage]]
  137. //a[@class="edit"][@title="Click to edit this page"][@href="http://localhost/test.pl?action=edit;id=other_page"][text()="?"]
  138. URL: http://www.oddmuse.org/
  139. //a[@class="url http"][@href="http://www.oddmuse.org/"][text()="http://www.oddmuse.org/"]
  140. URL in brackets: [http://www.oddmuse.org/]
  141. //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()="]"]
  142. URL in brackets with other text: [http://www.oddmuse.org/ oddmuse]
  143. //a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="oddmuse"]
  144. URL abbreviation: Oddmuse:Link_Pattern
  145. //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="interpage"][text()="Link_Pattern"]
  146. URL abbreviation with extra brackets: [Oddmuse:Link_Pattern]
  147. //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()="]"]
  148. URL abbreviation with other text: [Oddmuse:Link_Pattern link patterns]
  149. //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link_Pattern"][text()="link patterns"]
  150. free URL abbreviation: [[Oddmuse:Link Pattern]]
  151. //a[@class="inter Oddmuse"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"]/span[@class="site"][text()="Oddmuse"]/following-sibling::span[@class="separator"][text()=":"]/following-sibling::span[@class="interpage"][text()="Link Pattern"]
  152. free URL abbreviation with extra brackets: [[[Oddmuse:Link Pattern]]]
  153. //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()="]"]
  154. free URL abbreviation with other text: [[Oddmuse:Link Pattern|link pattern]]
  155. //a[@class="inter Oddmuse outside"][@href="http://www.emacswiki.org/cgi-bin/oddmuse.pl?Link%20Pattern"][text()="link pattern"]
  156. EOT