Akron | 4f67cd4 | 2020-07-02 12:27:58 +0200 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
Akron | 5fb5e8d | 2020-07-23 17:45:13 +0200 | [diff] [blame] | 4 | use Test::KorAP::XML::TEI qw!korap_tempfile!; |
Akron | 4f67cd4 | 2020-07-02 12:27:58 +0200 | [diff] [blame] | 5 | |
| 6 | use FindBin; |
| 7 | BEGIN { |
| 8 | unshift @INC, "$FindBin::Bin/../lib"; |
| 9 | }; |
| 10 | |
Akron | 95bc98a | 2020-07-11 12:00:12 +0200 | [diff] [blame] | 11 | use_ok('KorAP::XML::TEI', 'remove_xml_comments'); |
Akron | 4f67cd4 | 2020-07-02 12:27:58 +0200 | [diff] [blame] | 12 | |
Akron | 5fb5e8d | 2020-07-23 17:45:13 +0200 | [diff] [blame] | 13 | my ($fh, $filename) = korap_tempfile('tei'); |
Akron | 4f67cd4 | 2020-07-02 12:27:58 +0200 | [diff] [blame] | 14 | |
| 15 | print $fh <<'HTML'; |
| 16 | mehrzeiliger |
| 17 | Kommentar |
| 18 | --> |
| 19 | Test |
| 20 | HTML |
| 21 | |
Akron | 95bc98a | 2020-07-11 12:00:12 +0200 | [diff] [blame] | 22 | is(remove_xml_comments($fh, "hallo"),"hallo"); |
| 23 | is(remove_xml_comments($fh, "hallo <!-- Test -->"),"hallo "); |
| 24 | is(remove_xml_comments($fh, "<!-- Test --> hallo")," hallo"); |
Akron | 4f67cd4 | 2020-07-02 12:27:58 +0200 | [diff] [blame] | 25 | |
| 26 | seek($fh, 0, 0); |
| 27 | |
Akron | 95bc98a | 2020-07-11 12:00:12 +0200 | [diff] [blame] | 28 | is(remove_xml_comments($fh, '<!--'), "Test\n"); |
Akron | 4f67cd4 | 2020-07-02 12:27:58 +0200 | [diff] [blame] | 29 | |
Akron | 2d547bc | 2020-07-04 10:34:35 +0200 | [diff] [blame] | 30 | seek($fh, 0, 0); |
| 31 | |
| 32 | print $fh <<'HTML'; |
| 33 | mehrzeiliger |
| 34 | Kommentar |
| 35 | --><!-- Versuch |
| 36 | -->ist <!-- a --><!-- b --> ein Test |
| 37 | HTML |
| 38 | |
| 39 | seek($fh, 0, 0); |
| 40 | |
Akron | 95bc98a | 2020-07-11 12:00:12 +0200 | [diff] [blame] | 41 | is(remove_xml_comments($fh, 'Dies <!--'), "Dies ist ein Test\n"); |
Akron | 2d547bc | 2020-07-04 10:34:35 +0200 | [diff] [blame] | 42 | |
| 43 | close($fh); |
| 44 | |
Akron | 4f67cd4 | 2020-07-02 12:27:58 +0200 | [diff] [blame] | 45 | done_testing; |