xqsr3 0.38.1.1 → 0.39.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -6
  3. data/examples/count_word_frequencies.md +13 -13
  4. data/examples/count_word_frequencies.rb +5 -5
  5. data/lib/xqsr3/array_utilities/join_with_or.rb +53 -54
  6. data/lib/xqsr3/array_utilities.rb +2 -2
  7. data/lib/xqsr3/command_line_utilities/map_option_string.rb +66 -67
  8. data/lib/xqsr3/command_line_utilities.rb +2 -2
  9. data/lib/xqsr3/containers/frequency_map.rb +405 -404
  10. data/lib/xqsr3/containers/multi_map.rb +454 -453
  11. data/lib/xqsr3/containers.rb +3 -3
  12. data/lib/xqsr3/conversion/bool_parser.rb +56 -57
  13. data/lib/xqsr3/conversion/integer_parser.rb +92 -93
  14. data/lib/xqsr3/conversion.rb +3 -3
  15. data/lib/xqsr3/diagnostics/exception_utilities.rb +152 -151
  16. data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +99 -95
  17. data/lib/xqsr3/diagnostics/inspect_builder.rb +86 -86
  18. data/lib/xqsr3/diagnostics.rb +3 -3
  19. data/lib/xqsr3/doc_.rb +136 -136
  20. data/lib/xqsr3/extensions/array/join_with_or.rb +9 -9
  21. data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +18 -17
  22. data/lib/xqsr3/extensions/enumerable/detect_map.rb +41 -41
  23. data/lib/xqsr3/extensions/enumerable/unique.rb +32 -31
  24. data/lib/xqsr3/extensions/hash/deep_transform.rb +1 -1
  25. data/lib/xqsr3/extensions/hash/except.rb +16 -16
  26. data/lib/xqsr3/extensions/hash/has_match.rb +10 -10
  27. data/lib/xqsr3/extensions/hash/match.rb +10 -10
  28. data/lib/xqsr3/extensions/hash/slice.rb +11 -11
  29. data/lib/xqsr3/extensions/hash.rb +1 -1
  30. data/lib/xqsr3/extensions/integer/to_s_grp.rb +118 -0
  31. data/lib/xqsr3/extensions/integer.rb +3 -0
  32. data/lib/xqsr3/extensions/io/writelines.rb +34 -34
  33. data/lib/xqsr3/extensions/kernel/integer.rb +26 -26
  34. data/lib/xqsr3/extensions/kernel/raise_with_options.rb +15 -14
  35. data/lib/xqsr3/extensions/kernel.rb +1 -0
  36. data/lib/xqsr3/extensions/string/ends_with.rb +1 -1
  37. data/lib/xqsr3/extensions/string/map_option_string.rb +4 -5
  38. data/lib/xqsr3/extensions/string/nil_if_empty.rb +1 -1
  39. data/lib/xqsr3/extensions/string/nil_if_whitespace.rb +1 -1
  40. data/lib/xqsr3/extensions/string/quote_if.rb +1 -2
  41. data/lib/xqsr3/extensions/string/starts_with.rb +1 -1
  42. data/lib/xqsr3/extensions/string/to_bool.rb +8 -9
  43. data/lib/xqsr3/extensions/string/to_symbol.rb +1 -1
  44. data/lib/xqsr3/extensions/string/truncate.rb +1 -2
  45. data/lib/xqsr3/extensions/test/unit/assert_eql.rb +7 -7
  46. data/lib/xqsr3/extensions/test/unit/assert_false.rb +6 -7
  47. data/lib/xqsr3/extensions/test/unit/assert_not.rb +6 -7
  48. data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +7 -7
  49. data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +61 -62
  50. data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +7 -8
  51. data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +7 -8
  52. data/lib/xqsr3/extensions/test/unit/assert_true.rb +6 -7
  53. data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +36 -38
  54. data/lib/xqsr3/extensions.rb +5 -5
  55. data/lib/xqsr3/hash_utilities/deep_transform.rb +71 -71
  56. data/lib/xqsr3/hash_utilities/key_matching.rb +82 -82
  57. data/lib/xqsr3/hash_utilities.rb +3 -3
  58. data/lib/xqsr3/internal_/test_unit_version_.rb +130 -88
  59. data/lib/xqsr3/io/writelines.rb +125 -125
  60. data/lib/xqsr3/quality/parameter_checking.rb +452 -453
  61. data/lib/xqsr3/quality.rb +2 -2
  62. data/lib/xqsr3/string_utilities/ends_with.rb +64 -64
  63. data/lib/xqsr3/string_utilities/nil_if_empty.rb +33 -34
  64. data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +35 -35
  65. data/lib/xqsr3/string_utilities/quote_if.rb +55 -56
  66. data/lib/xqsr3/string_utilities/starts_with.rb +64 -64
  67. data/lib/xqsr3/string_utilities/to_symbol.rb +80 -80
  68. data/lib/xqsr3/string_utilities/truncate.rb +60 -61
  69. data/lib/xqsr3/string_utilities.rb +8 -8
  70. data/lib/xqsr3/version.rb +19 -20
  71. data/test/performance/frequency_map.rb +13 -27
  72. data/test/scratch/test_assert_raise_with_message.rb +12 -13
  73. data/test/unit/array_utilities/tc_join_with_or.rb +140 -142
  74. data/test/unit/command_line_utilities/tc_map_option_string.rb +18 -18
  75. data/test/unit/containers/tc_frequency_map.rb +607 -554
  76. data/test/unit/containers/tc_multi_map.rb +573 -522
  77. data/test/unit/conversion/tc_integer_parser.rb +73 -73
  78. data/test/unit/conversion/tc_to_bool.rb +26 -26
  79. data/test/unit/diagnostics/exceptions/tc_with_cause.rb +165 -165
  80. data/test/unit/diagnostics/tc_exception_utilities.rb +156 -156
  81. data/test/unit/extensions/enumerable/tc_collect_with_index.rb +14 -14
  82. data/test/unit/extensions/enumerable/tc_detect_map.rb +20 -20
  83. data/test/unit/extensions/enumerable/tc_unique.rb +34 -34
  84. data/test/unit/extensions/hash/tc_deep_transform.rb +22 -22
  85. data/test/unit/extensions/hash/tc_except.rb +28 -28
  86. data/test/unit/extensions/hash/tc_hash.rb +1 -1
  87. data/test/unit/extensions/hash/tc_slice.rb +14 -14
  88. data/test/unit/extensions/integer/tc_to_s_grp.rb +60 -0
  89. data/test/unit/extensions/integer/ts_all.rb +12 -0
  90. data/test/unit/extensions/io/tc_writelines.rb +77 -77
  91. data/test/unit/extensions/kernel/tc_integer.rb +75 -75
  92. data/test/unit/extensions/kernel/tc_raise_with_options.rb +155 -155
  93. data/test/unit/extensions/object/tc_inspect.rb +51 -51
  94. data/test/unit/extensions/string/tc_bool.tb +24 -24
  95. data/test/unit/extensions/string/tc_ends_with.rb +53 -53
  96. data/test/unit/extensions/string/tc_map_option_string.rb +15 -15
  97. data/test/unit/extensions/string/tc_nil_if_empty.rb +8 -8
  98. data/test/unit/extensions/string/tc_nil_if_whitespace.rb +8 -8
  99. data/test/unit/extensions/string/tc_quote_if.rb +18 -18
  100. data/test/unit/extensions/string/tc_starts_with.rb +53 -53
  101. data/test/unit/extensions/string/tc_to_symbol.rb +26 -26
  102. data/test/unit/extensions/string/tc_truncate.rb +18 -18
  103. data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +16 -16
  104. data/test/unit/extensions/test/unit/tc_assert_subclass_of.rb +9 -9
  105. data/test/unit/extensions/test/unit/tc_assert_superclass_of.rb +9 -9
  106. data/test/unit/hash_utilities/tc_has_match.rb +70 -70
  107. data/test/unit/hash_utilities/tc_match.rb +83 -83
  108. data/test/unit/io/tc_writelines.rb +106 -108
  109. data/test/unit/quality/tc_parameter_checking.rb +390 -390
  110. data/test/unit/string_utilities/tc_truncate.rb +28 -28
  111. data/test/unit/tc_version.rb +15 -15
  112. metadata +6 -2
