diff.t 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright (C) 2006-2019 Alex Schroeder <alex@gnu.org>
  2. # This program is free software: you can redistribute it and/or modify it under
  3. # the terms of the GNU General Public License as published by the Free Software
  4. # Foundation, either version 3 of the License, or (at your option) any later
  5. # version.
  6. #
  7. # This program is distributed in the hope that it will be useful, but WITHOUT
  8. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  10. #
  11. # You should have received a copy of the GNU General Public License along with
  12. # this program. If not, see <http://www.gnu.org/licenses/>.
  13. require './t/test.pl';
  14. package OddMuse;
  15. use Test::More tests => 30;
  16. use utf8;
  17. # encoding stuff
  18. update_page('dash', "- en ‘dash’\n");
  19. update_page('dash', "- en ‘dash’\n— em “dash”\n");
  20. test_page(get_page('action=browse diff=1 id=dash'),
  21. '<div class="new"><p>&gt; — em “dash”</p></div>',
  22. '- en ‘dash’ — em “dash”');
  23. # Highlighting differences
  24. update_page('xah', "When we judge people in society, often, we can see people's true nature not by the official defenses and behaviors, but by looking at the statistics (past records) of their behavior and the circumstances it happens.\n"
  25. . "For example, when we look at the leader in human history. Great many of them have caused thousands and millions of intentional deaths. Some of these leaders are hated by many, yet great many of them are adored and admired and respected... (ok, i'm digressing...)\n");
  26. update_page('xah', "When we judge people in society, often, we can see people's true nature not by the official defenses and behaviors, but by looking at some subtleties, and also the statistics (past records) of their behavior and the circumstances they were in.\n"
  27. . "For example, when we look at leaders in history. Great many of them have caused thousands and millions of intentional deaths. Some of these leaders are hated by many, yet great many of them are adored and admired and respected... (ok, i'm digressing...)\n");
  28. test_page(get_page('action=browse diff=1 id=xah'),
  29. '<strong class="changes">it happens</strong>',
  30. '<strong class="changes">the leader</strong>',
  31. '<strong class="changes">human</strong>',
  32. '<strong class="changes">some subtleties, and also</strong>',
  33. '<strong class="changes">they were in</strong>',
  34. '<strong class="changes">leaders</strong>',
  35. );
  36. update_page('code', 'This is the & character.');
  37. update_page('code', 'This is the <code>&</code> character.');
  38. test_page(get_page('action=browse diff=1 id=code'),
  39. '<strong class="changes">&lt;code&gt;</strong>&amp;<strong class="changes">&lt;/code&gt;</strong>');
  40. # make sure revision and diffrevision work correctly
  41. update_page('david', 'this is the first revision', 'first revision');
  42. update_page('david', 'this is the second revision', 'second revision');
  43. update_page('david', 'this is the third revision', 'third revision');
  44. update_page('david', 'this is the fourth revision', ' ');
  45. update_page('david', 'this is the fifth revision', '');
  46. # first make sure the history page shows the appropriate labels and
  47. # summaries
  48. test_page(get_page('action=history id=david'),
  49. 'Revision 1', 'first revision',
  50. 'Revision 2', 'second revision',
  51. 'Revision 3', 'third revision',
  52. 'Revision 4');
  53. # using diffrevision=1 will make sure that the third revision is not shown
  54. xpath_test(get_page('action=browse diff=1 id=david revision=2 diffrevision=1'),
  55. '//p[@class="summary"][text()="Summary: second revision"]',
  56. '//div[@class="old"]/p/strong[text()="first"]',
  57. '//div[@class="new"]/p/strong[text()="second"]',
  58. '//div[@class="content browse"]/p[text()="this is the second revision"]');
  59. # check with cache = 0
  60. xpath_test(get_page('action=browse diff=1 id=david revision=2 diffrevision=1 cache=0'),
  61. '//p[@class="summary"][text()="Summary: second revision"]',
  62. '//div[@class="old"]/p/strong[text()="first"]',
  63. '//div[@class="new"]/p/strong[text()="second"]',
  64. '//div[@class="content browse"]/p[text()="this is the second revision"]');
  65. # check summaries
  66. $page = get_page('action=browse diff=1 id=david revision=5 diffrevision=1 cache=0');
  67. xpath_test($page,
  68. '//div[@class="summary"]/ul/li[text()="second revision"]',
  69. '//div[@class="summary"]/ul/li[text()="third revision"]',
  70. '//div[@class="summary"]/ul[count(li)=2]',
  71. '//div[@class="old"]/p/strong[text()="first"]',
  72. '//div[@class="new"]/p/strong[text()="fifth"]',
  73. '//div[@class="content browse"]/p[text()="this is the fifth revision"]');