hamster 1.0.1.pre.rc.1 → 1.0.1.pre.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hamster/groupable.rb +12 -0
- data/lib/hamster/hash.rb +32 -12
- data/lib/hamster/list.rb +68 -22
- data/lib/hamster/queue.rb +5 -6
- data/lib/hamster/set.rb +50 -14
- data/lib/hamster/stack.rb +2 -0
- data/lib/hamster/trie.rb +34 -14
- data/lib/hamster/tuple.rb +9 -24
- data/lib/hamster/vector.rb +29 -7
- data/lib/hamster/version.rb +1 -1
- data/spec/hamster/core_ext/array_spec.rb +4 -10
- data/spec/hamster/core_ext/enumerable_spec.rb +1 -0
- data/spec/hamster/experimental/mutable_set/add_qm_spec.rb +14 -22
- data/spec/hamster/experimental/mutable_set/add_spec.rb +20 -34
- data/spec/hamster/experimental/mutable_set/delete_qm_spec.rb +15 -24
- data/spec/hamster/experimental/mutable_set/delete_spec.rb +15 -25
- data/spec/hamster/experimental/mutable_stack/pop_spec.rb +21 -27
- data/spec/hamster/experimental/mutable_stack/push_spec.rb +11 -31
- data/spec/hamster/hash/all_spec.rb +21 -34
- data/spec/hamster/hash/any_spec.rb +0 -15
- data/spec/hamster/hash/clear_spec.rb +1 -8
- data/spec/hamster/hash/construction_spec.rb +3 -11
- data/spec/hamster/hash/copying_spec.rb +1 -8
- data/spec/hamster/hash/delete_spec.rb +1 -10
- data/spec/hamster/hash/each_spec.rb +1 -12
- data/spec/hamster/hash/empty_spec.rb +8 -8
- data/spec/hamster/hash/eql_spec.rb +30 -22
- data/spec/hamster/hash/except_spec.rb +1 -10
- data/spec/hamster/hash/fetch_spec.rb +1 -24
- data/spec/hamster/hash/filter_spec.rb +1 -16
- data/spec/hamster/hash/find_spec.rb +1 -14
- data/spec/hamster/hash/has_key_spec.rb +1 -10
- data/spec/hamster/hash/hash_spec.rb +1 -16
- data/spec/hamster/hash/immutable_spec.rb +0 -3
- data/spec/hamster/hash/inspect_spec.rb +1 -9
- data/spec/hamster/hash/keys_spec.rb +4 -5
- data/spec/hamster/hash/map_spec.rb +1 -16
- data/spec/hamster/hash/merge_spec.rb +5 -11
- data/spec/hamster/hash/new_spec.rb +21 -0
- data/spec/hamster/hash/put_spec.rb +13 -11
- data/spec/hamster/hash/reduce_spec.rb +7 -15
- data/spec/hamster/hash/remove_spec.rb +1 -16
- data/spec/hamster/hash/uniq_spec.rb +1 -8
- data/spec/hamster/hash/values_spec.rb +1 -6
- data/spec/hamster/immutable/copying_spec.rb +1 -8
- data/spec/hamster/immutable/immutable_spec.rb +1 -14
- data/spec/hamster/immutable/memoize_spec.rb +0 -1
- data/spec/hamster/list/add_spec.rb +1 -6
- data/spec/hamster/list/all_spec.rb +1 -28
- data/spec/hamster/list/any_spec.rb +1 -20
- data/spec/hamster/list/append_spec.rb +1 -11
- data/spec/hamster/list/at_spec.rb +1 -13
- data/spec/hamster/list/break_spec.rb +1 -13
- data/spec/hamster/list/cadr_spec.rb +1 -9
- data/spec/hamster/list/chunk_spec.rb +1 -9
- data/spec/hamster/list/clear_spec.rb +1 -9
- data/spec/hamster/list/combinations_spec.rb +1 -11
- data/spec/hamster/list/compact_spec.rb +1 -9
- data/spec/hamster/list/cons_spec.rb +1 -10
- data/spec/hamster/list/construction_spec.rb +1 -30
- data/spec/hamster/list/copying_spec.rb +1 -9
- data/spec/hamster/list/count_spec.rb +1 -15
- data/spec/hamster/list/cycle_spec.rb +1 -10
- data/spec/hamster/list/drop_spec.rb +1 -9
- data/spec/hamster/list/drop_while_spec.rb +1 -13
- data/spec/hamster/list/each_slice_spec.rb +1 -17
- data/spec/hamster/list/each_spec.rb +1 -17
- data/spec/hamster/list/each_with_index_spec.rb +1 -10
- data/spec/hamster/list/elem_index_spec.rb +1 -13
- data/spec/hamster/list/elem_indices_spec.rb +1 -11
- data/spec/hamster/list/empty_spec.rb +1 -13
- data/spec/hamster/list/eql_spec.rb +52 -62
- data/spec/hamster/list/find_index_spec.rb +1 -13
- data/spec/hamster/list/find_indices_spec.rb +1 -11
- data/spec/hamster/list/find_spec.rb +1 -17
- data/spec/hamster/list/flatten_spec.rb +1 -9
- data/spec/hamster/list/grep_spec.rb +1 -16
- data/spec/hamster/list/group_by_spec.rb +1 -20
- data/spec/hamster/list/head_spec.rb +1 -11
- data/spec/hamster/list/include_spec.rb +1 -13
- data/spec/hamster/list/init_spec.rb +1 -8
- data/spec/hamster/list/inits_spec.rb +1 -9
- data/spec/hamster/list/inspect_spec.rb +1 -11
- data/spec/hamster/list/intersperse_spec.rb +1 -9
- data/spec/hamster/list/join_spec.rb +1 -18
- data/spec/hamster/list/last_spec.rb +1 -11
- data/spec/hamster/list/map_spec.rb +1 -15
- data/spec/hamster/list/maximum_spec.rb +1 -20
- data/spec/hamster/list/merge_by_spec.rb +1 -19
- data/spec/hamster/list/merge_spec.rb +1 -20
- data/spec/hamster/list/minimum_spec.rb +1 -20
- data/spec/hamster/list/none_spec.rb +1 -18
- data/spec/hamster/list/one_spec.rb +1 -16
- data/spec/hamster/list/partition_spec.rb +1 -13
- data/spec/hamster/list/product_spec.rb +1 -11
- data/spec/hamster/list/reduce_spec.rb +0 -1
- data/spec/hamster/list/remove_spec.rb +1 -15
- data/spec/hamster/list/reverse_spec.rb +1 -11
- data/spec/hamster/list/size_spec.rb +1 -13
- data/spec/hamster/list/slice_spec.rb +1 -11
- data/spec/hamster/list/sorting_spec.rb +1 -14
- data/spec/hamster/list/span_spec.rb +1 -12
- data/spec/hamster/list/split_at_spec.rb +1 -9
- data/spec/hamster/list/sum_spec.rb +1 -11
- data/spec/hamster/list/tail_spec.rb +1 -11
- data/spec/hamster/list/tails_spec.rb +1 -9
- data/spec/hamster/list/take_spec.rb +1 -9
- data/spec/hamster/list/take_while_spec.rb +0 -1
- data/spec/hamster/list/to_a_spec.rb +1 -13
- data/spec/hamster/list/to_ary_spec.rb +0 -1
- data/spec/hamster/list/to_list_spec.rb +1 -9
- data/spec/hamster/list/to_set_spec.rb +2 -8
- data/spec/hamster/list/union_spec.rb +1 -11
- data/spec/hamster/list/uniq_spec.rb +1 -11
- data/spec/hamster/queue/clear_spec.rb +1 -9
- data/spec/hamster/queue/construction_spec.rb +1 -10
- data/spec/hamster/queue/dequeue_spec.rb +1 -11
- data/spec/hamster/queue/empty_spec.rb +1 -13
- data/spec/hamster/queue/enqueue_spec.rb +1 -11
- data/spec/hamster/queue/head_spec.rb +1 -11
- data/spec/hamster/queue/inspect_spec.rb +1 -9
- data/spec/hamster/queue/size_spec.rb +1 -11
- data/spec/hamster/queue/to_a_spec.rb +1 -11
- data/spec/hamster/queue/to_list_spec.rb +1 -11
- data/spec/hamster/set/add_spec.rb +1 -12
- data/spec/hamster/set/all_spec.rb +1 -18
- data/spec/hamster/set/any_spec.rb +1 -17
- data/spec/hamster/set/clear_spec.rb +9 -8
- data/spec/hamster/set/compact_spec.rb +1 -9
- data/spec/hamster/set/construction_spec.rb +1 -9
- data/spec/hamster/set/copying_spec.rb +1 -8
- data/spec/hamster/set/count_spec.rb +1 -13
- data/spec/hamster/set/delete_spec.rb +1 -10
- data/spec/hamster/set/difference_spec.rb +1 -11
- data/spec/hamster/set/empty_spec.rb +1 -11
- data/spec/hamster/set/exclusion_spec.rb +1 -11
- data/spec/hamster/set/filter_spec.rb +10 -17
- data/spec/hamster/set/find_spec.rb +1 -14
- data/spec/hamster/set/flatten_spec.rb +8 -10
- data/spec/hamster/set/group_by_spec.rb +8 -17
- data/spec/hamster/set/head_spec.rb +1 -12
- data/spec/hamster/set/immutable_spec.rb +1 -4
- data/spec/hamster/set/include_spec.rb +1 -9
- data/spec/hamster/set/inspect_spec.rb +1 -9
- data/spec/hamster/set/intersection_spec.rb +1 -11
- data/spec/hamster/set/join_spec.rb +1 -16
- data/spec/hamster/set/map_spec.rb +1 -16
- data/spec/hamster/set/marshal_spec.rb +1 -6
- data/spec/hamster/set/maximum_spec.rb +1 -18
- data/spec/hamster/set/minimum_spec.rb +1 -17
- data/spec/hamster/set/new_spec.rb +21 -0
- data/spec/hamster/set/none_spec.rb +1 -16
- data/spec/hamster/set/one_spec.rb +1 -14
- data/spec/hamster/set/partition_spec.rb +1 -13
- data/spec/hamster/set/product_spec.rb +1 -9
- data/spec/hamster/set/reduce_spec.rb +1 -26
- data/spec/hamster/set/remove_spec.rb +1 -16
- data/spec/hamster/set/size_spec.rb +1 -9
- data/spec/hamster/set/sorting_spec.rb +1 -3
- data/spec/hamster/set/subset_spec.rb +1 -9
- data/spec/hamster/set/sum_spec.rb +1 -9
- data/spec/hamster/set/superset_spec.rb +1 -9
- data/spec/hamster/set/to_a_spec.rb +1 -11
- data/spec/hamster/set/to_list_spec.rb +1 -11
- data/spec/hamster/set/to_set_spec.rb +1 -9
- data/spec/hamster/set/union_spec.rb +1 -11
- data/spec/hamster/set/uniq_spec.rb +1 -7
- data/spec/hamster/sorter/immutable_spec.rb +1 -4
- data/spec/hamster/stack/clear_spec.rb +1 -9
- data/spec/hamster/stack/construction_spec.rb +1 -10
- data/spec/hamster/stack/copying_spec.rb +1 -9
- data/spec/hamster/stack/empty_spec.rb +1 -9
- data/spec/hamster/stack/eql_spec.rb +1 -13
- data/spec/hamster/stack/immutable_spec.rb +1 -4
- data/spec/hamster/stack/inspect_spec.rb +1 -9
- data/spec/hamster/stack/peek_spec.rb +1 -11
- data/spec/hamster/stack/pop_spec.rb +1 -11
- data/spec/hamster/stack/push_spec.rb +1 -11
- data/spec/hamster/stack/size_spec.rb +1 -11
- data/spec/hamster/stack/to_a_spec.rb +1 -11
- data/spec/hamster/stack/to_list_spec.rb +1 -9
- data/spec/hamster/tuple/construction_spec.rb +30 -0
- data/spec/hamster/tuple/copying_spec.rb +1 -8
- data/spec/hamster/tuple/eql_spec.rb +57 -40
- data/spec/hamster/tuple/first_spec.rb +1 -6
- data/spec/hamster/tuple/immutable_spec.rb +1 -4
- data/spec/hamster/tuple/inspect_spec.rb +1 -6
- data/spec/hamster/tuple/last_spec.rb +1 -6
- data/spec/hamster/tuple/to_a_spec.rb +1 -9
- data/spec/hamster/tuple/to_ary_spec.rb +0 -1
- data/spec/hamster/undefined/erase_spec.rb +1 -12
- data/spec/hamster/vector/add_spec.rb +8 -0
- data/spec/hamster/vector/clear_spec.rb +1 -8
- data/spec/hamster/vector/copying_spec.rb +1 -8
- data/spec/hamster/vector/each_spec.rb +1 -11
- data/spec/hamster/vector/each_with_index_spec.rb +1 -9
- data/spec/hamster/vector/empty_spec.rb +7 -9
- data/spec/hamster/vector/eql_spec.rb +1 -12
- data/spec/hamster/vector/filter_spec.rb +8 -12
- data/spec/hamster/vector/first_spec.rb +1 -11
- data/spec/hamster/vector/get_spec.rb +1 -23
- data/spec/hamster/vector/include_spec.rb +1 -10
- data/spec/hamster/vector/map_spec.rb +8 -14
- data/spec/hamster/vector/new_spec.rb +48 -0
- data/spec/hamster/vector/reduce_spec.rb +1 -26
- data/spec/hamster/vector/set_spec.rb +8 -0
- data/spec/spec_helper.rb +0 -5
- metadata +35 -68
@@ -1,13 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "hamster/vector"
|
4
3
|
|
5
4
|
describe Hamster::Vector do
|
6
|
-
|
7
5
|
[:first, :head].each do |method|
|
8
|
-
|
9
6
|
describe "##{method}" do
|
10
|
-
|
11
7
|
[
|
12
8
|
[[], nil],
|
13
9
|
[["A"], "A"],
|
@@ -15,7 +11,6 @@ describe Hamster::Vector do
|
|
15
11
|
].each do |values, expected|
|
16
12
|
|
17
13
|
describe "on #{values.inspect}" do
|
18
|
-
|
19
14
|
before do
|
20
15
|
@vector = Hamster.vector(*values)
|
21
16
|
end
|
@@ -23,13 +18,8 @@ describe Hamster::Vector do
|
|
23
18
|
it "returns #{expected.inspect}" do
|
24
19
|
@vector.send(method).should == expected
|
25
20
|
end
|
26
|
-
|
27
21
|
end
|
28
|
-
|
29
22
|
end
|
30
|
-
|
31
23
|
end
|
32
|
-
|
33
24
|
end
|
34
|
-
|
35
|
-
end
|
25
|
+
end
|
@@ -2,13 +2,9 @@ require "spec_helper"
|
|
2
2
|
require "hamster/vector"
|
3
3
|
|
4
4
|
describe Hamster::Vector do
|
5
|
-
|
6
5
|
[:get, :[], :at].each do |method|
|
7
|
-
|
8
6
|
describe "##{method}" do
|
9
|
-
|
10
7
|
describe "when empty" do
|
11
|
-
|
12
8
|
before do
|
13
9
|
@vector = Hamster.vector
|
14
10
|
end
|
@@ -18,63 +14,45 @@ describe Hamster::Vector do
|
|
18
14
|
@vector.send(method, i).should be_nil
|
19
15
|
end
|
20
16
|
end
|
21
|
-
|
22
17
|
end
|
23
18
|
|
24
19
|
describe "when not empty" do
|
25
|
-
|
26
20
|
before do
|
27
21
|
@vector = Hamster.vector(*(1..1025))
|
28
22
|
end
|
29
23
|
|
30
24
|
describe "with a positive index" do
|
31
|
-
|
32
25
|
describe "within the absolute bounds of the vector" do
|
33
|
-
|
34
26
|
it "returns the value at the specified index from the head" do
|
35
27
|
(0..(@vector.size - 1)).each do |i|
|
36
28
|
@vector.send(method, i).should == i + 1
|
37
29
|
end
|
38
30
|
end
|
39
|
-
|
40
31
|
end
|
41
32
|
|
42
33
|
describe "outside the absolute bounds of the vector" do
|
43
|
-
|
44
34
|
it "returns nil" do
|
45
35
|
@vector.send(method, @vector.size).should be_nil
|
46
36
|
end
|
47
|
-
|
48
37
|
end
|
49
|
-
|
50
38
|
end
|
51
39
|
|
52
40
|
describe "with a negative index" do
|
53
|
-
|
54
41
|
describe "within the absolute bounds of the vector" do
|
55
|
-
|
56
42
|
it "returns the value at the specified index from the tail" do
|
57
43
|
(-@vector.size..-1).each do |i|
|
58
44
|
@vector.send(method, i).should == @vector.size + i + 1
|
59
45
|
end
|
60
46
|
end
|
61
|
-
|
62
47
|
end
|
63
48
|
|
64
49
|
describe "outside the absolute bounds of the vector" do
|
65
|
-
|
66
50
|
it "returns nil" do
|
67
51
|
@vector.send(method, -@vector.size.next).should be_nil
|
68
52
|
end
|
69
|
-
|
70
53
|
end
|
71
|
-
|
72
54
|
end
|
73
|
-
|
74
55
|
end
|
75
|
-
|
76
56
|
end
|
77
|
-
|
78
57
|
end
|
79
|
-
|
80
|
-
end
|
58
|
+
end
|
@@ -2,11 +2,8 @@ require "spec_helper"
|
|
2
2
|
require "hamster/vector"
|
3
3
|
|
4
4
|
describe Hamster::Vector do
|
5
|
-
|
6
5
|
[:include?, :member?, :contains?, :elem?].each do |method|
|
7
|
-
|
8
6
|
describe "##{method}" do
|
9
|
-
|
10
7
|
[
|
11
8
|
[[], "A", false],
|
12
9
|
[[], nil, false],
|
@@ -24,7 +21,6 @@ describe Hamster::Vector do
|
|
24
21
|
].each do |values, item, expected|
|
25
22
|
|
26
23
|
describe "on #{values.inspect}" do
|
27
|
-
|
28
24
|
before do
|
29
25
|
@vector = Hamster.vector(*values)
|
30
26
|
end
|
@@ -32,13 +28,8 @@ describe Hamster::Vector do
|
|
32
28
|
it "returns #{expected.inspect}" do
|
33
29
|
@vector.send(method, item).should == expected
|
34
30
|
end
|
35
|
-
|
36
31
|
end
|
37
|
-
|
38
32
|
end
|
39
|
-
|
40
33
|
end
|
41
|
-
|
42
34
|
end
|
43
|
-
|
44
|
-
end
|
35
|
+
end
|
@@ -2,13 +2,9 @@ require "spec_helper"
|
|
2
2
|
require "hamster/vector"
|
3
3
|
|
4
4
|
describe Hamster::Vector do
|
5
|
-
|
6
5
|
[:map, :collect].each do |method|
|
7
|
-
|
8
6
|
describe "##{method}" do
|
9
|
-
|
10
7
|
describe "when empty" do
|
11
|
-
|
12
8
|
before do
|
13
9
|
@original = Hamster.vector
|
14
10
|
@mapped = @original.send(method) {}
|
@@ -17,17 +13,14 @@ describe Hamster::Vector do
|
|
17
13
|
it "returns self" do
|
18
14
|
@mapped.should equal(@original)
|
19
15
|
end
|
20
|
-
|
21
16
|
end
|
22
17
|
|
23
18
|
describe "when not empty" do
|
24
|
-
|
25
19
|
before do
|
26
20
|
@original = Hamster.vector("A", "B", "C")
|
27
21
|
end
|
28
22
|
|
29
23
|
describe "with a block" do
|
30
|
-
|
31
24
|
before do
|
32
25
|
@mapped = @original.send(method, &:downcase)
|
33
26
|
end
|
@@ -39,11 +32,9 @@ describe Hamster::Vector do
|
|
39
32
|
it "returns a new vector with the mapped values" do
|
40
33
|
@mapped.should == Hamster.vector("a", "b", "c")
|
41
34
|
end
|
42
|
-
|
43
35
|
end
|
44
36
|
|
45
37
|
describe "with no block" do
|
46
|
-
|
47
38
|
before do
|
48
39
|
@result = @original.send(method)
|
49
40
|
end
|
@@ -51,13 +42,16 @@ describe Hamster::Vector do
|
|
51
42
|
it "returns self" do
|
52
43
|
@result.should equal(@original)
|
53
44
|
end
|
54
|
-
|
55
45
|
end
|
56
|
-
|
57
46
|
end
|
58
47
|
|
48
|
+
context "from a subclass" do
|
49
|
+
it "returns an instance of the subclass" do
|
50
|
+
@subclass = Class.new(Hamster::Vector)
|
51
|
+
@instance = @subclass[1,2,3]
|
52
|
+
@instance.map { |x| x + 1 }.class.should be(@subclass)
|
53
|
+
end
|
54
|
+
end
|
59
55
|
end
|
60
|
-
|
61
56
|
end
|
62
|
-
|
63
|
-
end
|
57
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "hamster/vector"
|
3
|
+
|
4
|
+
describe Hamster::Vector do
|
5
|
+
describe "new" do
|
6
|
+
it "accepts a single enumerable argument and creates a new vector" do
|
7
|
+
vector = Hamster::Vector.new([1,2,3])
|
8
|
+
vector.size.should be(3)
|
9
|
+
vector[0].should be(1)
|
10
|
+
vector[1].should be(2)
|
11
|
+
vector[2].should be(3)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns the canonical empty vector if called with no arguments" do
|
15
|
+
Hamster::Vector.new.object_id.should be(Hamster::Vector.new.object_id)
|
16
|
+
Hamster::Vector.new.size.should be(0)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "from a subclass" do
|
20
|
+
before do
|
21
|
+
@subclass = Class.new(Hamster::Vector)
|
22
|
+
@instance = @subclass.new(["some", "values"])
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return an instance of the subclass" do
|
26
|
+
@instance.class.should be @subclass
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return a frozen instance" do
|
30
|
+
@instance.frozen?.should be true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "[]" do
|
36
|
+
it "accepts a variable number of items and creates a new vector" do
|
37
|
+
vector = Hamster::Vector['a', 'b']
|
38
|
+
vector.size.should be(2)
|
39
|
+
vector[0].should == 'a'
|
40
|
+
vector[1].should == 'b'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns the canonical empty vector if called with no arguments" do
|
44
|
+
Hamster::Vector[].should be(Hamster::Vector.empty)
|
45
|
+
Hamster::Vector[].size.should be(0)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,13 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "hamster/vector"
|
4
3
|
|
5
4
|
describe Hamster::Vector do
|
6
|
-
|
7
5
|
[:reduce, :inject, :fold, :foldr].each do |method|
|
8
|
-
|
9
6
|
describe "##{method}" do
|
10
|
-
|
11
7
|
[
|
12
8
|
[[], 10, 10],
|
13
9
|
[[1], 10, 9],
|
@@ -15,33 +11,24 @@ describe Hamster::Vector do
|
|
15
11
|
].each do |values, initial, expected|
|
16
12
|
|
17
13
|
describe "on #{values.inspect}" do
|
18
|
-
|
19
14
|
before do
|
20
15
|
@vector = Hamster.vector(*values)
|
21
16
|
end
|
22
17
|
|
23
18
|
describe "with an initial value of #{initial}" do
|
24
|
-
|
25
19
|
describe "and a block" do
|
26
|
-
|
27
20
|
it "returns #{expected.inspect}" do
|
28
21
|
@vector.send(method, initial) { |memo, item| memo - item }.should == expected
|
29
22
|
end
|
30
|
-
|
31
23
|
end
|
32
24
|
|
33
25
|
describe "and no block" do
|
34
|
-
|
35
26
|
it "returns the memo" do
|
36
27
|
@vector.send(method, initial).should == initial
|
37
28
|
end
|
38
|
-
|
39
29
|
end
|
40
|
-
|
41
30
|
end
|
42
|
-
|
43
31
|
end
|
44
|
-
|
45
32
|
end
|
46
33
|
|
47
34
|
[
|
@@ -51,37 +38,25 @@ describe Hamster::Vector do
|
|
51
38
|
].each do |values, expected|
|
52
39
|
|
53
40
|
describe "on #{values.inspect}" do
|
54
|
-
|
55
41
|
before do
|
56
42
|
@vector = Hamster.vector(*values)
|
57
43
|
end
|
58
44
|
|
59
45
|
describe "with no initial value" do
|
60
|
-
|
61
46
|
describe "and a block" do
|
62
|
-
|
63
47
|
it "returns #{expected.inspect}" do
|
64
48
|
@vector.send(method) { |memo, item| memo - item }.should == expected
|
65
49
|
end
|
66
|
-
|
67
50
|
end
|
68
51
|
|
69
52
|
describe "and no block" do
|
70
|
-
|
71
53
|
it "returns nil" do
|
72
54
|
@vector.send(method).should be_nil
|
73
55
|
end
|
74
|
-
|
75
56
|
end
|
76
|
-
|
77
57
|
end
|
78
|
-
|
79
58
|
end
|
80
|
-
|
81
59
|
end
|
82
|
-
|
83
60
|
end
|
84
|
-
|
85
61
|
end
|
86
|
-
|
87
|
-
end
|
62
|
+
end
|
@@ -109,5 +109,13 @@ describe Hamster::Vector do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
112
|
+
|
113
|
+
context "from a subclass" do
|
114
|
+
it "returns an instance of the subclass" do
|
115
|
+
@subclass = Class.new(Hamster::Vector)
|
116
|
+
@instance = @subclass[1,2,3]
|
117
|
+
@instance.set(1, 2.5).class.should be(@subclass)
|
118
|
+
end
|
119
|
+
end
|
112
120
|
end
|
113
121
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,141 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hamster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.1.pre.
|
4
|
+
version: 1.0.1.pre.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Harris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: mocha
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ~>
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.14'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.14'
|
40
|
+
version: '3.0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- - ~>
|
45
|
+
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
47
|
version: '10.1'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- - ~>
|
52
|
+
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '10.1'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: yard
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - ~>
|
59
|
+
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
61
|
version: '0.8'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - ~>
|
66
|
+
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0.8'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: kramdown
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ~>
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.2'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ~>
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.2'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: pry
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
100
72
|
requirements:
|
101
|
-
- - ~>
|
73
|
+
- - "~>"
|
102
74
|
- !ruby/object:Gem::Version
|
103
75
|
version: '0.9'
|
104
76
|
type: :development
|
105
77
|
prerelease: false
|
106
78
|
version_requirements: !ruby/object:Gem::Requirement
|
107
79
|
requirements:
|
108
|
-
- - ~>
|
80
|
+
- - "~>"
|
109
81
|
- !ruby/object:Gem::Version
|
110
82
|
version: '0.9'
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
84
|
+
name: pry-doc
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
114
86
|
requirements:
|
115
|
-
- - ~>
|
87
|
+
- - "~>"
|
116
88
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0.
|
89
|
+
version: '0.6'
|
118
90
|
type: :development
|
119
91
|
prerelease: false
|
120
92
|
version_requirements: !ruby/object:Gem::Requirement
|
121
93
|
requirements:
|
122
|
-
- - ~>
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0.7'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rubocop
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ~>
|
94
|
+
- - "~>"
|
130
95
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0.
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ~>
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0.15'
|
96
|
+
version: '0.6'
|
139
97
|
description: Efficient, immutable, thread-safe collection classes for Ruby
|
140
98
|
email:
|
141
99
|
- haruki_zaemon@mac.com
|
@@ -143,14 +101,16 @@ executables: []
|
|
143
101
|
extensions: []
|
144
102
|
extra_rdoc_files: []
|
145
103
|
files:
|
104
|
+
- lib/hamster.rb
|
105
|
+
- lib/hamster/core_ext.rb
|
146
106
|
- lib/hamster/core_ext/enumerable.rb
|
147
107
|
- lib/hamster/core_ext/enumerator.rb
|
148
108
|
- lib/hamster/core_ext/io.rb
|
149
|
-
- lib/hamster/core_ext.rb
|
150
109
|
- lib/hamster/enumerable.rb
|
151
110
|
- lib/hamster/experimental/mutable_queue.rb
|
152
111
|
- lib/hamster/experimental/mutable_set.rb
|
153
112
|
- lib/hamster/experimental/mutable_stack.rb
|
113
|
+
- lib/hamster/groupable.rb
|
154
114
|
- lib/hamster/hash.rb
|
155
115
|
- lib/hamster/immutable.rb
|
156
116
|
- lib/hamster/list.rb
|
@@ -165,7 +125,6 @@ files:
|
|
165
125
|
- lib/hamster/undefined.rb
|
166
126
|
- lib/hamster/vector.rb
|
167
127
|
- lib/hamster/version.rb
|
168
|
-
- lib/hamster.rb
|
169
128
|
- spec/fixtures/io_spec.txt
|
170
129
|
- spec/hamster/core_ext/array_spec.rb
|
171
130
|
- spec/hamster/core_ext/enumerable_spec.rb
|
@@ -199,6 +158,7 @@ files:
|
|
199
158
|
- spec/hamster/hash/map_spec.rb
|
200
159
|
- spec/hamster/hash/marshal_spec.rb
|
201
160
|
- spec/hamster/hash/merge_spec.rb
|
161
|
+
- spec/hamster/hash/new_spec.rb
|
202
162
|
- spec/hamster/hash/none_spec.rb
|
203
163
|
- spec/hamster/hash/put_spec.rb
|
204
164
|
- spec/hamster/hash/reduce_spec.rb
|
@@ -330,6 +290,7 @@ files:
|
|
330
290
|
- spec/hamster/set/marshal_spec.rb
|
331
291
|
- spec/hamster/set/maximum_spec.rb
|
332
292
|
- spec/hamster/set/minimum_spec.rb
|
293
|
+
- spec/hamster/set/new_spec.rb
|
333
294
|
- spec/hamster/set/none_spec.rb
|
334
295
|
- spec/hamster/set/one_spec.rb
|
335
296
|
- spec/hamster/set/partition_spec.rb
|
@@ -362,6 +323,7 @@ files:
|
|
362
323
|
- spec/hamster/stack/to_ary.rb
|
363
324
|
- spec/hamster/stack/to_list_spec.rb
|
364
325
|
- spec/hamster/trie/remove_spec.rb
|
326
|
+
- spec/hamster/tuple/construction_spec.rb
|
365
327
|
- spec/hamster/tuple/copying_spec.rb
|
366
328
|
- spec/hamster/tuple/eql_spec.rb
|
367
329
|
- spec/hamster/tuple/first_spec.rb
|
@@ -387,6 +349,7 @@ files:
|
|
387
349
|
- spec/hamster/vector/last_spec.rb
|
388
350
|
- spec/hamster/vector/length_spec.rb
|
389
351
|
- spec/hamster/vector/map_spec.rb
|
352
|
+
- spec/hamster/vector/new_spec.rb
|
390
353
|
- spec/hamster/vector/reduce_spec.rb
|
391
354
|
- spec/hamster/vector/set_spec.rb
|
392
355
|
- spec/hamster/vector/to_a_spec.rb
|
@@ -396,7 +359,7 @@ files:
|
|
396
359
|
- spec/lib/hamster/vector/exists_spec.rb
|
397
360
|
- spec/lib/hamster/vector/ltlt_spec.rb
|
398
361
|
- spec/spec_helper.rb
|
399
|
-
homepage:
|
362
|
+
homepage: https://github.com/hamstergem/hamster
|
400
363
|
licenses:
|
401
364
|
- MIT
|
402
365
|
metadata: {}
|
@@ -406,17 +369,17 @@ require_paths:
|
|
406
369
|
- lib
|
407
370
|
required_ruby_version: !ruby/object:Gem::Requirement
|
408
371
|
requirements:
|
409
|
-
- -
|
372
|
+
- - ">="
|
410
373
|
- !ruby/object:Gem::Version
|
411
|
-
version: 1.
|
374
|
+
version: 1.9.3
|
412
375
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
413
376
|
requirements:
|
414
|
-
- -
|
377
|
+
- - ">"
|
415
378
|
- !ruby/object:Gem::Version
|
416
379
|
version: 1.3.1
|
417
380
|
requirements: []
|
418
381
|
rubyforge_project:
|
419
|
-
rubygems_version: 2.
|
382
|
+
rubygems_version: 2.2.2
|
420
383
|
signing_key:
|
421
384
|
specification_version: 4
|
422
385
|
summary: Efficient, immutable, thread-safe collection classes for Ruby
|
@@ -454,6 +417,7 @@ test_files:
|
|
454
417
|
- spec/hamster/hash/map_spec.rb
|
455
418
|
- spec/hamster/hash/marshal_spec.rb
|
456
419
|
- spec/hamster/hash/merge_spec.rb
|
420
|
+
- spec/hamster/hash/new_spec.rb
|
457
421
|
- spec/hamster/hash/none_spec.rb
|
458
422
|
- spec/hamster/hash/put_spec.rb
|
459
423
|
- spec/hamster/hash/reduce_spec.rb
|
@@ -585,6 +549,7 @@ test_files:
|
|
585
549
|
- spec/hamster/set/marshal_spec.rb
|
586
550
|
- spec/hamster/set/maximum_spec.rb
|
587
551
|
- spec/hamster/set/minimum_spec.rb
|
552
|
+
- spec/hamster/set/new_spec.rb
|
588
553
|
- spec/hamster/set/none_spec.rb
|
589
554
|
- spec/hamster/set/one_spec.rb
|
590
555
|
- spec/hamster/set/partition_spec.rb
|
@@ -617,6 +582,7 @@ test_files:
|
|
617
582
|
- spec/hamster/stack/to_ary.rb
|
618
583
|
- spec/hamster/stack/to_list_spec.rb
|
619
584
|
- spec/hamster/trie/remove_spec.rb
|
585
|
+
- spec/hamster/tuple/construction_spec.rb
|
620
586
|
- spec/hamster/tuple/copying_spec.rb
|
621
587
|
- spec/hamster/tuple/eql_spec.rb
|
622
588
|
- spec/hamster/tuple/first_spec.rb
|
@@ -642,6 +608,7 @@ test_files:
|
|
642
608
|
- spec/hamster/vector/last_spec.rb
|
643
609
|
- spec/hamster/vector/length_spec.rb
|
644
610
|
- spec/hamster/vector/map_spec.rb
|
611
|
+
- spec/hamster/vector/new_spec.rb
|
645
612
|
- spec/hamster/vector/reduce_spec.rb
|
646
613
|
- spec/hamster/vector/set_spec.rb
|
647
614
|
- spec/hamster/vector/to_a_spec.rb
|