hamster 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +14 -0
- data/README.rdoc +2 -2
- data/lib/hamster/hash.rb +10 -9
- data/lib/hamster/list.rb +96 -64
- data/lib/hamster/set.rb +12 -5
- data/lib/hamster/version.rb +1 -1
- data/spec/hamster/hash/all_spec.rb +1 -1
- data/spec/hamster/hash/eql_spec.rb +42 -13
- data/spec/hamster/hash/filter_spec.rb +1 -1
- data/spec/hamster/hash/reduce_spec.rb +1 -1
- data/spec/hamster/hash/reject_spec.rb +31 -27
- data/spec/hamster/list/all_spec.rb +73 -0
- data/spec/hamster/list/any_spec.rb +77 -0
- data/spec/hamster/list/cadr_spec.rb +4 -2
- data/spec/hamster/list/cons_spec.rb +6 -4
- data/spec/hamster/list/copying_spec.rb +4 -2
- data/spec/hamster/list/drop_spec.rb +16 -2
- data/spec/hamster/list/drop_while_spec.rb +17 -3
- data/spec/hamster/list/each_spec.rb +18 -4
- data/spec/hamster/list/empty_spec.rb +4 -2
- data/spec/hamster/list/eql_spec.rb +41 -7
- data/spec/hamster/list/filter_spec.rb +20 -6
- data/spec/hamster/list/find_spec.rb +63 -0
- data/spec/hamster/list/head_spec.rb +4 -2
- data/spec/hamster/list/include_spec.rb +16 -2
- data/spec/hamster/list/inspect_spec.rb +16 -2
- data/spec/hamster/list/map_spec.rb +18 -4
- data/spec/hamster/list/none_spec.rb +73 -0
- data/spec/hamster/list/reduce_spec.rb +66 -12
- data/spec/hamster/list/reject_spec.rb +39 -21
- data/spec/hamster/list/size_spec.rb +16 -2
- data/spec/hamster/list/tail_spec.rb +4 -2
- data/spec/hamster/list/take_spec.rb +16 -2
- data/spec/hamster/list/take_while_spec.rb +18 -4
- data/spec/hamster/list/to_a_spec.rb +16 -2
- data/spec/hamster/list/to_ary_spec.rb +42 -0
- data/spec/hamster/set/eql_spec.rb +35 -5
- data/spec/hamster/set/filter_spec.rb +1 -1
- data/spec/hamster/set/reduce_spec.rb +1 -1
- data/spec/hamster/set/reject_spec.rb +31 -27
- data/spec/hamster/set/to_a_spec.rb +29 -0
- data/spec/hamster/stack/copying_spec.rb +4 -2
- data/spec/hamster/stack/empty_spec.rb +4 -2
- data/spec/hamster/stack/eql_spec.rb +27 -7
- data/spec/hamster/stack/inspect_spec.rb +4 -2
- data/spec/hamster/stack/pop_spec.rb +12 -8
- data/spec/hamster/stack/push_spec.rb +6 -4
- data/spec/hamster/stack/size_spec.rb +4 -2
- data/spec/hamster/stack/top_spec.rb +6 -4
- metadata +8 -2
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe Hamster::Set do
|
4
|
+
|
5
|
+
describe "#to_a" do
|
6
|
+
|
7
|
+
[
|
8
|
+
[],
|
9
|
+
["A"],
|
10
|
+
["A", "B", "C"],
|
11
|
+
].each do |values|
|
12
|
+
|
13
|
+
describe "on #{values.inspect}" do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@set = Hamster.set(*values)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns #{values.inspect}" do
|
20
|
+
@set.to_a.sort.should == values.sort
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -12,10 +12,12 @@ describe Hamster::Stack do
|
|
12
12
|
|
13
13
|
describe "on #{values.inspect}" do
|
14
14
|
|
15
|
-
|
15
|
+
before do
|
16
|
+
@stack = Hamster.stack(*values)
|
17
|
+
end
|
16
18
|
|
17
19
|
it "returns self" do
|
18
|
-
stack.send(method).should equal(stack)
|
20
|
+
@stack.send(method).should equal(@stack)
|
19
21
|
end
|
20
22
|
|
21
23
|
end
|
@@ -12,10 +12,12 @@ describe Hamster::Stack do
|
|
12
12
|
|
13
13
|
describe "on #{values.inspect}" do
|
14
14
|
|
15
|
-
|
15
|
+
before do
|
16
|
+
@stack = Hamster.stack(*values)
|
17
|
+
end
|
16
18
|
|
17
19
|
it "returns #{expected}" do
|
18
|
-
stack.empty?.should == expected
|
20
|
+
@stack.empty?.should == expected
|
19
21
|
end
|
20
22
|
|
21
23
|
end
|
@@ -6,25 +6,45 @@ describe Hamster::Stack do
|
|
6
6
|
|
7
7
|
describe "##{method}" do
|
8
8
|
|
9
|
+
describe "returns false when comparing with" do
|
10
|
+
|
11
|
+
before do
|
12
|
+
@stack = Hamster.stack("A", "B", "C")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "a list" do
|
16
|
+
@stack.send(method, Hamster.list("C", "B", "A")).should be_false
|
17
|
+
end
|
18
|
+
|
19
|
+
it "an aribtrary object" do
|
20
|
+
@stack.send(method, Object.new).should be_false
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
9
25
|
[
|
10
26
|
[[], [], true],
|
11
27
|
[["A"], [], false],
|
12
|
-
[[], ["A"], false],
|
13
28
|
[["A"], ["A"], true],
|
14
29
|
[["A"], ["B"], false],
|
15
30
|
[["A", "B"], ["A"], false],
|
16
|
-
[["A"], ["A", "B"], false],
|
17
31
|
[["A", "B", "C"], ["A", "B", "C"], true],
|
18
32
|
[["C", "A", "B"], ["A", "B", "C"], false],
|
19
33
|
].each do |a, b, expected|
|
20
34
|
|
21
|
-
describe "
|
35
|
+
describe "returns #{expected}" do
|
22
36
|
|
23
|
-
|
24
|
-
|
37
|
+
before do
|
38
|
+
@a = Hamster.stack(*a)
|
39
|
+
@b = Hamster.stack(*b)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "for #{a.inspect} and #{b.inspect}" do
|
43
|
+
@a.send(method, @b).should == expected
|
44
|
+
end
|
25
45
|
|
26
|
-
it "
|
27
|
-
|
46
|
+
it "for #{b.inspect} and #{a.inspect}" do
|
47
|
+
@b.send(method, @a).should == expected
|
28
48
|
end
|
29
49
|
|
30
50
|
end
|
@@ -12,10 +12,12 @@ describe Hamster::Stack do
|
|
12
12
|
|
13
13
|
describe "on #{values.inspect}" do
|
14
14
|
|
15
|
-
|
15
|
+
before do
|
16
|
+
@stack = Hamster.stack(*values)
|
17
|
+
end
|
16
18
|
|
17
19
|
it "returns #{expected}" do
|
18
|
-
stack.inspect.should == expected
|
20
|
+
@stack.inspect.should == expected
|
19
21
|
end
|
20
22
|
|
21
23
|
end
|
@@ -11,15 +11,17 @@ describe Hamster::Stack do
|
|
11
11
|
|
12
12
|
describe "on #{values.inspect}" do
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
before do
|
15
|
+
@original = Hamster.stack(*values)
|
16
|
+
@result = @original.pop
|
17
|
+
end
|
16
18
|
|
17
19
|
it "preserves the original" do
|
18
|
-
original.should == Hamster.stack(*values)
|
20
|
+
@original.should == Hamster.stack(*values)
|
19
21
|
end
|
20
22
|
|
21
23
|
it "returns #{expected.inspect}" do
|
22
|
-
result.should == Hamster.stack(*expected)
|
24
|
+
@result.should == Hamster.stack(*expected)
|
23
25
|
end
|
24
26
|
|
25
27
|
end
|
@@ -33,15 +35,17 @@ describe Hamster::Stack do
|
|
33
35
|
|
34
36
|
describe "on #{values.inspect}" do
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
+
before do
|
39
|
+
@original = Hamster.stack(*values)
|
40
|
+
@result = @original.pop
|
41
|
+
end
|
38
42
|
|
39
43
|
it "preserves the original" do
|
40
|
-
original.should == Hamster.stack(*values)
|
44
|
+
@original.should == Hamster.stack(*values)
|
41
45
|
end
|
42
46
|
|
43
47
|
it "returns the empty stack" do
|
44
|
-
result.should equal(Hamster.stack)
|
48
|
+
@result.should equal(Hamster.stack)
|
45
49
|
end
|
46
50
|
|
47
51
|
end
|
@@ -15,15 +15,17 @@ describe Hamster::Stack do
|
|
15
15
|
|
16
16
|
describe "on #{values.inspect} with #{new_value.inspect}" do
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
before do
|
19
|
+
@original = Hamster.stack(*values)
|
20
|
+
@result = @original.send(method, new_value)
|
21
|
+
end
|
20
22
|
|
21
23
|
it "preserves the original" do
|
22
|
-
original.should == Hamster.stack(*values)
|
24
|
+
@original.should == Hamster.stack(*values)
|
23
25
|
end
|
24
26
|
|
25
27
|
it "returns #{expected.inspect}" do
|
26
|
-
result.should == Hamster.stack(*expected)
|
28
|
+
@result.should == Hamster.stack(*expected)
|
27
29
|
end
|
28
30
|
|
29
31
|
end
|
@@ -14,10 +14,12 @@ describe Hamster::Stack do
|
|
14
14
|
|
15
15
|
describe "on #{values.inspect}" do
|
16
16
|
|
17
|
-
|
17
|
+
before do
|
18
|
+
@stack = Hamster.stack(*values)
|
19
|
+
end
|
18
20
|
|
19
21
|
it "returns #{expected}" do
|
20
|
-
stack.send(method).should == expected
|
22
|
+
@stack.send(method).should == expected
|
21
23
|
end
|
22
24
|
|
23
25
|
end
|
@@ -12,15 +12,17 @@ describe Hamster::Stack do
|
|
12
12
|
|
13
13
|
describe "on #{values.inspect}" do
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
before do
|
16
|
+
@original = Hamster.stack(*values)
|
17
|
+
@result = @original.top
|
18
|
+
end
|
17
19
|
|
18
20
|
it "preserves the original" do
|
19
|
-
original.should == Hamster.stack(*values)
|
21
|
+
@original.should == Hamster.stack(*values)
|
20
22
|
end
|
21
23
|
|
22
24
|
it "returns #{expected.inspect}" do
|
23
|
-
result.should == expected
|
25
|
+
@result.should == expected
|
24
26
|
end
|
25
27
|
|
26
28
|
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.1.
|
4
|
+
version: 0.1.14
|
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: 2009-12-
|
12
|
+
date: 2009-12-14 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -48,6 +48,8 @@ files:
|
|
48
48
|
- spec/hamster/hash/reject_spec.rb
|
49
49
|
- spec/hamster/hash/remove_spec.rb
|
50
50
|
- spec/hamster/hash/size_spec.rb
|
51
|
+
- spec/hamster/list/all_spec.rb
|
52
|
+
- spec/hamster/list/any_spec.rb
|
51
53
|
- spec/hamster/list/cadr_spec.rb
|
52
54
|
- spec/hamster/list/cons_spec.rb
|
53
55
|
- spec/hamster/list/construction_spec.rb
|
@@ -58,10 +60,12 @@ files:
|
|
58
60
|
- spec/hamster/list/empty_spec.rb
|
59
61
|
- spec/hamster/list/eql_spec.rb
|
60
62
|
- spec/hamster/list/filter_spec.rb
|
63
|
+
- spec/hamster/list/find_spec.rb
|
61
64
|
- spec/hamster/list/head_spec.rb
|
62
65
|
- spec/hamster/list/include_spec.rb
|
63
66
|
- spec/hamster/list/inspect_spec.rb
|
64
67
|
- spec/hamster/list/map_spec.rb
|
68
|
+
- spec/hamster/list/none_spec.rb
|
65
69
|
- spec/hamster/list/reduce_spec.rb
|
66
70
|
- spec/hamster/list/reject_spec.rb
|
67
71
|
- spec/hamster/list/size_spec.rb
|
@@ -69,6 +73,7 @@ files:
|
|
69
73
|
- spec/hamster/list/take_spec.rb
|
70
74
|
- spec/hamster/list/take_while_spec.rb
|
71
75
|
- spec/hamster/list/to_a_spec.rb
|
76
|
+
- spec/hamster/list/to_ary_spec.rb
|
72
77
|
- spec/hamster/set/add_spec.rb
|
73
78
|
- spec/hamster/set/all_spec.rb
|
74
79
|
- spec/hamster/set/any_spec.rb
|
@@ -85,6 +90,7 @@ files:
|
|
85
90
|
- spec/hamster/set/reject_spec.rb
|
86
91
|
- spec/hamster/set/remove_spec.rb
|
87
92
|
- spec/hamster/set/size_spec.rb
|
93
|
+
- spec/hamster/set/to_a_spec.rb
|
88
94
|
- spec/hamster/stack/construction_spec.rb
|
89
95
|
- spec/hamster/stack/copying_spec.rb
|
90
96
|
- spec/hamster/stack/empty_spec.rb
|