compsci 0.3.0.1 → 0.3.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/test/flex_node.rb ADDED
@@ -0,0 +1,226 @@
1
+ require 'compsci/flex_node'
2
+ require 'minitest/autorun'
3
+
4
+ include CompSci
5
+
6
+ describe FlexNode do
7
+ before do
8
+ @martin_sheen = FlexNode.new 'martin'
9
+ @charlie_sheen = FlexNode.new 'charlie'
10
+ @emilio_estevez = FlexNode.new 'emilio'
11
+ end
12
+
13
+ it "must track children" do
14
+ @charlie_sheen.add_parent(@martin_sheen)
15
+ expect(@martin_sheen.children).must_include @charlie_sheen
16
+ expect(@martin_sheen.children).wont_include @emilio_estevez
17
+
18
+ @martin_sheen.add_child @emilio_estevez
19
+ expect(@martin_sheen.children).must_include @emilio_estevez
20
+ end
21
+
22
+ it "must create children from scalars" do
23
+ @martin_sheen.new_child 'fake_emilio'
24
+ expect(@martin_sheen.children.size).must_equal 1
25
+ expect(@martin_sheen.children.first.value).must_equal 'fake_emilio'
26
+ expect(@martin_sheen.children).wont_include @emilio_estevez
27
+ end
28
+
29
+ it "does depth-first search" do
30
+ vals = (0..30).to_a
31
+ root = FlexNode.new vals.shift
32
+ root.new_child vals.shift
33
+ root.new_child vals.shift
34
+ root.children.each { |c|
35
+ c.new_child vals.shift
36
+ c.new_child vals.shift
37
+
38
+ c.children.each { |cc|
39
+ cc.new_child vals.shift
40
+ cc.new_child vals.shift
41
+ }
42
+ }
43
+
44
+ visited = []
45
+ root.df_search { |n|
46
+ visited << n.value
47
+ false
48
+ }
49
+ expect(visited).wont_be_empty
50
+ expect(visited).must_equal [0, 1, 3, 5, 6, 4, 7, 8, 2, 9, 11, 12, 10, 13, 14]
51
+ end
52
+
53
+ it "does breadth-first search" do
54
+ vals = (0..30).to_a
55
+ root = FlexNode.new vals.shift
56
+ root.new_child vals.shift
57
+ root.new_child vals.shift
58
+ root.children.each { |c|
59
+ c.new_child vals.shift
60
+ c.new_child vals.shift
61
+
62
+ c.children.each { |cc|
63
+ cc.new_child vals.shift
64
+ cc.new_child vals.shift
65
+ }
66
+ }
67
+
68
+ visited = []
69
+ root.bf_search { |n|
70
+ visited << n.value
71
+ false
72
+ }
73
+ expect(visited).wont_be_empty
74
+ expect(visited).must_equal [0, 1, 2, 3, 4, 9, 10, 5, 6, 7, 8, 11, 12, 13, 14]
75
+ end
76
+
77
+ describe "Binary FlexNode" do
78
+ before do
79
+ @root = FlexNode.new 100
80
+ @child_slots = 2
81
+ end
82
+
83
+ it "must have an open parent" do
84
+ expect(@root.open_parent?(@child_slots)).must_equal true
85
+ expect(@root.open_parent(@child_slots)).must_equal @root
86
+ end
87
+
88
+ it "must push a value onto an open parent" do
89
+ opc = @root.open_parent(@child_slots).children.size
90
+ @root.push 27, @child_slots
91
+ expect(@root.open_parent(@child_slots).children.size).must_equal opc + 1
92
+ end
93
+
94
+ it "must display properly via @root" do
95
+ item_count = 31
96
+ # tree already has a root node
97
+ (item_count - 1).times { @root.push(rand(99), @child_slots) }
98
+ str = @root.display
99
+ line_count = str.split("\n").size
100
+ expect(line_count).must_equal Math.log(item_count + 1, 2).ceil
101
+ end
102
+
103
+ describe "searching" do
104
+ before do
105
+ @root = FlexNode.new 42
106
+ @child_slots = 2
107
+ 99.times { |i| @root.push(i, @child_slots) }
108
+ end
109
+
110
+ it "must find 42 quickly" do
111
+ count = 0
112
+ expect(@root.df_search { |n|
113
+ count += 1
114
+ n.value == 42
115
+ }).must_equal @root
116
+ expect(count).must_equal 1
117
+
118
+ count = 0
119
+ expect(@root.bf_search { |n|
120
+ count += 1
121
+ n.value == 42
122
+ }).must_equal @root
123
+ expect(count).must_equal 1
124
+ end
125
+
126
+ it "must find 99 slowly" do
127
+ count = 0
128
+ @root.df_search { |n|
129
+ count += 1
130
+ n.value == 99
131
+ }
132
+ expect(count).must_equal 100
133
+
134
+ count = 0
135
+ @root.bf_search { |n|
136
+ count += 1
137
+ n.value == 99
138
+ }
139
+ expect(count).must_equal 100
140
+ end
141
+
142
+ it "must find 81 accordingly" do
143
+ count = 0
144
+ @root.df_search { |n|
145
+ count += 1
146
+ n.value == 81
147
+ }
148
+ expect(count).must_equal 42
149
+
150
+ count = 0
151
+ @root.bf_search { |n|
152
+ count += 1
153
+ n.value == 81
154
+ }
155
+ expect(count).must_equal 83
156
+ end
157
+ end
158
+ end
159
+ end
160
+
161
+
162
+
163
+
164
+ describe ChildFlexNode do
165
+ before do
166
+ @martin_sheen = ChildFlexNode.new 'martin'
167
+ @charlie_sheen = ChildFlexNode.new 'charlie'
168
+ @emilio_estevez = ChildFlexNode.new 'emilio'
169
+ end
170
+
171
+ it "must track parent and children" do
172
+ @charlie_sheen.add_parent(@martin_sheen)
173
+ expect(@charlie_sheen.parent).must_equal @martin_sheen
174
+ expect(@martin_sheen.children).must_include @charlie_sheen
175
+ expect(@martin_sheen.children).wont_include @emilio_estevez
176
+
177
+ @martin_sheen.add_child @emilio_estevez
178
+ expect(@martin_sheen.children).must_include @emilio_estevez
179
+ expect(@emilio_estevez.parent).must_equal @martin_sheen
180
+ end
181
+
182
+ it "must determine a node's generation" do
183
+ expect(@emilio_estevez.gen).must_equal 0
184
+ @martin_sheen.add_child @emilio_estevez
185
+ expect(@emilio_estevez.gen).must_equal 1
186
+ end
187
+
188
+ it "must create children from scalars" do
189
+ @martin_sheen.new_child 'fake_emilio'
190
+ expect(@martin_sheen.children.size).must_equal 1
191
+ expect(@martin_sheen.children.first.value).must_equal 'fake_emilio'
192
+ expect(@martin_sheen.children).wont_include @emilio_estevez
193
+ end
194
+
195
+ it "must recognize siblings" do
196
+ @charlie_sheen.add_parent @martin_sheen
197
+ @emilio_estevez.add_parent @martin_sheen
198
+ @martin_sheen.new_child 'fake_emilio'
199
+
200
+ expect(@charlie_sheen.siblings).must_include @emilio_estevez
201
+ expect(@charlie_sheen.siblings).wont_include @martin_sheen
202
+ expect(@emilio_estevez.siblings).must_include @charlie_sheen
203
+ expect(@martin_sheen.siblings).must_be_empty
204
+ expect(@emilio_estevez.siblings.find { |n|
205
+ n.value == 'fake_emilio'
206
+ }).wont_be_nil
207
+ end
208
+
209
+ describe "Quaternary ChildFlexNode" do
210
+ before do
211
+ @root = ChildFlexNode.new 42
212
+ @child_slots = 4
213
+ end
214
+
215
+ it "must have an open parent" do
216
+ expect(@root.open_parent?(@child_slots)).must_equal true
217
+ expect(@root.open_parent(@child_slots)).must_equal @root
218
+ end
219
+
220
+ it "must push a value onto an open parent" do
221
+ opc = @root.open_parent(@child_slots).children.size
222
+ @root.push 27, @child_slots
223
+ expect(@root.open_parent(@child_slots).children.size).must_equal opc + 1
224
+ end
225
+ end
226
+ end
data/test/heap.rb CHANGED
@@ -11,39 +11,39 @@ describe Heap do
11
11
  end
