less 0.8.13 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. data/README.md +10 -1
  2. data/Rakefile +21 -3
  3. data/VERSION +1 -1
  4. data/bin/lessc +0 -8
  5. data/less.gemspec +138 -15
  6. data/lib/less.rb +67 -11
  7. data/lib/less/command.rb +24 -25
  8. data/lib/less/engine.rb +36 -140
  9. data/lib/less/engine/builder.rb +8 -0
  10. data/lib/less/engine/less.tt +374 -0
  11. data/lib/less/engine/nodes.rb +8 -0
  12. data/lib/less/engine/nodes/element.rb +150 -0
  13. data/lib/less/engine/nodes/entity.rb +73 -0
  14. data/lib/less/engine/nodes/function.rb +82 -0
  15. data/lib/less/engine/nodes/literal.rb +135 -0
  16. data/lib/less/engine/nodes/property.rb +112 -0
  17. data/lib/less/engine/nodes/selector.rb +39 -0
  18. data/lib/less/engine/parser.rb +3860 -0
  19. data/lib/vendor/treetop/.gitignore +7 -0
  20. data/lib/vendor/treetop/LICENSE +19 -0
  21. data/lib/vendor/treetop/README +164 -0
  22. data/lib/vendor/treetop/Rakefile +19 -0
  23. data/lib/vendor/treetop/benchmark/seqpar.gnuplot +15 -0
  24. data/lib/vendor/treetop/benchmark/seqpar.treetop +16 -0
  25. data/lib/vendor/treetop/benchmark/seqpar_benchmark.rb +107 -0
  26. data/lib/vendor/treetop/bin/tt +28 -0
  27. data/lib/vendor/treetop/lib/treetop.rb +8 -0
  28. data/lib/vendor/treetop/lib/treetop/bootstrap_gen_1_metagrammar.rb +45 -0
  29. data/lib/vendor/treetop/lib/treetop/compiler.rb +6 -0
  30. data/lib/vendor/treetop/lib/treetop/compiler/grammar_compiler.rb +42 -0
  31. data/lib/vendor/treetop/lib/treetop/compiler/lexical_address_space.rb +17 -0
  32. data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.rb +3097 -0
  33. data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.treetop +408 -0
  34. data/lib/vendor/treetop/lib/treetop/compiler/node_classes.rb +19 -0
  35. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/anything_symbol.rb +18 -0
  36. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/atomic_expression.rb +14 -0
  37. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/character_class.rb +23 -0
  38. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/choice.rb +31 -0
  39. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/declaration_sequence.rb +24 -0
  40. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/grammar.rb +28 -0
  41. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/inline_module.rb +27 -0
  42. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/nonterminal.rb +13 -0
  43. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/optional.rb +19 -0
  44. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parenthesized_expression.rb +9 -0
  45. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_expression.rb +146 -0
  46. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_rule.rb +55 -0
  47. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/predicate.rb +45 -0
  48. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/repetition.rb +55 -0
  49. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/sequence.rb +68 -0
  50. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/terminal.rb +20 -0
  51. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/transient_prefix.rb +9 -0
  52. data/lib/vendor/treetop/lib/treetop/compiler/node_classes/treetop_file.rb +9 -0
  53. data/lib/vendor/treetop/lib/treetop/compiler/ruby_builder.rb +113 -0
  54. data/lib/vendor/treetop/lib/treetop/ruby_extensions.rb +2 -0
  55. data/lib/vendor/treetop/lib/treetop/ruby_extensions/string.rb +42 -0
  56. data/lib/vendor/treetop/lib/treetop/runtime.rb +5 -0
  57. data/lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb +109 -0
  58. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list.rb +4 -0
  59. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/head_node.rb +15 -0
  60. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +200 -0
  61. data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/node.rb +164 -0
  62. data/lib/vendor/treetop/lib/treetop/runtime/syntax_node.rb +90 -0
  63. data/lib/vendor/treetop/lib/treetop/runtime/terminal_parse_failure.rb +16 -0
  64. data/lib/vendor/treetop/lib/treetop/runtime/terminal_syntax_node.rb +17 -0
  65. data/lib/vendor/treetop/lib/treetop/version.rb +9 -0
  66. data/lib/vendor/treetop/spec/compiler/and_predicate_spec.rb +36 -0
  67. data/lib/vendor/treetop/spec/compiler/anything_symbol_spec.rb +44 -0
  68. data/lib/vendor/treetop/spec/compiler/character_class_spec.rb +247 -0
  69. data/lib/vendor/treetop/spec/compiler/choice_spec.rb +80 -0
  70. data/lib/vendor/treetop/spec/compiler/circular_compilation_spec.rb +28 -0
  71. data/lib/vendor/treetop/spec/compiler/failure_propagation_functional_spec.rb +21 -0
  72. data/lib/vendor/treetop/spec/compiler/grammar_compiler_spec.rb +84 -0
  73. data/lib/vendor/treetop/spec/compiler/grammar_spec.rb +41 -0
  74. data/lib/vendor/treetop/spec/compiler/nonterminal_symbol_spec.rb +40 -0
  75. data/lib/vendor/treetop/spec/compiler/not_predicate_spec.rb +38 -0
  76. data/lib/vendor/treetop/spec/compiler/one_or_more_spec.rb +35 -0
  77. data/lib/vendor/treetop/spec/compiler/optional_spec.rb +37 -0
  78. data/lib/vendor/treetop/spec/compiler/parenthesized_expression_spec.rb +19 -0
  79. data/lib/vendor/treetop/spec/compiler/parsing_rule_spec.rb +32 -0
  80. data/lib/vendor/treetop/spec/compiler/sequence_spec.rb +115 -0
  81. data/lib/vendor/treetop/spec/compiler/terminal_spec.rb +81 -0
  82. data/lib/vendor/treetop/spec/compiler/terminal_symbol_spec.rb +37 -0
  83. data/lib/vendor/treetop/spec/compiler/test_grammar.treetop +7 -0
  84. data/lib/vendor/treetop/spec/compiler/test_grammar.tt +7 -0
  85. data/lib/vendor/treetop/spec/compiler/test_grammar_do.treetop +7 -0
  86. data/lib/vendor/treetop/spec/compiler/zero_or_more_spec.rb +56 -0
  87. data/lib/vendor/treetop/spec/composition/a.treetop +11 -0
  88. data/lib/vendor/treetop/spec/composition/b.treetop +11 -0
  89. data/lib/vendor/treetop/spec/composition/c.treetop +10 -0
  90. data/lib/vendor/treetop/spec/composition/d.treetop +10 -0
  91. data/lib/vendor/treetop/spec/composition/f.treetop +17 -0
  92. data/lib/vendor/treetop/spec/composition/grammar_composition_spec.rb +40 -0
  93. data/lib/vendor/treetop/spec/composition/subfolder/e_includes_c.treetop +15 -0
  94. data/lib/vendor/treetop/spec/ruby_extensions/string_spec.rb +32 -0
  95. data/lib/vendor/treetop/spec/runtime/compiled_parser_spec.rb +101 -0
  96. data/lib/vendor/treetop/spec/runtime/interval_skip_list/delete_spec.rb +147 -0
  97. data/lib/vendor/treetop/spec/runtime/interval_skip_list/expire_range_spec.rb +349 -0
  98. data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_and_delete_node.rb +385 -0
  99. data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_spec.rb +660 -0
  100. data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +6175 -0
  101. data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +58 -0
  102. data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture.rb +23 -0
  103. data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +164 -0
  104. data/lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb +84 -0
  105. data/lib/vendor/treetop/spec/runtime/syntax_node_spec.rb +68 -0
  106. data/lib/vendor/treetop/spec/spec_helper.rb +106 -0
  107. data/lib/vendor/treetop/spec/spec_suite.rb +4 -0
  108. data/lib/vendor/treetop/treetop.gemspec +17 -0
  109. data/spec/command_spec.rb +2 -6
  110. data/spec/css/accessors-1.0.css +18 -0
  111. data/spec/css/big-1.0.css +3768 -0
  112. data/spec/css/comments-1.0.css +9 -0
  113. data/spec/css/css-1.0.css +40 -0
  114. data/spec/css/functions-1.0.css +6 -0
  115. data/spec/css/import-1.0.css +11 -0
  116. data/spec/css/mixins-1.0.css +28 -0
  117. data/spec/css/operations-1.0.css +28 -0
  118. data/spec/css/rulesets-1.0.css +17 -0
  119. data/spec/css/scope-1.0.css +14 -0
  120. data/spec/css/strings-1.0.css +12 -0
  121. data/spec/css/variables-1.0.css +6 -0
  122. data/spec/css/whitespace-1.0.css +9 -0
  123. data/spec/engine_spec.rb +66 -18
  124. data/spec/less/accessors-1.0.less +20 -0
  125. data/spec/less/big-1.0.less +4810 -0
  126. data/spec/less/colors-1.0.less +0 -0
  127. data/spec/less/comments-1.0.less +46 -0
  128. data/spec/less/css-1.0.less +84 -0
  129. data/spec/less/exceptions/mixed-units-error.less +3 -0
  130. data/spec/less/exceptions/name-error-1.0.less +3 -0
  131. data/spec/less/exceptions/syntax-error-1.0.less +3 -0
  132. data/spec/less/functions-1.0.less +6 -0
  133. data/spec/less/import-1.0.less +7 -0
  134. data/spec/less/import/import-test-a.less +2 -0
  135. data/spec/less/import/import-test-b.less +8 -0
  136. data/spec/less/import/import-test-c.less +5 -0
  137. data/spec/less/mixins-1.0.less +43 -0
  138. data/spec/less/operations-1.0.less +39 -0
  139. data/spec/less/rulesets-1.0.less +30 -0
  140. data/spec/less/scope-1.0.less +33 -0
  141. data/spec/less/strings-1.0.less +14 -0
  142. data/spec/less/variables-1.0.less +18 -0
  143. data/spec/less/whitespace-1.0.less +21 -0
  144. data/spec/spec.css +79 -24
  145. data/spec/spec.less +2 -3
  146. data/spec/spec_helper.rb +4 -1
  147. metadata +136 -13
  148. data/lib/less/tree.rb +0 -82
  149. data/spec/css/less-0.8.10.css +0 -30
  150. data/spec/css/less-0.8.11.css +0 -31
  151. data/spec/css/less-0.8.12.css +0 -28
  152. data/spec/css/less-0.8.5.css +0 -24
  153. data/spec/css/less-0.8.6.css +0 -24
  154. data/spec/css/less-0.8.7.css +0 -24
  155. data/spec/css/less-0.8.8.css +0 -25
  156. data/spec/tree_spec.rb +0 -5
