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,255 +8,255 @@ require 'test/unit'
8
8
 
9
9
  class Test_WithCause < Test::Unit::TestCase
10
10
 
11
- class SomeExceptionWithCause < ::Exception
11
+ class SomeExceptionWithCause < ::Exception
12
12
 
13
- include ::Xqsr3::Diagnostics::Exceptions::WithCause
14
- end
13
+ include ::Xqsr3::Diagnostics::Exceptions::WithCause
14
+ end
15
15
 
16
- def test_no_ctor_args
16
+ def test_no_ctor_args
17
17
 
18
- x = SomeExceptionWithCause.new
18
+ x = SomeExceptionWithCause.new
19
19
 
20
- assert_nil x.cause
21
- assert_equal SomeExceptionWithCause.to_s, x.message
22
- assert_equal SomeExceptionWithCause.to_s, x.chained_message
23
- assert_empty x.chainees
24
- assert_equal [ x ], x.exceptions
25
- assert_nil x.backtrace
26
- assert_empty x.options
27
- end
20
+ assert_nil x.cause
21
+ assert_equal SomeExceptionWithCause.to_s, x.message
22
+ assert_equal SomeExceptionWithCause.to_s, x.chained_message
23
+ assert_empty x.chainees
24
+ assert_equal [ x ], x.exceptions
25
+ assert_nil x.backtrace
26
+ assert_empty x.options
27
+ end
28
28
 
29
- def test_1_ctor_arg_that_is_a_message
29
+ def test_1_ctor_arg_that_is_a_message
30
30
 
31
- msg = 'stuff'
31
+ msg = 'stuff'
32
32
 
33
- x = SomeExceptionWithCause.new msg
33
+ x = SomeExceptionWithCause.new msg
34
34
 
35
- assert_nil x.cause
36
- assert_equal msg, x.message
37
- assert_equal msg, x.chained_message
38
- assert_empty x.chainees
39
- assert_equal [ x ], x.exceptions
40
- assert_nil x.backtrace
41
- assert_empty x.options
42
- end
35
+ assert_nil x.cause
36
+ assert_equal msg, x.message
37
+ assert_equal msg, x.chained_message
38
+ assert_empty x.chainees
39
+ assert_equal [ x ], x.exceptions
40
+ assert_nil x.backtrace
41
+ assert_empty x.options
42
+ end
43
43
 
44
- def test_1_ctor_arg_that_is_a_cause_and_has_no_message
44
+ def test_1_ctor_arg_that_is_a_cause_and_has_no_message
45
45
 
46
- c = RuntimeError.new
46
+ c = RuntimeError.new
47
47
 
48
- x = SomeExceptionWithCause.new c
48
+ x = SomeExceptionWithCause.new c
49
49
 
50
- assert_not_nil x.cause
51
- assert_equal SomeExceptionWithCause.to_s, x.message
52
- assert_equal "#{SomeExceptionWithCause.to_s}: #{RuntimeError.to_s}", x.chained_message
53
- assert_not_empty x.chainees
54
- assert_equal [ c ], x.chainees
55
- assert_equal [ x, c ], x.exceptions
56
- assert_nil x.backtrace
57
- assert_empty x.options
58
- end
50
+ assert_not_nil x.cause
51
+ assert_equal SomeExceptionWithCause.to_s, x.message
52
+ assert_equal "#{SomeExceptionWithCause.to_s}: #{RuntimeError.to_s}", x.chained_message
53
+ assert_not_empty x.chainees
54
+ assert_equal [ c ], x.chainees
55
+ assert_equal [ x, c ], x.exceptions
56
+ assert_nil x.backtrace
57
+ assert_empty x.options
58
+ end
59
59
 
60
- def test_1_ctor_arg_that_is_a_cause_and_has_a_message
60
+ def test_1_ctor_arg_that_is_a_cause_and_has_a_message
61
61
 
62
- c = RuntimeError.new 'blah'
62
+ c = RuntimeError.new 'blah'
63
63
 