12
12
 
13
13
  it "must satisfy the heap property" do
14
- @maxheap.heap?.must_equal true
15
- @maxheap.array.wont_equal @inserts
16
- @maxheap.array.wont_equal @inserts.reverse
14
+ expect(@maxheap.heap?).must_equal true
15
+ expect(@maxheap.array).wont_equal @inserts
16
+ expect(@maxheap.array).wont_equal @inserts.reverse
17
17
  end
18
18
 
19
19
  it "must recognize heap violations" do
20
20
  @maxheap.array.unshift 0
21
- @maxheap.heap?.must_equal false
21
+ expect(@maxheap.heap?).must_equal false
22
22
  @maxheap.array.shift
23
- @maxheap.heap?.must_equal true
23
+ expect(@maxheap.heap?).must_equal true
24
24
 
25
25
  @maxheap.array.push 10
26
- @maxheap.heap?.must_equal false
26
+ expect(@maxheap.heap?).must_equal false
27
27
  @maxheap.sift_up @maxheap.last_idx
28
- @maxheap.heap?.must_equal true
28
+ expect(@maxheap.heap?).must_equal true
29
29
  end
30
30
 
31
31
  it "must pop" do
32
- @maxheap.pop.must_equal 10
33
- @maxheap.peek.wont_equal 10
34
- @maxheap.heap?.must_equal true
32
+ expect(@maxheap.pop).must_equal 10
33
+ expect(@maxheap.peek).wont_equal 10
34
+ expect(@maxheap.heap?).must_equal true
35
35
  end
