Akron | faf5291 | 2022-12-16 14:05:18 +0100 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
| 4 | use Test::Script; |
| 5 | use Mojo::File qw'tempdir'; |
| 6 | use File::Copy::Recursive qw'dircopy'; |
| 7 | |
| 8 | |
| 9 | script_runs([ 'script/korapxml_offset_checker', '-h' ], { exit => 1 }); |
| 10 | script_stdout_like(qr'korapxml_offset_checker - v\d\.\d.\d', "Can print help message"); |
| 11 | |
| 12 | script_runs([ 'script/korapxml_offset_checker', '-i', 't/example/NKJP/NKJP/620-3-010001144', '-a', 'nkjp/morpho' ], { exit => 1 }); |
| 13 | |
| 14 | script_stdout_like(qr'1\. Problem found', 'Show problem'); |
| 15 | script_stdout_unlike(qr'2\. Problem found', 'Show problem'); |
| 16 | script_stdout_like(qr'Jakubowska będzie naczelną\?-\[\[ \]\]jak wyjdzie z he! he! upadku', 'Show snippet'); |
| 17 | script_stdout_like(qr!Lemma: '-'!, 'Show lemma'); |
| 18 | |
| 19 | script_runs([ 'script/korapxml_offset_checker', '-i', 't/example/NKJP/NKJP/620-3-010000835', '-a', 'nkjp/morpho' ], { exit => 1 }); |
| 20 | |
| 21 | script_stdout_like(qr'1\. Problem found', 'Show problem'); |
| 22 | script_stdout_like(qr'2\. Problem found', 'Show problem'); |
| 23 | script_stdout_like(qr'3\. Problem found', 'Show problem'); |
| 24 | script_stdout_like(qr'4\. Problem found', 'Show problem'); |
| 25 | script_stdout_like(qr'5\. Problem found', 'Show problem'); |
| 26 | script_stdout_like(qr'6\. Problem found', 'Show problem'); |
| 27 | script_stdout_like(qr'7\. Problem found', 'Show problem'); |
| 28 | script_stdout_like(qr'8\. Problem found', 'Show problem'); |
| 29 | script_stdout_like(qr'9\. Problem found', 'Show problem'); |
| 30 | script_stdout_unlike(qr'10\. Problem found', 'Show problem'); |
| 31 | |
| 32 | script_stdout_like(qr'Lemma: \'od\'', 'Show lemma 1'); |
| 33 | script_stdout_like(qr'Snippet: ,że te pumy nie mają młodych\?O\[\[d \]\]marcowania do sierpnia to 90 d', 'Show snippet 1'); |
| 34 | |
| 35 | script_stdout_like(qr'Lemma: \'od\'', 'Show lemma 9'); |
| 36 | script_stdout_like(qr'Snippet \(adjusted\): kury,która znosi złote jajka\.Z\[\[a \]\]dużo zainwestowali i robią to', 'Show snippet 9'); |
| 37 | |
| 38 | my $t = tempdir; |
| 39 | |
| 40 | ok(dircopy('t/example/NKJP/NKJP/620-3-010000835', $t)); |
| 41 | |
| 42 | script_runs([ 'script/korapxml_offset_checker', '-i', "$t", '-a', 'nkjp/morpho', '--fix', '--quiet' ], { exit => 0 }); |
| 43 | |
| 44 | script_stdout_like(qr'1\. Problem found', 'Show problem'); |
| 45 | script_stdout_like(qr'Check fixed data \.\.\.', ''); |
| 46 | script_stdout_like(qr'Fix: ł,że te pumy nie mają młodych\? \[\[Od\]\] marcowania do sierpnia to 90', 'Fix 1'); |
| 47 | script_stdout_like(qr'Fix: kury,która znosi złote jajka\. \[\[Za\]\] dużo zainwestowali i robią to', 'Fix 9'); |
| 48 | |
| 49 | script_runs([ 'script/korapxml_offset_checker', '-i', 't/example/NKJP/NKJP/620-3-010001144', '-a', 'nkjp/morpho', '--fix', '--quiet' ], { exit => 1 }); |
| 50 | |
| 51 | script_stdout_like(qr'1\. Problem found', 'Show problem'); |
| 52 | script_stdout_unlike(qr'2\. Problem found', 'Show problem'); |
| 53 | script_stdout_like(qr'Jakubowska będzie naczelną\?-\[\[ \]\]jak wyjdzie z he! he! upadku', 'Show snippet'); |
| 54 | script_stdout_like(qr!Lemma: '-'!, 'Show lemma'); |
| 55 | script_stdout_like(qr!Unable to fix file!, 'Show lemma'); |
| 56 | |
| 57 | done_testing; |