64
- x = SomeExceptionWithCause.new c
64
+ x = SomeExceptionWithCause.new c
65
65
 
66
- assert_not_nil x.cause
67
- assert_equal 'blah', x.message
68
- assert_equal 'blah', x.chained_message
69
- assert_not_empty x.chainees
70
- assert_equal [ c ], x.chainees
71
- assert_equal [ x, c ], x.exceptions
72
- assert_nil x.backtrace
73
- assert_empty x.options
74
- end
66
+ assert_not_nil x.cause
67
+ assert_equal 'blah', x.message
68
+ assert_equal 'blah', x.chained_message
69
+ assert_not_empty x.chainees
70
+ assert_equal [ c ], x.chainees
71
+ assert_equal [ x, c ], x.exceptions
72
+ assert_nil x.backtrace
73
+ assert_empty x.options
74
+ end
75
75
 
76
- def test_2_ctor_args_that_are_message_and_cause
76
+ def test_2_ctor_args_that_are_message_and_cause
77
77
 
78
- msg = 'stuff'
78
+ msg = 'stuff'
79
79
 
80
- c = RuntimeError.new
80
+ c = RuntimeError.new
81
81
 
82
- x = SomeExceptionWithCause.new msg, c
82
+ x = SomeExceptionWithCause.new msg, c
83
83
 
84
- assert_not_nil x.cause
85
- assert_equal msg, x.message
86
- assert_equal "#{msg}: #{RuntimeError.to_s}", x.chained_message
87
- assert_not_empty x.chainees
88
- assert_equal [ c ], x.chainees
89
- assert_equal [ x, c ], x.exceptions
90
- assert_nil x.backtrace
91
- assert_empty x.options
92
- end
84
+ assert_not_nil x.cause
85
+ assert_equal msg, x.message
86
+ assert_equal "#{msg}: #{RuntimeError.to_s}", x.chained_message
87
+ assert_not_empty x.chainees
88
+ assert_equal [ c ], x.chainees
89
+ assert_equal [ x, c ], x.exceptions
90
+ assert_nil x.backtrace
91
+ assert_empty x.options
92
+ end
93
93
 
94
- def test_2_ctor_args_that_are_message_and_cause_that_has_a_message
94
+ def test_2_ctor_args_that_are_message_and_cause_that_has_a_message
95
95
 
96
- msg = 'stuff'
96
+ msg = 'stuff'
97
97
 
98
- c = RuntimeError.new 'blah'
98
+ c = RuntimeError.new 'blah'
99
99
 
100
- x = SomeExceptionWithCause.new msg, c
100
+ x = SomeExceptionWithCause.new msg, c
101
101
 
102
- assert_not_nil x.cause
103
- assert_equal msg, x.message
104
- assert_equal 'stuff: blah', x.chained_message
102
+ assert_not_nil x.cause
103
+ assert_equal msg, x.message
104
+ assert_equal 'stuff: blah', x.chained_message
105
105
 
106
- assert_not_empty x.chainees
107
- assert_equal [ c ], x.chainees
108
- assert_equal [ x, c ], x.exceptions
109
- assert_nil x.backtrace
110
- assert_empty x.options
111
- end
106
+ assert_not_empty x.chainees
107
+ assert_equal [ c ], x.chainees
108
+ assert_equal [ x, c ], x.exceptions
109
+ assert_nil x.backtrace
110
+ assert_empty x.options
111
+ end
112
112
 
113
- def test_cause_in_options
113
+ def test_cause_in_options
114
114
 
115
- c = RuntimeError.new 'inner'
115
+ c = RuntimeError.new 'inner'
116
116
 
117
- x = SomeExceptionWithCause.new 'outer', cause: c
117
+ x = SomeExceptionWithCause.new 'outer', cause: c
118
118
 