36
36
 
37
37
  it "must heapish?" do
38
- @maxheap.array[0].must_be :>, @maxheap.array[1]
39
- @maxheap.heapish?(0, 1).must_equal true
38
+ expect(@maxheap.array[0]).must_be :>, @maxheap.array[1]
39
+ expect(@maxheap.heapish?(0, 1)).must_equal true
40
40
  end
41
41
 
42
42
  it "must heapiest" do
43
- @maxheap.heapiest([1, 2]).must_equal 1
44
- @maxheap.heapiest([3, 4]).must_equal 4
45
- @maxheap.heapiest([5, 6]).must_equal 6
46
- @maxheap.heapiest([7, 8]).must_equal 8
43
+ expect(@maxheap.heapiest([1, 2])).must_equal 1
44
+ expect(@maxheap.heapiest([3, 4])).must_equal 4
45
+ expect(@maxheap.heapiest([5, 6])).must_equal 6
46
+ expect(@maxheap.heapiest([7, 8])).must_equal 8
47
47
  end
48
48
  end
49
49
 
@@ -54,38 +54,38 @@ describe Heap do
54
54
  end
55
55
 
56
56
  it "must satisfy the heap property" do
57
- @minheap.heap?.must_equal true
58
- @minheap.array.must_equal @inserts
57
+ expect(@minheap.heap?).must_equal true
58
+ expect(@minheap.array).must_equal @inserts
59
59
  end
60
60
 
61
61
  it "must recognize heap violations" do
62
62
  @minheap.array.unshift 10
63
- @minheap.heap?.must_equal false
63
+ expect(@minheap.heap?).must_equal false
64
64
  @minheap.array.shift
65
- @minheap.heap?.must_equal true
65
+ expect(@minheap.heap?).must_equal true
66
66
 
67
67
  @minheap.array.push 0
68
- @minheap.heap?.must_equal false
68
+ expect(@minheap.heap?).must_equal false
69
69
  @minheap.sift_up @minheap.last_idx
70
- @minheap.heap?.must_equal true
70
+ expect(@minheap.heap?).must_equal true
71
71
  end
72
72
 
73
73
  it "must pop" do
74
- @minheap.pop.must_equal 1
75
- @minheap.peek.wont_equal 1
76
- @minheap.heap?.must_equal true
74
+ expect(@minheap.pop).must_equal 1
75
+ expect(@minheap.peek).wont_equal 1
76
+ expect(@minheap.heap?).must_equal true
77
77
  end
78
78
 
79
79
  it "must heapish?" do
80
- @minheap.array[0].must_be :<, @minheap.array[1]
81
- @minheap.heapish?(0, 1).must_equal true
80
+ expect(@minheap.array[0]).must_be :<, @minheap.array[1]
81
+ expect(@minheap.heapish?(0, 1)).must_equal true
82
82
  end
83
83
 
84
84
  it "must heapiest" do