@@ -8,218 +8,218 @@ require 'test/unit'
8
8
 
9
9
  class Test_ExceptionUtilities_raise_with_options < Test::Unit::TestCase
10
10
 
11
- include ::Xqsr3::Diagnostics
11
+ include ::Xqsr3::Diagnostics
12
12
 
13
- OS_IS_WINDOWS = (RUBY_PLATFORM =~ /(mswin|mingw|bccwin|wince)/i) ? true : false
14
- LINE_NUM_RE = OS_IS_WINDOWS ? /.+:(\d+):/ : /^[^:]+:(\d+)/
13
+ OS_IS_WINDOWS = (RUBY_PLATFORM =~ /(mswin|mingw|bccwin|wince)/i) ? true : false
14
+ LINE_NUM_RE = OS_IS_WINDOWS ? /.+:(\d+):/ : /^[^:]+:(\d+)/
15
15
 
16
- class ArgumentErrorWithOptions < ArgumentError
17
- def initialize(message = nil, **options)
18
- super(message)
19
- options ||= {}
20
- @options = options
21
- end
22
- attr_reader :options
16
+ class ArgumentErrorWithOptions < ArgumentError
17
+ def initialize(message = nil, **options)
18
+ super(message)
19
+ options ||= {}
20
+ @options = options
21
+ end
22
+ attr_reader :options
23
23
 
