Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 2
- Log:
Initial import of Instiki 0.11.0 sources from a downloaded Tarball.
Instiki is a Ruby On Rails based Wiki clone.
- Author:
- adh
- Date:
- Sat Jul 22 14:54:51 +0100 2006
- Size:
- 3541 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/env ruby |
2 | |
3 | require File.expand_path(File.dirname(__FILE__) + '/../test_helper') |
4 | require 'diff' |
5 | |
6 | class DiffTest < Test::Unit::TestCase |
7 | |
8 | include HTMLDiff |
9 | |
10 | def setup |
11 | @builder = DiffBuilder.new('old', 'new') |
12 | end |
13 | |
14 | def test_start_of_tag |
15 | assert @builder.start_of_tag?('<') |
16 | assert(!@builder.start_of_tag?('>')) |
17 | assert(!@builder.start_of_tag?('a')) |
18 | end |
19 | |
20 | def test_end_of_tag |
21 | assert @builder.end_of_tag?('>') |
22 | assert(!@builder.end_of_tag?('<')) |
23 | assert(!@builder.end_of_tag?('a')) |
24 | end |
25 | |
26 | def test_whitespace |
27 | assert @builder.whitespace?(" ") |
28 | assert @builder.whitespace?("\n") |
29 | assert @builder.whitespace?("\r") |
30 | assert(!@builder.whitespace?("a")) |
31 | end |
32 | |
33 | def test_convert_html_to_list_of_words_simple |
34 | assert_equal( |
35 | ['the', ' ', 'original', ' ', 'text'], |
36 | @builder.convert_html_to_list_of_words('the original text')) |
37 | end |
38 | |
39 | def test_convert_html_to_list_of_words_should_separate_endlines |
40 | assert_equal( |
41 | ['a', "\n", 'b', "\r", 'c'], |
42 | @builder.convert_html_to_list_of_words("a\nb\rc")) |
43 | end |
44 | |
45 | def test_convert_html_to_list_of_words_should_not_compress_whitespace |
46 | assert_equal( |
47 | ['a', ' ', 'b', ' ', 'c', "\r \n ", 'd'], |
48 | @builder.convert_html_to_list_of_words("a b c\r \n d")) |
49 | end |
50 | |
51 | def test_convert_html_to_list_of_words_should_handle_tags_well |
52 | assert_equal( |
53 | ['<p>', 'foo', ' ', 'bar', '</p>'], |
54 | @builder.convert_html_to_list_of_words("<p>foo bar</p>")) |
55 | end |
56 | |
57 | def test_convert_html_to_list_of_words_interesting |
58 | assert_equal( |
59 | ['<p>', 'this', ' ', 'is', '</p>', "\r\n", '<p>', 'the', ' ', 'new', ' ', 'string', |
60 | '</p>', "\r\n", '<p>', 'around', ' ', 'the', ' ', 'world', '</p>'], |
61 | @builder.convert_html_to_list_of_words( |
62 | "<p>this is</p>\r\n<p>the new string</p>\r\n<p>around the world</p>")) |
63 | end |
64 | |
65 | def test_html_diff_simple |
66 | a = 'this was the original string' |
67 | b = 'this is the new string' |
68 | assert_equal('this <del class="diffmod">was</del><ins class="diffmod">is</ins> the ' + |
69 | '<del class="diffmod">original</del><ins class="diffmod">new</ins> string', |
70 | diff(a, b)) |
71 | end |
72 | |
73 | def test_html_diff_with_multiple_paragraphs |
74 | a = "<p>this was the original string</p>" |
75 | b = "<p>this is</p>\r\n<p> the new string</p>\r\n<p>around the world</p>" |
76 | |
77 | # Some of this expected result is accidental to implementation. |
78 | # At least it's well-formed and more or less correct. |
79 | assert_equal( |
80 | "<p>this <del class=\"diffmod\">was</del><ins class=\"diffmod\">is</ins></p>"+ |
81 | "<ins class=\"diffmod\">\r\n</ins><p> the " + |
82 | "<del class=\"diffmod\">original</del><ins class=\"diffmod\">new</ins>" + |
83 | " string</p><ins class=\"diffins\">\r\n</ins>" + |
84 | "<p><ins class=\"diffins\">around the world</ins></p>", |
85 | diff(a, b)) |
86 | end |
87 | |
88 | # FIXME this test fails (ticket #67, http://dev.instiki.org/ticket/67) |
89 | def test_html_diff_preserves_endlines_in_pre |
90 | a = "<pre>\na\nb\nc\n</pre>" |
91 | b = "<pre>\n</pre>" |
92 | assert_equal( |
93 | "<pre>\n<del class=\"diffdel\">a\nb\nc\n</del></pre>", |
94 | diff(a, b)) |
95 | end |
96 | |
97 | def test_html_diff_with_tags |
98 | a = "" |
99 | b = "<div>foo</div>" |
100 | assert_equal '<div><ins class="diffins">foo</ins></div>', diff(a, b) |
101 | end |
102 | |
103 | def test_diff_for_tag_change |
104 | a = "<a>x</a>" |
105 | b = "<b>x</b>" |
106 | # FIXME sad, but true - this case produces an invalid XML. If handle this you can, strong your foo is. |
107 | assert_equal '<a><b>x</a></b>', diff(a, b) |
108 | end |
109 | |
110 | end |