| use strict; |
| use warnings; |
| use Test::More; |
| use Test::Script; |
| use Mojo::File qw'tempdir'; |
| use File::Copy::Recursive qw'dircopy'; |
| |
| |
| script_runs([ 'script/korapxml_offset_checker', '-h' ], { exit => 1 }); |
| script_stdout_like(qr'korapxml_offset_checker - v\d\.\d.\d', "Can print help message"); |
| |
| script_runs([ 'script/korapxml_offset_checker', '-i', 't/example/NKJP/NKJP/620-3-010001144', '-a', 'nkjp/morpho' ], { exit => 1 }); |
| |
| script_stdout_like(qr'1\. Problem found', 'Show problem'); |
| script_stdout_unlike(qr'2\. Problem found', 'Show problem'); |
| script_stdout_like(qr'Jakubowska będzie naczelną\?-\[\[ \]\]jak wyjdzie z he! he! upadku', 'Show snippet'); |
| script_stdout_like(qr!Lemma: '-'!, 'Show lemma'); |
| |
| script_runs([ 'script/korapxml_offset_checker', '-i', 't/example/NKJP/NKJP/620-3-010000835', '-a', 'nkjp/morpho' ], { exit => 1 }); |
| |
| script_stdout_like(qr'1\. Problem found', 'Show problem'); |
| script_stdout_like(qr'2\. Problem found', 'Show problem'); |
| script_stdout_like(qr'3\. Problem found', 'Show problem'); |
| script_stdout_like(qr'4\. Problem found', 'Show problem'); |
| script_stdout_like(qr'5\. Problem found', 'Show problem'); |
| script_stdout_like(qr'6\. Problem found', 'Show problem'); |
| script_stdout_like(qr'7\. Problem found', 'Show problem'); |
| script_stdout_like(qr'8\. Problem found', 'Show problem'); |
| script_stdout_like(qr'9\. Problem found', 'Show problem'); |
| script_stdout_unlike(qr'10\. Problem found', 'Show problem'); |
| |
| script_stdout_like(qr'Lemma: \'od\'', 'Show lemma 1'); |
| script_stdout_like(qr'Snippet: ,że te pumy nie mają młodych\?O\[\[d \]\]marcowania do sierpnia to 90 d', 'Show snippet 1'); |
| |
| script_stdout_like(qr'Lemma: \'od\'', 'Show lemma 9'); |
| script_stdout_like(qr'Snippet \(adjusted\): kury,która znosi złote jajka\.Z\[\[a \]\]dużo zainwestowali i robią to', 'Show snippet 9'); |
| |
| my $t = tempdir; |
| |
| ok(dircopy('t/example/NKJP/NKJP/620-3-010000835', $t)); |
| |
| script_runs([ 'script/korapxml_offset_checker', '-i', "$t", '-a', 'nkjp/morpho', '--fix', '--quiet' ], { exit => 0 }); |
| |
| script_stdout_like(qr'1\. Problem found', 'Show problem'); |
| script_stdout_like(qr'Check fixed data \.\.\.', ''); |
| script_stdout_like(qr'Fix: ł,że te pumy nie mają młodych\? \[\[Od\]\] marcowania do sierpnia to 90', 'Fix 1'); |
| script_stdout_like(qr'Fix: kury,która znosi złote jajka\. \[\[Za\]\] dużo zainwestowali i robią to', 'Fix 9'); |
| |
| script_runs([ 'script/korapxml_offset_checker', '-i', 't/example/NKJP/NKJP/620-3-010001144', '-a', 'nkjp/morpho', '--fix', '--quiet' ], { exit => 1 }); |
| |
| script_stdout_like(qr'1\. Problem found', 'Show problem'); |
| script_stdout_unlike(qr'2\. Problem found', 'Show problem'); |
| script_stdout_like(qr'Jakubowska będzie naczelną\?-\[\[ \]\]jak wyjdzie z he! he! upadku', 'Show snippet'); |
| script_stdout_like(qr!Lemma: '-'!, 'Show lemma'); |
| script_stdout_like(qr!Unable to fix file!, 'Show lemma'); |
| |
| done_testing; |