sqlpostgres 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.md +23 -0
- data/README.rdoc +59 -0
- data/Rakefile +32 -0
- data/VERSION +1 -0
- data/doc/BUGS +2 -0
- data/doc/examples/README +6 -0
- data/doc/examples/connection.rb +16 -0
- data/doc/examples/connection_auto.rb +22 -0
- data/doc/examples/connection_ctor.rb +18 -0
- data/doc/examples/connection_default.rb +15 -0
- data/doc/examples/connection_exec.rb +18 -0
- data/doc/examples/connection_manual.rb +12 -0
- data/doc/examples/connection_wrapped_new.rb +13 -0
- data/doc/examples/connection_wrapped_open.rb +13 -0
- data/doc/examples/cursor.rb +38 -0
- data/doc/examples/include_module.rb +9 -0
- data/doc/examples/include_module2.rb +12 -0
- data/doc/examples/insert.rb +30 -0
- data/doc/examples/insert2.rb +36 -0
- data/doc/examples/insert_bytea.rb +16 -0
- data/doc/examples/insert_bytea_array.rb +17 -0
- data/doc/examples/insert_default_values.rb +16 -0
- data/doc/examples/insert_insert.rb +16 -0
- data/doc/examples/insert_insert_default.rb +16 -0
- data/doc/examples/insert_insert_select.rb +20 -0
- data/doc/examples/insert_select.rb +20 -0
- data/doc/examples/interval.rb +17 -0
- data/doc/examples/savepoint.rb +38 -0
- data/doc/examples/select.rb +33 -0
- data/doc/examples/select2.rb +36 -0
- data/doc/examples/select_cross_join.rb +18 -0
- data/doc/examples/select_distinct.rb +18 -0
- data/doc/examples/select_distinct_on +19 -0
- data/doc/examples/select_for_update.rb +18 -0
- data/doc/examples/select_from.rb +17 -0
- data/doc/examples/select_from_subselect.rb +20 -0
- data/doc/examples/select_group_by.rb +19 -0
- data/doc/examples/select_having.rb +20 -0
- data/doc/examples/select_join_on.rb +18 -0
- data/doc/examples/select_join_using.rb +18 -0
- data/doc/examples/select_limit.rb +19 -0
- data/doc/examples/select_natural_join.rb +18 -0
- data/doc/examples/select_offset.rb +19 -0
- data/doc/examples/select_order_by.rb +20 -0
- data/doc/examples/select_select.rb +30 -0
- data/doc/examples/select_select_alias.rb +30 -0
- data/doc/examples/select_select_expression.rb +31 -0
- data/doc/examples/select_select_literal.rb +24 -0
- data/doc/examples/select_union.rb +21 -0
- data/doc/examples/select_where_array.rb +18 -0
- data/doc/examples/select_where_in.rb +18 -0
- data/doc/examples/select_where_string.rb +18 -0
- data/doc/examples/simple.rb +34 -0
- data/doc/examples/transaction.rb +30 -0
- data/doc/examples/transaction_abort.rb +30 -0
- data/doc/examples/transaction_commit.rb +34 -0
- data/doc/examples/translate_substitute_values.rb +17 -0
- data/doc/examples/update.rb +32 -0
- data/doc/examples/update2.rb +44 -0
- data/doc/examples/update_only.rb +17 -0
- data/doc/examples/update_set.rb +17 -0
- data/doc/examples/update_set_array.rb +16 -0
- data/doc/examples/update_set_bytea.rb +16 -0
- data/doc/examples/update_set_expression.rb +16 -0
- data/doc/examples/update_set_subselect.rb +20 -0
- data/doc/examples/update_where.rb +17 -0
- data/doc/examples/use_prefix.rb +8 -0
- data/doc/examples/use_prefix2.rb +11 -0
- data/doc/index.html +31 -0
- data/doc/insertexamples.rb +9 -0
- data/doc/makemanual +4 -0
- data/doc/makerdoc +5 -0
- data/doc/manual.dbk +622 -0
- data/lib/sqlpostgres/Connection.rb +198 -0
- data/lib/sqlpostgres/Cursor.rb +157 -0
- data/lib/sqlpostgres/Delete.rb +67 -0
- data/lib/sqlpostgres/Exceptions.rb +15 -0
- data/lib/sqlpostgres/Insert.rb +279 -0
- data/lib/sqlpostgres/NullConnection.rb +22 -0
- data/lib/sqlpostgres/PgBit.rb +73 -0
- data/lib/sqlpostgres/PgBox.rb +37 -0
- data/lib/sqlpostgres/PgCidr.rb +21 -0
- data/lib/sqlpostgres/PgCircle.rb +75 -0
- data/lib/sqlpostgres/PgInet.rb +21 -0
- data/lib/sqlpostgres/PgInterval.rb +208 -0
- data/lib/sqlpostgres/PgLineSegment.rb +37 -0
- data/lib/sqlpostgres/PgMacAddr.rb +21 -0
- data/lib/sqlpostgres/PgPath.rb +64 -0
- data/lib/sqlpostgres/PgPoint.rb +65 -0
- data/lib/sqlpostgres/PgPolygon.rb +56 -0
- data/lib/sqlpostgres/PgTime.rb +77 -0
- data/lib/sqlpostgres/PgTimeWithTimeZone.rb +98 -0
- data/lib/sqlpostgres/PgTimestamp.rb +93 -0
- data/lib/sqlpostgres/PgTwoPoints.rb +54 -0
- data/lib/sqlpostgres/PgType.rb +34 -0
- data/lib/sqlpostgres/PgWrapper.rb +41 -0
- data/lib/sqlpostgres/Savepoint.rb +98 -0
- data/lib/sqlpostgres/Select.rb +855 -0
- data/lib/sqlpostgres/Transaction.rb +120 -0
- data/lib/sqlpostgres/Translate.rb +436 -0
- data/lib/sqlpostgres/Update.rb +188 -0
- data/lib/sqlpostgres.rb +67 -0
- data/test/Assert.rb +72 -0
- data/test/Connection.test.rb +246 -0
- data/test/Cursor.test.rb +190 -0
- data/test/Delete.test.rb +68 -0
- data/test/Insert.test.rb +123 -0
- data/test/MockPGconn.rb +62 -0
- data/test/NullConnection.test.rb +32 -0
- data/test/PgBit.test.rb +98 -0
- data/test/PgBox.test.rb +108 -0
- data/test/PgCidr.test.rb +61 -0
- data/test/PgCircle.test.rb +107 -0
- data/test/PgInet.test.rb +61 -0
- data/test/PgInterval.test.rb +180 -0
- data/test/PgLineSegment.test.rb +108 -0
- data/test/PgMacAddr.test.rb +61 -0
- data/test/PgPath.test.rb +106 -0
- data/test/PgPoint.test.rb +100 -0
- data/test/PgPolygon.test.rb +95 -0
- data/test/PgTime.test.rb +120 -0
- data/test/PgTimeWithTimeZone.test.rb +117 -0
- data/test/PgTimestamp.test.rb +134 -0
- data/test/RandomThings.rb +25 -0
- data/test/Savepoint.test.rb +286 -0
- data/test/Select.test.rb +930 -0
- data/test/Test.rb +62 -0
- data/test/TestConfig.rb +21 -0
- data/test/TestSetup.rb +13 -0
- data/test/TestUtil.rb +92 -0
- data/test/Transaction.test.rb +275 -0
- data/test/Translate.test.rb +354 -0
- data/test/Update.test.rb +227 -0
- data/test/roundtrip.test.rb +565 -0
- data/test/test +34 -0
- data/tools/exampleinserter/ExampleInserter.rb +177 -0
- data/tools/rdoc/ChangeLog +796 -0
- data/tools/rdoc/EXAMPLE.rb +48 -0
- data/tools/rdoc/MANIFEST +58 -0
- data/tools/rdoc/Makefile +27 -0
- data/tools/rdoc/NEW_FEATURES +226 -0
- data/tools/rdoc/README +390 -0
- data/tools/rdoc/ToDo +6 -0
- data/tools/rdoc/contrib/Index +6 -0
- data/tools/rdoc/contrib/xslfo/ChangeLog +181 -0
- data/tools/rdoc/contrib/xslfo/README +106 -0
- data/tools/rdoc/contrib/xslfo/TODO +10 -0
- data/tools/rdoc/contrib/xslfo/convert.xsl +151 -0
- data/tools/rdoc/contrib/xslfo/demo/README +21 -0
- data/tools/rdoc/contrib/xslfo/demo/rdocfo +99 -0
- data/tools/rdoc/contrib/xslfo/fcm.xsl +54 -0
- data/tools/rdoc/contrib/xslfo/files.xsl +62 -0
- data/tools/rdoc/contrib/xslfo/labeled-lists.xsl +66 -0
- data/tools/rdoc/contrib/xslfo/lists.xsl +44 -0
- data/tools/rdoc/contrib/xslfo/modules.xsl +152 -0
- data/tools/rdoc/contrib/xslfo/rdoc.xsl +75 -0
- data/tools/rdoc/contrib/xslfo/source.xsl +66 -0
- data/tools/rdoc/contrib/xslfo/styles.xsl +69 -0
- data/tools/rdoc/contrib/xslfo/tables.xsl +67 -0
- data/tools/rdoc/contrib/xslfo/utils.xsl +21 -0
- data/tools/rdoc/debian/changelog +33 -0
- data/tools/rdoc/debian/compat +1 -0
- data/tools/rdoc/debian/control +20 -0
- data/tools/rdoc/debian/copyright +10 -0
- data/tools/rdoc/debian/dirs +2 -0
- data/tools/rdoc/debian/docs +2 -0
- data/tools/rdoc/debian/rdoc.1 +252 -0
- data/tools/rdoc/debian/rdoc.manpages +1 -0
- data/tools/rdoc/debian/rdoc.pod +149 -0
- data/tools/rdoc/debian/rules +9 -0
- data/tools/rdoc/dot/dot.rb +255 -0
- data/tools/rdoc/etc/rdoc.dtd +203 -0
- data/tools/rdoc/install.rb +137 -0
- data/tools/rdoc/markup/install.rb +43 -0
- data/tools/rdoc/markup/sample/sample.rb +42 -0
- data/tools/rdoc/markup/simple_markup/fragments.rb +323 -0
- data/tools/rdoc/markup/simple_markup/inline.rb +348 -0
- data/tools/rdoc/markup/simple_markup/lines.rb +147 -0
- data/tools/rdoc/markup/simple_markup/preprocess.rb +68 -0
- data/tools/rdoc/markup/simple_markup/to_html.rb +281 -0
- data/tools/rdoc/markup/simple_markup.rb +474 -0
- data/tools/rdoc/markup/test/AllTests.rb +2 -0
- data/tools/rdoc/markup/test/TestInline.rb +151 -0
- data/tools/rdoc/markup/test/TestParse.rb +411 -0
- data/tools/rdoc/rdoc/code_objects.rb +536 -0
- data/tools/rdoc/rdoc/diagram.rb +331 -0
- data/tools/rdoc/rdoc/generators/chm_generator.rb +112 -0
- data/tools/rdoc/rdoc/generators/html_generator.rb +1268 -0
- data/tools/rdoc/rdoc/generators/template/chm/chm.rb +86 -0
- data/tools/rdoc/rdoc/generators/template/html/html.rb +705 -0
- data/tools/rdoc/rdoc/generators/template/html/kilmer.rb +377 -0
- data/tools/rdoc/rdoc/generators/template/xml/rdf.rb +110 -0
- data/tools/rdoc/rdoc/generators/template/xml/xml.rb +110 -0
- data/tools/rdoc/rdoc/generators/xml_generator.rb +130 -0
- data/tools/rdoc/rdoc/options.rb +451 -0
- data/tools/rdoc/rdoc/parsers/parse_c.rb +287 -0
- data/tools/rdoc/rdoc/parsers/parse_f95.rb +118 -0
- data/tools/rdoc/rdoc/parsers/parse_rb.rb +2311 -0
- data/tools/rdoc/rdoc/parsers/parse_simple.rb +37 -0
- data/tools/rdoc/rdoc/parsers/parserfactory.rb +75 -0
- data/tools/rdoc/rdoc/rdoc.rb +219 -0
- data/tools/rdoc/rdoc/template.rb +234 -0
- data/tools/rdoc/rdoc/tokenstream.rb +25 -0
- data/tools/rdoc/rdoc.rb +9 -0
- metadata +291 -0
@@ -0,0 +1,411 @@
|
|
1
|
+
require 'rubyunit'
|
2
|
+
|
3
|
+
$:.unshift "../.."
|
4
|
+
|
5
|
+
require 'markup/simple_markup'
|
6
|
+
include SM
|
7
|
+
|
8
|
+
class TestParse < RUNIT::TestCase
|
9
|
+
|
10
|
+
class MockOutput
|
11
|
+
def start_accepting
|
12
|
+
@res = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def end_accepting
|
16
|
+
@res
|
17
|
+
end
|
18
|
+
|
19
|
+
def accept_paragraph(am, fragment)
|
20
|
+
@res << fragment.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def accept_verbatim(am, fragment)
|
24
|
+
@res << fragment.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def accept_list_start(am, fragment)
|
28
|
+
@res << fragment.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def accept_list_end(am, fragment)
|
32
|
+
@res << fragment.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def accept_list_item(am, fragment)
|
36
|
+
@res << fragment.to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
def accept_blank_line(am, fragment)
|
40
|
+
@res << fragment.to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
def accept_heading(am, fragment)
|
44
|
+
@res << fragment.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def accept_rule(am, fragment)
|
48
|
+
@res << fragment.to_s
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def basic_conv(str)
|
54
|
+
sm = SimpleMarkup.new
|
55
|
+
mock = MockOutput.new
|
56
|
+
sm.convert(str, mock)
|
57
|
+
sm.content
|
58
|
+
end
|
59
|
+
|
60
|
+
def line_types(str, expected)
|
61
|
+
p = SimpleMarkup.new
|
62
|
+
mock = MockOutput.new
|
63
|
+
p.convert(str, mock)
|
64
|
+
assert_equal(expected, p.get_line_types.map{|type| type.to_s[0,1]}.join(''))
|
65
|
+
end
|
66
|
+
|
67
|
+
def line_groups(str, expected)
|
68
|
+
p = SimpleMarkup.new
|
69
|
+
mock = MockOutput.new
|
70
|
+
|
71
|
+
block = p.convert(str, mock)
|
72
|
+
|
73
|
+
if block != expected
|
74
|
+
rows = (0...([expected.size, block.size].max)).collect{|i|
|
75
|
+
[expected[i]||"nil", block[i]||"nil"]
|
76
|
+
}
|
77
|
+
printf "\n\n%35s %35s\n", "Expected", "Got"
|
78
|
+
rows.each {|e,g| printf "%35s %35s\n", e.dump, g.dump }
|
79
|
+
end
|
80
|
+
|
81
|
+
assert_equal(expected, block)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_tabs
|
85
|
+
str = "hello\n dave"
|
86
|
+
assert_equal(str, basic_conv(str))
|
87
|
+
str = "hello\n\tdave"
|
88
|
+
assert_equal("hello\n dave", basic_conv(str))
|
89
|
+
str = "hello\n \tdave"
|
90
|
+
assert_equal("hello\n dave", basic_conv(str))
|
91
|
+
str = "hello\n \tdave"
|
92
|
+
assert_equal("hello\n dave", basic_conv(str))
|
93
|
+
str = "hello\n \tdave"
|
94
|
+
assert_equal("hello\n dave", basic_conv(str))
|
95
|
+
str = "hello\n \tdave"
|
96
|
+
assert_equal("hello\n dave", basic_conv(str))
|
97
|
+
str = "hello\n \tdave"
|
98
|
+
assert_equal("hello\n dave", basic_conv(str))
|
99
|
+
str = "hello\n \tdave"
|
100
|
+
assert_equal("hello\n dave", basic_conv(str))
|
101
|
+
str = "hello\n \tdave"
|
102
|
+
assert_equal("hello\n dave", basic_conv(str))
|
103
|
+
str = "hello\n \tdave"
|
104
|
+
assert_equal("hello\n dave", basic_conv(str))
|
105
|
+
str = ".\t\t."
|
106
|
+
assert_equal(". .", basic_conv(str))
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_whitespace
|
110
|
+
assert_equal("hello", basic_conv("hello"))
|
111
|
+
assert_equal("hello", basic_conv(" hello "))
|
112
|
+
assert_equal("hello", basic_conv(" \t \t hello\t\t"))
|
113
|
+
|
114
|
+
assert_equal("1\n 2\n 3", basic_conv("1\n 2\n 3"))
|
115
|
+
assert_equal("1\n 2\n 3", basic_conv(" 1\n 2\n 3"))
|
116
|
+
|
117
|
+
assert_equal("1\n 2\n 3\n1\n 2", basic_conv("1\n 2\n 3\n1\n 2"))
|
118
|
+
assert_equal("1\n 2\n 3\n1\n 2", basic_conv(" 1\n 2\n 3\n 1\n 2"))
|
119
|
+
|
120
|
+
assert_equal("1\n 2\n\n 3", basic_conv(" 1\n 2\n\n 3"))
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_types
|
124
|
+
str = "now is the time"
|
125
|
+
line_types(str, 'P')
|
126
|
+
|
127
|
+
str = "now is the time\nfor all good men"
|
128
|
+
line_types(str, 'PP')
|
129
|
+
|
130
|
+
str = "now is the time\n code\nfor all good men"
|
131
|
+
line_types(str, 'PVP')
|
132
|
+
|
133
|
+
str = "now is the time\n code\n more code\nfor all good men"
|
134
|
+
line_types(str, 'PVVP')
|
135
|
+
|
136
|
+
str = "now is\n---\nthe time"
|
137
|
+
line_types(str, 'PRP')
|
138
|
+
|
139
|
+
str = %{\
|
140
|
+
now is
|
141
|
+
* l1
|
142
|
+
* l2
|
143
|
+
the time}
|
144
|
+
line_types(str, 'PLLP')
|
145
|
+
|
146
|
+
str = %{\
|
147
|
+
now is
|
148
|
+
* l1
|
149
|
+
l1+
|
150
|
+
* l2
|
151
|
+
the time}
|
152
|
+
line_types(str, 'PLPLP')
|
153
|
+
|
154
|
+
str = %{\
|
155
|
+
now is
|
156
|
+
* l1
|
157
|
+
* l1.1
|
158
|
+
* l2
|
159
|
+
the time}
|
160
|
+
line_types(str, 'PLLLP')
|
161
|
+
|
162
|
+
str = %{\
|
163
|
+
now is
|
164
|
+
* l1
|
165
|
+
* l1.1
|
166
|
+
text
|
167
|
+
code
|
168
|
+
code
|
169
|
+
|
170
|
+
text
|
171
|
+
* l2
|
172
|
+
the time}
|
173
|
+
line_types(str, 'PLLPVVBPLP')
|
174
|
+
|
175
|
+
str = %{\
|
176
|
+
now is
|
177
|
+
1. l1
|
178
|
+
* l1.1
|
179
|
+
2. l2
|
180
|
+
the time}
|
181
|
+
line_types(str, 'PLLLP')
|
182
|
+
|
183
|
+
str = %{\
|
184
|
+
now is
|
185
|
+
[cat] l1
|
186
|
+
* l1.1
|
187
|
+
[dog] l2
|
188
|
+
the time}
|
189
|
+
line_types(str, 'PLLLP')
|
190
|
+
|
191
|
+
str = %{\
|
192
|
+
now is
|
193
|
+
[cat] l1
|
194
|
+
continuation
|
195
|
+
[dog] l2
|
196
|
+
the time}
|
197
|
+
line_types(str, 'PLPLP')
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_groups
|
201
|
+
str = "now is the time"
|
202
|
+
line_groups(str, ["L0: Paragraph\nnow is the time"] )
|
203
|
+
|
204
|
+
str = "now is the time\nfor all good men"
|
205
|
+
line_groups(str, ["L0: Paragraph\nnow is the time for all good men"] )
|
206
|
+
|
207
|
+
str = %{\
|
208
|
+
now is the time
|
209
|
+
code _line_ here
|
210
|
+
for all good men}
|
211
|
+
|
212
|
+
line_groups(str,
|
213
|
+
[ "L0: Paragraph\nnow is the time",
|
214
|
+
"L0: Verbatim\n code _line_ here\n",
|
215
|
+
"L0: Paragraph\nfor all good men"
|
216
|
+
] )
|
217
|
+
|
218
|
+
str = "now is the time\n code\n more code\nfor all good men"
|
219
|
+
line_groups(str,
|
220
|
+
[ "L0: Paragraph\nnow is the time",
|
221
|
+
"L0: Verbatim\n code\n more code\n",
|
222
|
+
"L0: Paragraph\nfor all good men"
|
223
|
+
] )
|
224
|
+
|
225
|
+
str = %{\
|
226
|
+
now is
|
227
|
+
* l1
|
228
|
+
* l2
|
229
|
+
the time}
|
230
|
+
line_groups(str,
|
231
|
+
[ "L0: Paragraph\nnow is",
|
232
|
+
"L1: ListStart\n",
|
233
|
+
"L1: ListItem\nl1",
|
234
|
+
"L1: ListItem\nl2",
|
235
|
+
"L1: ListEnd\n",
|
236
|
+
"L0: Paragraph\nthe time"
|
237
|
+
])
|
238
|
+
|
239
|
+
str = %{\
|
240
|
+
now is
|
241
|
+
* l1
|
242
|
+
l1+
|
243
|
+
* l2
|
244
|
+
the time}
|
245
|
+
line_groups(str,
|
246
|
+
[ "L0: Paragraph\nnow is",
|
247
|
+
"L1: ListStart\n",
|
248
|
+
"L1: ListItem\nl1 l1+",
|
249
|
+
"L1: ListItem\nl2",
|
250
|
+
"L1: ListEnd\n",
|
251
|
+
"L0: Paragraph\nthe time"
|
252
|
+
])
|
253
|
+
|
254
|
+
str = %{\
|
255
|
+
now is
|
256
|
+
* l1
|
257
|
+
* l1.1
|
258
|
+
* l2
|
259
|
+
the time}
|
260
|
+
line_groups(str,
|
261
|
+
[ "L0: Paragraph\nnow is",
|
262
|
+
"L1: ListStart\n",
|
263
|
+
"L1: ListItem\nl1",
|
264
|
+
"L2: ListStart\n",
|
265
|
+
"L2: ListItem\nl1.1",
|
266
|
+
"L2: ListEnd\n",
|
267
|
+
"L1: ListItem\nl2",
|
268
|
+
"L1: ListEnd\n",
|
269
|
+
"L0: Paragraph\nthe time"
|
270
|
+
])
|
271
|
+
|
272
|
+
|
273
|
+
str = %{\
|
274
|
+
now is
|
275
|
+
* l1
|
276
|
+
* l1.1
|
277
|
+
text
|
278
|
+
code
|
279
|
+
code
|
280
|
+
|
281
|
+
text
|
282
|
+
* l2
|
283
|
+
the time}
|
284
|
+
line_groups(str,
|
285
|
+
[ "L0: Paragraph\nnow is",
|
286
|
+
"L1: ListStart\n",
|
287
|
+
"L1: ListItem\nl1",
|
288
|
+
"L2: ListStart\n",
|
289
|
+
"L2: ListItem\nl1.1 text",
|
290
|
+
"L2: Verbatim\n code\n code\n",
|
291
|
+
"L2: BlankLine\n",
|
292
|
+
"L2: Paragraph\ntext",
|
293
|
+
"L2: ListEnd\n",
|
294
|
+
"L1: ListItem\nl2",
|
295
|
+
"L1: ListEnd\n",
|
296
|
+
"L0: Paragraph\nthe time"
|
297
|
+
])
|
298
|
+
|
299
|
+
|
300
|
+
str = %{\
|
301
|
+
now is
|
302
|
+
1. l1
|
303
|
+
* l1.1
|
304
|
+
2. l2
|
305
|
+
the time}
|
306
|
+
line_groups(str,
|
307
|
+
[ "L0: Paragraph\nnow is",
|
308
|
+
"L1: ListStart\n",
|
309
|
+
"L1: ListItem\nl1",
|
310
|
+
"L2: ListStart\n",
|
311
|
+
"L2: ListItem\nl1.1",
|
312
|
+
"L2: ListEnd\n",
|
313
|
+
"L1: ListItem\nl2",
|
314
|
+
"L1: ListEnd\n",
|
315
|
+
"L0: Paragraph\nthe time"
|
316
|
+
])
|
317
|
+
|
318
|
+
str = %{\
|
319
|
+
now is
|
320
|
+
[cat] l1
|
321
|
+
* l1.1
|
322
|
+
[dog] l2
|
323
|
+
the time}
|
324
|
+
line_groups(str,
|
325
|
+
[ "L0: Paragraph\nnow is",
|
326
|
+
"L1: ListStart\n",
|
327
|
+
"L1: ListItem\nl1",
|
328
|
+
"L2: ListStart\n",
|
329
|
+
"L2: ListItem\nl1.1",
|
330
|
+
"L2: ListEnd\n",
|
331
|
+
"L1: ListItem\nl2",
|
332
|
+
"L1: ListEnd\n",
|
333
|
+
"L0: Paragraph\nthe time"
|
334
|
+
])
|
335
|
+
|
336
|
+
str = %{\
|
337
|
+
now is
|
338
|
+
[cat] l1
|
339
|
+
continuation
|
340
|
+
[dog] l2
|
341
|
+
the time}
|
342
|
+
line_groups(str,
|
343
|
+
[ "L0: Paragraph\nnow is",
|
344
|
+
"L1: ListStart\n",
|
345
|
+
"L1: ListItem\nl1 continuation",
|
346
|
+
"L1: ListItem\nl2",
|
347
|
+
"L1: ListEnd\n",
|
348
|
+
"L0: Paragraph\nthe time"
|
349
|
+
])
|
350
|
+
|
351
|
+
|
352
|
+
end
|
353
|
+
|
354
|
+
def test_list_split
|
355
|
+
str = %{\
|
356
|
+
now is
|
357
|
+
* l1
|
358
|
+
1. n1
|
359
|
+
2. n2
|
360
|
+
* l2
|
361
|
+
the time}
|
362
|
+
line_groups(str,
|
363
|
+
[ "L0: Paragraph\nnow is",
|
364
|
+
"L1: ListStart\n",
|
365
|
+
"L1: ListItem\nl1",
|
366
|
+
"L1: ListEnd\n",
|
367
|
+
"L1: ListStart\n",
|
368
|
+
"L1: ListItem\nn1",
|
369
|
+
"L1: ListItem\nn2",
|
370
|
+
"L1: ListEnd\n",
|
371
|
+
"L1: ListStart\n",
|
372
|
+
"L1: ListItem\nl2",
|
373
|
+
"L1: ListEnd\n",
|
374
|
+
"L0: Paragraph\nthe time"
|
375
|
+
])
|
376
|
+
|
377
|
+
end
|
378
|
+
|
379
|
+
|
380
|
+
def test_headings
|
381
|
+
str = "= heading one"
|
382
|
+
line_groups(str,
|
383
|
+
[ "L0: Heading\nheading one"
|
384
|
+
])
|
385
|
+
|
386
|
+
str = "=== heading three"
|
387
|
+
line_groups(str,
|
388
|
+
[ "L0: Heading\nheading three"
|
389
|
+
])
|
390
|
+
|
391
|
+
str = "text\n === heading three"
|
392
|
+
line_groups(str,
|
393
|
+
[ "L0: Paragraph\ntext",
|
394
|
+
"L0: Verbatim\n === heading three\n"
|
395
|
+
])
|
396
|
+
|
397
|
+
str = "text\n code\n === heading three"
|
398
|
+
line_groups(str,
|
399
|
+
[ "L0: Paragraph\ntext",
|
400
|
+
"L0: Verbatim\n code\n === heading three\n"
|
401
|
+
])
|
402
|
+
|
403
|
+
str = "text\n code\n=== heading three"
|
404
|
+
line_groups(str,
|
405
|
+
[ "L0: Paragraph\ntext",
|
406
|
+
"L0: Verbatim\n code\n",
|
407
|
+
"L0: Heading\nheading three"
|
408
|
+
])
|
409
|
+
|
410
|
+
end
|
411
|
+
end
|