119
- assert_not_nil x.cause
120
- assert_equal 'outer', x.message
121
- assert_equal 'outer: inner', x.chained_message
119
+ assert_not_nil x.cause
120
+ assert_equal 'outer', x.message
121
+ assert_equal 'outer: inner', x.chained_message
122
122
 
123
- assert_not_empty x.chainees
124
- assert_equal [ c ], x.chainees
125
- assert_equal [ x, c ], x.exceptions
126
- assert_nil x.backtrace
127
- assert_empty x.options
128
- end
123
+ assert_not_empty x.chainees
124
+ assert_equal [ c ], x.chainees
125
+ assert_equal [ x, c ], x.exceptions
126
+ assert_nil x.backtrace
127
+ assert_empty x.options
128
+ end
129
129
 
130
130
 
131
131
 
132
- class GrandchildException < Exception
132
+ class GrandchildException < Exception
133
133
 
134
- include ::Xqsr3::Diagnostics::Exceptions::WithCause
135
- end
134
+ include ::Xqsr3::Diagnostics::Exceptions::WithCause
135
+ end
136
136
 
137
- class ChildException < Exception
137
+ class ChildException < Exception
138
138
 
139
- def initialize(*args, **options)
139
+ def initialize(*args, **options)
140
140
 
141
- super *args, **options
142
- end
141
+ super *args, **options
142
+ end
143
143
 
144
- include ::Xqsr3::Diagnostics::Exceptions::WithCause
145
- end
144
+ include ::Xqsr3::Diagnostics::Exceptions::WithCause
145
+ end
146
146
 
147
- class ParentException < Exception
147
+ class ParentException < Exception
148
148
 
149
- include ::Xqsr3::Diagnostics::Exceptions::WithCause
149
+ include ::Xqsr3::Diagnostics::Exceptions::WithCause
150
150
 
151
- def initialize(*args, **options)
151
+ def initialize(*args, **options)
152
152
 
153
- super *args, **options
154
- end
155
- end
153
+ super *args, **options
154
+ end
155
+ end
156
156
 
157
- class GrandparentException < Exception
157
+ class GrandparentException < Exception
158
158
 
159
- include ::Xqsr3::Diagnostics::Exceptions::WithCause
160
- end
159
+ include ::Xqsr3::Diagnostics::Exceptions::WithCause
160
+ end
161
161
 
162
162
 
163
- def test_four_levels
163
+ def test_four_levels
164
164
 
165
- gc = GrandchildException.new 'gc'
165
+ gc = GrandchildException.new 'gc'
166
166
 
167
- c = ChildException.new 'c', gc
167
+ c = ChildException.new 'c', gc
168
168
 
169
- p = ParentException.new c, 'p'
169
+ p = ParentException.new c, 'p'
170
170
 
171
- gp = GrandparentException.new 'gp', cause: p
171
+ gp = GrandparentException.new 'gp', cause: p
172
172
 
173
- assert_equal 'gp: p: c: gc', gp.chained_message
174
- assert_equal 'gp-p-c-gc', gp.chained_message(separator: '-')
175
- end
173
+ assert_equal 'gp: p: c: gc', gp.chained_message
174
+ assert_equal 'gp-p-c-gc', gp.chained_message(separator: '-')
175
+ end
176
176
  end
177
177
 
178
178
  class Test_WithCause_throwing < Test::Unit::TestCase
179
179
 
180
- class SomeExceptionWithCause < ::Exception
180
+ class SomeExceptionWithCause < ::Exception
181
181
 
182
- include ::Xqsr3::Diagnostics::Exceptions::WithCause
183
- end
182
+ include ::Xqsr3::Diagnostics::Exceptions::WithCause
183
+ end
184
184
 
185
- def f m
185
+ def f m
186
186
 
187
- raise SomeExceptionWithCause, m
188
- end
187
+ raise SomeExceptionWithCause, m
188
+ end
189
189
 
190
- def g m, n
190
+ def g m, n
191
191
 
192
- begin
192
+ begin
193
193
 
