blob: b602df66ef9c56d38ee0d59cf1c4402257ae36a2 [file] [log] [blame]
Akron4f67cd42020-07-02 12:27:58 +02001use strict;
2use warnings;
3use Test::More;
4use File::Temp 'tempfile';
5
6use FindBin;
7BEGIN {
8 unshift @INC, "$FindBin::Bin/../lib";
9};
10
Peter Harders57c884e2020-07-16 01:28:52 +020011our %ENV;
12# default: remove temp. file created by func. tempfile
13# to keep temp. files use e.g. 'KORAPXMLTEI_DONTUNLINK=1 prove -lr t/script.t'
14my $_UNLINK = $ENV{KORAPXMLTEI_DONTUNLINK}?0:1;
15
Akron95bc98a2020-07-11 12:00:12 +020016use_ok('KorAP::XML::TEI', 'remove_xml_comments');
Akron4f67cd42020-07-02 12:27:58 +020017
Peter Harders57c884e2020-07-16 01:28:52 +020018my ($fh, $filename) = tempfile("KorAP-XML-TEI_tei_XXXXXXXXXX", SUFFIX => ".tmp", TMPDIR => 1, UNLINK => $_UNLINK);
Akron4f67cd42020-07-02 12:27:58 +020019
20print $fh <<'HTML';
21mehrzeiliger
22Kommentar
23 -->
24Test
25HTML
26
Akron95bc98a2020-07-11 12:00:12 +020027is(remove_xml_comments($fh, "hallo"),"hallo");
28is(remove_xml_comments($fh, "hallo <!-- Test -->"),"hallo ");
29is(remove_xml_comments($fh, "<!-- Test --> hallo")," hallo");
Akron4f67cd42020-07-02 12:27:58 +020030
31seek($fh, 0, 0);
32
Akron95bc98a2020-07-11 12:00:12 +020033is(remove_xml_comments($fh, '<!--'), "Test\n");
Akron4f67cd42020-07-02 12:27:58 +020034
Akron2d547bc2020-07-04 10:34:35 +020035seek($fh, 0, 0);
36
37print $fh <<'HTML';
38mehrzeiliger
39Kommentar
40 --><!-- Versuch
41-->ist <!-- a --><!-- b --> ein Test
42HTML
43
44seek($fh, 0, 0);
45
Akron95bc98a2020-07-11 12:00:12 +020046is(remove_xml_comments($fh, 'Dies <!--'), "Dies ist ein Test\n");
Akron2d547bc2020-07-04 10:34:35 +020047
48close($fh);
49
Akron4f67cd42020-07-02 12:27:58 +020050done_testing;