24
- def exception(msg = nil, options = nil)
24
+ def exception(msg = nil, options = nil)
25
25
 
26
- return self if msg.nil?
27
- return self if msg.object_id == self.object_id
26
+ return self if msg.nil?
27
+ return self if msg.object_id == self.object_id
28
28
 
29
- msg ||= self.message
30
- options ||= {}
31
- r = self.class.new msg, **self.options.merge(options)
32
- r
33
- end
34
- end
29
+ msg ||= self.message
30
+ options ||= {}
31
+ r = self.class.new msg, **self.options.merge(options)
32
+ r
33
+ end
34
+ end
35
35
 
36
- def execute(&block)
36
+ def execute(&block)
37
37
 
38
- block.call
39
- end
38
+ block.call
39
+ end
40
40
 
41
- def test_0
41
+ def test_0
42
42
 
43
- # standard raise: message-only
44
- begin
45
- raise "abc"
43
+ # standard raise: message-only
44
+ begin
45
+ raise "abc"
46
46
 
47
- assert false, "should not get here"
48
- rescue => x
47
+ assert false, "should not get here"
48
+ rescue => x
49
49
 
50
- assert_kind_of(RuntimeError, x)
51
- assert_equal "abc", x.message
52
- end
50
+ assert_kind_of(RuntimeError, x)
51
+ assert_equal "abc", x.message
52
+ end
53
53
 
54
- # RWO: message-only
55
- begin
56
- ExceptionUtilities.raise_with_options "abc"
54
+ # RWO: message-only
55
+ begin
56
+ ExceptionUtilities.raise_with_options "abc"
57
57
 
58
- assert false, "should not get here"
59
- rescue => x
58
+ assert false, "should not get here"
59
+ rescue => x
60
60
 
61
- assert_kind_of(RuntimeError, x)
62
- assert_equal "abc", x.message
63
- end
64
- end
61
+ assert_kind_of(RuntimeError, x)
62
+ assert_equal "abc", x.message
63
+ end
64
+ end
65
65
 
66
- def test_1
66
+ def test_1
67
67
 
68
- # standard raise: class
69
- begin
70
- raise ArgumentError
68
+ # standard raise: class
69
+ begin
70
+ raise ArgumentError
71
71
 
72
- assert false, "should not get here"
73
- rescue => x
72
+ assert false, "should not get here"
73
+ rescue => x
74
74
 
