#------------------------------------------------------------------- # WebGUI is Copyright 2001-2009 Plain Black Corporation. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license # (docs/license.txt) that came with this distribution before using # this software. #------------------------------------------------------------------- # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- use FindBin; use strict; use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::HTML; use WebGUI::Session; use Test::More; use Test::Deep; use Data::Dumper; my $session = WebGUI::Test->session; my @testArray = ( { inputText => q!section_1!, output => [ qw/section_1/ ], comment => 'bare text, no macro', }, { inputText => q!section_1^-;section_2!, output => [ qw/section_1 section_2/ ], comment => 'bare text, 2 sections', }, { inputText => q!
section_1
^-;
section_2
!, output => [ qw{section_1
section_2
} ], comment => 'paragraph text, 2 sections, macro in separate paragraph', }, { inputText => q!section_1
^-;
section_2
!, output => [ qw{section_1
section_2
} ], comment => 'paragraph text, 2 sections, macro in separate paragraph with whitespace', }, { inputText => q!section_1
^-;
section_2
^-;
section_3
!, output => [ qw{section_1
section_2
section_3
} ], comment => 'paragraph text, 3 sections, macros in separate paragraphs with whitespace', }, { inputText => q!section_1^-;section_2
!, output => [ qw{section_1
section_2
} ], comment => 'paragraph text, 2 sections, macro inside tags', }, { inputText => q!section_1^-;section_2trailer
!, output => [ qw{section_1
section_2trailer
} ], comment => 'paragraph text, 2 sections, macro inside 2 nested tags', }, { inputText => q!section_1^-;
section_2
section_1
', '
section_2
section_1^-;
section_2
section_1
', '
section_2
section_1
trailer_1^-;section_2
section_1
trailer_1
section_2
' ], comment => 'paragraph text, 2 sections, macro inside tags, with br unclosed in first section', }, { inputText => q!Very^-;long^-;paragraph
!, output => [ 'Very
', 'long
', 'paragraph
' ], comment => 'paragraph text, 3 sections, macros inside tags', }, { inputText => q!Very^-;long^-;paragraph
!, output => [ 'Very
', 'long
', 'paragraph
' ], comment => 'paragraph text, 3 sections, macros inside tags, nesting first two tags', }, { inputText => q!Very^-;long^-;paragraph
!, output => [ 'Very
', 'long
', 'paragraph
' ], comment => 'paragraph text, 3 sections, macros inside tags, nesting all 3 sections', }, { inputText => q!Very^-;long^-;paragraph
!, output => [ 'Very
', 'long
', 'paragraph
' ], comment => 'paragraph text, 3 sections, macros inside tags, bridge right after macro', }, ); my $numTests = scalar @testArray; plan tests => $numTests; foreach my $testSet (@testArray) { my @output = WebGUI::HTML::splitSeparator($testSet->{inputText}); my $ok = cmp_deeply( \@output, $testSet->{output}, $testSet->{comment} ); if (!$ok) { diag explain \@output; } }