Class TestInline
In: markup/test/TestInline.rb
Parent: Test::Unit::TestCase

Methods

Public Instance methods

[Source]

    # File markup/test/TestInline.rb, line 34
34:   def crossref(text)
35:     [ @am.changed_attribute_by_name([], [:CROSSREF] | [:_SPECIAL_]),
36:       SM::Special.new(33, text),
37:       @am.changed_attribute_by_name([:CROSSREF] | [:_SPECIAL_], [])
38:     ]
39:   end

[Source]

    # File markup/test/TestInline.rb, line 10
10:   def setup
11:     @am = SM::AttributeManager.new
12: 
13:     @bold_on  = @am.changed_attribute_by_name([], [:BOLD])
14:     @bold_off = @am.changed_attribute_by_name([:BOLD], [])
15:     
16:     @tt_on    = @am.changed_attribute_by_name([], [:TT])
17:     @tt_off   = @am.changed_attribute_by_name([:TT], [])
18:     
19:     @em_on    = @am.changed_attribute_by_name([], [:EM])
20:     @em_off   = @am.changed_attribute_by_name([:EM], [])
21:     
22:     @bold_em_on   = @am.changed_attribute_by_name([], [:BOLD] | [:EM])
23:     @bold_em_off  = @am.changed_attribute_by_name([:BOLD] | [:EM], [])
24:     
25:     @em_then_bold = @am.changed_attribute_by_name([:EM], [:EM] | [:BOLD])
26:     
27:     @em_to_bold   = @am.changed_attribute_by_name([:EM], [:BOLD])
28:     
29:     @am.add_word_pair("{", "}", :WOMBAT)
30:     @wombat_on    = @am.changed_attribute_by_name([], [:WOMBAT])
31:     @wombat_off   = @am.changed_attribute_by_name([:WOMBAT], [])
32:   end

[Source]

     # File markup/test/TestInline.rb, line 149
149:   def test_adding
150:     assert_equal(["cat ", @wombat_on, "and", @wombat_off, " dog" ],
151:                   @am.flow("cat {and} dog"))
152: #    assert_equal(["cat {and} dog" ], @am.flow("cat \\{and} dog"))
153:   end

[Source]

    # File markup/test/TestInline.rb, line 61
61:   def test_basic
62:     assert_equal(["cat"], @am.flow("cat"))
63: 
64:     assert_equal(["cat ", @bold_on, "and", @bold_off, " dog"],
65:                   @am.flow("cat *and* dog"))
66: 
67:     assert_equal(["cat ", @bold_on, "AND", @bold_off, " dog"],
68:                   @am.flow("cat *AND* dog"))
69: 
70:     assert_equal(["cat ", @em_on, "And", @em_off, " dog"],
71:                   @am.flow("cat _And_ dog"))
72: 
73:     assert_equal(["cat *and dog*"], @am.flow("cat *and dog*"))
74: 
75:     assert_equal(["*cat and* dog"], @am.flow("*cat and* dog"))
76: 
77:     assert_equal(["cat *and ", @bold_on, "dog", @bold_off],
78:                   @am.flow("cat *and *dog*"))
79: 
80:     assert_equal(["cat ", @em_on, "and", @em_off, " dog"],
81:                   @am.flow("cat _and_ dog"))
82: 
83:     assert_equal(["cat_and_dog"],
84:                   @am.flow("cat_and_dog"))
85: 
86:     assert_equal(["cat ", @tt_on, "and", @tt_off, " dog"],
87:                   @am.flow("cat +and+ dog"))
88: 
89:     assert_equal(["cat ", @bold_on, "a_b_c", @bold_off, " dog"],
90:                   @am.flow("cat *a_b_c* dog"))
91: 
92:     assert_equal(["cat __ dog"],
93:                   @am.flow("cat __ dog"))
94: 
95:     assert_equal(["cat ", @em_on, "_", @em_off, " dog"],
96:                   @am.flow("cat ___ dog"))
97: 
98:   end

[Source]

     # File markup/test/TestInline.rb, line 100
100:   def test_combined
101:     assert_equal(["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off],
102:                   @am.flow("cat _and_ *dog*"))
103: 
104:     assert_equal(["cat ", @em_on, "a__nd", @em_off, " ", @bold_on, "dog", @bold_off], 
105:                   @am.flow("cat _a__nd_ *dog*"))
106:   end

[Source]

     # File markup/test/TestInline.rb, line 108
108:   def test_html_like
109:     assert_equal(["cat ", @tt_on, "dog", @tt_off], @am.flow("cat <tt>dog</Tt>"))
110: 
111:     assert_equal(["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off], 
112:                   @am.flow("cat <i>and</i> <B>dog</b>"))
113:     
114:     assert_equal(["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off], 
115:                   @am.flow("cat <i>and <B>dog</B></I>"))
116:     
117:     assert_equal(["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off], 
118:                   @am.flow("cat <i>and </i><b>dog</b>"))
119:     
120:     assert_equal(["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off], 
121:                   @am.flow("cat <i>and <b></i>dog</b>"))
122:     
123:     assert_equal([@tt_on, "cat", @tt_off, " ", @em_on, "and ", @em_to_bold, "dog", @bold_off], 
124:                   @am.flow("<tt>cat</tt> <i>and <b></i>dog</b>"))
125: 
126:     assert_equal(["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off], 
127:                   @am.flow("cat <i>and <b>dog</b></i>"))
128:     
129:     assert_equal(["cat ", @bold_em_on, "and", @bold_em_off, " dog"], 
130:                   @am.flow("cat <i><b>and</b></i> dog"))
131:     
132:     
133:   end

[Source]

     # File markup/test/TestInline.rb, line 135
135:   def test_protect
136:     assert_equal(['cat \\ dog'], @am.flow('cat \\ dog'))
137: 
138:     assert_equal(["cat <tt>dog</Tt>"], @am.flow("cat \\<tt>dog</Tt>"))
139: 
140:     assert_equal(["cat ", @em_on, "and", @em_off, " <B>dog</b>"], 
141:                   @am.flow("cat <i>and</i> \\<B>dog</b>"))
142:     
143:     assert_equal(["*word* or <b>text</b>"], @am.flow("\\*word* or \\<b>text</b>"))
144: 
145:     assert_equal(["_cat_", @em_on, "dog", @em_off], 
146:                   @am.flow("\\_cat_<i>dog</i>"))
147:   end

[Source]

    # File markup/test/TestInline.rb, line 41
41:   def test_special
42:     # class names, variable names, file names, or instance variables
43:     @am.add_special(/(
44:                        \b([A-Z]\w+(::\w+)*)
45:                        | \#\w+[!?=]?
46:                        | \b\w+([_\/\.]+\w+)+[!?=]?
47:                       )/x, 
48:                     :CROSSREF)
49:     
50:     assert_equal(["cat"], @am.flow("cat"))
51: 
52:     assert_equal(["cat ", crossref("#fred"), " dog"].flatten,
53:                   @am.flow("cat #fred dog"))
54: 
55:     assert_equal([crossref("#fred"), " dog"].flatten,
56:                   @am.flow("#fred dog"))
57: 
58:     assert_equal(["cat ", crossref("#fred")].flatten, @am.flow("cat #fred"))
59:   end

[Validate]