75
- assert_kind_of(ArgumentError, x)
76
- assert_equal "ArgumentError", x.message
77
- end
75
+ assert_kind_of(ArgumentError, x)
76
+ assert_equal "ArgumentError", x.message
77
+ end
78
78
 
79
- # RWO: class + message
80
- begin
81
- ExceptionUtilities.raise_with_options ArgumentError
79
+ # RWO: class + message
80
+ begin
81
+ ExceptionUtilities.raise_with_options ArgumentError
82
82
 
83
- assert false, "should not get here"
84
- rescue => x
83
+ assert false, "should not get here"
84
+ rescue => x
85
85
 
86
- assert_kind_of(ArgumentError, x)
87
- assert_equal "ArgumentError", x.message
88
- end
89
- end
86
+ assert_kind_of(ArgumentError, x)
87
+ assert_equal "ArgumentError", x.message
88
+ end
89
+ end
90
90
 
91
- def test_2
91
+ def test_2
92
92
 
93
- # standard raise: class + message
94
- begin
95
- raise ArgumentError, "abc"
93
+ # standard raise: class + message
94
+ begin
95
+ raise ArgumentError, "abc"
96
96
 
97
- assert false, "should not get here"
98
- rescue => x
97
+ assert false, "should not get here"
98
+ rescue => x
99
99
 
100
- assert_kind_of(ArgumentError, x)
101
- assert_equal "abc", x.message
102
- end
100
+ assert_kind_of(ArgumentError, x)
101
+ assert_equal "abc", x.message
102
+ end
103
103
 
104
- # RWO: class + message
105
- begin
106
- ExceptionUtilities.raise_with_options ArgumentError, "abc"
104
+ # RWO: class + message
105
+ begin
106
+ ExceptionUtilities.raise_with_options ArgumentError, "abc"
107
107
 
108
- assert false, "should not get here"
109
- rescue => x
108
+ assert false, "should not get here"
109
+ rescue => x
110
110
 
111
- assert_kind_of(ArgumentError, x)
112
- assert_equal "abc", x.message
113
- end
114
- end
111
+ assert_kind_of(ArgumentError, x)
112
+ assert_equal "abc", x.message
113
+ end
114
+ end
115
115
 
116
- def test_2_b_no_options
116
+ def test_2_b_no_options
117
117
 
118
- # standard raise: class + message
119
- begin
120
- raise ArgumentErrorWithOptions, "abc"
118
+ # standard raise: class + message
119
+ begin
120
+ raise ArgumentErrorWithOptions, "abc"
121
121
 
122
- assert false, "should not get here"
123
- rescue => x
122
+ assert false, "should not get here"
123
+ rescue => x
124
124
 
125
- assert_kind_of(ArgumentError, x)
126
- assert_equal "abc", x.message
127
- end
125
+ assert_kind_of(ArgumentError, x)
126
+ assert_equal "abc", x.message
127
+ end
128
128
 
129
- # RWO: class + message
130
- begin
131
- ExceptionUtilities.raise_with_options ArgumentErrorWithOptions, "abc"
129
+ # RWO: class + message
130
+ begin
131
+ ExceptionUtilities.raise_with_options ArgumentErrorWithOptions, "abc"
132
132
 
133
- assert false, "should not get here"
134
- rescue => x
133
+ assert false, "should not get here"
134
+ rescue => x
135
135
 
136
- assert_kind_of(ArgumentError, x)
137
- assert_equal "abc", x.message
138
- end
139
- end
136
+ assert_kind_of(ArgumentError, x)
137
+ assert_equal "abc", x.message
138
+ end
139
+ end
140
140
 
141
- def test_2_b_with_options
141
+ def test_2_b_with_options
142
142
 
143
- # standard raise: class + message + options
144
- begin
145
- raise ArgumentErrorWithOptions.new("abc", blah: :blech, id: 23)
143
+ # standard raise: class + message + options
144
+ begin
145
+ raise ArgumentErrorWithOptions.new("abc", blah: :blech, id: 23)
146
146
 
147
- assert false, "should not get here"
148
- rescue => x
147
+ assert false, "should not get here"
148
+ rescue => x
149
149
 
