bbcode.t 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # Copyright (C) 2007, 2008 Alex Schroeder <alex@emacswiki.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 => 39;
  18. add_module('bbcode.pl');
  19. run_tests(split('\n',<<'EOT'));
  20. [b]this text is bold[/b]
  21. <b>this text is bold</b>
  22. [i]this text is italic[/i]
  23. <i>this text is italic</i>
  24. [u]this text is underlined[/u]
  25. <em style="text-decoration: underline; font-style: normal;">this text is underlined</em>
  26. [s]this text is deleted[/s]
  27. <del>this text is deleted</del>
  28. [strike]this text is deleted[/strike]
  29. <del>this text is deleted</del>
  30. [color=blue]this text is blue[/color]
  31. <em style="color: blue; font-style: normal;">this text is blue</em>
  32. [size=+2]this text is two sizes larger than normal[/size]
  33. <em style="font-size: 200%; font-style: normal;">this text is two sizes larger than normal</em>
  34. [size=test]this text is two sizes larger than normal[/size]
  35. [size=test]this text is two sizes larger than normal[/size]
  36. [font=courier]this text is in the courier font[/font]
  37. <span style="font-family: courier;">this text is in the courier font</span>
  38. [url]yadda
  39. [url]yadda
  40. [quote]quoted text[/quote]
  41. <blockquote><p>quoted text</p></blockquote>
  42. [quote]first paragraph\n\nsecond paragraph[/quote]
  43. <blockquote><p>first paragraph</p><p>second paragraph</p></blockquote>
  44. [quote]quoted text[/quote]\nmore text
  45. <blockquote><p>quoted text</p></blockquote><p>more text</p>
  46. [quote]quoted text[/quote]\nmore text\nand some more\n
  47. <blockquote><p>quoted text</p></blockquote><p>more text and some more</p>
  48. [quote]quoted text[/quote]\n more text
  49. <blockquote><p>quoted text</p></blockquote><p> more text</p>
  50. [quote]quoted\ntext\n[/quote]\n more text\n
  51. <blockquote><p>quoted text </p></blockquote><p> more text</p>
  52. [code]monospaced text[/code]
  53. <pre>monospaced text</pre>
  54. [code]monospaced\n\n text[/code]
  55. <pre>monospaced\n\n text</pre>
  56. [code]monospaced text[/code]\nmore text
  57. <pre>monospaced text</pre><p>more text</p>
  58. [code]monospaced text[/code]\n more text
  59. <pre>monospaced text</pre><p> more text</p>
  60. [code]monospaced text[/code]\nmore text\nand last line
  61. <pre>monospaced text</pre><p>more text and last line</p>
  62. :) :-) :( :-(
  63. &#x1F60A; &#x1F60A; &#x1F61F; &#x1F61F;
  64. :smile: :happy: :frown: :sad:
  65. &#x1F60A; &#x1F60A; &#x1F61F; &#x1F61F;
  66. foo\n[h1]blarg
  67. foo <h1>blarg</h1>
  68. foo[h2]blarg[/h2]fnord
  69. foo<h2>blarg</h2><p>fnord</p>
  70. [h3]blarg [i]moo[/i][/h3]
  71. <h3>blarg <i>moo</i></h3>
  72. [h5][h6]blarg[/h6]foo
  73. <h5></h5><h6>blarg</h6><p>foo</p>
  74. [center][size=5]The Savage Tides[/size][/center]
  75. <div class="center" style="text-align: center"><p><em style="font-size: 500%; font-style: normal;">The Savage Tides</em></p></div>
  76. [left]This is left[/left]
  77. <div class="left" style="float: left"><p>This is left</p></div>
  78. [right]This is right[/right]
  79. <div class="right" style="float: right"><p>This is right</p></div>
  80. [list]\n[*]one\n[*]two\n[/list]
  81. <ul> <li>one </li><li>two </li></ul>
  82. [quote][list][*]one[*]two[/list][/quote]
  83. <blockquote></blockquote><ul><li>one</li><li>two</li></ul><p>[/quote]</p>
  84. [highlight]this text is highlighted[/highlight]
  85. <strong class="highlight">this text is highlighted</strong>
  86. EOT
  87. xpath_run_tests(split('\n',<<'EOT'));
  88. [url]http://wikipedia.org[/url]
  89. //a[@class="url http"][@href="http://wikipedia.org"][text()="http://wikipedia.org"]
  90. [url=http://wikipedia.org]Wikipedia[/url]
  91. //a[@class="url http"][@href="http://wikipedia.org"][text()="Wikipedia"]
  92. [img]http://upload.wikimedia.org/wikipedia/commons/thumb/6/63/Wikipedia-logo.png/150px-Wikipedia-logo.png[/img]
  93. //img[@class="url http"][@src="http://upload.wikimedia.org/wikipedia/commons/thumb/6/63/Wikipedia-logo.png/150px-Wikipedia-logo.png"]
  94. [H4][url=http://example.org]mu[/url][/h4]
  95. //h4/a[@class="url http"][@href="http://example.org"][text()="mu"]
  96. EOT
  97. add_module('creole.pl');
  98. run_tests(split('\n',<<'EOT'));
  99. * [s]this text is deleted[/s]
  100. <ul><li><del>this text is deleted</del></li></ul>
  101. EOT
  102. test_page(update_page('test', '[b]Important:[/b]'),
  103. '<b>Important:</b>');