@@ -0,0 +1,385 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
+
3
+ describe "it is non-empty", :shared => true do
4
+ specify "#empty? returns false" do
5
+ list.should_not be_empty
6
+ end
7
+ end
8
+
9
+ describe "#nodes is an array of the three inserted nodes in key order", :shared => true do
10
+ specify "#nodes is an array of the three inserted nodes in key order" do
11
+ list.nodes.should == inserted_nodes.sort_by(&:key)
12
+ end
13
+ end
14
+
15
+ describe "it has nil forward pointers", :shared => true do
16
+ it "has nil forward pointers" do
17
+ inserted_node.forward.each do |next_pointer|
18
+ next_pointer.should be_nil
19
+ end
20
+ end
21
+ end
22
+
23
+ describe IntervalSkipList do
24
+ attr_reader :list
25
+
26
+ before do
27
+ @list = IntervalSkipList.new
28
+ end
29
+
30
+ describe " when nothing has been inserted" do
31
+ specify "#empty? returns true" do
32
+ list.should be_empty
33
+ end
34
+
35
+ specify "#nodes returns an empty array" do
36
+ list.nodes.should == []
37
+ end
38
+
39
+ describe "#head" do
40
+ attr_reader :head
41
+
42
+ before do
43
+ @head = list.head
44
+ end
45
+
46
+ it "#has a height of #max_height" do
47
+ head.height.should == list.max_height
48
+ end
49
+
50
+ it "has nil forward pointers" do
51
+ 0.upto(list.max_height - 1) do |i|
52
+ head.forward[i].should be_nil
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ describe " when 1 has been inserted" do
59
+ attr_reader :inserted_node, :inserted_nodes
60
+
61
+ def expected_node_heights
62
+ [1]
63
+ end
64
+
65
+ it_should_behave_like "#next_node_height is deterministic"
66
+
67
+ before do
68
+ @inserted_node = list.insert_node(1)
69
+ @inserted_nodes = [@inserted_node]
70
+ end
71
+
72
+ it_should_behave_like "it is non-empty"
73
+ it_should_behave_like "#nodes is an array of the three inserted nodes in key order"
74
+
75
+ describe "#head" do
76
+ attr_reader :head
77
+
78
+ before do
79
+ @head = list.head
80
+ end
81
+
82
+ it "has inserted_node.height forward pointers pointing at the inserted node" do
83
+ 0.upto(inserted_node.height - 1) do |i|
84
+ head.forward[i].should == inserted_node
85
+ end
86
+ end
87
+
88
+ it "has the rest of its forward pointers pointing at nil" do
89
+ inserted_node.height.upto(list.max_height - 1) do |i|
90
+ head.forward[i].should == nil
91
+ end
92
+ end
93
+ end
94
+
95
+ describe "the inserted node" do
96
+ it_should_behave_like "it has nil forward pointers"
97
+
98
+ it "has a height of the expected_node_heights.first" do
99
+ inserted_node.height.should == expected_node_heights.first
100
+ end
101
+
102
+ it "has a key of 1" do
103
+ inserted_node.key.should == 1
104
+ end
105
+ end
106
+
107
+ describe "and subsequently deleted" do
108
+ before do
109
+ list.delete_node(1)
110
+ end
111
+
112
+ specify "#empty? returns true" do
113
+ list.should be_empty
114
+ end
115
+ end
116
+ end
117
+
118
+ describe " when 1 and 3 have been inserted in order" do
119
+ attr_reader :inserted_nodes
120
+
121
+ def expected_node_heights
122
+ [1, 2]
123
+ end
124
+
125
+ it_should_behave_like "#next_node_height is deterministic"
126
+
127
+ before do
128
+ @inserted_nodes = []
129
+ inserted_nodes << list.insert_node(1)
130
+ inserted_nodes << list.insert_node(3)
131
+ end
132
+
133
+ it_should_behave_like "it is non-empty"
134
+ it_should_behave_like "#nodes is an array of the three inserted nodes in key order"
135
+
136
+ describe "the first inserted node" do
137
+ attr_reader :inserted_node
138
+
139
+ before do
140
+ @inserted_node = inserted_nodes[0]
141
+ end
142
+
143
+ it "has a key of 1" do
144
+ inserted_node.key.should == 1
145
+ end
146
+
147
+ it "has a height of the first expected node height" do
148
+ inserted_node.height.should == expected_node_heights[0]
149
+ end
150
+
151
+ it "has its single forward pointer pointing at the second inserted node" do
152
+ inserted_node.forward[0].should == inserted_nodes[1]
153
+ end
154
+ end
155
+
156
+ describe "the second inserted node" do
157
+ attr_reader :inserted_node
158
+
159
+ before do
160
+ @inserted_node = inserted_nodes[1]
161
+ end
162
+
163
+ it_should_behave_like "it has nil forward pointers"
164
+
165
+ it "has a key of 3" do
166
+ inserted_node.key.should == 3
167
+ end
168
+
169
+ it "has a height of the second expected node height" do
170
+ inserted_node.height.should == expected_node_heights[1]
171
+ end
172
+ end
173
+
174
+ describe "and 1 is subsequently deleted" do
175
+ before do
176
+ list.delete_node(1)
177
+ end
178
+
179
+ describe "the remaining node" do
180
+ attr_reader :inserted_node
181
+
182
+ before do
183
+ @inserted_node = inserted_nodes[1]
184
+ end
185
+
186
+ it "is the first node in the list" do
187
+ inserted_node.should == list.nodes[0]
188
+ end
189
+
190
+ it_should_behave_like "it has nil forward pointers"
191
+ end
192
+ end
193
+
194
+ describe "and 3 is subsequently deleted" do
195
+ before do
196
+ list.delete_node(3)
197
+ end
198
+
199
+ describe "the remaining node" do
200
+ attr_reader :inserted_node
201
+
202
+ before do
203
+ @inserted_node = inserted_nodes[0]
204
+ end
205
+
206
+ it "is the first node in the list" do
207
+ inserted_node.should == list.nodes[0]
208
+ end
209
+
210
+ it_should_behave_like "it has nil forward pointers"
211
+ end
212
+ end
213
+ end
214
+
215
+ describe " when 1, 3 and 7 have been inserted in order" do
216
+ attr_reader :inserted_nodes
217
+
218
+ def expected_node_heights
219
+ [1, 2, 1]
220
+ end
221
+
222
+ it_should_behave_like "#next_node_height is deterministic"
223
+
224
+ before do
225
+ @inserted_nodes = []
226
+ inserted_nodes << list.insert_node(1)
227
+ inserted_nodes << list.insert_node(3)
228
+ inserted_nodes << list.insert_node(7)
229
+ end
230
+
231
+ it_should_behave_like "it is non-empty"
232
+ it_should_behave_like "#nodes is an array of the three inserted nodes in key order"
233
+
234
+ describe "the first inserted node" do
235
+ attr_reader :inserted_node
236
+
237
+ before do
238
+ @inserted_node = inserted_nodes[0]
239
+ end
240
+
241
+ it "has a key of 1" do
242
+ inserted_node.key.should == 1
243
+ end
244
+
245
+ it "has a height of the first expected node height" do
246
+ inserted_node.height.should == expected_node_heights[0]
247
+ end
248
+
249
+ it "has its single forward pointer pointing at the second inserted node" do
250
+ inserted_node.forward[0].should == inserted_nodes[1]
251
+ end
252
+ end
253
+
254
+ describe "the second inserted node" do
255
+ attr_reader :inserted_node
256
+
257
+ before do
258
+ @inserted_node = inserted_nodes[1]
259
+ end
260
+
261
+ it "has a key of 3" do
262
+ inserted_node.key.should == 3
263
+ end
264
+
265
+ it "has a height of the second expected node height" do
266
+ inserted_node.height.should == expected_node_heights[1]
267
+ end
268
+
269
+ it "has a forward pointer at level 0 pointing to the third inserted node" do
270
+ inserted_node.forward[0].should == inserted_nodes[2]
271
+ end
272
+
273
+ it "has nil forward pointer at level 1" do
274
+ inserted_node.forward[1].should be_nil
275
+ end
276
+ end
277
+
278
+ describe "the third inserted node" do
279
+ attr_reader :inserted_node
280
+
281
+ before do
282
+ @inserted_node = inserted_nodes[2]
283
+ end
284
+
285
+ it_should_behave_like "it has nil forward pointers"
286
+
287
+ it "has a key of 3" do
288
+ inserted_node.key.should == 7
289
+ end
290
+
291
+ it "has a height of the third expected node height" do
292
+ inserted_node.height.should == expected_node_heights[2]
293
+ end
294
+ end
295
+
296
+ describe "and 3 is subsequently deleted" do
297
+ before do
298
+ list.delete_node(3)
299
+ end
300
+
301
+ specify "#head points at nil at levels 1 and 2" do
302
+ list.head.forward[1].should be_nil
303
+ list.head.forward[2].should be_nil
304
+ end
305
+
306
+ specify "#nodes contains the remaining nodes in order" do
307
+ list.nodes.should == [inserted_nodes[0], inserted_nodes[2]]
308
+ end
309
+ end
310
+ end
311
+
312
+ describe " when 7, 1 and 3 have been inserted in order" do
313
+ attr_reader :inserted_nodes
314
+
315
+ def expected_node_heights
316
+ [1, 1, 2]
317
+ end
318
+
319
+ it_should_behave_like "#next_node_height is deterministic"
320
+
321
+ before do
322
+ @inserted_nodes = []
323
+ inserted_nodes << list.insert_node(7)
324
+ inserted_nodes << list.insert_node(1)
325
+ inserted_nodes << list.insert_node(3)
326
+ end
327
+
328
+ it_should_behave_like "it is non-empty"
329
+ it_should_behave_like "#nodes is an array of the three inserted nodes in key order"
330
+
331
+ describe "the first inserted node" do
332
+ attr_reader :inserted_node
333
+
334
+ before do
335
+ @inserted_node = inserted_nodes[0]
336
+ end
337
+
338
+ it_should_behave_like "it has nil forward pointers"
339
+
340
+ it "has a key of 7" do
341
+ inserted_node.key.should == 7
342
+ end
343
+
344
+ it "has a height of the first expected node height" do
345
+ inserted_node.height.should == expected_node_heights[0]
346
+ end
347
+ end
348
+
349
+ describe "the second inserted node" do
350
+ attr_reader :inserted_node
351
+
352
+ before do
353
+ @inserted_node = inserted_nodes[1]
354
+ end
355
+
356
+ it "has a key of 1" do
357
+ inserted_node.key.should == 1
358
+ end
359
+
360
+ it "has a height of the second expected node height" do
361
+ inserted_node.height.should == expected_node_heights[1]
362
+ end
363
+
364
+ it "has a forward pointer at level 0 pointing to the second node in the list" do
365
+ inserted_node.forward[0].should == list.nodes[1]
366
+ end
367
+ end
368
+
369
+ describe "the third inserted node" do
370
+ attr_reader :inserted_node
371
+
372
+ before do
373
+ @inserted_node = inserted_nodes[2]
374
+ end
375
+
376
+ it "has a key of 3" do
377
+ inserted_node.key.should == 3
378
+ end
379
+
380
+ it "has a height of the third expected node height" do
381
+ inserted_node.height.should == expected_node_heights[2]
382
+ end
383
+ end
384
+ end
385
+ end
@@ -0,0 +1,660 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
+
3
+ describe IntervalSkipList, " when #next_node_height returns 1, 3, 2, 3, 1 in order" do
4
+ include IntervalSkipListSpecHelper
5
+ attr_reader :list, :node
6
+
7
+ before do
8
+ @list = IntervalSkipList.new
9
+ end
10
+
11
+ it_should_behave_like "#next_node_height is deterministic"
12
+
13
+ def expected_node_heights
14
+ [1, 3, 2, 3, 1]
15
+ end
16
+
17
+ describe ", when :a is inserted on 1..7" do
18
+ before do
19
+ list.insert(1..7, :a)
20
+ end
21
+
22
+ describe ", #containing" do
23
+ it "returns only :a from 2 through 6" do
24
+ (2..6).should contain_marker(:a)
25
+ end
26
+
27
+ it "returns nothing at 1 and 7" do
28
+ list.containing(1).should be_empty
29
+ list.containing(7).should be_empty
30
+ end
31
+ end
32
+
33
+ describe " #nodes[0]" do
34
+ before do
35
+ @node = list.nodes[0]
36
+ end
37
+
38
+ it "has a key of 1 and height of 1" do
39
+ node.key.should == 1
40
+ node.height.should == 1
41
+ end
42
+
43
+ it "has :a as its only marker at level 0" do
44
+ node.forward_markers[0].should have_marker(:a)
45
+ end
46
+
47
+ it "has no markers" do
48
+ node.markers.should be_empty
49
+ end
50
+
51
+ it "is an endpoint of only :a" do
52
+ node.endpoint_of.should have_marker(:a)
53
+ end
54
+ end
55
+
56
+ describe " #nodes[1]" do
57
+ before do
58
+ @node = list.nodes[1]
59
+ end
60
+
61
+ it "has a key of 7 and height of 3" do
62
+ node.key.should == 7
63
+ node.height.should == 3
64
+ end
65
+
66
+ it "has no forward markers at any level" do
67
+ node.forward_markers[0].should be_empty
68
+ node.forward_markers[1].should be_empty
69
+ node.forward_markers[2].should be_empty
70
+ end
71
+
72
+ it "has :a as its only marker" do
73
+ node.markers.should have_marker(:a)
74
+ end
75
+
76
+ it "is an endpoint of only :a" do
77
+ node.endpoint_of.should have_marker(:a)
78
+ end
79
+ end
80
+
81
+ describe ", and then :b is inserted on 1..5" do
82
+ before do
83
+ list.insert(1..5, :b)
84
+ end
85
+
86
+ describe ", #containing" do
87
+ it "returns only :a and :b from 2 through 4" do
88
+ (2..4).should contain_markers(:a, :b)
89
+ end
90
+
91
+ it "returns only :a from 5 through 6" do
92
+ (5..6).should contain_marker(:a)
93
+ end
94
+
95
+ it "returns nothing at 1 and 7" do
96
+ list.containing(1).should be_empty
97
+ list.containing(7).should be_empty
98
+ end
99
+ end
100
+
101
+ describe " #nodes[0]" do
102
+ before do
103
+ @node = list.nodes[0]
104
+ end
105
+
106
+ it "has a key of 1 and height of 1" do
107
+ node.key.should == 1
108
+ node.height.should == 1
109
+ end
110
+
111
+ it "has :a and :b as its only forward markers at level 0" do
112
+ node.forward_markers[0].should have_markers(:a, :b)
113
+ end
114
+
115
+ it "has no markers" do
116
+ node.markers.should be_empty
117
+ end
118
+
119
+ it "is an endpoint of only :a and :b" do
120
+ node.endpoint_of.should have_markers(:a, :b)
121
+ end
122
+ end
123
+
124
+ describe " #nodes[1]" do
125
+ before do
126
+ @node = list.nodes[1]
127
+ end
128
+
129
+ it "has a key of 5 and height of 2" do
130
+ node.key.should == 5
131
+ node.height.should == 2
132
+ end
133
+
134
+ it "has :a as its only forward marker at level 1" do
135
+ node.forward_markers[1].should have_marker(:a)
136
+ end
137
+
138
+ it "has no forward markers at level 0" do
139
+ node.forward_markers[0].should be_empty
140
+ end
141
+
142
+ it "has :a and :b as its only markers" do
143
+ node.markers.should have_markers(:a, :b)
144
+ end
145
+
146
+ it "is an endpoint of only :b" do
147
+ node.endpoint_of.should have_marker(:b)
148
+ end
149
+ end
150
+
151
+ describe " #nodes[2]" do
152
+ before do
153
+ @node = list.nodes[2]
154
+ end
155
+
156
+ it "has a key of 7 and height of 3" do
157
+ node.key.should == 7
158
+ node.height.should == 3
159
+ end
160
+
161
+ it "has no forward markers at any level" do
162
+ node.forward_markers[0].should be_empty
163
+ node.forward_markers[1].should be_empty
164
+ node.forward_markers[2].should be_empty
165
+ end
166
+
167
+ it "has :a its only marker" do
168
+ node.markers.should have_marker(:a)
169
+ end
170
+
171
+ it "is an endpoint of only :a" do
172
+ node.endpoint_of.should have_marker(:a)
173
+ end
174
+ end
175
+
176
+ describe ", and then :c is inserted on 1..3" do
177
+ before do
178
+ list.insert(1..3, :c)
179
+ end
180
+
181
+ describe ", #containing" do
182
+ it "returns only :a, :b, and :c for 2" do
183
+ (2..2).should contain_markers(:a, :b, :c)
184
+ end
185
+
186
+ it "returns only :a, :b from 3..4" do
187
+ (3..4).should contain_markers(:a, :b)
188
+ end
189
+
190
+ it "returns only :a from 5..6" do
191
+ (5..6).should contain_markers(:a)
192
+ end
193
+
194
+ it "returns nothing at 1 and 7" do
195
+ list.containing(1).should be_empty
196
+ list.containing(7).should be_empty
197
+ end
198
+ end
199
+
200
+ describe " #nodes[0]" do
201
+ before do
202
+ @node = list.nodes[0]
203
+ end
204
+
205
+ it "has a key of 1 and height of 1" do
206
+ node.key.should == 1
207
+ node.height.should == 1
208
+ end
209
+
210
+ it "has :a, :b, :c as its only forward markers at level 0" do
211
+ node.forward_markers[0].should have_markers(:a, :b, :c)
212
+ end
213
+
214
+ it "has no markers" do
215
+ node.markers.should be_empty
216
+ end
217
+
218
+ it "is an endpoint of only :a, :b, :c" do
219
+ node.endpoint_of.should have_markers(:a, :b, :c)
220
+ end
221
+ end
222
+
223
+ describe " #nodes[1]" do
224
+ before do
225
+ @node = list.nodes[1]
226
+ end
227
+
228
+ it "has a key of 3 and height of 3" do
229
+ node.key.should == 3
230
+ node.height.should == 3
231
+ end
232
+
233
+ it "has :a as its only forward marker at level 2" do
234
+ node.forward_markers[2].should have_marker(:a)
235
+ end
236
+
237
+ it "has :b as its only forward marker at level 1" do
238
+ node.forward_markers[1].should have_marker(:b)
239
+ end
240
+
241
+ it "has no forward markers at level 0" do
242
+ node.forward_markers[0].should be_empty
243
+ end
244
+
245
+ it "has :a, :b, and :c as its only markers" do
246
+ node.markers.should have_markers(:a, :b, :c)
247
+ end
248
+
249
+ it "is an endpoint of only :c" do
250
+ node.endpoint_of.should have_marker(:c)
251
+ end
252
+ end
253
+
254
+ describe " #nodes[2]" do
255
+ before do
256
+ @node = list.nodes[2]
257
+ end
258
+
259
+ it "has a key of 5 and height of 2" do
260
+ node.key.should == 5
261
+ node.height.should == 2
262
+ end
263
+
264
+ it "has no forward markers at any level" do
265
+ node.forward_markers[0].should be_empty
266
+ node.forward_markers[1].should be_empty
267
+ end
268
+
269
+ it "has :b as its only markers" do
270
+ node.markers.should have_marker(:b)
271
+ end
272
+
273
+ it "is an endpoint of only :b" do
274
+ node.endpoint_of.should have_marker(:b)
275
+ end
276
+ end
277
+
278
+ describe " #nodes[3]" do
279
+ before do
280
+ @node = list.nodes[3]
281
+ end
282
+
283
+ it "has a key of 7 and height of 3" do
284
+ node.key.should == 7
285
+ node.height.should == 3
286
+ end
287
+
288
+ it "has no forward markers at any level" do
289
+ node.forward_markers[0].should be_empty
290
+ node.forward_markers[1].should be_empty
291
+ node.forward_markers[2].should be_empty
292
+ end
293
+
294
+ it "has :a as its only marker" do
295
+ node.markers.should have_marker(:a)
296
+ end
297
+
298
+ it "is an endpoint of only :a" do
299
+ node.endpoint_of.should have_marker(:a)
300
+ end
301
+ end
302
+
303
+ describe ", and then :d is inserted on 1..9" do
304
+ before do
305
+ list.insert(1..9, :d)
306
+ end
307
+
308
+ describe ", #containing" do
309
+ it "returns only :a, :b, :c, and :d for 2" do
310
+ (2..2).should contain_markers(:a, :b, :c, :d)
311
+ end
312
+
313
+ it "returns only :a, :b from 3..4" do
314
+ (3..4).should contain_markers(:a, :b, :d)
315
+ end
316
+
317
+ it "returns only :a from 5..6" do
318
+ (5..6).should contain_markers(:a, :d)
319
+ end
320
+
321
+ it "returns only :a from 7..8" do
322
+ (7..8).should contain_markers(:d)
323
+ end
324
+
325
+ it "returns nothing at 1 and 9" do
326
+ list.containing(1).should be_empty
327
+ list.containing(9).should be_empty
328
+ end
329
+
330
+ it "returns nothing for -1, 0, and 10" do
331
+ list.containing(-1).should be_empty
332
+ list.containing(0).should be_empty
333
+ list.containing(10).should be_empty
334
+ end
335
+ end
336
+
337
+ describe " #nodes[0]" do
338
+ before do
339
+ @node = list.nodes[0]
340
+ end
341
+
342
+ it "has a key of 1 and height of 1" do
343
+ node.key.should == 1
344
+ node.height.should == 1
345
+ end
346
+
347
+ it "has :a, :b, :c, :d as its only forward markers at level 0" do
348
+ node.forward_markers[0].should have_markers(:a, :b, :c, :d)
349
+ end
350
+
351
+ it "has no markers" do
352
+ node.markers.should be_empty
353
+ end
354
+
355
+ it "is an endpoint of only :a, :b, :c, and :d" do
356
+ node.endpoint_of.should have_markers(:a, :b, :c, :d)
357
+ end
358
+ end
359
+
360
+ describe " #nodes[1]" do
361
+ before do
362
+ @node = list.nodes[1]
363
+ end
364
+
365
+ it "has a key of 3 and height of 3" do
366
+ node.key.should == 3
367
+ node.height.should == 3
368
+ end
369
+
370
+ it "has :a and :d as its only forward markers at level 2" do
371
+ node.forward_markers[2].should have_markers(:a, :d)
372
+ end
373
+
374
+ it "has :b as its only marker at level 1" do
375
+ node.forward_markers[1].should have_marker(:b)
376
+ end
377
+
378
+ it "has no forward markers at level 0" do
379
+ node.forward_markers[0].should be_empty
380
+ end
381
+
382
+ it "has :a, :b, :c, :d as its only markers" do
383
+ node.markers.should have_markers(:a, :b, :c, :d)
384
+ end
385
+
386
+ it "is an endpoint of only :c" do
387
+ node.endpoint_of.should have_marker(:c)
388
+ end
389
+ end
390
+
391
+ describe " #nodes[2]" do
392
+ before do
393
+ @node = list.nodes[2]
394
+ end
395
+
396
+ it "has a key of 5 and height of 2" do
397
+ node.key.should == 5
398
+ node.height.should == 2
399
+ end
400
+
401
+ it "has no markers on any level" do
402
+ node.forward_markers[0].should be_empty
403
+ node.forward_markers[1].should be_empty
404
+ end
405
+
406
+ it "has :b as its only marker" do
407
+ node.markers.should have_marker(:b)
408
+ end
409
+
410
+ it "is an endpoint of only :b" do
411
+ node.endpoint_of.should have_marker(:b)
412
+ end
413
+ end
414
+
415
+ describe " #nodes[3]" do
416
+ before do
417
+ @node = list.nodes[3]
418
+ end
419
+
420
+ it "has a key of 7 and height of 3" do
421
+ node.key.should == 7
422
+ node.height.should == 3
423
+ end
424
+
425
+ it "has :d as its only marker at level 0" do
426
+ node.forward_markers[0].should have_marker(:d)
427
+ end
428
+
429
+ it "has no forward markers at levels 1 and 2" do
430
+ node.forward_markers[1].should be_empty
431
+ node.forward_markers[2].should be_empty
432
+ end
433
+
434
+ it "has :a, :d as its only markers" do
435
+ node.markers.should have_markers(:a, :d)
436
+ end
437
+
438
+ it "is an endpoint of only :a" do
439
+ node.endpoint_of.should have_marker(:a)
440
+ end
441
+ end
442
+
443
+ describe " #nodes[4]" do
444
+ before do
445
+ @node = list.nodes[4]
446
+ end
447
+
448
+ it "has a key of 9 and height of 1" do
449
+ node.key.should == 9
450
+ node.height.should == 1
451
+ end
452
+
453
+ it "has no forward markers at level 0" do
454
+ node.forward_markers[0].should be_empty
455
+ end
456
+
457
+ it "has :d as its only marker" do
458
+ node.markers.should have_marker(:d)
459
+ end
460
+
461
+ it "is an endpoint of only :d" do
462
+ node.endpoint_of.should have_marker(:d)
463
+ end
464
+ end
465
+
466
+ describe ", and then :d is deleted" do
467
+ before do
468
+ list.delete(:d)
469
+ end
470
+
471
+ it "has only 4 nodes" do
472
+ list.nodes.size.should == 4
473
+ end
474
+
475
+ describe " #nodes[0]" do
476
+ before do
477
+ @node = list.nodes[0]
478
+ end
479
+
480
+ it "has a key of 1 and height of 1" do
481
+ node.key.should == 1
482
+ node.height.should == 1
483
+ end
484
+
485
+ it "has :a, :b, and :c as its only forward markers at level 0" do
486
+ node.forward_markers[0].should have_markers(:a, :b, :c)
487
+ end
488
+ end
489
+
490
+ describe " #nodes[1]" do
491
+ before do
492
+ @node = list.nodes[1]
493
+ end
494
+
495
+ it "has a key of 3 and height of 3" do
496
+ node.key.should == 3
497
+ node.height.should == 3
498
+ end
499
+
500
+ it "has :a as its only forward marker at level 2" do
501
+ node.forward_markers[2].should have_marker(:a)
502
+ end
503
+
504
+ it "has :b as its only forward marker at level 1" do
505
+ node.forward_markers[1].should have_marker(:b)
506
+ end
507
+
508
+ it "has no forward markers at level 0" do
509
+ node.forward_markers[0].should be_empty
510
+ end
511
+
512
+ it "has :a, :b, and :c as its only markers" do
513
+ node.markers.should have_markers(:a, :b, :c)
514
+ end
515
+
516
+ it "is the endpoint of only :c" do
517
+ node.endpoint_of.should have_marker(:c)
518
+ end
519
+ end
520
+
521
+ describe " #nodes[2]" do
522
+ before do
523
+ @node = list.nodes[2]
524
+ end
525
+
526
+ it "has a key of 5 and height of 2" do
527
+ node.key.should == 5
528
+ node.height.should == 2
529
+ end
530
+
531
+ it "has no forward markers at any level" do
532
+ node.forward_markers[0].should be_empty
533
+ node.forward_markers[1].should be_empty
534
+ end
535
+
536
+ it "has :b as its only marker" do
537
+ node.markers.should have_marker(:b)
538
+ end
539
+
540
+ it "is the endpoint of only :b" do
541
+ node.endpoint_of.should have_marker(:b)
542
+ end
543
+ end
544
+
545
+ describe " #nodes[3]" do
546
+ before do
547
+ @node = list.nodes[3]
548
+ end
549
+
550
+ it "has a key of 7 and height of 3" do
551
+ node.key.should == 7
552
+ node.height.should == 3
553
+ end
554
+
555
+ it "has no forward markers at any level" do
556
+ node.forward_markers[0].should be_empty
557
+ node.forward_markers[1].should be_empty
558
+ node.forward_markers[2].should be_empty
559
+ end
560
+
561
+ it "has :a as its only marker" do
562
+ node.markers.should have_marker(:a)
563
+ end
564
+
565
+ it "is the endpoint of only :a" do
566
+ node.endpoint_of.should have_marker(:a)
567
+ end
568
+ end
569
+
570
+ describe ", and then :c is deleted" do
571
+ before do
572
+ list.delete(:c)
573
+ end
574
+
575
+ it "has only 3 nodes" do
576
+ list.nodes.size.should == 3
577
+ end
578
+
579
+ describe " #nodes[0]" do
580
+ before do
581
+ @node = list.nodes[0]
582
+ end
583
+
584
+ it "has a key of 1 and height of 1" do
585
+ node.key.should == 1
586
+ node.height.should == 1
587
+ end
588
+
589
+ it "has :a and :b as its only forward markers at level 0" do
590
+ node.forward_markers[0].should have_markers(:a, :b)
591
+ end
592
+
593
+ it "has no markers" do
594
+ node.markers.should be_empty
595
+ end
596
+
597
+ it "is an endpoint of only :a and :b" do
598
+ node.endpoint_of.should have_markers(:a, :b)
599
+ end
600
+ end
601
+
602
+ describe " #nodes[1]" do
603
+ before do
604
+ @node = list.nodes[1]
605
+ end
606
+
607
+ it "has a key of 5 and height of 2" do
608
+ node.key.should == 5
609
+ node.height.should == 2
610
+ end
611
+
612
+ it "has :a as its only forward marker at level 1" do
613
+ node.forward_markers[1].should have_marker(:a)
614
+ end
615
+
616
+ it "has no forward markers at level 0" do
617
+ node.forward_markers[0].should be_empty
618
+ end
619
+
620
+ it "has :a and :b as its only markers" do
621
+ node.markers.should have_markers(:a, :b)
622
+ end
623
+
624
+ it "is an endpoint of only :b" do
625
+ node.endpoint_of.should have_marker(:b)
626
+ end
627
+ end
628
+
629
+ describe " #nodes[2]" do
630
+ before do
631
+ @node = list.nodes[2]
632
+ end
633
+
634
+ it "has a key of 7 and height of 3" do
635
+ node.key.should == 7
636
+ node.height.should == 3
637
+ end
638
+
639
+ it "has no forward markers at any level" do
640
+ node.forward_markers[0].should be_empty
641
+ node.forward_markers[1].should be_empty
642
+ node.forward_markers[2].should be_empty
643
+ end
644
+
645
+ it "has :a its only marker" do
646
+ node.markers.should have_marker(:a)
647
+ end
648
+
649
+ it "is an endpoint of only :a" do
650
+ node.endpoint_of.should have_marker(:a)
651
+ end
652
+ end
653
+ end
654
+ end
655
+ end
656
+ end
657
+ end
658
+ end
659
+ end
660
+