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