2008-11-15 12:48:13 +00:00
|
|
|
|
#!/usr/bin/env perl
|
2015-05-15 16:28:25 +02:00
|
|
|
|
# Copyright (C) 2006–2015 Alex Schroeder <alex@gnu.org>
|
2006-09-20 00:11:31 +00:00
|
|
|
|
#
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-08-17 00:30:31 +00:00
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2006-09-20 00:11:31 +00:00
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
#
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
#
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-17 00:30:31 +00:00
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-09-20 00:11:31 +00:00
|
|
|
|
|
2006-09-19 23:48:31 +00:00
|
|
|
|
require 't/test.pl';
|
|
|
|
|
|
package OddMuse;
|
2007-11-14 22:04:38 +00:00
|
|
|
|
use Test::More tests => 30;
|
2015-05-15 16:28:25 +02:00
|
|
|
|
use utf8;
|
2006-09-19 23:48:31 +00:00
|
|
|
|
|
|
|
|
|
|
add_module('toc.pl');
|
|
|
|
|
|
add_module('usemod.pl');
|
|
|
|
|
|
|
|
|
|
|
|
InitVariables(); # do this after loading usemod.pl!
|
|
|
|
|
|
|
2007-02-09 21:53:57 +00:00
|
|
|
|
# Note that we're not calling TocInit between tests, so we rely on
|
|
|
|
|
|
# them being run in order.
|
2008-11-15 12:48:13 +00:00
|
|
|
|
run_tests('== make honey ==\n\nMoo.\n',
|
2008-12-14 00:52:04 +00:00
|
|
|
|
qq{<h2 id="${TocAnchorPrefix}1">make honey</h2><p>Moo.</p>},
|
2008-11-15 12:48:13 +00:00
|
|
|
|
'== make honey ==\nMoo.\n== make honey ==\nMoo.\n',
|
|
|
|
|
|
qq{<h2 id="${TocAnchorPrefix}2">make honey</h2><p>Moo. </p><h2 id="${TocAnchorPrefix}3">make honey</h2><p>Moo.</p>},
|
|
|
|
|
|
);
|
2006-09-19 23:48:31 +00:00
|
|
|
|
|
2007-02-15 21:58:21 +00:00
|
|
|
|
test_page(update_page('toc', "bla\n"
|
2008-11-15 12:48:13 +00:00
|
|
|
|
. "<toc/fnord/mu>\n"
|
|
|
|
|
|
. "murks\n"
|
|
|
|
|
|
. "==two=\n"
|
|
|
|
|
|
. "bla\n"
|
|
|
|
|
|
. "===three==\n"
|
|
|
|
|
|
. "bla\n"
|
|
|
|
|
|
. "=one=\n"),
|
|
|
|
|
|
quotemeta('<div class="toc fnord mu">'));
|
2007-02-15 21:58:21 +00:00
|
|
|
|
|
2007-11-14 22:04:38 +00:00
|
|
|
|
# check whether the toc remains in the HTML cache
|
2007-08-29 12:27:16 +00:00
|
|
|
|
|
|
|
|
|
|
test_page(get_page('toc'),
|
2008-11-15 12:48:13 +00:00
|
|
|
|
quotemeta('<div class="toc fnord mu">'));
|
2007-08-29 12:27:16 +00:00
|
|
|
|
|
2007-11-14 22:04:38 +00:00
|
|
|
|
# no cache
|
|
|
|
|
|
|
|
|
|
|
|
test_page(get_page('action=browse id=toc cache=0'),
|
2008-11-15 12:48:13 +00:00
|
|
|
|
quotemeta('<div class="toc fnord mu">'));
|
2007-11-14 22:04:38 +00:00
|
|
|
|
|
|
|
|
|
|
# check again!
|
|
|
|
|
|
|
|
|
|
|
|
test_page(get_page('toc'),
|
2008-11-15 12:48:13 +00:00
|
|
|
|
quotemeta('<div class="toc fnord mu">'));
|
2007-11-14 22:04:38 +00:00
|
|
|
|
|
|
|
|
|
|
# details of the toc
|
|
|
|
|
|
|
2006-09-19 23:48:31 +00:00
|
|
|
|
test_page(update_page('toc', "bla\n"
|
2008-11-15 12:48:13 +00:00
|
|
|
|
. "=one=\n"
|
|
|
|
|
|
. "blarg\n"
|
|
|
|
|
|
. "==two==\n"
|
|
|
|
|
|
. "bla\n"
|
|
|
|
|
|
. "==two==\n"
|
|
|
|
|
|
. "mu."),
|
|
|
|
|
|
quotemeta(qq{<ol><li><a href="#${TocAnchorPrefix}1">one</a></li><li><a href="#${TocAnchorPrefix}2">two</a></li><li><a href="#${TocAnchorPrefix}3">two</a></li></ol>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}1">one</h2>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}2">two</h2>}),
|
2008-11-23 22:13:29 +00:00
|
|
|
|
quotemeta(qq{bla </p><div class="toc"><h2>$TocHeaderText</h2><ol><li><a }),
|
2008-11-15 12:48:13 +00:00
|
|
|
|
quotemeta(qq{two</a></li></ol></div><h2 id="${TocAnchorPrefix}1">one</h2>}));
|
2006-09-19 23:48:31 +00:00
|
|
|
|
|
|
|
|
|
|
test_page(update_page('toc', "bla\n"
|
2008-11-15 12:48:13 +00:00
|
|
|
|
. "==two=\n"
|
|
|
|
|
|
. "bla\n"
|
|
|
|
|
|
. "===three==\n"
|
|
|
|
|
|
. "bla\n"
|
|
|
|
|
|
. "==two==\n"),
|
|
|
|
|
|
quotemeta(qq{<ol><li><a href="#${TocAnchorPrefix}1">two</a><ol><li><a href="#${TocAnchorPrefix}2">three</a></li></ol></li><li><a href="#${TocAnchorPrefix}3">two</a></li></ol>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}1">two</h2>}),
|
|
|
|
|
|
quotemeta(qq{<h3 id="${TocAnchorPrefix}2">three</h3>}));
|
2006-09-19 23:48:31 +00:00
|
|
|
|
|
|
|
|
|
|
test_page(update_page('toc', "bla\n"
|
2008-11-15 12:48:13 +00:00
|
|
|
|
. "<toc>\n"
|
|
|
|
|
|
. "murks\n"
|
|
|
|
|
|
. "==two=\n"
|
|
|
|
|
|
. "bla\n"
|
|
|
|
|
|
. "===three==\n"
|
|
|
|
|
|
. "bla\n"
|
|
|
|
|
|
. "=one=\n"),
|
|
|
|
|
|
quotemeta(qq{<ol><li><a href="#${TocAnchorPrefix}1">two</a><ol><li><a href="#${TocAnchorPrefix}2">three</a></li></ol></li><li><a href="#${TocAnchorPrefix}3">one</a></li></ol>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}1">two</h2>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}3">one</h2>}),
|
2008-11-23 22:13:29 +00:00
|
|
|
|
quotemeta(qq{bla </p><div class="toc"><h2>$TocHeaderText</h2><ol><li><a }),
|
2008-11-15 12:48:13 +00:00
|
|
|
|
quotemeta('one</a></li></ol></div><p>murks'));
|
2006-09-19 23:48:31 +00:00
|
|
|
|
|
|
|
|
|
|
test_page(update_page('toc', "bla\n"
|
2008-11-15 12:48:13 +00:00
|
|
|
|
. "=one=\n"
|
|
|
|
|
|
. "blarg\n"
|
|
|
|
|
|
. "==two==\n"
|
|
|
|
|
|
. "<nowiki>bla\n"
|
|
|
|
|
|
. "==two==\n"
|
|
|
|
|
|
. "mu.</nowiki>\n"
|
|
|
|
|
|
. "<nowiki>bla\n"
|
|
|
|
|
|
. "==two==\n"
|
|
|
|
|
|
. "mu.</nowiki>\n"
|
|
|
|
|
|
. "yadda <code>bla\n"
|
|
|
|
|
|
. "==two==\n"
|
|
|
|
|
|
. "mu.</code>\n"
|
|
|
|
|
|
. "yadda <pre> has no effect! \n"
|
|
|
|
|
|
. "##bla\n"
|
|
|
|
|
|
. "==three==\n"
|
|
|
|
|
|
. "mu.##\n"
|
|
|
|
|
|
. "=one=\n"
|
|
|
|
|
|
. "blarg </pre>\n"),
|
|
|
|
|
|
quotemeta(qq{<ol><li><a href="#${TocAnchorPrefix}1">one</a></li><li><a href="#${TocAnchorPrefix}2">two</a></li><li><a href="#${TocAnchorPrefix}3">three</a></li><li><a href="#${TocAnchorPrefix}4">one</a></li></ol>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}1">one</h2>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}2">two</h2>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}3">three</h2>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}4">one</h2>}));
|
2006-09-19 23:48:31 +00:00
|
|
|
|
|
|
|
|
|
|
add_module('markup.pl');
|
|
|
|
|
|
|
|
|
|
|
|
test_page(update_page('toc', "bla\n"
|
2008-11-15 12:48:13 +00:00
|
|
|
|
. "=one=\n"
|
|
|
|
|
|
. "blarg\n"
|
|
|
|
|
|
. "<code>##bla\n"
|
|
|
|
|
|
. "=two=\n"
|
|
|
|
|
|
. "mu.</code>\n"
|
|
|
|
|
|
. "##bla\n"
|
|
|
|
|
|
. "=three=\n"
|
|
|
|
|
|
. "mu.##\n"
|
|
|
|
|
|
. "=four=\n"
|
|
|
|
|
|
. "blarg\n"),
|
|
|
|
|
|
quotemeta(qq{<ol><li><a href="#${TocAnchorPrefix}1">one</a></li><li><a href="#${TocAnchorPrefix}2">four</a></li></ol>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}1">one</h2>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}2">four</h2>}));
|
2007-08-03 08:31:28 +00:00
|
|
|
|
|
|
|
|
|
|
test_page(update_page('toc', "bla\n"
|
2008-11-15 12:48:13 +00:00
|
|
|
|
. "=one=\n"
|
|
|
|
|
|
. "blarg ##<code>## and <code>##</code>\n"
|
|
|
|
|
|
. "=two=\n"
|
|
|
|
|
|
. "blarg ##</code>##\n"),
|
|
|
|
|
|
quotemeta(qq{<ol><li><a href="#${TocAnchorPrefix}1">one</a></li><li><a href="#${TocAnchorPrefix}2">two</a></li></ol>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}1">one</h2>}),
|
|
|
|
|
|
quotemeta(qq{<h2 id="${TocAnchorPrefix}2">two</h2>}));
|