hamster 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,7 @@
1
+ === 0.2.7 / 2010-02-08
2
+
3
+ * Fixed bug with Hamster.interval (and Hamster.range) not handling Strings correctly.
4
+
1
5
  === 0.2.6 / 2010-01-29
2
6
 
3
7
  * Implement Array#to_list.
@@ -24,7 +24,7 @@ module Hamster
24
24
 
25
25
  def interval(from, to)
26
26
  return EmptyList if from > to
27
- Stream.new { Sequence.new(from, interval(from.succ, to)) }
27
+ interval_exclusive(from, to.succ)
28
28
  end
29
29
  def_delegator :self, :interval, :range
30
30
 
@@ -40,6 +40,13 @@ module Hamster
40
40
  Stream.new { Sequence.new(item, iterate(yield(item), &block)) }
41
41
  end
42
42
 
43
+ private
44
+
45
+ def interval_exclusive(from, to)
46
+ return EmptyList if from == to
47
+ Stream.new { Sequence.new(from, interval_exclusive(from.succ, to)) }
48
+ end
49
+
43
50
  end
44
51
 
45
52
  module List
@@ -1,5 +1,5 @@
1
1
  module Hamster
2
2
 
3
- VERSION = "0.2.6".freeze
3
+ VERSION = "0.2.7".freeze
4
4
 
5
5
  end
@@ -73,12 +73,28 @@ describe Hamster do
73
73
 
74
74
  describe ".#{method}" do
75
75
 
76
- before do
77
- @list = Hamster.send(method, "A", "D")
76
+ describe "for numbers" do
77
+
78
+ before do
79
+ @list = Hamster.send(method, 98, 102)
80
+ end
81
+
82
+ it "is equivalent to a list with explicit values" do
83
+ @list.should == Hamster.list(98, 99, 100, 101, 102)
84
+ end
85
+
78
86
  end
79
87
 
80
- it "is equivalent to a list with explicit values" do
81
- @list.should == Hamster.list("A", "B", "C", "D")
88
+ describe "for strings" do
89
+
90
+ before do
91
+ @list = Hamster.send(method, "A", "AA")
92
+ end
93
+
94
+ it "is equivalent to a list with explicit values" do
95
+ @list.should == Hamster.list("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "AA")
96
+ end
97
+
82
98
  end
83
99
 
84
100
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hamster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Harris
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-29 00:00:00 +11:00
12
+ date: 2010-02-08 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency