#!/usr/bin/env perl # Copyright (C) 2006–2015 Alex Schroeder # # 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 # the Free Software Foundation; either version 3 of the License, or # (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 # along with this program. If not, see . require 't/test.pl'; package OddMuse; use Test::More tests => 30; use utf8; add_module('toc.pl'); add_module('usemod.pl'); InitVariables(); # do this after loading usemod.pl! # Note that we're not calling TocInit between tests, so we rely on # them being run in order. run_tests('== make honey ==\n\nMoo.\n', qq{

make honey

Moo.

}, '== make honey ==\nMoo.\n== make honey ==\nMoo.\n', qq{

make honey

Moo.

make honey

Moo.

}, ); test_page(update_page('toc', "bla\n" . "\n" . "murks\n" . "==two=\n" . "bla\n" . "===three==\n" . "bla\n" . "=one=\n"), quotemeta('
')); # check whether the toc remains in the HTML cache test_page(get_page('toc'), quotemeta('
')); # no cache test_page(get_page('action=browse id=toc cache=0'), quotemeta('
')); # check again! test_page(get_page('toc'), quotemeta('
')); # details of the toc test_page(update_page('toc', "bla\n" . "=one=\n" . "blarg\n" . "==two==\n" . "bla\n" . "==two==\n" . "mu."), quotemeta(qq{
  1. one
  2. two
  3. two
}), quotemeta(qq{

one

}), quotemeta(qq{

two

}), quotemeta(qq{bla

$TocHeaderText

one

})); test_page(update_page('toc', "bla\n" . "==two=\n" . "bla\n" . "===three==\n" . "bla\n" . "==two==\n"), quotemeta(qq{
  1. two
    1. three
  2. two
}), quotemeta(qq{

two

}), quotemeta(qq{

three

})); test_page(update_page('toc', "bla\n" . "\n" . "murks\n" . "==two=\n" . "bla\n" . "===three==\n" . "bla\n" . "=one=\n"), quotemeta(qq{
  1. two
    1. three
  2. one
}), quotemeta(qq{

two

}), quotemeta(qq{

one

}), quotemeta(qq{bla

$TocHeaderText

murks')); test_page(update_page('toc', "bla\n" . "=one=\n" . "blarg\n" . "==two==\n" . "bla\n" . "==two==\n" . "mu.\n" . "bla\n" . "==two==\n" . "mu.\n" . "yadda bla\n" . "==two==\n" . "mu.\n" . "yadda

 has no effect! \n"
          . "##bla\n"
          . "==three==\n"
          . "mu.##\n"
          . "=one=\n"
          . "blarg 
\n"), quotemeta(qq{
  1. one
  2. two
  3. three
  4. one
}), quotemeta(qq{

one

}), quotemeta(qq{

two

}), quotemeta(qq{

three

}), quotemeta(qq{

one

})); add_module('markup.pl'); test_page(update_page('toc', "bla\n" . "=one=\n" . "blarg\n" . "##bla\n" . "=two=\n" . "mu.\n" . "##bla\n" . "=three=\n" . "mu.##\n" . "=four=\n" . "blarg\n"), quotemeta(qq{
  1. one
  2. four
}), quotemeta(qq{

one

}), quotemeta(qq{

four

})); test_page(update_page('toc', "bla\n" . "=one=\n" . "blarg #### and ##\n" . "=two=\n" . "blarg ####\n"), quotemeta(qq{
  1. one
  2. two
}), quotemeta(qq{

one

}), quotemeta(qq{

two

}));