150
- assert_kind_of(ArgumentError, x)
151
- assert_equal "abc", x.message
152
- assert_equal ({ :blah => :blech, :id => 23 }), x.options
153
- end
150
+ assert_kind_of(ArgumentError, x)
151
+ assert_equal "abc", x.message
152
+ assert_equal ({ :blah => :blech, :id => 23 }), x.options
153
+ end
154
154
 
155
- # RWO: class + message + options (raise-way)
156
- begin
157
- ExceptionUtilities.raise_with_options ArgumentErrorWithOptions.new("abc", blah: :blech, id: 23)
155
+ # RWO: class + message + options (raise-way)
156
+ begin
157
+ ExceptionUtilities.raise_with_options ArgumentErrorWithOptions.new("abc", blah: :blech, id: 23)
158
158
 
159
- assert false, "should not get here"
160
- rescue => x
159
+ assert false, "should not get here"
160
+ rescue => x
161
161
 
162
- assert_kind_of(ArgumentError, x)
163
- assert_equal "abc", x.message
164
- assert_equal ({ :blah => :blech, :id => 23 }), x.options
165
- end
162
+ assert_kind_of(ArgumentError, x)
163
+ assert_equal "abc", x.message
164
+ assert_equal ({ :blah => :blech, :id => 23 }), x.options
165
+ end
166
166
 
167
- # RWO: class + message + options (raise_with_options-way)
168
- begin
169
- ExceptionUtilities.raise_with_options ArgumentErrorWithOptions, "abc", blah: :blech, id: 23
167
+ # RWO: class + message + options (raise_with_options-way)
168
+ begin
169
+ ExceptionUtilities.raise_with_options ArgumentErrorWithOptions, "abc", blah: :blech, id: 23
170
170
 
171
- assert false, "should not get here"
172
- rescue => x
171
+ assert false, "should not get here"
172
+ rescue => x
173
173
 
174
- assert_kind_of(ArgumentError, x)
175
- assert_equal "abc", x.message
176
- assert_equal ({ :blah => :blech, :id => 23 }), x.options
177
- end
178
- end
174
+ assert_kind_of(ArgumentError, x)
175
+ assert_equal "abc", x.message
176
+ assert_equal ({ :blah => :blech, :id => 23 }), x.options
177
+ end
178
+ end
179
179
 
180
180
 
181
- def test_with_backtrace
182
- line_number = nil
181
+ def test_with_backtrace
182
+ line_number = nil
183
183
 
184
- # standard raise: class + message + stack trace
185
- begin
186
- begin
187
- execute { line_number = __LINE__; raise ArgumentError }
188
- rescue => x
189
- raise x, "abc", x.backtrace
190
- end
184
+ # standard raise: class + message + stack trace
185
+ begin
186
+ begin
187
+ execute { line_number = __LINE__; raise ArgumentError }
188
+ rescue => x
189
+ raise x, "abc", x.backtrace
190
+ end
191
191
 
192
- assert false, "should not get here"
193
- rescue => x
192
+ assert false, "should not get here"
193
+ rescue => x
194
194
 
195
- assert_kind_of(ArgumentError, x)
196
- assert_equal "abc", x.message
195
+ assert_kind_of(ArgumentError, x)
196
+ assert_equal "abc", x.message
197
197
 
198
198
 
199
- assert $@[0] =~ LINE_NUM_RE
200
- assert_equal line_number.to_s, $1.to_s
201
- end
199
+ assert $@[0] =~ LINE_NUM_RE
200
+ assert_equal line_number.to_s, $1.to_s
201
+ end
202
202
 
203
- # RWO: class + message + stack trace
204
- begin
205
- begin
206
- execute { line_number = __LINE__; ExceptionUtilities.raise_with_options ArgumentErrorWithOptions, blah: :blech, id: 23 }
203
+ # RWO: class + message + stack trace
204
+ begin
205
+ begin
206
+ execute { line_number = __LINE__; ExceptionUtilities.raise_with_options ArgumentErrorWithOptions, blah: :blech, id: 23 }
207
207
 