194
- f n
195
- rescue Exception => x
194
+ f n
195
+ rescue Exception => x
196
196
 
197
- raise SomeExceptionWithCause.new m, x
198
- end
199
- end
197
+ raise SomeExceptionWithCause.new m, x
198
+ end
199
+ end
200
200
 
201
- def h m, n, o
201
+ def h m, n, o
202
202
 
203
- begin
203
+ begin
204
204
 
205
- g n, 0
206
- rescue Exception => x
205
+ g n, 0
206
+ rescue Exception => x
207
207
 
208
- raise SomeExceptionWithCause.new m, x
209
- end
210
- end
208
+ raise SomeExceptionWithCause.new m, x
209
+ end
210
+ end
211
211
 
212
- def test_one_level
212
+ def test_one_level
213
213
 
214
- begin
214
+ begin
215
215
 
216
- f 'one-level'
216
+ f 'one-level'
217
217
 
218
- assert false, 'should not get here!'
219
- rescue Exception => x
218
+ assert false, 'should not get here!'
219
+ rescue Exception => x
220
220
 
221
- assert_nil x.cause
222
- assert_equal 'one-level', x.message
223
- assert_equal 'one-level', x.chained_message
224
- assert_empty x.chainees
225
- assert_not_empty x.backtrace
221
+ assert_nil x.cause
222
+ assert_equal 'one-level', x.message
223
+ assert_equal 'one-level', x.chained_message
224
+ assert_empty x.chainees
225
+ assert_not_empty x.backtrace
226
226
 
227
- x_bt0 = x.backtrace[0]
227
+ x_bt0 = x.backtrace[0]
228
228
 
229
- assert /:in\s+\`f\'\s*$/ =~ x_bt0, 'not receieved from f()'
230
- end
231
- end
229
+ assert /:in\s+\`f\'\s*$/ =~ x_bt0, 'not receieved from f()'
230
+ end
231
+ end
232
232
 
233
- def test_two_levels
233
+ def test_two_levels
234
234
 
235
- begin
235
+ begin
236
236
 
237
- g 'two-levels', 'one-level'
237
+ g 'two-levels', 'one-level'
238
238
 
239
- assert false, 'should not get here!'
240
- rescue Exception => x
239
+ assert false, 'should not get here!'
240
+ rescue Exception => x
241
241
 
242
- assert_not_nil x.cause
243
- assert_equal 'two-levels', x.message
244
- assert_equal 'two-levels: one-level', x.chained_message
245
- assert_not_empty x.chainees
246
- assert_kind_of SomeExceptionWithCause, x.chainees[0]
247
- assert_not_empty x.backtrace
248
- assert_not_empty x.cause.backtrace
242
+ assert_not_nil x.cause
243
+ assert_equal 'two-levels', x.message
244
+ assert_equal 'two-levels: one-level', x.chained_message
245
+ assert_not_empty x.chainees
246
+ assert_kind_of SomeExceptionWithCause, x.chainees[0]
247
+ assert_not_empty x.backtrace
248
+ assert_not_empty x.cause.backtrace
249
249
 
250
- x_bt0 = x.backtrace[0]
250
+ x_bt0 = x.backtrace[0]
251
251
 
252
- assert /:in\s+\`rescue in g\'\s*$/ =~ x_bt0, 'not receieved from g()'
252
+ assert /:in\s+\`rescue in g\'\s*$/ =~ x_bt0, 'not receieved from g()'
253
253
 
254
- c_bt0 = x.cause.backtrace[0]
254
+ c_bt0 = x.cause.backtrace[0]
255
255
 
256
- assert /:in\s+\`f\'\s*$/ =~ c_bt0, 'not receieved from f()'
256
+ assert /:in\s+\`f\'\s*$/ =~ c_bt0, 'not receieved from f()'
257
257
 
258
- assert_not_empty x.chained_backtrace
259
- end
260
- end
258
+ assert_not_empty x.chained_backtrace
259
+ end
260
+ end
261
261
  end
262
262