diff --git a/t/parse-lists.t b/t/parse-lists.t new file mode 100644 index 0000000..fc26ca8 --- /dev/null +++ b/t/parse-lists.t @@ -0,0 +1,47 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use utf8; + +use Test::More tests => 3; +use Text::Dokuwiki; + +my @lines = split /\n/, <new; +isa_ok($dw, 'Text::Dokuwiki'); +my @lists = $dw->_parse_list([ @lines ]); + +is (scalar @lists, 2); +is_deeply(\@lists, [ + [ul => {}, + [li => {}, 'level1 item1'], + [li => {}, 'level1 item2'], + [li => {}, + [ol => {}, + [li => {}, 'level2 item1'], + [li => {}, 'level2 item2'], + ], + ], + [li => {}, + [ul => {}, + [li => {}, 'level2 item3'] + ], + ], + [li => {}, 'level1 item3'], + ], + [ol => {}, + [li => {}, 'level1 of 2nd list, item1'], + [li => {}, 'level1 of 2nd list, item2'], + ] +]); diff --git a/t/parse-table.t b/t/parse-table.t new file mode 100644 index 0000000..274b7de --- /dev/null +++ b/t/parse-table.t @@ -0,0 +1,55 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use utf8; + +use Test::More tests => 3; +use Text::Dokuwiki; + +my @lines = split /\n/, <new; +isa_ok($dw, 'Text::Dokuwiki'); + +my $table = $dw->_parse_table([ @lines ]); +is(ref $table, 'ARRAY'); +is_deeply($table, [ + table => {}, + [tr => {}, + [td => {align => 'center'}, 'table'], + [th => {align => 'center'}, 'head1'], + [th => {align => 'center'}, 'head2'], + [th => {align => 'center'}, 'sum'], + ], + [tr => {}, + [th => {align => 'center'}, 'data1'], + [td => {align => 'left'}, '1-1'], + [td => {align => 'center'}, '1-2'], + [td => {align => 'right'}, '1-3'], + ], + [tr => {}, + [th => {align => 'left'}, 'data2'], + [td => {align => 'center'}, '2-1'], + [td => {align => 'right'}, '2-222'], + [td => {align => 'left'}, '2-3'], + ], + [tr => {}, + [td => {align => 'center'}, 'data3'], + [th => {align => 'center', colspan => 2}, '3-1'], + [td => {align => 'center', skip => 1}, ''], + [td => {align => 'center', rowspan => 2}, '3-2'], + ], + [tr => {}, + [th => {align => 'center'}, 'data4'], + [td => {align => 'center'}, '4-1'], + [td => {align => 'center'}, '4-2'], + [td => {align => 'center', skip => 1}, ':::'], + ], +]);