208
- assert false, "should not get here"
209
- rescue => x
210
- raise x, "abc", x.backtrace
211
- end
208
+ assert false, "should not get here"
209
+ rescue => x
210
+ raise x, "abc", x.backtrace
211
+ end
212
212
 
213
- assert false, "should not get here"
214
- rescue => x
213
+ assert false, "should not get here"
214
+ rescue => x
215
215
 
216
- assert_kind_of(ArgumentError, x)
217
- assert_equal "abc", x.message
218
- assert_equal ({ :blah => :blech, :id => 23 }), x.options
216
+ assert_kind_of(ArgumentError, x)
217
+ assert_equal "abc", x.message
218
+ assert_equal ({ :blah => :blech, :id => 23 }), x.options
219
219
 
220
- assert $@[0] =~ LINE_NUM_RE
221
- assert_equal line_number.to_s, $1.to_s
222
- end
223
- end
220
+ assert $@[0] =~ LINE_NUM_RE
221
+ assert_equal line_number.to_s, $1.to_s
222
+ end
223
+ end
224
224
  end
225
225
 
@@ -8,29 +8,29 @@ require 'test/unit'
8
8
 
9
9
  class Test_Enumerable_collect_with_index < Test::Unit::TestCase
10
10
 
11
- def test_simple
11
+ def test_simple
12
12
 
13
- ar = [ 1, -2, 3, -4, 5, -6 ]
13
+ ar = [ 1, -2, 3, -4, 5, -6 ]
14
14
 
15
- r = ar.collect_with_index do |v, index0|
15
+ r = ar.collect_with_index do |v, index0|
16
16
 
17
- index0 * v.abs
18
- end
17
+ index0 * v.abs
18
+ end
19
19
 
20
- assert_equal [ 0, 2, 6, 12, 20, 30 ], r
21
- end
20
+ assert_equal [ 0, 2, 6, 12, 20, 30 ], r
21
+ end
22
22
 
23
- def test_simple_with_offset
23
+ def test_simple_with_offset
24
24
 
25
- ar = [ 1, -2, 3, -4, 5, -6 ]
25
+ ar = [ 1, -2, 3, -4, 5, -6 ]
26
26
 
27
- r = ar.collect_with_index(1) do |v, index0|
27
+ r = ar.collect_with_index(1) do |v, index0|
28
28
 
29
- index0 * v.abs
30
- end
29
+ index0 * v.abs
30
+ end
31
31
 
32
- assert_equal [ 1, 4, 9, 16, 25, 36 ], r
33
- end
32
+ assert_equal [ 1, 4, 9, 16, 25, 36 ], r
33
+ end
34
34
  end
35
35
 
36
36
 
@@ -10,34 +10,34 @@ require 'test/unit'
10
10
 
11
11
  class Test_Enumerable_detect_map < Test::Unit::TestCase
12
12
 
13
- def test_with_array
13
+ def test_with_array
14
14
 
15
- assert_nil [].detect_map { |v| nil }
16
- assert_nil [ 1, 2, 3, 4, 5 ].detect_map { |v| nil }
15
+ assert_nil [].detect_map { |v| nil }
16
+ assert_nil [ 1, 2, 3, 4, 5 ].detect_map { |v| nil }
17
17
 
18
- assert_nil [].detect_map { |v| :nil }
19
- assert_not_nil [ 1, 2, 3, 4, 5 ].detect_map { |v| :nil }
18
+ assert_nil [].detect_map { |v| :nil }
19
+ assert_not_nil [ 1, 2, 3, 4, 5 ].detect_map { |v| :nil }
20
20
 
21
- assert_nil [].detect_map { |v| return -2 * v }
22
- assert_equal -2, [ 1, 2, 3, 4, 5 ].detect_map { |v| -2 * v }
23
- assert_equal(-4, [ 1, 2, 3, 4, 5 ].detect_map { |v| -2 * v if 2 == v })
24
- end
21
+ assert_nil [].detect_map { |v| return -2 * v }
22
+ assert_equal -2, [ 1, 2, 3, 4, 5 ].detect_map { |v| -2 * v }
23
+ assert_equal(-4, [ 1, 2, 3, 4, 5 ].detect_map { |v| -2 * v if 2 == v })
24
+ end
25
25
 
