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