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/immutable"
|
4
3
|
|
5
4
|
describe Hamster::Immutable do
|
6
|
-
|
7
5
|
describe "#immutable?" do
|
8
|
-
|
9
6
|
describe "object constructed after its class becomes Immutable" do
|
10
|
-
|
11
7
|
class Fixture
|
12
8
|
include Hamster::Immutable
|
13
9
|
end
|
@@ -19,11 +15,9 @@ describe Hamster::Immutable do
|
|
19
15
|
it "returns true" do
|
20
16
|
@fixture.should be_immutable
|
21
17
|
end
|
22
|
-
|
23
18
|
end
|
24
19
|
|
25
20
|
describe "object constructed before its class becomes Immutable" do
|
26
|
-
|
27
21
|
before do
|
28
22
|
@fixture = Class.new.new
|
29
23
|
@fixture.class.instance_eval do
|
@@ -32,15 +26,12 @@ describe Hamster::Immutable do
|
|
32
26
|
end
|
33
27
|
|
34
28
|
describe "that are not frozen" do
|
35
|
-
|
36
29
|
it "returns false" do
|
37
30
|
@fixture.should_not be_immutable
|
38
31
|
end
|
39
|
-
|
40
32
|
end
|
41
33
|
|
42
34
|
describe "that are frozen" do
|
43
|
-
|
44
35
|
before do
|
45
36
|
@fixture.freeze
|
46
37
|
end
|
@@ -48,11 +39,7 @@ describe Hamster::Immutable do
|
|
48
39
|
it "returns true" do
|
49
40
|
@fixture.should be_immutable
|
50
41
|
end
|
51
|
-
|
52
42
|
end
|
53
|
-
|
54
43
|
end
|
55
|
-
|
56
44
|
end
|
57
|
-
|
58
|
-
end
|
45
|
+
end
|
@@ -1,16 +1,11 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "hamster/list"
|
4
3
|
|
5
4
|
describe Hamster::List do
|
6
|
-
|
7
5
|
describe "#add" do
|
8
|
-
|
9
6
|
it "should add an item onto the end of a list" do
|
10
7
|
list = Hamster.list("a", "b")
|
11
8
|
list.add("c").should == Hamster.list("a", "b", "c")
|
12
9
|
end
|
13
|
-
|
14
10
|
end
|
15
|
-
|
16
|
-
end
|
11
|
+
end
|
@@ -1,15 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "hamster/list"
|
4
3
|
|
5
4
|
describe Hamster::List do
|
6
|
-
|
7
5
|
[:all?, :forall?].each do |method|
|
8
|
-
|
9
6
|
describe "##{method}" do
|
10
|
-
|
11
7
|
describe "on a really big list" do
|
12
|
-
|
13
8
|
before do
|
14
9
|
@list = Hamster.interval(0, STACK_OVERFLOW_DEPTH)
|
15
10
|
end
|
@@ -17,11 +12,9 @@ describe Hamster::List do
|
|
17
12
|
it "doesn't run out of stack" do
|
18
13
|
-> { @list.send(method) }.should_not raise_error
|
19
14
|
end
|
20
|
-
|
21
15
|
end
|
22
16
|
|
23
17
|
describe "when empty" do
|
24
|
-
|
25
18
|
before do
|
26
19
|
@list = Hamster.list
|
27
20
|
end
|
@@ -33,19 +26,15 @@ describe Hamster::List do
|
|
33
26
|
it "with no block returns true" do
|
34
27
|
@list.send(method).should == true
|
35
28
|
end
|
36
|
-
|
37
29
|
end
|
38
30
|
|
39
31
|
describe "when not empty" do
|
40
|
-
|
41
32
|
describe "with a block" do
|
42
|
-
|
43
33
|
before do
|
44
34
|
@list = Hamster.list("A", "B", "C")
|
45
35
|
end
|
46
36
|
|
47
37
|
describe "if the block always returns true" do
|
48
|
-
|
49
38
|
before do
|
50
39
|
@result = @list.send(method) { |item| true }
|
51
40
|
end
|
@@ -53,11 +42,9 @@ describe Hamster::List do
|
|
53
42
|
it "returns true" do
|
54
43
|
@result.should == true
|
55
44
|
end
|
56
|
-
|
57
45
|
end
|
58
46
|
|
59
47
|
describe "if the block ever returns false" do
|
60
|
-
|
61
48
|
before do
|
62
49
|
@result = @list.send(method) { |item| item == "D" }
|
63
50
|
end
|
@@ -65,15 +52,11 @@ describe Hamster::List do
|
|
65
52
|
it "returns false" do
|
66
53
|
@result.should == false
|
67
54
|
end
|
68
|
-
|
69
55
|
end
|
70
|
-
|
71
56
|
end
|
72
57
|
|
73
58
|
describe "with no block" do
|
74
|
-
|
75
59
|
describe "if all values are truthy" do
|
76
|
-
|
77
60
|
before do
|
78
61
|
@result = Hamster.list(true, "A").send(method)
|
79
62
|
end
|
@@ -81,13 +64,10 @@ describe Hamster::List do
|
|
81
64
|
it "returns true" do
|
82
65
|
@result.should == true
|
83
66
|
end
|
84
|
-
|
85
67
|
end
|
86
68
|
|
87
69
|
[nil, false].each do |value|
|
88
|
-
|
89
70
|
describe "if any value is #{value.inspect}" do
|
90
|
-
|
91
71
|
before do
|
92
72
|
@result = Hamster.list(value, true, "A").send(method)
|
93
73
|
end
|
@@ -95,17 +75,10 @@ describe Hamster::List do
|
|
95
75
|
it "returns false" do
|
96
76
|
@result.should == false
|
97
77
|
end
|
98
|
-
|
99
78
|
end
|
100
|
-
|
101
79
|
end
|
102
|
-
|
103
80
|
end
|
104
|
-
|
105
81
|
end
|
106
|
-
|
107
82
|
end
|
108
|
-
|
109
83
|
end
|
110
|
-
|
111
|
-
end
|
84
|
+
end
|
@@ -1,15 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "hamster/list"
|
4
3
|
|
5
4
|
describe Hamster::List do
|
6
|
-
|
7
5
|
[:any?, :exist?, :exists?].each do |method|
|
8
|
-
|
9
6
|
describe "##{method}" do
|
10
|
-
|
11
7
|
describe "on a really big list" do
|
12
|
-
|
13
8
|
before do
|
14
9
|
@list = Hamster.interval(0, STACK_OVERFLOW_DEPTH)
|
15
10
|
end
|
@@ -17,11 +12,9 @@ describe Hamster::List do
|
|
17
12
|
it "doesn't run out of stack" do
|
18
13
|
-> { @list.send(method) { false } }.should_not raise_error
|
19
14
|
end
|
20
|
-
|
21
15
|
end
|
22
16
|
|
23
17
|
describe "when empty" do
|
24
|
-
|
25
18
|
before do
|
26
19
|
@list = Hamster.list
|
27
20
|
end
|
@@ -33,33 +26,26 @@ describe Hamster::List do
|
|
33
26
|
it "with no block returns false" do
|
34
27
|
@list.send(method).should == false
|
35
28
|
end
|
36
|
-
|
37
29
|
end
|
38
30
|
|
39
31
|
describe "when not empty" do
|
40
|
-
|
41
32
|
describe "with a block" do
|
42
|
-
|
43
33
|
before do
|
44
34
|
@list = Hamster.list("A", "B", "C", nil)
|
45
35
|
end
|
46
36
|
|
47
37
|
["A", "B", "C", nil].each do |value|
|
48
|
-
|
49
38
|
it "returns true if the block ever returns true (#{value.inspect})" do
|
50
39
|
@list.send(method) { |item| item == value }.should == true
|
51
40
|
end
|
52
|
-
|
53
41
|
end
|
54
42
|
|
55
43
|
it "returns false if the block always returns false" do
|
56
44
|
@list.send(method) { |item| item == "D" }.should == false
|
57
45
|
end
|
58
|
-
|
59
46
|
end
|
60
47
|
|
61
48
|
describe "with no block" do
|
62
|
-
|
63
49
|
it "returns true if any value is truthy" do
|
64
50
|
Hamster.list(nil, false, "A", true).send(method).should == true
|
65
51
|
end
|
@@ -67,13 +53,8 @@ describe Hamster::List do
|
|
67
53
|
it "returns false if all values are falsey" do
|
68
54
|
Hamster.list(nil, false).send(method).should == false
|
69
55
|
end
|
70
|
-
|
71
56
|
end
|
72
|
-
|
73
57
|
end
|
74
|
-
|
75
58
|
end
|
76
|
-
|
77
59
|
end
|
78
|
-
|
79
|
-
end
|
60
|
+
end
|
@@ -1,13 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "hamster/list"
|
4
3
|
|
5
4
|
describe Hamster::List do
|
6
|
-
|
7
5
|
[:append, :concat, :cat, :+].each do |method|
|
8
|
-
|
9
6
|
describe "##{method}" do
|
10
|
-
|
11
7
|
it "is lazy" do
|
12
8
|
-> { Hamster.stream { fail }.append(Hamster.stream { fail }) }.should_not raise_error
|
13
9
|
end
|
@@ -20,7 +16,6 @@ describe Hamster::List do
|
|
20
16
|
].each do |left_values, right_values, expected|
|
21
17
|
|
22
18
|
describe "on #{left_values.inspect} and #{right_values.inspect}" do
|
23
|
-
|
24
19
|
before do
|
25
20
|
@left = Hamster.list(*left_values)
|
26
21
|
@right = Hamster.list(*right_values)
|
@@ -38,13 +33,8 @@ describe Hamster::List do
|
|
38
33
|
it "returns #{expected.inspect}" do
|
39
34
|
@result.should == Hamster.list(*expected)
|
40
35
|
end
|
41
|
-
|
42
36
|
end
|
43
|
-
|
44
37
|
end
|
45
|
-
|
46
38
|
end
|
47
|
-
|
48
39
|
end
|
49
|
-
|
50
|
-
end
|
40
|
+
end
|
@@ -1,15 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "hamster/list"
|
4
3
|
|
5
4
|
describe Hamster::List do
|
6
|
-
|
7
5
|
[:at, :[]].each do |method|
|
8
|
-
|
9
6
|
describe "##{method}" do
|
10
|
-
|
11
7
|
describe "on a really big list" do
|
12
|
-
|
13
8
|
before do
|
14
9
|
@list = Hamster.interval(0, STACK_OVERFLOW_DEPTH)
|
15
10
|
end
|
@@ -17,7 +12,6 @@ describe Hamster::List do
|
|
17
12
|
it "doesn't run out of stack" do
|
18
13
|
-> { @list.send(method, STACK_OVERFLOW_DEPTH) }.should_not raise_error
|
19
14
|
end
|
20
|
-
|
21
15
|
end
|
22
16
|
|
23
17
|
[
|
@@ -28,7 +22,6 @@ describe Hamster::List do
|
|
28
22
|
].each do |values, number, expected|
|
29
23
|
|
30
24
|
describe "#{values.inspect} with #{number}" do
|
31
|
-
|
32
25
|
before do
|
33
26
|
@original = Hamster.list(*values)
|
34
27
|
@result = @original.send(method, number)
|
@@ -37,13 +30,8 @@ describe Hamster::List do
|
|
37
30
|
it "returns #{expected.inspect}" do
|
38
31
|
@result.should == expected
|
39
32
|
end
|
40
|
-
|
41
33
|
end
|
42
|
-
|
43
34
|
end
|
44
|
-
|
45
35
|
end
|
46
|
-
|
47
36
|
end
|
48
|
-
|
49
|
-
end
|
37
|
+
end
|
@@ -1,12 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "hamster/tuple"
|
4
3
|
require "hamster/list"
|
5
4
|
|
6
5
|
describe Hamster::List do
|
7
|
-
|
8
6
|
describe "#break" do
|
9
|
-
|
10
7
|
it "is lazy" do
|
11
8
|
-> { Hamster.stream { fail }.break { |item| false } }.should_not raise_error
|
12
9
|
end
|
@@ -23,13 +20,11 @@ describe Hamster::List do
|
|
23
20
|
].each do |values, expected_prefix, expected_remainder|
|
24
21
|
|
25
22
|
describe "on #{values.inspect}" do
|
26
|
-
|
27
23
|
before do
|
28
24
|
@original = Hamster.list(*values)
|
29
25
|
end
|
30
26
|
|
31
27
|
describe "with a block" do
|
32
|
-
|
33
28
|
before do
|
34
29
|
@result = @original.break { |item| item > 2 }
|
35
30
|
@prefix = @result.first
|
@@ -51,11 +46,9 @@ describe Hamster::List do
|
|
51
46
|
it "correctly identifies the remainder" do
|
52
47
|
@remainder.should == Hamster.list(*expected_remainder)
|
53
48
|
end
|
54
|
-
|
55
49
|
end
|
56
50
|
|
57
51
|
describe "without a block" do
|
58
|
-
|
59
52
|
before do
|
60
53
|
@result = @original.break
|
61
54
|
@prefix = @result.first
|
@@ -73,13 +66,8 @@ describe Hamster::List do
|
|
73
66
|
it "leaves the remainder empty" do
|
74
67
|
@remainder.should be_empty
|
75
68
|
end
|
76
|
-
|
77
69
|
end
|
78
|
-
|
79
70
|
end
|
80
|
-
|
81
71
|
end
|
82
|
-
|
83
72
|
end
|
84
|
-
|
85
|
-
end
|
73
|
+
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "hamster/list"
|
4
3
|
|
5
4
|
describe Hamster::List do
|
6
|
-
|
7
5
|
[
|
8
6
|
[[], :car, nil],
|
9
7
|
[["A"], :car, "A"],
|
@@ -21,13 +19,11 @@ describe Hamster::List do
|
|
21
19
|
].each do |values, method, expected|
|
22
20
|
|
23
21
|
describe "##{method}" do
|
24
|
-
|
25
22
|
it "is responded to" do
|
26
23
|
Hamster.list.respond_to?(method).should == true
|
27
24
|
end
|
28
25
|
|
29
26
|
describe "on #{values.inspect}" do
|
30
|
-
|
31
27
|
before do
|
32
28
|
@original = Hamster.list(*values)
|
33
29
|
@result = @original.send(method)
|
@@ -40,11 +36,7 @@ describe Hamster::List do
|
|
40
36
|
it "returns #{expected.inspect}" do
|
41
37
|
@result.should == expected
|
42
38
|
end
|
43
|
-
|
44
39
|
end
|
45
|
-
|
46
40
|
end
|
47
|
-
|
48
41
|
end
|
49
|
-
|
50
|
-
end
|
42
|
+
end
|
@@ -1,11 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
require "hamster/list"
|
4
3
|
|
5
4
|
describe Hamster::List do
|
6
|
-
|
7
5
|
describe "#chunk" do
|
8
|
-
|
9
6
|
it "is lazy" do
|
10
7
|
-> { Hamster.stream { fail }.chunk(2) }.should_not raise_error
|
11
8
|
end
|
@@ -17,7 +14,6 @@ describe Hamster::List do
|
|
17
14
|
].each do |values, expected|
|
18
15
|
|
19
16
|
describe "on #{values.inspect}" do
|
20
|
-
|
21
17
|
before do
|
22
18
|
@original = Hamster.list(*values)
|
23
19
|
@result = @original.chunk(2)
|
@@ -30,11 +26,7 @@ describe Hamster::List do
|
|
30
26
|
it "returns #{expected.inspect}" do
|
31
27
|
@result.should == Hamster.list(*expected)
|
32
28
|
end
|
33
|
-
|
34
29
|
end
|
35
|
-
|
36
30
|
end
|
37
|
-
|
38
31
|
end
|
39
|
-
|
40
|
-
end
|
32
|
+
end
|