picky 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,8 +23,9 @@ class Symbol
23
23
  sub = self.id2name
24
24
 
25
25
  size = sub.size
26
- down_to_length = size + down_to_length if down_to_length < 0
26
+ down_to_length = size + down_to_length + 1 if down_to_length < 0
27
27
  down_to_length = size if size < down_to_length
28
+ down_to_length = 1 if down_to_length < 1
28
29
 
29
30
  yield self
30
31
  size.downto(down_to_length + 1) { yield sub.chop!.intern }
@@ -49,10 +49,8 @@ describe Cacher::Partial::Subtoken do
49
49
  @cacher.generate_from( :florian => [1], :flavia => [2] ).should == {
50
50
  :florian => [1],
51
51
  :floria => [1],
52
- :flori => [1],
53
52
  :flavia => [2],
54
- :flavi => [2],
55
- :flav => [2]
53
+ :flavi => [2]
56
54
  }
57
55
  end
58
56
  end
@@ -97,7 +97,7 @@ describe Symbol do
97
97
  @sym.each_subtoken(@downto) do |subtoken|
98
98
  result << subtoken
99
99
  end
100
- result.should == [:reinke, :reink, :rein, :rei, :re, :r, :'']
100
+ result.should == [:reinke, :reink, :rein, :rei, :re, :r]
101
101
  end
102
102
  end
103
103
  context 'downto is less than zero' do
@@ -109,7 +109,129 @@ describe Symbol do
109
109
  @sym.each_subtoken(@downto) do |subtoken|
110
110
  result << subtoken
111
111
  end
112
- result.should == [:reinke, :reink, :rein]
112
+ result.should == [:reinke, :reink]
113
+ end
114
+ end
115
+ end
116
+ context 'very short symbol' do
117
+ before(:each) do
118
+ @sym = :r
119
+ end
120
+ context 'no downto' do
121
+ it "should return an array of pieces of the original token, each 1 smaller than the other" do
122
+ result = []
123
+ @sym.each_subtoken do |subtoken|
124
+ result << subtoken
125
+ end
126
+ result.should == [:r]
127
+ end
128
+ end
129
+ context 'downto is larger than the symbol' do
130
+ before(:each) do
131
+ @downto = 8
132
+ end
133
+ it "should return an array of pieces of the original token, each 1 smaller than the other" do
134
+ result = []
135
+ @sym.each_subtoken(@downto) do |subtoken|
136
+ result << subtoken
137
+ end
138
+ result.should == [:r]
139
+ end
140
+ end
141
+ context 'downto is exactly the same as symbol' do
142
+ before(:each) do
143
+ @downto = 6
144
+ end
145
+ it "should return an array of pieces of the original token, each 1 smaller than the other" do
146
+ result = []
147
+ @sym.each_subtoken(@downto) do |subtoken|
148
+ result << subtoken
149
+ end
150
+ result.should == [:r]
151
+ end
152
+ end
153
+ context 'downto is smaller than the length of the symbol' do
154
+ before(:each) do
155
+ @downto = 4
156
+ end
157
+ it "should return an array of pieces of the original token, each 1 smaller than the other" do
158
+ result = []
159
+ @sym.each_subtoken(@downto) do |subtoken|
160
+ result << subtoken
161
+ end
162
+ result.should == [:r]
163
+ end
164
+ end
165
+ context 'downto is 1' do
166
+ before(:each) do
167
+ @downto = 1
168
+ end
169
+ it "should return an array of pieces of the original token, each 1 smaller than the other" do
170
+ result = []
171
+ @sym.each_subtoken(@downto) do |subtoken|
172
+ result << subtoken
173
+ end
174
+ result.should == [:r]
175
+ end
176
+ end
177
+ context 'downto is 0' do
178
+ before(:each) do
179
+ @downto = 0
180
+ end
181
+ it "should return an array of pieces of the original token, each 1 smaller than the other" do
182
+ result = []
183
+ @sym.each_subtoken(@downto) do |subtoken|
184
+ result << subtoken
185
+ end
186
+ result.should == [:r]
187
+ end
188
+ end
189
+ context 'downto is less than zero' do
190
+ before(:each) do
191
+ @downto = -1
192
+ end
193
+ it "should return an array of pieces of the original token, each 1 smaller than the other" do
194
+ result = []
195
+ @sym.each_subtoken(@downto) do |subtoken|
196
+ result << subtoken
197
+ end
198
+ result.should == [:r]
199
+ end
200
+ end
201
+ context 'downto is less than zero' do
202
+ before(:each) do
203
+ @downto = -2
204
+ end
205
+ it "should return an array of pieces of the original token, each 1 smaller than the other" do
206
+ result = []
207
+ @sym.each_subtoken(@downto) do |subtoken|
208
+ result << subtoken
209
+ end
210
+ result.should == [:r]
211
+ end
212
+ end
213
+ context 'downto is less than zero' do
214
+ before(:each) do
215
+ @downto = -3
216
+ end
217
+ it "should return an array of pieces of the original token, each 1 smaller than the other" do
218
+ result = []
219
+ @sym.each_subtoken(@downto) do |subtoken|
220
+ result << subtoken
221
+ end
222
+ result.should == [:r]
223
+ end
224
+ end
225
+ context 'downto is less than zero' do
226
+ before(:each) do
227
+ @downto = -100
228
+ end
229
+ it "should return an array of pieces of the original token, each 1 smaller than the other" do
230
+ result = []
231
+ @sym.each_subtoken(@downto) do |subtoken|
232
+ result << subtoken
233
+ end
234
+ result.should == [:r]
113
235
  end
114
236
  end
115
237
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke