less 0.8.13 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -1
- data/Rakefile +21 -3
- data/VERSION +1 -1
- data/bin/lessc +0 -8
- data/less.gemspec +138 -15
- data/lib/less.rb +67 -11
- data/lib/less/command.rb +24 -25
- data/lib/less/engine.rb +36 -140
- data/lib/less/engine/builder.rb +8 -0
- data/lib/less/engine/less.tt +374 -0
- data/lib/less/engine/nodes.rb +8 -0
- data/lib/less/engine/nodes/element.rb +150 -0
- data/lib/less/engine/nodes/entity.rb +73 -0
- data/lib/less/engine/nodes/function.rb +82 -0
- data/lib/less/engine/nodes/literal.rb +135 -0
- data/lib/less/engine/nodes/property.rb +112 -0
- data/lib/less/engine/nodes/selector.rb +39 -0
- data/lib/less/engine/parser.rb +3860 -0
- data/lib/vendor/treetop/.gitignore +7 -0
- data/lib/vendor/treetop/LICENSE +19 -0
- data/lib/vendor/treetop/README +164 -0
- data/lib/vendor/treetop/Rakefile +19 -0
- data/lib/vendor/treetop/benchmark/seqpar.gnuplot +15 -0
- data/lib/vendor/treetop/benchmark/seqpar.treetop +16 -0
- data/lib/vendor/treetop/benchmark/seqpar_benchmark.rb +107 -0
- data/lib/vendor/treetop/bin/tt +28 -0
- data/lib/vendor/treetop/lib/treetop.rb +8 -0
- data/lib/vendor/treetop/lib/treetop/bootstrap_gen_1_metagrammar.rb +45 -0
- data/lib/vendor/treetop/lib/treetop/compiler.rb +6 -0
- data/lib/vendor/treetop/lib/treetop/compiler/grammar_compiler.rb +42 -0
- data/lib/vendor/treetop/lib/treetop/compiler/lexical_address_space.rb +17 -0
- data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.rb +3097 -0
- data/lib/vendor/treetop/lib/treetop/compiler/metagrammar.treetop +408 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes.rb +19 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/anything_symbol.rb +18 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/atomic_expression.rb +14 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/character_class.rb +23 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/choice.rb +31 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/declaration_sequence.rb +24 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/grammar.rb +28 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/inline_module.rb +27 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/nonterminal.rb +13 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/optional.rb +19 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parenthesized_expression.rb +9 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_expression.rb +146 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/parsing_rule.rb +55 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/predicate.rb +45 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/repetition.rb +55 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/sequence.rb +68 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/terminal.rb +20 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/transient_prefix.rb +9 -0
- data/lib/vendor/treetop/lib/treetop/compiler/node_classes/treetop_file.rb +9 -0
- data/lib/vendor/treetop/lib/treetop/compiler/ruby_builder.rb +113 -0
- data/lib/vendor/treetop/lib/treetop/ruby_extensions.rb +2 -0
- data/lib/vendor/treetop/lib/treetop/ruby_extensions/string.rb +42 -0
- data/lib/vendor/treetop/lib/treetop/runtime.rb +5 -0
- data/lib/vendor/treetop/lib/treetop/runtime/compiled_parser.rb +109 -0
- data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list.rb +4 -0
- data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/head_node.rb +15 -0
- data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +200 -0
- data/lib/vendor/treetop/lib/treetop/runtime/interval_skip_list/node.rb +164 -0
- data/lib/vendor/treetop/lib/treetop/runtime/syntax_node.rb +90 -0
- data/lib/vendor/treetop/lib/treetop/runtime/terminal_parse_failure.rb +16 -0
- data/lib/vendor/treetop/lib/treetop/runtime/terminal_syntax_node.rb +17 -0
- data/lib/vendor/treetop/lib/treetop/version.rb +9 -0
- data/lib/vendor/treetop/spec/compiler/and_predicate_spec.rb +36 -0
- data/lib/vendor/treetop/spec/compiler/anything_symbol_spec.rb +44 -0
- data/lib/vendor/treetop/spec/compiler/character_class_spec.rb +247 -0
- data/lib/vendor/treetop/spec/compiler/choice_spec.rb +80 -0
- data/lib/vendor/treetop/spec/compiler/circular_compilation_spec.rb +28 -0
- data/lib/vendor/treetop/spec/compiler/failure_propagation_functional_spec.rb +21 -0
- data/lib/vendor/treetop/spec/compiler/grammar_compiler_spec.rb +84 -0
- data/lib/vendor/treetop/spec/compiler/grammar_spec.rb +41 -0
- data/lib/vendor/treetop/spec/compiler/nonterminal_symbol_spec.rb +40 -0
- data/lib/vendor/treetop/spec/compiler/not_predicate_spec.rb +38 -0
- data/lib/vendor/treetop/spec/compiler/one_or_more_spec.rb +35 -0
- data/lib/vendor/treetop/spec/compiler/optional_spec.rb +37 -0
- data/lib/vendor/treetop/spec/compiler/parenthesized_expression_spec.rb +19 -0
- data/lib/vendor/treetop/spec/compiler/parsing_rule_spec.rb +32 -0
- data/lib/vendor/treetop/spec/compiler/sequence_spec.rb +115 -0
- data/lib/vendor/treetop/spec/compiler/terminal_spec.rb +81 -0
- data/lib/vendor/treetop/spec/compiler/terminal_symbol_spec.rb +37 -0
- data/lib/vendor/treetop/spec/compiler/test_grammar.treetop +7 -0
- data/lib/vendor/treetop/spec/compiler/test_grammar.tt +7 -0
- data/lib/vendor/treetop/spec/compiler/test_grammar_do.treetop +7 -0
- data/lib/vendor/treetop/spec/compiler/zero_or_more_spec.rb +56 -0
- data/lib/vendor/treetop/spec/composition/a.treetop +11 -0
- data/lib/vendor/treetop/spec/composition/b.treetop +11 -0
- data/lib/vendor/treetop/spec/composition/c.treetop +10 -0
- data/lib/vendor/treetop/spec/composition/d.treetop +10 -0
- data/lib/vendor/treetop/spec/composition/f.treetop +17 -0
- data/lib/vendor/treetop/spec/composition/grammar_composition_spec.rb +40 -0
- data/lib/vendor/treetop/spec/composition/subfolder/e_includes_c.treetop +15 -0
- data/lib/vendor/treetop/spec/ruby_extensions/string_spec.rb +32 -0
- data/lib/vendor/treetop/spec/runtime/compiled_parser_spec.rb +101 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/delete_spec.rb +147 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/expire_range_spec.rb +349 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_and_delete_node.rb +385 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/insert_spec.rb +660 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +6175 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +58 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture.rb +23 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +164 -0
- data/lib/vendor/treetop/spec/runtime/interval_skip_list/spec_helper.rb +84 -0
- data/lib/vendor/treetop/spec/runtime/syntax_node_spec.rb +68 -0
- data/lib/vendor/treetop/spec/spec_helper.rb +106 -0
- data/lib/vendor/treetop/spec/spec_suite.rb +4 -0
- data/lib/vendor/treetop/treetop.gemspec +17 -0
- data/spec/command_spec.rb +2 -6
- data/spec/css/accessors-1.0.css +18 -0
- data/spec/css/big-1.0.css +3768 -0
- data/spec/css/comments-1.0.css +9 -0
- data/spec/css/css-1.0.css +40 -0
- data/spec/css/functions-1.0.css +6 -0
- data/spec/css/import-1.0.css +11 -0
- data/spec/css/mixins-1.0.css +28 -0
- data/spec/css/operations-1.0.css +28 -0
- data/spec/css/rulesets-1.0.css +17 -0
- data/spec/css/scope-1.0.css +14 -0
- data/spec/css/strings-1.0.css +12 -0
- data/spec/css/variables-1.0.css +6 -0
- data/spec/css/whitespace-1.0.css +9 -0
- data/spec/engine_spec.rb +66 -18
- data/spec/less/accessors-1.0.less +20 -0
- data/spec/less/big-1.0.less +4810 -0
- data/spec/less/colors-1.0.less +0 -0
- data/spec/less/comments-1.0.less +46 -0
- data/spec/less/css-1.0.less +84 -0
- data/spec/less/exceptions/mixed-units-error.less +3 -0
- data/spec/less/exceptions/name-error-1.0.less +3 -0
- data/spec/less/exceptions/syntax-error-1.0.less +3 -0
- data/spec/less/functions-1.0.less +6 -0
- data/spec/less/import-1.0.less +7 -0
- data/spec/less/import/import-test-a.less +2 -0
- data/spec/less/import/import-test-b.less +8 -0
- data/spec/less/import/import-test-c.less +5 -0
- data/spec/less/mixins-1.0.less +43 -0
- data/spec/less/operations-1.0.less +39 -0
- data/spec/less/rulesets-1.0.less +30 -0
- data/spec/less/scope-1.0.less +33 -0
- data/spec/less/strings-1.0.less +14 -0
- data/spec/less/variables-1.0.less +18 -0
- data/spec/less/whitespace-1.0.less +21 -0
- data/spec/spec.css +79 -24
- data/spec/spec.less +2 -3
- data/spec/spec_helper.rb +4 -1
- metadata +136 -13
- data/lib/less/tree.rb +0 -82
- data/spec/css/less-0.8.10.css +0 -30
- data/spec/css/less-0.8.11.css +0 -31
- data/spec/css/less-0.8.12.css +0 -28
- data/spec/css/less-0.8.5.css +0 -24
- data/spec/css/less-0.8.6.css +0 -24
- data/spec/css/less-0.8.7.css +0 -24
- data/spec/css/less-0.8.8.css +0 -25
- data/spec/tree_spec.rb +0 -5
@@ -0,0 +1,101 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
|
2
|
+
|
3
|
+
module CompiledParserSpec
|
4
|
+
describe Runtime::CompiledParser, "for a grammar with two rules" do
|
5
|
+
attr_reader :parser
|
6
|
+
|
7
|
+
testing_grammar %{
|
8
|
+
grammar TwoRules
|
9
|
+
rule a
|
10
|
+
'a'
|
11
|
+
end
|
12
|
+
|
13
|
+
rule b
|
14
|
+
'b'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
}
|
18
|
+
|
19
|
+
before do
|
20
|
+
@parser = parser_class_under_test.new
|
21
|
+
end
|
22
|
+
|
23
|
+
it "allows its root to be specified" do
|
24
|
+
parser.parse('a').should_not be_nil
|
25
|
+
parser.parse('b').should be_nil
|
26
|
+
|
27
|
+
parser.root = :b
|
28
|
+
parser.parse('b').should_not be_nil
|
29
|
+
parser.parse('a').should be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it "allows the requirement that all input be consumed to be disabled" do
|
33
|
+
parser.parse('ab').should be_nil
|
34
|
+
parser.consume_all_input = false
|
35
|
+
result = parser.parse('ab')
|
36
|
+
result.should_not be_nil
|
37
|
+
result.interval.should == (0...1)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "allows input to be parsed at a given index" do
|
41
|
+
parser.parse('ba').should be_nil
|
42
|
+
parser.parse('ba', :index => 1).should_not be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe Runtime::CompiledParser, "for a grammar with a choice between terminals" do
|
48
|
+
attr_reader :parser
|
49
|
+
|
50
|
+
testing_grammar %{
|
51
|
+
grammar Choice
|
52
|
+
rule choice
|
53
|
+
'a' / 'b' / 'c'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
}
|
57
|
+
|
58
|
+
before do
|
59
|
+
@parser = parser_class_under_test.new
|
60
|
+
end
|
61
|
+
|
62
|
+
it "provides #failure_reason, #failure_column, and #failure_line when there is a parse failure" do
|
63
|
+
parser.parse('z').should be_nil
|
64
|
+
parser.failure_reason.should == "Expected one of a, b, c at line 1, column 1 (byte 1) after "
|
65
|
+
parser.failure_line.should == 1
|
66
|
+
parser.failure_column.should == 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe Runtime::CompiledParser, "#terminal_failures" do
|
71
|
+
attr_reader:parser
|
72
|
+
|
73
|
+
testing_grammar %{
|
74
|
+
grammar SequenceOfTerminals
|
75
|
+
rule foo
|
76
|
+
'a' 'b' 'c'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
}
|
80
|
+
|
81
|
+
before do
|
82
|
+
@parser = parser_class_under_test.new
|
83
|
+
end
|
84
|
+
|
85
|
+
it "is reset between parses" do
|
86
|
+
parser.parse('ac')
|
87
|
+
terminal_failures = parser.terminal_failures
|
88
|
+
terminal_failures.size.should == 1
|
89
|
+
failure = terminal_failures.first
|
90
|
+
failure.index.should == 1
|
91
|
+
failure.expected_string.should == 'b'
|
92
|
+
|
93
|
+
parser.parse('b')
|
94
|
+
terminal_failures = parser.terminal_failures
|
95
|
+
terminal_failures.size.should == 1
|
96
|
+
failure = terminal_failures.first
|
97
|
+
failure.index.should == 0
|
98
|
+
failure.expected_string.should == 'a'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
|
2
|
+
|
3
|
+
class IntervalSkipList
|
4
|
+
public :insert_node, :delete_node, :head, :nodes
|
5
|
+
end
|
6
|
+
|
7
|
+
describe IntervalSkipList do
|
8
|
+
it_should_behave_like "the palindromic fixture"
|
9
|
+
|
10
|
+
describe " when :c is deleted" do
|
11
|
+
before do
|
12
|
+
list.delete(:c)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "[0]" do
|
16
|
+
before do
|
17
|
+
@node = list.nodes[0]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has a key of 1 and a height of 3" do
|
21
|
+
node.key.should == 1
|
22
|
+
node.height.should == 3
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has :f as its only forward marker at level 2" do
|
26
|
+
node.forward_markers[2].should have_markers(:f)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "has :a, :b, :d, and :e as its only forward markers at level 1" do
|
30
|
+
node.forward_markers[1].should have_markers(:a, :b, :d, :e)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has no forward markers at level 0" do
|
34
|
+
node.forward_markers[0].should be_empty
|
35
|
+
end
|
36
|
+
|
37
|
+
it "has no markers" do
|
38
|
+
node.markers.should be_empty
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "[1]" do
|
43
|
+
before do
|
44
|
+
@node = list.nodes[1]
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has a key of 3 and a height of 2" do
|
48
|
+
node.key.should == 3
|
49
|
+
node.height.should == 2
|
50
|
+
end
|
51
|
+
|
52
|
+
it "has :e as its only forward marker at level 1" do
|
53
|
+
node.forward_markers[1].should have_markers(:e)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "has :b and :d as its only forward markers at level 0" do
|
57
|
+
node.forward_markers[0].should have_markers(:b, :d)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "has :a, :b, :d, and :e as its only markers" do
|
61
|
+
node.markers.should have_markers(:a, :b, :d, :e)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "[2]" do
|
66
|
+
before do
|
67
|
+
@node = list.nodes[2]
|
68
|
+
end
|
69
|
+
|
70
|
+
it "has a key of 5 and a height of 1" do
|
71
|
+
node.key.should == 5
|
72
|
+
node.height.should == 1
|
73
|
+
end
|
74
|
+
|
75
|
+
it "has :d and :g as its only forward markers at level 0" do
|
76
|
+
node.forward_markers[0].should have_markers(:d, :g)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "has :b and :d as its only markers" do
|
80
|
+
node.markers.should have_markers(:b, :d)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "[3]" do
|
85
|
+
before do
|
86
|
+
@node = list.nodes[3]
|
87
|
+
end
|
88
|
+
|
89
|
+
it "has a key of 9 and a height of 1" do
|
90
|
+
node.key.should == 9
|
91
|
+
node.height.should == 1
|
92
|
+
end
|
93
|
+
|
94
|
+
it "has :g as its only forward marker at level 0" do
|
95
|
+
node.forward_markers[0].should have_markers(:g)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "has :d and :g as its only markers" do
|
99
|
+
node.markers.should have_markers(:d, :g)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "[4]" do
|
104
|
+
before do
|
105
|
+
@node = list.nodes[4]
|
106
|
+
end
|
107
|
+
|
108
|
+
it "has a key of 11 and a height of 2" do
|
109
|
+
node.key.should == 11
|
110
|
+
node.height.should == 2
|
111
|
+
end
|
112
|
+
|
113
|
+
it "has :g as its only forward marker at level 1" do
|
114
|
+
node.forward_markers[1].should have_markers(:g)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "has no forward markers at level 0" do
|
118
|
+
node.forward_markers[0].should be_empty
|
119
|
+
end
|
120
|
+
|
121
|
+
it "has :e and :g as its only markers" do
|
122
|
+
node.markers.should have_markers(:e, :g)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "[5]" do
|
127
|
+
before do
|
128
|
+
@node = list.nodes[5]
|
129
|
+
end
|
130
|
+
|
131
|
+
it "has a key of 13 and a height of 3" do
|
132
|
+
node.key.should == 13
|
133
|
+
node.height.should == 3
|
134
|
+
end
|
135
|
+
|
136
|
+
it "has no forward markers at any level" do
|
137
|
+
node.forward_markers[0].should be_empty
|
138
|
+
node.forward_markers[1].should be_empty
|
139
|
+
node.forward_markers[2].should be_empty
|
140
|
+
end
|
141
|
+
|
142
|
+
it "has :f and :g as its only markers" do
|
143
|
+
node.markers.should have_markers(:f, :g)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,349 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
|
2
|
+
|
3
|
+
describe IntervalSkipList do
|
4
|
+
it_should_behave_like "the palindromic fixture"
|
5
|
+
|
6
|
+
describe "#overlapping" do
|
7
|
+
it "returns intervals :d, :e, :f, and :g for 7..9" do
|
8
|
+
list.overlapping(7..9)[0].should have_markers(:d, :e, :f, :g)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns intervals :b, :c, :d, :e, :f, and :g for 3..7" do
|
12
|
+
list.overlapping(3..7)[0].should have_markers(:b, :c, :d, :e, :f, :g )
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns intervals :b, :c, :d, :e, :f, and :g for 3..6" do
|
16
|
+
list.overlapping(3..6)[0].should have_markers(:b, :c, :d, :e, :f, :g )
|
17
|
+
end
|
18
|
+
|
19
|
+
describe ", when :x is inserted on 3..7" do
|
20
|
+
before do
|
21
|
+
list.insert(3..7, :x)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns intervals :b, :c, :d, :e, :f, :x for 3..5" do
|
25
|
+
list.overlapping(3..5)[0].should have_markers(:b, :c, :d, :e, :f, :x)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
describe "when 7..7 is expired with a length change of 0" do
|
32
|
+
before do
|
33
|
+
list.expire(7..7, 0)
|
34
|
+
end
|
35
|
+
|
36
|
+
describe " #nodes" do
|
37
|
+
attr_reader :nodes, :node
|
38
|
+
|
39
|
+
before do
|
40
|
+
@nodes = list.nodes
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has a size of 4" do
|
44
|
+
nodes.size.should == 4
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "[0]" do
|
48
|
+
before do
|
49
|
+
@node = nodes[0]
|
50
|
+
end
|
51
|
+
|
52
|
+
it "has a key of 1 and a height of 3" do
|
53
|
+
node.key.should == 1
|
54
|
+
node.height.should == 3
|
55
|
+
end
|
56
|
+
|
57
|
+
it "has no forward markers at level 0" do
|
58
|
+
node.forward_markers[0].should be_empty
|
59
|
+
end
|
60
|
+
|
61
|
+
it "has :a and :b as its only forward markers on level 1" do
|
62
|
+
node.forward_markers[1].should have_markers(:a, :b)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "has :c as its only forward marker on level 2" do
|
66
|
+
node.forward_markers[2].should have_markers(:c)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "has no markers" do
|
70
|
+
node.markers.should be_empty
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "[1]" do
|
75
|
+
before do
|
76
|
+
@node = nodes[1]
|
77
|
+
end
|
78
|
+
|
79
|
+
it "has a key of 3 and a height of 2" do
|
80
|
+
node.key.should == 3
|
81
|
+
node.height.should == 2
|
82
|
+
end
|
83
|
+
|
84
|
+
it "has :b as its only forward marker on level 0" do
|
85
|
+
node.forward_markers[0].should have_markers(:b)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "has no forward markers on level 1" do
|
89
|
+
node.forward_markers[1].should be_empty
|
90
|
+
end
|
91
|
+
|
92
|
+
it "has :a and :b as its only markers" do
|
93
|
+
node.markers.should have_markers(:a, :b)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "[2]" do
|
98
|
+
before do
|
99
|
+
@node = nodes[2]
|
100
|
+
end
|
101
|
+
|
102
|
+
it "has a key of 5 and a height of 1" do
|
103
|
+
node.key.should == 5
|
104
|
+
node.height.should == 1
|
105
|
+
end
|
106
|
+
|
107
|
+
it "has no forward markers on level 0" do
|
108
|
+
node.forward_markers[0].should be_empty
|
109
|
+
end
|
110
|
+
|
111
|
+
it "has :b as its only marker" do
|
112
|
+
node.markers.should have_markers(:b)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "[3]" do
|
117
|
+
before do
|
118
|
+
@node = nodes[3]
|
119
|
+
end
|
120
|
+
|
121
|
+
it "has a key of 7 and a height of 3" do
|
122
|
+
node.key.should == 7
|
123
|
+
node.height.should == 3
|
124
|
+
end
|
125
|
+
|
126
|
+
it "has no forward markers at any level" do
|
127
|
+
node.forward_markers[0].should be_empty
|
128
|
+
node.forward_markers[1].should be_empty
|
129
|
+
node.forward_markers[2].should be_empty
|
130
|
+
end
|
131
|
+
|
132
|
+
it "has :c as its only marker" do
|
133
|
+
node.markers.should have_markers(:c)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "when 4..4 is expired with a length change of 2" do
|
140
|
+
before do
|
141
|
+
list.expire(4..4, 2)
|
142
|
+
end
|
143
|
+
|
144
|
+
describe " #nodes" do
|
145
|
+
attr_reader :nodes, :node
|
146
|
+
|
147
|
+
before do
|
148
|
+
@nodes = list.nodes
|
149
|
+
end
|
150
|
+
|
151
|
+
it "has a size of 4" do
|
152
|
+
nodes.size.should == 4
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "[0]" do
|
156
|
+
before do
|
157
|
+
@node = nodes[0]
|
158
|
+
end
|
159
|
+
|
160
|
+
it "has a key of 1 and a height of 3" do
|
161
|
+
node.key.should == 1
|
162
|
+
node.height.should == 3
|
163
|
+
end
|
164
|
+
|
165
|
+
it "has no forward markers at level 0 and 2" do
|
166
|
+
node.forward_markers[0].should be_empty
|
167
|
+
node.forward_markers[2].should be_empty
|
168
|
+
end
|
169
|
+
|
170
|
+
it "has :a as its only forward marker on level 1" do
|
171
|
+
node.forward_markers[1].should have_markers(:a)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "has no markers" do
|
175
|
+
node.markers.should be_empty
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "[1]" do
|
180
|
+
before do
|
181
|
+
@node = nodes[1]
|
182
|
+
end
|
183
|
+
|
184
|
+
it "has a key of 3 and a height of 2" do
|
185
|
+
node.key.should == 3
|
186
|
+
node.height.should == 2
|
187
|
+
end
|
188
|
+
|
189
|
+
it "has no forward markers at any level" do
|
190
|
+
node.forward_markers[0].should be_empty
|
191
|
+
node.forward_markers[1].should be_empty
|
192
|
+
end
|
193
|
+
|
194
|
+
it "has :a as its only marker" do
|
195
|
+
node.markers.should have_markers(:a)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe "[2]" do
|
200
|
+
before do
|
201
|
+
@node = nodes[2]
|
202
|
+
end
|
203
|
+
|
204
|
+
it "has a key of 7 and a height of 1" do
|
205
|
+
node.key.should == 7
|
206
|
+
node.height.should == 1
|
207
|
+
end
|
208
|
+
|
209
|
+
it "has :g as its only forward marker at level 0" do
|
210
|
+
node.forward_markers[0].should have_markers(:g)
|
211
|
+
end
|
212
|
+
|
213
|
+
it "has no markers" do
|
214
|
+
node.markers.should be_empty
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
describe "[3]" do
|
219
|
+
before do
|
220
|
+
@node = nodes[3]
|
221
|
+
end
|
222
|
+
|
223
|
+
it "has a key of 15 and a height of 3" do
|
224
|
+
node.key.should == 15
|
225
|
+
node.height.should == 3
|
226
|
+
end
|
227
|
+
|
228
|
+
it "has no forward markers at any level" do
|
229
|
+
node.forward_markers[0].should be_empty
|
230
|
+
node.forward_markers[1].should be_empty
|
231
|
+
node.forward_markers[2].should be_empty
|
232
|
+
end
|
233
|
+
|
234
|
+
it "has :g as its only marker" do
|
235
|
+
node.markers.should have_markers(:g)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
describe "when :x is inserted on 1..5, :y on 7..11, and :z on 9..13" do
|
242
|
+
before do
|
243
|
+
list.insert(1..5, :x)
|
244
|
+
list.insert(7..11, :y)
|
245
|
+
list.insert(9..13, :z)
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "when 4..8 is expired with a length change of -3" do
|
249
|
+
before do
|
250
|
+
list.expire(4..8, -3)
|
251
|
+
end
|
252
|
+
|
253
|
+
describe "#nodes" do
|
254
|
+
attr_reader :nodes, :node
|
255
|
+
before do
|
256
|
+
@nodes = list.nodes
|
257
|
+
end
|
258
|
+
|
259
|
+
it "has a size of 4" do
|
260
|
+
nodes.size.should == 4
|
261
|
+
end
|
262
|
+
|
263
|
+
describe "[0]" do
|
264
|
+
before do
|
265
|
+
@node = nodes[0]
|
266
|
+
end
|
267
|
+
|
268
|
+
it "has a key of 1 and height of 3" do
|
269
|
+
node.key.should == 1
|
270
|
+
node.height.should == 3
|
271
|
+
end
|
272
|
+
|
273
|
+
it "has :a as its only forward marker on level 1" do
|
274
|
+
node.forward_markers[1].should have_markers(:a)
|
275
|
+
end
|
276
|
+
|
277
|
+
it "has no forward markers at level 0 and 2" do
|
278
|
+
node.forward_markers[0].should be_empty
|
279
|
+
node.forward_markers[2].should be_empty
|
280
|
+
end
|
281
|
+
|
282
|
+
it "has no markers" do
|
283
|
+
node.markers.should be_empty
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
describe "[1]" do
|
288
|
+
before do
|
289
|
+
@node = nodes[1]
|
290
|
+
end
|
291
|
+
|
292
|
+
it "has a key of 3 and height of 2" do
|
293
|
+
node.key.should == 3
|
294
|
+
node.height.should == 2
|
295
|
+
end
|
296
|
+
|
297
|
+
it "has no forward markers" do
|
298
|
+
node.forward_markers[0].should be_empty
|
299
|
+
node.forward_markers[1].should be_empty
|
300
|
+
end
|
301
|
+
|
302
|
+
it "has :a as its only marker" do
|
303
|
+
node.markers.should have_markers(:a)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe "[2]" do
|
308
|
+
before do
|
309
|
+
@node = nodes[2]
|
310
|
+
end
|
311
|
+
|
312
|
+
it "has a key of 6 and a height of 1" do
|
313
|
+
node.key.should == 6
|
314
|
+
node.height.should == 1
|
315
|
+
end
|
316
|
+
|
317
|
+
it "has :z as its only forward marker at level 0" do
|
318
|
+
node.forward_markers[0].should have_markers(:z)
|
319
|
+
end
|
320
|
+
|
321
|
+
it "has no markers" do
|
322
|
+
node.markers.should be_empty
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
describe "[3]" do
|
327
|
+
before do
|
328
|
+
@node = nodes[3]
|
329
|
+
end
|
330
|
+
|
331
|
+
it "has a key of 10 and height of 3" do
|
332
|
+
node.key.should == 10
|
333
|
+
node.height.should == 3
|
334
|
+
end
|
335
|
+
|
336
|
+
it "has no forward markers at any level" do
|
337
|
+
node.forward_markers[0].should be_empty
|
338
|
+
node.forward_markers[1].should be_empty
|
339
|
+
node.forward_markers[2].should be_empty
|
340
|
+
end
|
341
|
+
|
342
|
+
it "has :z as its only marker" do
|
343
|
+
node.markers.should have_markers(:z)
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|