85
- @minheap.heapiest([1, 2]).must_equal 1
86
- @minheap.heapiest([3, 4]).must_equal 3
87
- @minheap.heapiest([5, 6]).must_equal 5
88
- @minheap.heapiest([7, 8]).must_equal 7
85
+ expect(@minheap.heapiest([1, 2])).must_equal 1
86
+ expect(@minheap.heapiest([3, 4])).must_equal 3
87
+ expect(@minheap.heapiest([5, 6])).must_equal 5
88
+ expect(@minheap.heapiest([7, 8])).must_equal 7
89
89
  end
90
90
  end
91
91
 
@@ -96,38 +96,38 @@ describe Heap do
96
96
  end
97
97
 
98
98
  it "must satisfy the heap property" do
99
- @heap3.heap?.must_equal true
100
- @heap3.array.wont_equal @inserts
101
- @heap3.array.wont_equal @inserts.reverse
99
+ expect(@heap3.heap?).must_equal true
100
+ expect(@heap3.array).wont_equal @inserts
101
+ expect(@heap3.array).wont_equal @inserts.reverse
102
102
  end
103
103
 
104
104
  it "must recognize heap violations" do
105
105
  @heap3.array.unshift 0
106
- @heap3.heap?.must_equal false
106
+ expect(@heap3.heap?).must_equal false
107
107
  @heap3.array.shift
108
- @heap3.heap?.must_equal true
108
+ expect(@heap3.heap?).must_equal true
109
109
 
110
110
  @heap3.array.push 10
111
- @heap3.heap?.must_equal false
111
+ expect(@heap3.heap?).must_equal false
112
112
  @heap3.sift_up @heap3.last_idx
113
- @heap3.heap?.must_equal true
113
+ expect(@heap3.heap?).must_equal true
114
114
  end
115
115
 
116
116
  it "must pop" do
117
- @heap3.pop.must_equal 10
118
- @heap3.peek.wont_equal 10
119
- @heap3.heap?.must_equal true
117
+ expect(@heap3.pop).must_equal 10
118
+ expect(@heap3.peek).wont_equal 10
119
+ expect(@heap3.heap?).must_equal true
120
120
  end
121
121
 
122
122
  it "must heapish?" do
123
- @heap3.array[0].must_be :>, @heap3.array[1]
124
- @heap3.heapish?(0, 1).must_equal true
123
+ expect(@heap3.array[0]).must_be :>, @heap3.array[1]
124
+ expect(@heap3.heapish?(0, 1)).must_equal true
125
125
  end
126
126
 
127
127
  it "must heapiest" do
128
- @heap3.heapiest([1, 2, 3]).must_equal 2
129
- @heap3.heapiest([4, 5, 6]).must_equal 6
130
- @heap3.heapiest([7, 8, 9]).must_equal 9
128
+ expect(@heap3.heapiest([1, 2, 3])).must_equal 2
129
+ expect(@heap3.heapiest([4, 5, 6])).must_equal 6
130
+ expect(@heap3.heapiest([7, 8, 9])).must_equal 9
131
131
  end
132
132
  end
133
133
  end
data/test/names.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'compsci/names'
2
2
  require 'compsci/names/greek'
3
+ require 'compsci/names/pokemon'
3
4
  require 'minitest/autorun'
4
5
 
5
6
  include CompSci
@@ -7,91 +8,129 @@ include CompSci
7
8
  describe Names do
8
9
  describe "alphabetic constants" do
9
10
  it "must have size 26" do
10
- Names::WW1.size.must_equal 26
11
- Names::WW2.size.must_equal 26
12
- Names::NATO.size.must_equal 26
13
- Names::ENGLISH_UPPER.size.must_equal 26
14
- Names::ENGLISH_LOWER.size.must_equal 26
11
+ expect(Names::WW1.size).must_equal 26
12
+ expect(Names::WW2.size).must_equal 26
13
+ expect(Names::NATO.size).must_equal 26
14
+ expect(Names::ENGLISH_UPPER.size).must_equal 26
15
+ expect(Names::ENGLISH_LOWER.size).must_equal 26
15
16
  end
16
17
  end
17
18
 
18
19
  describe "Names.assign" do
19
20
  it "must handle English / ASCII strings" do
20
21
  upper_lower = Names::ENGLISH_UPPER + Names::ENGLISH_LOWER
