1use strict;
2use utf8;
3use Test::Base;
4
5plan tests => 2 * blocks;
6
7use String::Diff qw( diff );
8
9filters { data1 => 'yaml', data2 => 'yaml' };
10
11sub string_diff {
12    my $input = shift;
13    my $diff = diff($input->{old}, $input->{new}, %{ $input->{options} });
14    $diff;
15}
16
17run {
18    my $block = shift;
19
20    my $diff = diff($block->data2->{old}, $block->data2->{new}, %{ $block->data2->{options} });
21    my @diff = diff($block->data2->{old}, $block->data2->{new}, %{ $block->data2->{options} });
22
23    is_deeply $block->data1, $diff;
24    is_deeply $block->data1, \@diff;
25};
26
27
28__END__
29
30===
31--- data1
32- perl
33- pe{a}rl
34--- data2
35old: perl
36new: pearl
37
38===
39--- data1
40- 'th[i]s [is ]a[ pen]'
41- "th{at'}s a{ll}"
42--- data2
43old: this is a pen
44new: that's all
45
46===
47--- data1
48- '[S]oo[z]y'
49- '{B}oo{f}y'
50--- data2
51old: Soozy
52new: Boofy
53
54===
55--- data1
56- '[あ]る[晴れた日に散歩をすると]、そ[こに]は'
57- '{いつもい}る{人がいないので}、そ{れ}は'
58--- data2
59old: ある晴れた日に散歩をすると、そこには
60new: いつもいる人がいないので、それは
61
62===
63--- data1
64- |-
65  This library is [free software]; you can redistribute it and[/or] modify
66  it under the same terms as Perl itself.
67- |-
68  This library is {自由なソフト}; you can {not }redistribute it {or/}and modify
69  it under the same terms as Pe{a}rl it{ }self.
70--- data2
71old: |-
72  This library is free software; you can redistribute it and/or modify
73  it under the same terms as Perl itself.
74new: |-
75  This library is 自由なソフト; you can not redistribute it or/and modify
76  it under the same terms as Pearl it self.
77
78===
79--- data1
80- |-
81  This library is [free software]; you can redistribute it and[/or] modify[
82  ]it under the same terms as Perl itself.
83- This library is {自由なソフト}; you can {not }redistribute it {or/}and modify{ }it under the same terms as Pe{a}rl it{ }self.
84--- data2
85old: |-
86  This library is free software; you can redistribute it and/or modify
87  it under the same terms as Perl itself.
88new: This library is 自由なソフト; you can not redistribute it or/and modify it under the same terms as Pearl it self.
89
90===
91--- data1
92- |-
93  [remove
94  ]This library is [free software]; you can redistribute it and[/or] modify
95  (snip)
96  it under the same terms as Perl itself.
97- |-
98  This library is {自由なソフト}; you can {not }redistribute it {or/}and modify
99  (snip)
100  it under the same terms as Pe{a}rl it{ }self.{
101  append}
102--- data2
103old: |-
104  remove
105  This library is free software; you can redistribute it and/or modify
106  (snip)
107  it under the same terms as Perl itself.
108new: |-
109  This library is 自由なソフト; you can not redistribute it or/and modify
110  (snip)
111  it under the same terms as Pearl it self.
112  append
113
114===
115--- data1
116- |-
117  This library is [free software]; you can redistribute it and[/or] modify
118  it under the same terms as Perl itself.
119- |-
120  This library is {自由なソフト}; you can {not }redistribute it {or/}and modify
121  it under the same terms as Pe{a}rl it{ }self.
122--- data2
123old: |-
124  This library is free software; you can redistribute it and/or modify
125  it under the same terms as Perl itself.
126new: |-
127  This library is 自由なソフト; you can not redistribute it or/and modify
128  it under the same terms as Pearl it self.
129options:
130  linebreak: 1
131
132===
133--- data1
134- |-
135  remo[ve]
136  [This library is free software; you can redistribute it and/or modify][
137  ](snip)
138  it under the same terms as Perl itself.
139- |-
140  {This lib}r{ary is 自由なソフト; you can not r}e{distribute it or/and }mo{dify}
141  (snip)
142  it under the same terms as Pe{a}rl it{ }self.{
143  }{append}
144--- data2
145old: |-
146  remove
147  This library is free software; you can redistribute it and/or modify
148  (snip)
149  it under the same terms as Perl itself.
150new: |-
151  This library is 自由なソフト; you can not redistribute it or/and modify
152  (snip)
153  it under the same terms as Pearl it self.
154  append
155options:
156  linebreak: 1
157
158===
159--- data1
160- |-
161  This library is <del>free software</del>; you can redistribute it and<del>/or</del> modify
162  it under the same terms as Perl itself.
163- |-
164  This library is <ins>自由なソフト</ins>; you can <ins>not </ins>redistribute it <ins>or/</ins>and modify
165  it under the same terms as Pe<ins>a</ins>rl it<ins> </ins>self.
166--- data2
167old: |-
168  This library is free software; you can redistribute it and/or modify
169  it under the same terms as Perl itself.
170new: |-
171  This library is 自由なソフト; you can not redistribute it or/and modify
172  it under the same terms as Pearl it self.
173options:
174  linebreak: 1
175  remove_open: <del>
176  remove_close: </del>
177  append_open: <ins>
178  append_close: </ins>
179
180===
181--- data1
182- 1[0]
183- 1{1}
184--- data2
185old: 10
186new: 11
187
188