26
- def test_with_hash
26
+ def test_with_hash
27
27
 
28
- h1 = {}
29
- h2 = { :abc => 'def', :ghi => 'jkl' }
28
+ h1 = {}
29
+ h2 = { :abc => 'def', :ghi => 'jkl' }
30
30
 
31
- assert_nil h1.detect_map { |k, v| nil }
32
- assert_nil h2.detect_map { |k, v| nil }
31
+ assert_nil h1.detect_map { |k, v| nil }
32
+ assert_nil h2.detect_map { |k, v| nil }
33
33
 
34
- assert_nil h1.detect_map { |k, v| :nil }
35
- assert_not_nil h2.detect_map { |k, v| :nil }
34
+ assert_nil h1.detect_map { |k, v| :nil }
35
+ assert_not_nil h2.detect_map { |k, v| :nil }
36
36
 
37
- assert_nil h1.detect_map { |k, v| v.upcase }
38
- assert_equal 'DEF', h2.detect_map { |k, v| v.upcase }
39
- assert_equal 'JKL', h2.detect_map { |k, v| v.upcase if :ghi == k }
40
- end
37
+ assert_nil h1.detect_map { |k, v| v.upcase }
38
+ assert_equal 'DEF', h2.detect_map { |k, v| v.upcase }
39
+ assert_equal 'JKL', h2.detect_map { |k, v| v.upcase if :ghi == k }
40
+ end
41
41
  end
42
42
 
43
43
 
@@ -8,64 +8,64 @@ require 'test/unit'
8
8
 
9
9
  class Test_Enumerable_unique_test < Test::Unit::TestCase
10
10
 
11
- def test_empty
11
+ def test_empty
12
12
 
13
- src = []
13
+ src = []
14
14
 
15
- dest = src.unique
15
+ dest = src.unique
16
16
 
17
- assert dest.empty?
18
- end
17
+ assert dest.empty?
18
+ end
19
19
 
20
- def test_already_unique
20
+ def test_already_unique
21
21
 
22
- src = [ 1, 2, 3, 4 ]
22
+ src = [ 1, 2, 3, 4 ]
23
23
 
24
- dest = src.unique
24
+ dest = src.unique
25
25
 
26
- assert_equal src, dest
27
- end
26
+ assert_equal src, dest
27
+ end
28
28
 
29
- def test_unique_contiguous
29
+ def test_unique_contiguous
30
30
 
31
- src = [ 1, 2, 3, 3, 4 ]
31
+ src = [ 1, 2, 3, 3, 4 ]
32
32
 
33
- dest = src.unique
33
+ dest = src.unique
34
34
 
35
- assert_equal [ 1, 2, 3, 4], dest
36
- end
35
+ assert_equal [ 1, 2, 3, 4], dest
36
+ end
37
37
 
38
- def test_unique_noncontiguous
38
+ def test_unique_noncontiguous
39
39
 
40
- src = [ 1, 2, 3, 4, 3 ]
40
+ src = [ 1, 2, 3, 4, 3 ]
41
41
 
42
- dest = src.unique
42
+ dest = src.unique
43
43
 
44
- assert_equal [ 1, 2, 3, 4], dest
45
- end
44
+ assert_equal [ 1, 2, 3, 4], dest
45
+ end
46
46
 
47
- def test_unique_very_large_sorted
47
+ def test_unique_very_large_sorted
48
48
 
49
- max = 100000
49
+ max = 100000
50
50
 
51
- src = (0...max).to_a * 2
52
- exp = (0...max).to_a
51
+ src = (0...max).to_a * 2
52
+ exp = (0...max).to_a
53
53
 
54
- dest = src.unique
54
+ dest = src.unique
55
55
 
56
- assert_equal exp, dest
57
- end
56
+ assert_equal exp, dest
57
+ end
58
58
 