21
- Names.assign('cat', Names::ENGLISH_UPPER).must_equal 'C'
22
- Names.assign('Cat', Names::ENGLISH_UPPER).must_equal 'C'
23
- Names.assign('cat', Names::ENGLISH_LOWER).must_equal 'c'
24
- Names.assign('Cat', Names::ENGLISH_LOWER).must_equal 'c'
25
- Names.assign('Cat', upper_lower).must_equal 'C'
26
- Names.assign('cat', upper_lower).must_equal 'c'
27
- Names.assign('cat', Names::NATO).must_equal :charlie
28
- Names.assign('Cat', Names::NATO).must_equal :charlie
29
- Names.assign('Dog', Names::CRYPTO).must_equal :david
30
- Names.assign('2', Names::PLANETS).must_equal :earth
31
- end
22
+ expect(Names.assign('cat', Names::ENGLISH_UPPER)).must_equal 'C'
23
+ expect(Names.assign('Cat', Names::ENGLISH_UPPER)).must_equal 'C'
24
+ expect(Names.assign('cat', Names::ENGLISH_LOWER)).must_equal 'c'
25
+ expect(Names.assign('Cat', Names::ENGLISH_LOWER)).must_equal 'c'
26
+ expect(Names.assign('Cat', upper_lower)).must_equal 'C'
27
+ expect(Names.assign('cat', upper_lower)).must_equal 'c'
28
+ expect(Names.assign('cat', Names::NATO)).must_equal :charlie
29
+ expect(Names.assign('Cat', Names::NATO)).must_equal :charlie
30
+ expect(Names.assign('Dog', Names::CRYPTO)).must_equal :david
31
+ expect(Names.assign('2', Names::PLANETS)).must_equal :earth end
32
32
 
33
33
  it "must handle integers" do
34
34
  upper_lower = Names::ENGLISH_UPPER + Names::ENGLISH_LOWER
35
- Names.assign(36, upper_lower).must_equal 'k'
36
- Names.assign(0, upper_lower).must_equal 'A'
37
- Names.assign(0, Names::ENGLISH_UPPER).must_equal 'A'
38
- Names.assign(3, Names::ENGLISH_LOWER).must_equal 'd'
39
- Names.assign(3, Names::PLANETS).must_equal :mars
35
+ expect(Names.assign(36, upper_lower)).must_equal 'k'
36
+ expect(Names.assign(0, upper_lower)).must_equal 'A'
37
+ expect(Names.assign(0, Names::ENGLISH_UPPER)).must_equal 'A'
38
+ expect(Names.assign(3, Names::ENGLISH_LOWER)).must_equal 'd'
39
+ expect(Names.assign(3, Names::PLANETS)).must_equal :mars
40
40
  end
41
41
  end
42
42
 
43
43
  describe Names::Greek do
44
44
  describe "greek alphabetic constants" do
45
45
  it "must have size 24" do
46
- Names::Greek::UPPER.size.must_equal 24
47
- Names::Greek::LOWER.size.must_equal 24
48
- Names::Greek::SYMBOLS.size.must_equal 24
49
- Names::Greek::CHAR_MAP.size.must_equal 24
46
+ expect(Names::Greek::UPPER.size).must_equal 24
47
+ expect(Names::Greek::LOWER.size).must_equal 24
48
+ expect(Names::Greek::SYMBOLS.size).must_equal 24
49
+ expect(Names::Greek::CHAR_MAP.size).must_equal 24
50
50
  end
51
51
  end
52
52
 
53
53
  describe "SYMBOLS26" do
54
54
  it "must work well with Names.assign" do
55
55
  s26 = Names::Greek::SYMBOLS26
56
- Names.assign('iota', s26).must_equal :iota
57
- Names.assign('jota', s26).must_equal :xi
58
- Names.assign('Query', s26).must_equal :xi
59
- Names.assign('who', s26).must_equal :xi
60
- Names.assign('zeta', s26).must_equal :omega
61
- Names.assign(0, s26).must_equal :alpha
62
- Names.assign('1', s26).must_equal :beta
56
+ expect(Names.assign('iota', s26)).must_equal :iota
57
+ expect(Names.assign('jota', s26)).must_equal :xi
58
+ expect(Names.assign('Query', s26)).must_equal :xi
59
+ expect(Names.assign('who', s26)).must_equal :xi
60
+ expect(Names.assign('zeta', s26)).must_equal :omega
61
+ expect(Names.assign(0, s26)).must_equal :alpha
62
+ expect(Names.assign('1', s26)).must_equal :beta
63
63
  end
64
64
  end
