Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 22 lines (16 sloc) 1.18 kb
1dd7321 Dan Dascalescu Made all tests use strict, removed t/c/journal.t (leftover from old days...
dandv authored
1 #!/usr/bin/env perl
488610e Marcus Ramberg Add changelog entry, add stub test
marcusramberg authored
2 use strict;
3 use warnings;
4
1dd7321 Dan Dascalescu Made all tests use strict, removed t/c/journal.t (leftover from old days...
dandv authored
5 use Test::More tests => 6;
488610e Marcus Ramberg Add changelog entry, add stub test
marcusramberg authored
6
7
8 BEGIN {
1dd7321 Dan Dascalescu Made all tests use strict, removed t/c/journal.t (leftover from old days...
dandv authored
9 use_ok('MojoMojo::WordDiff');
488610e Marcus Ramberg Add changelog entry, add stub test
marcusramberg authored
10 }
1db2925 Ryan Niebur add some tests for Text::WordDiff::MojoMojo
ryan52 authored
11
12 sub test_diff {
13 my ($in1, $in2, $expected) = (shift, shift, shift);
14 is(word_diff($in1, $in2), $expected, scalar(@_) ? $_[0] : undef);
15 }
16
17 test_diff('Perl is great', 'MojoMojo is great', "<del>Perl</del><ins>MojoMojo</ins> is great", "normal word change");
18 test_diff("V&aring;re norske tegn b&oslash;r &#230res", "V&aring;re norske tegn b&oslash;r &#230res", "V&aring;re norske tegn b&oslash;r &aelig;res", "encoded characters");
19 test_diff('<div>foo</div>', '<div>bar</div>', '<div><del>foo</del><ins>bar</ins></div>', "word change inside of tags");
20 test_diff('<div class="a">foo</div>', '<div>foo</div>', '<del><div class="a"></del><ins><div></ins>foo</div>', "change of tags attributes");
21 test_diff('Once upon a time in a country called the United States, there was a programmer named Ryan.', 'Once upon a time in a country called Canada, there was a programmer named Jon.', 'Once upon a time in a country called <del>the United States</del><ins>Canada</ins>, there was a programmer named <del>Ryan</del><ins>Jon</ins>.', "multiple word changes");
Something went wrong with that request. Please try again.