Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | use utf8; |
| 5 | use Test::More; |
Akron | 151676d | 2016-03-14 20:12:14 +0100 | [diff] [blame] | 6 | use lib 't/annotation'; |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 7 | use TestInit; |
| 8 | use Scalar::Util qw/weaken/; |
| 9 | use Data::Dumper; |
| 10 | |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 11 | ok(my $tokens = TestInit::tokens('0001'), 'Parse tokens'); |
| 12 | |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame^] | 13 | ok($tokens->add('DeReKo', 'Structure', 'pagebreaks'), 'Add Structure'); |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 14 | |
| 15 | my $data = $tokens->to_data->{data}; |
| 16 | |
| 17 | like($data->{foundries}, qr!dereko/structure!, 'data'); |
| 18 | like($data->{layerInfos}, qr!dereko/s=spans!, 'data'); |
| 19 | |
| 20 | # Empty element (from 0 to 0) on level 1, with TUI 2 |
| 21 | is($data->{stream}->[0]->[1], |
Akron | 69a4a2f | 2016-01-17 12:55:50 +0100 | [diff] [blame] | 22 | '<>:dereko/s:idsHeader$<b>65<i>0<i>0<i>0<b>1<s>2', |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 23 | 'Empty element'); |
| 24 | |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 25 | |
Akron | ee443f9 | 2016-02-25 23:56:49 +0100 | [diff] [blame] | 26 | is($data->{stream}->[0]->[5], '<>:base/s:t$<b>64<i>0<i>129<i>17<b>0', 'Text boundary'); |
| 27 | |
| 28 | # Attributes: |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 29 | is($data->{stream}->[0]->[11], |
Akron | ee443f9 | 2016-02-25 23:56:49 +0100 | [diff] [blame] | 30 | '@:dereko/s:type:text$<b>17<s>2', |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 31 | 'Attribute of idsHeader'); |
| 32 | |
| 33 | is($data->{stream}->[0]->[12], |
| 34 | '@:dereko/s:status:new$<b>17<s>2', |
| 35 | 'Attribute of idsHeader'); |
| 36 | |
| 37 | is($data->{stream}->[0]->[13], |
Akron | ee443f9 | 2016-02-25 23:56:49 +0100 | [diff] [blame] | 38 | '@:dereko/s:version:1.1$<b>17<s>2', |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 39 | 'Attribute of idsHeader'); |
| 40 | |
| 41 | is($data->{stream}->[0]->[14], |
| 42 | '@:dereko/s:pattern:text$<b>17<s>2', |
| 43 | 'Attribute of idsHeader'); |
| 44 | |
Akron | 69a4a2f | 2016-01-17 12:55:50 +0100 | [diff] [blame] | 45 | is($data->{stream}->[4]->[1], |
| 46 | '<>:dereko/s:s$<b>64<i>32<i>42<i>6<b>6<s>1', |
| 47 | 'Sentence span'); |
| 48 | |
| 49 | is($data->{stream}->[4]->[2], |
| 50 | '@:dereko/s:broken:no$<b>17<s>1<i>6', |
| 51 | 'Attribute of sentence span'); |
| 52 | |
| 53 | is($data->{stream}->[6]->[0], |
| 54 | '<>:dereko/s:pb$<b>65<i>42<i>42<i>6<b>6<s>1', |
| 55 | 'Pagebreak element'); |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 56 | |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame^] | 57 | is($data->{stream}->[6]->[-1], |
| 58 | '~:base/s:pb$<i>2<i>42', |
| 59 | 'Pagebreak element'); |
| 60 | |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 61 | done_testing; |
| 62 | |
| 63 | __END__ |