xqsr3 0.39.1 → 0.39.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/count_word_frequencies.rb +2 -0
- data/lib/xqsr3/array_utilities/join_with_or.rb +50 -53
- data/lib/xqsr3/command_line_utilities/map_option_string.rb +66 -69
- data/lib/xqsr3/containers/frequency_map.rb +408 -394
- data/lib/xqsr3/containers/multi_map.rb +464 -446
- data/lib/xqsr3/conversion/bool_parser.rb +49 -54
- data/lib/xqsr3/conversion/integer_parser.rb +84 -89
- data/lib/xqsr3/diagnostics/exception_utilities.rb +127 -132
- data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +98 -102
- data/lib/xqsr3/diagnostics/inspect_builder.rb +83 -84
- data/lib/xqsr3/extensions/array/join_with_or.rb +2 -1
- data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +1 -4
- data/lib/xqsr3/extensions/enumerable/unique.rb +1 -4
- data/lib/xqsr3/extensions/hash/deep_transform.rb +1 -0
- data/lib/xqsr3/extensions/hash/except.rb +1 -1
- data/lib/xqsr3/extensions/hash/has_match.rb +3 -2
- data/lib/xqsr3/extensions/hash/match.rb +3 -2
- data/lib/xqsr3/extensions/integer/to_s_grp.rb +1 -4
- data/lib/xqsr3/extensions/io/writelines.rb +4 -7
- data/lib/xqsr3/extensions/kernel/integer.rb +7 -9
- data/lib/xqsr3/extensions/kernel/raise_with_options.rb +1 -3
- data/lib/xqsr3/extensions/string/ends_with.rb +1 -0
- data/lib/xqsr3/extensions/string/map_option_string.rb +1 -0
- data/lib/xqsr3/extensions/string/nil_if_empty.rb +1 -0
- data/lib/xqsr3/extensions/string/nil_if_whitespace.rb +1 -0
- data/lib/xqsr3/extensions/string/quote_if.rb +1 -0
- data/lib/xqsr3/extensions/string/starts_with.rb +1 -0
- data/lib/xqsr3/extensions/string/to_bool.rb +1 -0
- data/lib/xqsr3/extensions/string/to_symbol.rb +1 -0
- data/lib/xqsr3/extensions/string/truncate.rb +1 -0
- data/lib/xqsr3/extensions/test/unit/assert_eql.rb +11 -9
- data/lib/xqsr3/extensions/test/unit/assert_false.rb +10 -8
- data/lib/xqsr3/extensions/test/unit/assert_not.rb +10 -8
- data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +11 -9
- data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +58 -55
- data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +11 -9
- data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +11 -9
- data/lib/xqsr3/extensions/test/unit/assert_true.rb +10 -8
- data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +39 -37
- data/lib/xqsr3/hash_utilities/deep_transform.rb +63 -67
- data/lib/xqsr3/hash_utilities/key_matching.rb +72 -76
- data/lib/xqsr3/internal_/test_unit_version_.rb +10 -8
- data/lib/xqsr3/io/writelines.rb +12 -12
- data/lib/xqsr3/quality/parameter_checking.rb +406 -411
- data/lib/xqsr3/string_utilities/ends_with.rb +60 -64
- data/lib/xqsr3/string_utilities/nil_if_empty.rb +31 -35
- data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +32 -36
- data/lib/xqsr3/string_utilities/quote_if.rb +48 -57
- data/lib/xqsr3/string_utilities/starts_with.rb +60 -64
- data/lib/xqsr3/string_utilities/to_symbol.rb +77 -81
- data/lib/xqsr3/string_utilities/truncate.rb +56 -60
- data/lib/xqsr3/version.rb +2 -2
- data/test/performance/frequency_map.rb +3 -0
- data/test/scratch/test_assert_raise_with_message.rb +2 -0
- data/test/unit/array_utilities/tc_join_with_or.rb +3 -1
- data/test/unit/command_line_utilities/tc_map_option_string.rb +3 -0
- data/test/unit/containers/tc_frequency_map.rb +5 -2
- data/test/unit/containers/tc_multi_map.rb +3 -0
- data/test/unit/conversion/tc_integer_parser.rb +18 -17
- data/test/unit/conversion/tc_to_bool.rb +2 -0
- data/test/unit/diagnostics/exceptions/tc_with_cause.rb +7 -5
- data/test/unit/diagnostics/tc_exception_utilities.rb +2 -0
- data/test/unit/extensions/enumerable/tc_collect_with_index.rb +2 -0
- data/test/unit/extensions/enumerable/tc_detect_map.rb +3 -2
- data/test/unit/extensions/enumerable/tc_unique.rb +2 -0
- data/test/unit/extensions/hash/tc_deep_transform.rb +2 -0
- data/test/unit/extensions/hash/tc_except.rb +3 -1
- data/test/unit/extensions/hash/tc_hash.rb +1 -0
- data/test/unit/extensions/hash/tc_slice.rb +2 -0
- data/test/unit/extensions/integer/tc_to_s_grp.rb +2 -0
- data/test/unit/extensions/io/tc_writelines.rb +86 -0
- data/test/unit/extensions/kernel/tc_integer.rb +10 -9
- data/test/unit/extensions/kernel/tc_raise_with_options.rb +2 -0
- data/test/unit/extensions/object/tc_inspect.rb +15 -13
- data/test/unit/extensions/string/tc_bool.tb +2 -0
- data/test/unit/extensions/string/tc_ends_with.rb +2 -0
- data/test/unit/extensions/string/tc_map_option_string.rb +2 -0
- data/test/unit/extensions/string/tc_nil_if_empty.rb +2 -0
- data/test/unit/extensions/string/tc_nil_if_whitespace.rb +2 -0
- data/test/unit/extensions/string/tc_quote_if.rb +2 -0
- data/test/unit/extensions/string/tc_starts_with.rb +2 -0
- data/test/unit/extensions/string/tc_to_symbol.rb +2 -0
- data/test/unit/extensions/string/tc_truncate.rb +2 -0
- data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +2 -0
- data/test/unit/extensions/test/unit/tc_assert_subclass_of.rb +2 -0
- data/test/unit/extensions/test/unit/tc_assert_superclass_of.rb +2 -0
- data/test/unit/hash_utilities/tc_has_match.rb +1 -0
- data/test/unit/hash_utilities/tc_match.rb +1 -0
- data/test/unit/io/tc_writelines.rb +63 -0
- data/test/unit/quality/tc_parameter_checking.rb +1 -0
- data/test/unit/string_utilities/tc_truncate.rb +2 -0
- data/test/unit/tc_version.rb +2 -0
- metadata +3 -3
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Definition of the ::Xqsr3::StringUtilities::ToSymbol module
|
6
6
|
#
|
7
7
|
# Created: 14th April 2016
|
8
|
-
# Updated:
|
8
|
+
# Updated: 12th April 2024
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
@@ -45,118 +45,114 @@
|
|
45
45
|
# ######################################################################## #
|
46
46
|
|
47
47
|
|
48
|
-
# ##########################################################
|
49
|
-
# ::Xqsr3::StringUtilities::ToSymbol
|
50
|
-
|
51
48
|
=begin
|
52
49
|
=end
|
53
50
|
|
54
51
|
module Xqsr3
|
55
52
|
module StringUtilities
|
56
53
|
|
57
|
-
# To-symbol conversion facilities
|
58
|
-
#
|
59
|
-
module ToSymbol
|
54
|
+
# To-symbol conversion facilities
|
55
|
+
#
|
56
|
+
module ToSymbol
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
private
|
59
|
+
# @!visibility private
|
60
|
+
module ToSymbol_Helper_ # :nodoc: all
|
64
61
|
|
65
|
-
|
62
|
+
module Constants # :nodoc:
|
66
63
|
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
SymbolCharacters0 = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
65
|
+
SymbolCharactersN = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789'
|
66
|
+
end
|
70
67
|
|
71
|
-
|
68
|
+
def self.string_to_symbol_with_options_ s, options # :nodoc:
|
72
69
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
case s
|
71
|
+
when ::String
|
72
|
+
;
|
73
|
+
else
|
77
74
|
|
78
|
-
|
75
|
+
if s.respond_to? :to_str
|
79
76
|
|
80
|
-
|
81
|
-
|
77
|
+
s = s.to_str
|
78
|
+
else
|
82
79
|
|
83
|
-
|
80
|
+
raise TypeError, "string argument must be of type #{::String} or a type that will respond to to_str"
|
81
|
+
end
|
84
82
|
end
|
85
|
-
end
|
86
83
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
84
|
+
case options
|
85
|
+
when ::Hash
|
86
|
+
;
|
87
|
+
else
|
91
88
|
|
92
|
-
|
93
|
-
|
89
|
+
raise TypeError, "options must be of type #{::Hash}, #{options.class} given"
|
90
|
+
end
|
94
91
|
|
95
|
-
|
92
|
+
return nil if s.empty?
|
96
93
|
|
97
|
-
|
94
|
+
transform_characters = options[:transform_characters] || []
|
98
95
|
|
99
|
-
|
96
|
+
s.chars.map.with_index do |c, index|
|
100
97
|
|
101
|
-
|
98
|
+
if 0 != index && Constants::SymbolCharactersN.include?(c)
|
102
99
|
|
103
|
-
|
104
|
-
|
100
|
+
c
|
101
|
+
elsif 0 == index && Constants::SymbolCharacters0.include?(c)
|
105
102
|
|
106
|
-
|
107
|
-
|
103
|
+
c
|
104
|
+
else
|
108
105
|
|
109
|
-
|
110
|
-
|
106
|
+
case c
|
107
|
+
when '-'
|
111
108
|
|
112
|
-
|
113
|
-
|
109
|
+
return nil if options[:reject_hyphens]
|
110
|
+
when ' '
|
114
111
|
|
115
|
-
|
116
|
-
|
112
|
+
return nil if options[:reject_spaces] || options[:reject_whitespace]
|
113
|
+
when ?\t
|
117
114
|
|
118
|
-
|
119
|
-
|
115
|
+
return nil if options[:reject_tabs] || options[:reject_whitespace]
|
116
|
+
else
|
120
117
|
|
121
|
-
|
122
|
-
|
118
|
+
return nil unless transform_characters.include? c
|
119
|
+
end
|
123
120
|
|
124
|
-
|
125
|
-
|
126
|
-
|
121
|
+
'_'
|
122
|
+
end
|
123
|
+
end.join('').to_sym
|
124
|
+
end
|
125
|
+
end
|
126
|
+
public
|
127
|
+
|
128
|
+
# Converts the given string +s+ to a symbol according to the given
|
129
|
+
# +options+
|
130
|
+
#
|
131
|
+
# === Signature
|
132
|
+
#
|
133
|
+
# * *Parameters:*
|
134
|
+
# - +s+ (+String+) The string to convert;
|
135
|
+
# - +options+ (+Hash+) Options that control the behaviour of the method;
|
136
|
+
#
|
137
|
+
# * *Options:*
|
138
|
+
# - +:reject_hyphens+ (boolean);
|
139
|
+
# - +:reject_spaces+ (boolean);
|
140
|
+
# - +:reject_tabs+ (boolean);
|
141
|
+
# - +:reject_whitespace+ (boolean);
|
142
|
+
# - +:transform_characters+ (boolean);
|
143
|
+
def self.string_to_symbol s, options = {}
|
144
|
+
|
145
|
+
ToSymbol_Helper_.string_to_symbol_with_options_ s, options
|
127
146
|
end
|
128
|
-
end
|
129
|
-
public
|
130
|
-
|
131
|
-
# Converts the given string +s+ to a symbol according to the given
|
132
|
-
# +options+
|
133
|
-
#
|
134
|
-
# === Signature
|
135
|
-
#
|
136
|
-
# * *Parameters:*
|
137
|
-
# - +s+ (String) The string to convert
|
138
|
-
# - +options+ (Hash) Options hash
|
139
|
-
#
|
140
|
-
# * *Options:*
|
141
|
-
# - +:reject_hyphens+ (boolean)
|
142
|
-
# - +:reject_spaces+ (boolean)
|
143
|
-
# - +:reject_tabs+ (boolean)
|
144
|
-
# - +:reject_whitespace+ (boolean)
|
145
|
-
# - +:transform_characters+ (boolean)
|
146
|
-
def self.string_to_symbol s, options = {}
|
147
|
-
|
148
|
-
ToSymbol_Helper_.string_to_symbol_with_options_ s, options
|
149
|
-
end
|
150
|
-
|
151
|
-
# Converts the instance to a symbol, according to the given +options+
|
152
|
-
#
|
153
|
-
# See Xqsr3::StringUtilities::ToSymbol::string_to_symbol for options
|
154
|
-
def to_symbol options = {}
|
155
147
|
|
156
|
-
|
157
|
-
|
158
|
-
|
148
|
+
# Converts the instance to a symbol, according to the given +options+
|
149
|
+
#
|
150
|
+
# See Xqsr3::StringUtilities::ToSymbol::string_to_symbol for options
|
151
|
+
def to_symbol options = {}
|
159
152
|
|
153
|
+
ToSymbol_Helper_.string_to_symbol_with_options_ self, options
|
154
|
+
end
|
155
|
+
end # module ToSymbol
|
160
156
|
end # module StringUtilities
|
161
157
|
end # module Xqsr3
|
162
158
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Definition of the ::Xqsr3::StringUtilities::Truncate module
|
6
6
|
#
|
7
7
|
# Created: 12th April 2018
|
8
|
-
# Updated:
|
8
|
+
# Updated: 12th April 2024
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
@@ -45,90 +45,86 @@
|
|
45
45
|
# ######################################################################## #
|
46
46
|
|
47
47
|
|
48
|
-
# ##########################################################
|
49
|
-
# ::Xqsr3::StringUtilities::Truncate
|
50
|
-
|
51
48
|
=begin
|
52
49
|
=end
|
53
50
|
|
54
51
|
module Xqsr3
|
55
52
|
module StringUtilities
|
56
53
|
|
57
|
-
# To-symbol conversion facilities
|
58
|
-
#
|
59
|
-
module Truncate
|
54
|
+
# To-symbol conversion facilities
|
55
|
+
#
|
56
|
+
module Truncate
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
private
|
59
|
+
# @!visibility private
|
60
|
+
module Truncate_Helper_ # :nodoc: all
|
64
61
|
|
65
|
-
|
62
|
+
def self.string_truncate_with_options_ s, width, options # :nodoc:
|
66
63
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
case s
|
65
|
+
when ::String
|
66
|
+
;
|
67
|
+
else
|
71
68
|
|
72
|
-
|
69
|
+
if s.respond_to? :to_str
|
73
70
|
|
74
|
-
|
75
|
-
|
71
|
+
s = s.to_str
|
72
|
+
else
|
76
73
|
|
77
|
-
|
74
|
+
raise TypeError, "string argument must be of type #{::String} or a type that will respond to to_str"
|
75
|
+
end
|
78
76
|
end
|
79
|
-
end
|
80
77
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
78
|
+
case options
|
79
|
+
when ::Hash
|
80
|
+
;
|
81
|
+
else
|
85
82
|
|
86
|
-
|
87
|
-
|
83
|
+
raise TypeError, "options must be of type #{::Hash}, #{options.class} given"
|
84
|
+
end
|
88
85
|
|
89
|
-
|
86
|
+
len = s.size
|
90
87
|
|
91
|
-
|
88
|
+
return s if len <= width
|
92
89
|
|
93
|
-
|
90
|
+
omission = options[:omission] || '...'
|
94
91
|
|
95
|
-
|
92
|
+
if width < omission.size
|
96
93
|
|
97
|
-
|
98
|
-
|
94
|
+
return omission[0...width]
|
95
|
+
else
|
99
96
|
|
100
|
-
|
97
|
+
return s[0...(width - omission.size)] + omission
|
98
|
+
end
|
101
99
|
end
|
102
100
|
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
# Truncates the instance, according to the given +width+ and +options+
|
124
|
-
#
|
125
|
-
# See Xqsr3::StringUtilities::ToSymbol::string_truncate for options
|
126
|
-
def truncate width, options = {}
|
101
|
+
public
|
102
|
+
|
103
|
+
# Truncates the given string +s+ to the given +width+ according to the
|
104
|
+
# given +options+
|
105
|
+
#
|
106
|
+
# === Signature
|
107
|
+
#
|
108
|
+
# * *Parameters:*
|
109
|
+
# - +s+ (+String+) The string to convert;
|
110
|
+
# - +width+ (+Integer+) The truncation width;
|
111
|
+
# - +options+ (+Hash+) Options that control the behaviour of the method;
|
112
|
+
#
|
113
|
+
# * *Options:*
|
114
|
+
# - +:omission+ (+String+) Omission string. Defaults to "...";
|
115
|
+
def self.string_truncate s, width, options = {}
|
116
|
+
|
117
|
+
Truncate_Helper_.string_truncate_with_options_ s, width, options
|
118
|
+
end
|
127
119
|
|
128
|
-
|
129
|
-
|
130
|
-
|
120
|
+
# Truncates the instance, according to the given +width+ and +options+
|
121
|
+
#
|
122
|
+
# See Xqsr3::StringUtilities::ToSymbol::string_truncate for options
|
123
|
+
def truncate width, options = {}
|
131
124
|
|
125
|
+
Truncate_Helper_.string_truncate_with_options_ self, width, options
|
126
|
+
end
|
127
|
+
end # module Truncate
|
132
128
|
end # module StringUtilities
|
133
129
|
end # module Xqsr3
|
134
130
|
|
data/lib/xqsr3/version.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: Version for Xqsr3 library
|
6
6
|
#
|
7
7
|
# Created: 3rd April 2016
|
8
|
-
# Updated:
|
8
|
+
# Updated: 12th April 2024
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
@@ -51,7 +51,7 @@
|
|
51
51
|
module Xqsr3
|
52
52
|
|
53
53
|
# Current version of the Xqsr3 library
|
54
|
-
VERSION = '0.39.1'
|
54
|
+
VERSION = '0.39.2.1'
|
55
55
|
|
56
56
|
private
|
57
57
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), '../../lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'xqsr3/extensions/test/unit/assert_raise_with_message'
|
6
7
|
|
7
8
|
require 'test/unit'
|
8
9
|
|
10
|
+
|
9
11
|
class Test_assert_raise_with_message < Test::Unit::TestCase
|
10
12
|
|
11
13
|
class UnusedException < RuntimeError; end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), '../../../lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'xqsr3/array_utilities/join_with_or'
|
6
7
|
|
7
8
|
require 'xqsr3/extensions/test/unit'
|
8
|
-
|
9
9
|
require 'test/unit'
|
10
10
|
|
11
11
|
|
@@ -109,8 +109,10 @@ class Test_Xqsr3_ArrayUtilities_join_with_or_by_module < Test::Unit::TestCase
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
|
112
113
|
require 'xqsr3/extensions/array/join_with_or'
|
113
114
|
|
115
|
+
|
114
116
|
class Test_Xqsr3_ArrayUtilities_join_with_or_by_include < Test::Unit::TestCase
|
115
117
|
|
116
118
|
include ::Xqsr3::ArrayUtilities::JoinWithOr
|
@@ -2,13 +2,16 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), '../../../lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'xqsr3/command_line_utilities/map_option_string'
|
6
7
|
|
7
8
|
require 'xqsr3/extensions/test/unit'
|
8
9
|
require 'test/unit'
|
9
10
|
|
11
|
+
|
10
12
|
include ::Xqsr3::CommandLineUtilities
|
11
13
|
|
14
|
+
|
12
15
|
class Test_Xqsr3_CommandLineUtilities_map_option_string < Test::Unit::TestCase
|
13
16
|
|
14
17
|
def test_simple_uses
|
@@ -2,13 +2,16 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), '../../../lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'xqsr3/containers/frequency_map'
|
6
7
|
|
7
8
|
require 'xqsr3/extensions/test/unit'
|
8
9
|
require 'test/unit'
|
9
10
|
|
11
|
+
|
10
12
|
include ::Xqsr3::Containers
|
11
13
|
|
14
|
+
|
12
15
|
class Test_Xqsr3_Containers_FrequencyMap < Test::Unit::TestCase
|
13
16
|
|
14
17
|
def test_class_operator_subscript_1
|
@@ -21,7 +24,7 @@ class Test_Xqsr3_Containers_FrequencyMap < Test::Unit::TestCase
|
|
21
24
|
|
22
25
|
assert_nil fm1.default
|
23
26
|
|
24
|
-
assert_match /^#<Xqsr3::Containers::FrequencyMap:0x\d+:\s*@count\(\w+\)=0; @elements\(Hash\)={}\s
|
27
|
+
assert_match (/^#<Xqsr3::Containers::FrequencyMap:0x\d+:\s*@count\(\w+\)=0; @elements\(Hash\)={}\s*>$/), fm1.inspect
|
25
28
|
end
|
26
29
|
|
27
30
|
def test_class_operator_subscript_2
|
@@ -32,7 +35,7 @@ class Test_Xqsr3_Containers_FrequencyMap < Test::Unit::TestCase
|
|
32
35
|
assert_not fm2.empty?
|
33
36
|
assert_equal 2, fm2.size
|
34
37
|
|
35
|
-
assert_match /^#<Xqsr3::Containers::FrequencyMap:0x\d+:\s*@count\(\w+\)=3; @elements\(Hash\)={.*abc.*def.*}\s
|
38
|
+
assert_match (/^#<Xqsr3::Containers::FrequencyMap:0x\d+:\s*@count\(\w+\)=3; @elements\(Hash\)={.*abc.*def.*}\s*>$/), fm2.inspect
|
36
39
|
end
|
37
40
|
|
38
41
|
def test_class_operator_subscript_3
|
@@ -2,13 +2,16 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), '../../../lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'xqsr3/containers/multi_map'
|
6
7
|
|
7
8
|
require 'xqsr3/extensions/test/unit'
|
8
9
|
require 'test/unit'
|
9
10
|
|
11
|
+
|
10
12
|
include ::Xqsr3::Containers
|
11
13
|
|
14
|
+
|
12
15
|
class Test_Xqsr3_Containers_MultiMap < Test::Unit::TestCase
|
13
16
|
|
14
17
|
def test_class_operator_subscript_1
|
@@ -2,12 +2,13 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), '../../../lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'xqsr3/conversion/integer_parser'
|
6
7
|
|
7
8
|
require 'xqsr3/extensions/test/unit'
|
8
|
-
|
9
9
|
require 'test/unit'
|
10
10
|
|
11
|
+
|
11
12
|
class Test_IntegerParser < Test::Unit::TestCase
|
12
13
|
|
13
14
|
IP = ::Xqsr3::Conversion::IntegerParser
|
@@ -16,15 +17,15 @@ class Test_IntegerParser < Test::Unit::TestCase
|
|
16
17
|
|
17
18
|
def test_show_base_being_ignored
|
18
19
|
|
19
|
-
assert_equal
|
20
|
-
assert_equal
|
21
|
-
assert_equal
|
22
|
-
assert_equal
|
20
|
+
assert_equal(-100, IP.to_integer(-100))
|
21
|
+
assert_equal(-100, IP.to_integer(-100, 0))
|
22
|
+
assert_equal(-100, IP.to_integer(-100.0, 0))
|
23
|
+
assert_equal(-100, IP.to_integer(-100.0, 10))
|
23
24
|
|
24
|
-
assert_equal
|
25
|
-
assert_equal
|
26
|
-
assert_equal
|
27
|
-
assert_equal
|
25
|
+
assert_equal(-100, IP.to_integer('-100'))
|
26
|
+
assert_equal(-100, IP.to_integer('-100', 0))
|
27
|
+
assert_equal(-100, IP.to_integer('-100', 10))
|
28
|
+
assert_equal(-4, IP.to_integer('-100', 2))
|
28
29
|
end
|
29
30
|
|
30
31
|
def test_default_for_invalid_type
|
@@ -34,15 +35,15 @@ class Test_IntegerParser < Test::Unit::TestCase
|
|
34
35
|
|
35
36
|
def test_to_integer_with_valid_values
|
36
37
|
|
37
|
-
assert_equal
|
38
|
-
assert_equal
|
39
|
-
assert_equal
|
40
|
-
assert_equal
|
38
|
+
assert_equal(0, IP.to_integer(0))
|
39
|
+
assert_equal(+1, IP.to_integer(1))
|
40
|
+
assert_equal(+1, IP.to_integer(+1))
|
41
|
+
assert_equal(-1, IP.to_integer(-1))
|
41
42
|
|
42
|
-
assert_equal
|
43
|
-
assert_equal
|
44
|
-
assert_equal
|
45
|
-
assert_equal
|
43
|
+
assert_equal(0, IP.to_integer('0'))
|
44
|
+
assert_equal(+1, IP.to_integer('1'))
|
45
|
+
assert_equal(+1, IP.to_integer('+1'))
|
46
|
+
assert_equal(-1, IP.to_integer('-1'))
|
46
47
|
end
|
47
48
|
|
48
49
|
def test_to_integer_with_invalid_values
|
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), '../../../lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'xqsr3/conversion/bool_parser'
|
6
7
|
|
7
8
|
require 'xqsr3/extensions/test/unit'
|
8
9
|
require 'test/unit'
|
9
10
|
|
11
|
+
|
10
12
|
class Test_Xqsr3_ConversionMultiMap < Test::Unit::TestCase
|
11
13
|
|
12
14
|
include ::Xqsr3::Conversion
|
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), '../../../../lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'xqsr3/diagnostics/exceptions/with_cause'
|
6
7
|
|
7
8
|
require 'test/unit'
|
8
9
|
|
10
|
+
|
9
11
|
class Test_WithCause < Test::Unit::TestCase
|
10
12
|
|
11
13
|
class SomeExceptionWithCause < ::Exception
|
@@ -138,7 +140,7 @@ class Test_WithCause < Test::Unit::TestCase
|
|
138
140
|
|
139
141
|
def initialize(*args, **options)
|
140
142
|
|
141
|
-
super
|
143
|
+
super(*args, **options)
|
142
144
|
end
|
143
145
|
|
144
146
|
include ::Xqsr3::Diagnostics::Exceptions::WithCause
|
@@ -150,7 +152,7 @@ class Test_WithCause < Test::Unit::TestCase
|
|
150
152
|
|
151
153
|
def initialize(*args, **options)
|
152
154
|
|
153
|
-
super
|
155
|
+
super(*args, **options)
|
154
156
|
end
|
155
157
|
end
|
156
158
|
|
@@ -226,7 +228,7 @@ class Test_WithCause_throwing < Test::Unit::TestCase
|
|
226
228
|
|
227
229
|
x_bt0 = x.backtrace[0]
|
228
230
|
|
229
|
-
assert /:in\s+\`f\'\s*$/ =~ x_bt0, 'not receieved from f()'
|
231
|
+
assert (/:in\s+\`f\'\s*$/ =~ x_bt0), 'not receieved from f()'
|
230
232
|
end
|
231
233
|
end
|
232
234
|
|
@@ -249,11 +251,11 @@ class Test_WithCause_throwing < Test::Unit::TestCase
|
|
249
251
|
|
250
252
|
x_bt0 = x.backtrace[0]
|
251
253
|
|
252
|
-
assert /:in\s+\`rescue in g\'\s*$/ =~ x_bt0, 'not receieved from g()'
|
254
|
+
assert (/:in\s+\`rescue in g\'\s*$/ =~ x_bt0), 'not receieved from g()'
|
253
255
|
|
254
256
|
c_bt0 = x.cause.backtrace[0]
|
255
257
|
|
256
|
-
assert /:in\s+\`f\'\s*$/ =~ c_bt0, 'not receieved from f()'
|
258
|
+
assert (/:in\s+\`f\'\s*$/ =~ c_bt0), 'not receieved from f()'
|
257
259
|
|
258
260
|
assert_not_empty x.chained_backtrace
|
259
261
|
end
|
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), '../../../lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'xqsr3/diagnostics/exception_utilities'
|
6
7
|
|
7
8
|
require 'test/unit'
|
8
9
|
|
10
|
+
|
9
11
|
class Test_ExceptionUtilities_raise_with_options < Test::Unit::TestCase
|
10
12
|
|
11
13
|
include ::Xqsr3::Diagnostics
|