65
- end
66
65
 
67
- describe "Greek.sym" do
68
- it "must handle strings and integers" do
69
- Names::Greek.sym('cat').must_equal :gamma
70
- Names::Greek.sym('Cat').must_equal :gamma
71
- Names::Greek.sym('zeta').must_equal :omega
72
- Names::Greek.sym(0).must_equal :alpha
73
- Names::Greek.sym('1').must_equal :beta
74
- Names::Greek.sym(23).must_equal :omega
66
+ describe "Greek.sym" do
67
+ it "must handle strings and integers" do
68
+ expect(Names::Greek.sym('cat')).must_equal :gamma
69
+ expect(Names::Greek.sym('Cat')).must_equal :gamma
70
+ expect(Names::Greek.sym('zeta')).must_equal :omega
71
+ expect(Names::Greek.sym(0)).must_equal :alpha
72
+ expect(Names::Greek.sym('1')).must_equal :beta
73
+ expect(Names::Greek.sym(23)).must_equal :omega
74
+ end
75
75
  end
76
- end
77
76
 
78
- describe "Greek.lower" do
79
- it "must handle strings and integers" do
80
- third = Names::Greek::LOWER[2]
81
- Names::Greek.lower('cat').must_equal third
82
- Names::Greek.lower('Cat').must_equal third
83
- Names::Greek.lower(2).must_equal third
84
- Names::Greek.lower('2').must_equal third
77
+ describe "Greek.lower" do
78
+ it "must handle strings and integers" do
79
+ third = Names::Greek::LOWER[2]
80
+ expect(Names::Greek.lower('cat')).must_equal third
81
+ expect(Names::Greek.lower('Cat')).must_equal third
82
+ expect(Names::Greek.lower(2)).must_equal third
83
+ expect(Names::Greek.lower('2')).must_equal third
84
+ end
85
+ end
86
+
87
+ describe "Greek.upper" do
88
+ it "must handle strings and integers" do
89
+ fourth = Names::Greek::UPPER[3]
90
+ expect(Names::Greek.upper('dog')).must_equal fourth
91
+ expect(Names::Greek.upper('Dog')).must_equal fourth
92
+ expect(Names::Greek.upper(3)).must_equal fourth
93
+ expect(Names::Greek.upper('3')).must_equal fourth
94
+ end
85
95
  end
86
96
  end
87
97
 
88
- describe "Greek.upper" do
89
- it "must handle strings and integers" do
90
- fourth = Names::Greek::UPPER[3]
91
- Names::Greek.upper('dog').must_equal fourth
92
- Names::Greek.upper('Dog').must_equal fourth
93
- Names::Greek.upper(3).must_equal fourth
94
- Names::Greek.upper('3').must_equal fourth
98
+ describe Names::Pokemon do
99
+ it "must have an array" do
100
+ ary = Names::Pokemon.array
101
+ expect(ary).must_be_kind_of Array
102
+ expect(ary.size).must_be :>, 99
103
+ end
104
+
105
+ it "must have a hash keyed by first letter" do
106
+ hsh = Names::Pokemon.hash
107
+ expect(hsh).must_be_kind_of Hash
108
+ expect(hsh.size).must_equal 26
109
+ expect(hsh['n']).must_be_kind_of Array
110
+ expect(hsh['n'].first).must_be_kind_of String
111
+ expect(hsh['n'].first).must_match(/^n/)
112
+ end
113
+
114
+ it "must grep for charizard" do
115
+ ary = Names::Pokemon.grep(/^char/, all: true)
116
+ expect(ary).must_include 'charizard'
117
+ char = Names::Pokemon.grep(/^char/, all: false)
118
+ expect(char).wont_equal 'charizard'
119
+ expect(char).must_equal 'charmander'
120
+ end
121
+
122
+ it "must convert vals to key letters" do
123
+ [5, '5', 'food', 'Food'].each { |valid|
124
+ expect(Names::Pokemon.key(valid)).must_equal 'f'
125
+ }
126
+
127
+ ['---', Names::Pokemon].each { |invalid_raise|
128
+ expect(proc { Names::Pokemon.key(invalid_raise) }).must_raise Exception
129
+ }
130
+
131
+ [4359873548].each { |invalid_nil|
132
+ expect(Names::Pokemon.key(invalid_nil).nil?).must_equal true
133
+ }
95
134
  end
96
135
  end
97
136
  end