59
- def test_unique_very_large_unsorted
59
+ def test_unique_very_large_unsorted
60
60
 
61
- max = 100000
61
+ max = 100000
62
62
 
63
- src = ((0...max).to_a * 2).sort
64
- exp = (0...max).to_a
63
+ src = ((0...max).to_a * 2).sort
64
+ exp = (0...max).to_a
65
65
 
66
- dest = src.unique
66
+ dest = src.unique
67
67
 
68
- assert_equal exp, dest
69
- end
68
+ assert_equal exp, dest
69
+ end
70
70
  end
71
71
 
@@ -11,38 +11,38 @@ require 'stringio'
11
11
 
12
12
  class Test_Hash_deep_transform < Test::Unit::TestCase
13
13
 
14
- def test_Hash_has_method
14
+ def test_Hash_has_method
15
15
 
16
- assert Hash.new.respond_to? :deep_transform
17
- end
16
+ assert Hash.new.respond_to? :deep_transform
17
+ end
18
18
 
19
- def test_with_empty
19
+ def test_with_empty
20
20
 
21
- assert_equal Hash.new, Hash.new.deep_transform { |k| k }
22
- assert_equal Hash.new, Hash.new.deep_transform { |k, v| [ k, v ] }
23
- end
21
+ assert_equal Hash.new, Hash.new.deep_transform { |k| k }
22
+ assert_equal Hash.new, Hash.new.deep_transform { |k, v| [ k, v ] }
23
+ end
24
24
 
25
- def test_transform_to_same
25
+ def test_transform_to_same
26
26
 
27
- jkl = 12
28
- h = { 'abc' => 'def', ghi: jkl, mno: { p: 'q', 'r' => 'st' } }
27
+ jkl = 12
28
+ h = { 'abc' => 'def', ghi: jkl, mno: { p: 'q', 'r' => 'st' } }
29
29
 
30
- assert_equal h, h.deep_transform { |k| k }
31
- assert_equal h, h.deep_transform { |k, v| [ k, v ] }
32
- end
30
+ assert_equal h, h.deep_transform { |k| k }
31
+ assert_equal h, h.deep_transform { |k, v| [ k, v ] }
32
+ end
33
33
 
34
- def test_transform_to_symbolise_keys
34
+ def test_transform_to_symbolise_keys
35
35
 
36
- jkl = 12
37
- h = { 'abc' => 'def', ghi: jkl, mno: { p: 'q', 'r' => 'st' } }
36
+ jkl = 12
37
+ h = { 'abc' => 'def', ghi: jkl, mno: { p: 'q', 'r' => 'st' } }
38
38
 
39
- h_1 = { abc: 'def', ghi: jkl, mno: { p: 'q', r: 'st' } }
40
- h_2 = { abc: :def, ghi: jkl, mno: { p: :q, r: :st } }
39
+ h_1 = { abc: 'def', ghi: jkl, mno: { p: 'q', r: 'st' } }
40
+ h_2 = { abc: :def, ghi: jkl, mno: { p: :q, r: :st } }
41
41
 
42
- assert_equal h_1, h.deep_transform { |k| k.respond_to?(:to_sym) ? k.to_sym : k }
43
- assert_equal h_1, h.deep_transform { |k, v| [ k.respond_to?(:to_sym) ? k.to_sym : k, v ] }
44
- assert_equal h_2, h.deep_transform { |k, v| [ k.respond_to?(:to_sym) ? k.to_sym : k, v.respond_to?(:to_sym) ? v.to_sym : v ] }
45
- end
42
+ assert_equal h_1, h.deep_transform { |k| k.respond_to?(:to_sym) ? k.to_sym : k }
43
+ assert_equal h_1, h.deep_transform { |k, v| [ k.respond_to?(:to_sym) ? k.to_sym : k, v ] }
44
+ assert_equal h_2, h.deep_transform { |k, v| [ k.respond_to?(:to_sym) ? k.to_sym : k, v.respond_to?(:to_sym) ? v.to_sym : v ] }
45
+ end
46
46
  end
47
47
 
48
48