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.
- checksums.yaml +4 -4
- data/README.md +15 -6
- data/examples/count_word_frequencies.md +13 -13
- data/examples/count_word_frequencies.rb +5 -5
- data/lib/xqsr3/array_utilities/join_with_or.rb +53 -54
- data/lib/xqsr3/array_utilities.rb +2 -2
- data/lib/xqsr3/command_line_utilities/map_option_string.rb +66 -67
- data/lib/xqsr3/command_line_utilities.rb +2 -2
- data/lib/xqsr3/containers/frequency_map.rb +405 -404
- data/lib/xqsr3/containers/multi_map.rb +454 -453
- data/lib/xqsr3/containers.rb +3 -3
- data/lib/xqsr3/conversion/bool_parser.rb +56 -57
- data/lib/xqsr3/conversion/integer_parser.rb +92 -93
- data/lib/xqsr3/conversion.rb +3 -3
- data/lib/xqsr3/diagnostics/exception_utilities.rb +152 -151
- data/lib/xqsr3/diagnostics/exceptions/with_cause.rb +99 -95
- data/lib/xqsr3/diagnostics/inspect_builder.rb +86 -86
- data/lib/xqsr3/diagnostics.rb +3 -3
- data/lib/xqsr3/doc_.rb +136 -136
- data/lib/xqsr3/extensions/array/join_with_or.rb +9 -9
- data/lib/xqsr3/extensions/enumerable/collect_with_index.rb +18 -17
- data/lib/xqsr3/extensions/enumerable/detect_map.rb +41 -41
- data/lib/xqsr3/extensions/enumerable/unique.rb +32 -31
- data/lib/xqsr3/extensions/hash/deep_transform.rb +1 -1
- data/lib/xqsr3/extensions/hash/except.rb +16 -16
- data/lib/xqsr3/extensions/hash/has_match.rb +10 -10
- data/lib/xqsr3/extensions/hash/match.rb +10 -10
- data/lib/xqsr3/extensions/hash/slice.rb +11 -11
- data/lib/xqsr3/extensions/hash.rb +1 -1
- data/lib/xqsr3/extensions/integer/to_s_grp.rb +118 -0
- data/lib/xqsr3/extensions/integer.rb +3 -0
- data/lib/xqsr3/extensions/io/writelines.rb +34 -34
- data/lib/xqsr3/extensions/kernel/integer.rb +26 -26
- data/lib/xqsr3/extensions/kernel/raise_with_options.rb +15 -14
- data/lib/xqsr3/extensions/kernel.rb +1 -0
- data/lib/xqsr3/extensions/string/ends_with.rb +1 -1
- data/lib/xqsr3/extensions/string/map_option_string.rb +4 -5
- data/lib/xqsr3/extensions/string/nil_if_empty.rb +1 -1
- data/lib/xqsr3/extensions/string/nil_if_whitespace.rb +1 -1
- data/lib/xqsr3/extensions/string/quote_if.rb +1 -2
- data/lib/xqsr3/extensions/string/starts_with.rb +1 -1
- data/lib/xqsr3/extensions/string/to_bool.rb +8 -9
- data/lib/xqsr3/extensions/string/to_symbol.rb +1 -1
- data/lib/xqsr3/extensions/string/truncate.rb +1 -2
- data/lib/xqsr3/extensions/test/unit/assert_eql.rb +7 -7
- data/lib/xqsr3/extensions/test/unit/assert_false.rb +6 -7
- data/lib/xqsr3/extensions/test/unit/assert_not.rb +6 -7
- data/lib/xqsr3/extensions/test/unit/assert_not_eql.rb +7 -7
- data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +61 -62
- data/lib/xqsr3/extensions/test/unit/assert_subclass_of.rb +7 -8
- data/lib/xqsr3/extensions/test/unit/assert_superclass_of.rb +7 -8
- data/lib/xqsr3/extensions/test/unit/assert_true.rb +6 -7
- data/lib/xqsr3/extensions/test/unit/assert_type_has_instance_methods.rb +36 -38
- data/lib/xqsr3/extensions.rb +5 -5
- data/lib/xqsr3/hash_utilities/deep_transform.rb +71 -71
- data/lib/xqsr3/hash_utilities/key_matching.rb +82 -82
- data/lib/xqsr3/hash_utilities.rb +3 -3
- data/lib/xqsr3/internal_/test_unit_version_.rb +130 -88
- data/lib/xqsr3/io/writelines.rb +125 -125
- data/lib/xqsr3/quality/parameter_checking.rb +452 -453
- data/lib/xqsr3/quality.rb +2 -2
- data/lib/xqsr3/string_utilities/ends_with.rb +64 -64
- data/lib/xqsr3/string_utilities/nil_if_empty.rb +33 -34
- data/lib/xqsr3/string_utilities/nil_if_whitespace.rb +35 -35
- data/lib/xqsr3/string_utilities/quote_if.rb +55 -56
- data/lib/xqsr3/string_utilities/starts_with.rb +64 -64
- data/lib/xqsr3/string_utilities/to_symbol.rb +80 -80
- data/lib/xqsr3/string_utilities/truncate.rb +60 -61
- data/lib/xqsr3/string_utilities.rb +8 -8
- data/lib/xqsr3/version.rb +19 -20
- data/test/performance/frequency_map.rb +13 -27
- data/test/scratch/test_assert_raise_with_message.rb +12 -13
- data/test/unit/array_utilities/tc_join_with_or.rb +140 -142
- data/test/unit/command_line_utilities/tc_map_option_string.rb +18 -18
- data/test/unit/containers/tc_frequency_map.rb +607 -554
- data/test/unit/containers/tc_multi_map.rb +573 -522
- data/test/unit/conversion/tc_integer_parser.rb +73 -73
- data/test/unit/conversion/tc_to_bool.rb +26 -26
- data/test/unit/diagnostics/exceptions/tc_with_cause.rb +165 -165
- data/test/unit/diagnostics/tc_exception_utilities.rb +156 -156
- data/test/unit/extensions/enumerable/tc_collect_with_index.rb +14 -14
- data/test/unit/extensions/enumerable/tc_detect_map.rb +20 -20
- data/test/unit/extensions/enumerable/tc_unique.rb +34 -34
- data/test/unit/extensions/hash/tc_deep_transform.rb +22 -22
- data/test/unit/extensions/hash/tc_except.rb +28 -28
- data/test/unit/extensions/hash/tc_hash.rb +1 -1
- data/test/unit/extensions/hash/tc_slice.rb +14 -14
- data/test/unit/extensions/integer/tc_to_s_grp.rb +60 -0
- data/test/unit/extensions/integer/ts_all.rb +12 -0
- data/test/unit/extensions/io/tc_writelines.rb +77 -77
- data/test/unit/extensions/kernel/tc_integer.rb +75 -75
- data/test/unit/extensions/kernel/tc_raise_with_options.rb +155 -155
- data/test/unit/extensions/object/tc_inspect.rb +51 -51
- data/test/unit/extensions/string/tc_bool.tb +24 -24
- data/test/unit/extensions/string/tc_ends_with.rb +53 -53
- data/test/unit/extensions/string/tc_map_option_string.rb +15 -15
- data/test/unit/extensions/string/tc_nil_if_empty.rb +8 -8
- data/test/unit/extensions/string/tc_nil_if_whitespace.rb +8 -8
- data/test/unit/extensions/string/tc_quote_if.rb +18 -18
- data/test/unit/extensions/string/tc_starts_with.rb +53 -53
- data/test/unit/extensions/string/tc_to_symbol.rb +26 -26
- data/test/unit/extensions/string/tc_truncate.rb +18 -18
- data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +16 -16
- data/test/unit/extensions/test/unit/tc_assert_subclass_of.rb +9 -9
- data/test/unit/extensions/test/unit/tc_assert_superclass_of.rb +9 -9
- data/test/unit/hash_utilities/tc_has_match.rb +70 -70
- data/test/unit/hash_utilities/tc_match.rb +83 -83
- data/test/unit/io/tc_writelines.rb +106 -108
- data/test/unit/quality/tc_parameter_checking.rb +390 -390
- data/test/unit/string_utilities/tc_truncate.rb +28 -28
- data/test/unit/tc_version.rb +15 -15
- metadata +6 -2
@@ -11,59 +11,59 @@ require 'stringio'
|
|
11
11
|
|
12
12
|
class Test_String_ends_with < Test::Unit::TestCase
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
14
|
+
def test_String_has_method
|
15
|
+
|
16
|
+
assert ''.respond_to? :ends_with?
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_with_nil
|
20
|
+
|
21
|
+
assert ''.ends_with? nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_with_single_strings
|
25
|
+
|
26
|
+
assert ''.ends_with? ''
|
27
|
+
assert 'a'.ends_with? ''
|
28
|
+
assert 'a'.ends_with? 'a'
|
29
|
+
assert_not 'b'.ends_with? 'a'
|
30
|
+
assert_nil 'b'.ends_with? 'a'
|
31
|
+
assert 'ab'.ends_with? 'b'
|
32
|
+
assert 'abc'.ends_with? 'c'
|
33
|
+
assert 'abc'.ends_with? 'bc'
|
34
|
+
assert_not 'abc'.ends_with? 'ac'
|
35
|
+
assert_nil 'abc'.ends_with? 'ac'
|
36
|
+
|
37
|
+
assert 'abcdefghijklmnopqrstuvwxyz'.ends_with? ''
|
38
|
+
assert 'abcdefghijklmnopqrstuvwxyz'.ends_with? 'z'
|
39
|
+
assert 'abcdefghijklmnopqrstuvwxyz'.ends_with? 'yz'
|
40
|
+
assert 'abcdefghijklmnopqrstuvwxyz'.ends_with? 'xyz'
|
41
|
+
assert 'abcdefghijklmnopqrstuvwxyz'.ends_with? 'wxyz'
|
42
|
+
assert 'abcdefghijklmnopqrstuvwxyz'.ends_with? 'vwxyz'
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_multiple_strings
|
46
|
+
|
47
|
+
assert ''.ends_with? '', 'd'
|
48
|
+
assert_not ''.ends_with? 'c', 'd'
|
49
|
+
assert_nil ''.ends_with? 'c', 'd'
|
50
|
+
assert 'c'.ends_with? 'c', 'd'
|
51
|
+
assert 'd'.ends_with? 'c', 'd'
|
52
|
+
|
53
|
+
assert_equal 'd', 'abcd'.ends_with?('c', 'd')
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_with_array
|
57
|
+
|
58
|
+
prefixes = %w{ a c def }
|
59
|
+
|
60
|
+
assert_not ''.ends_with?(*prefixes)
|
61
|
+
assert_nil ''.ends_with?(*prefixes), 'empty string does not yield nil with given non-empty prefix(es)'
|
62
|
+
assert 'abc'.ends_with?(*prefixes)
|
63
|
+
assert_not 'd'.ends_with?(*prefixes)
|
64
|
+
assert_nil 'd'.ends_with?(*prefixes)
|
65
|
+
assert 'abcdef'.ends_with?(*prefixes)
|
66
|
+
end
|
67
67
|
end
|
68
68
|
|
69
69
|
|
@@ -9,29 +9,29 @@ require 'test/unit'
|
|
9
9
|
|
10
10
|
class Test_String_map_option_string < Test::Unit::TestCase
|
11
11
|
|
12
|
-
|
12
|
+
def test_simple_uses
|
13
13
|
|
14
|
-
|
14
|
+
assert_nil 'abc'.map_option_string [ 'option-1', 'option-2' ]
|
15
15
|
|
16
|
-
|
16
|
+
assert_equal :abc, 'abc'.map_option_string([ 'abc' ])
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
assert_equal :option_1, 'option-1'.map_option_string([ 'option-1', 'option-2' ])
|
19
|
+
end
|
20
20
|
|
21
|
-
|
21
|
+
def test_shortcuts
|
22
22
|
|
23
|
-
|
23
|
+
option_strings = [ '[n]ame-only', '[f]ull-[p]ath' ]
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
assert_equal :name_only, 'name-only'.map_option_string(option_strings)
|
26
|
+
assert_equal :full_path, 'full-path'.map_option_string(option_strings)
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
assert_equal :name_only, 'n'.map_option_string(option_strings)
|
29
|
+
assert_equal :full_path, 'fp'.map_option_string(option_strings)
|
30
30
|
|
31
|
-
|
31
|
+
%w{ a m e - o l y u l p a t h }.each do |shortcut|
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
assert_nil shortcut.map_option_string(option_strings)
|
34
|
+
end
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
@@ -11,17 +11,17 @@ require 'stringio'
|
|
11
11
|
|
12
12
|
class Test_String_nil_if_empty < Test::Unit::TestCase
|
13
13
|
|
14
|
-
|
14
|
+
def test_String_has_method
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
assert ''.respond_to? :nil_if_empty
|
17
|
+
end
|
18
18
|
|
19
|
-
|
19
|
+
def test_nil_if_empty
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
assert_nil ''.nil_if_empty
|
22
|
+
assert_equal ' ', ' '.nil_if_empty
|
23
|
+
assert_equal 'a', 'a'.nil_if_empty
|
24
|
+
end
|
25
25
|
end
|
26
26
|
|
27
27
|
|
@@ -11,17 +11,17 @@ require 'stringio'
|
|
11
11
|
|
12
12
|
class Test_String_nil_if_whitespace < Test::Unit::TestCase
|
13
13
|
|
14
|
-
|
14
|
+
def test_String_has_method
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
assert ''.respond_to? :nil_if_whitespace
|
17
|
+
end
|
18
18
|
|
19
|
-
|
19
|
+
def test_nil_if_whitespace
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
assert_nil ''.nil_if_whitespace
|
22
|
+
assert_nil ' '.nil_if_whitespace
|
23
|
+
assert_equal 'a', 'a'.nil_if_whitespace
|
24
|
+
end
|
25
25
|
end
|
26
26
|
|
27
27
|
|
@@ -11,31 +11,31 @@ require 'stringio'
|
|
11
11
|
|
12
12
|
class Test_String_quote_if < Test::Unit::TestCase
|
13
13
|
|
14
|
-
|
14
|
+
def test_String_has_method
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
assert ''.respond_to? :quote_if
|
17
|
+
end
|
18
18
|
|
19
|
-
|
19
|
+
def test_with_no_options
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
assert_equal '', ''.quote_if
|
22
|
+
assert_equal 'a', 'a'.quote_if
|
23
|
+
assert_equal 'ab', 'ab'.quote_if
|
24
|
+
assert_equal '"a b"', 'a b'.quote_if
|
25
|
+
end
|
26
26
|
|
27
|
-
|
27
|
+
def test_with_quotables
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
assert_equal 'a b', 'a b'.quote_if(quotables: '-')
|
30
|
+
assert_equal '"a-b"', 'a-b'.quote_if(quotables: '-')
|
31
|
+
end
|
32
32
|
|
33
|
-
|
33
|
+
def test_with_quotes
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
assert_equal '"a b"', 'a b'.quote_if
|
36
|
+
assert_equal '|a b|', 'a b'.quote_if(quotes: '|')
|
37
|
+
assert_equal '[a b]', 'a b'.quote_if(quotes: [ '[', ']' ])
|
38
|
+
end
|
39
39
|
end
|
40
40
|
|
41
41
|
|
@@ -11,59 +11,59 @@ require 'stringio'
|
|
11
11
|
|
12
12
|
class Test_String_starts_with < Test::Unit::TestCase
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
14
|
+
def test_String_has_method
|
15
|
+
|
16
|
+
assert ''.respond_to? :starts_with?
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_with_nil
|
20
|
+
|
21
|
+
assert ''.starts_with? nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_with_single_strings
|
25
|
+
|
26
|
+
assert ''.starts_with? ''
|
27
|
+
assert 'a'.starts_with? ''
|
28
|
+
assert 'a'.starts_with? 'a'
|
29
|
+
assert_not 'b'.starts_with? 'a'
|
30
|
+
assert_nil 'b'.starts_with? 'a'
|
31
|
+
assert 'ab'.starts_with? 'a'
|
32
|
+
assert 'abc'.starts_with? 'a'
|
33
|
+
assert 'abc'.starts_with? 'ab'
|
34
|
+
assert_not 'abc'.starts_with? 'ac'
|
35
|
+
assert_nil 'abc'.starts_with? 'ac'
|
36
|
+
|
37
|
+
assert 'abcdefghijklmnopqrstuvwxz'.starts_with? ''
|
38
|
+
assert 'abcdefghijklmnopqrstuvwxz'.starts_with? 'a'
|
39
|
+
assert 'abcdefghijklmnopqrstuvwxz'.starts_with? 'ab'
|
40
|
+
assert 'abcdefghijklmnopqrstuvwxz'.starts_with? 'abc'
|
41
|
+
assert 'abcdefghijklmnopqrstuvwxz'.starts_with? 'abcd'
|
42
|
+
assert 'abcdefghijklmnopqrstuvwxz'.starts_with? 'abcde'
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_multiple_strings
|
46
|
+
|
47
|
+
assert ''.starts_with? '', 'd'
|
48
|
+
assert_not ''.starts_with? 'c', 'd'
|
49
|
+
assert_nil ''.starts_with? 'c', 'd'
|
50
|
+
assert 'c'.starts_with? 'c', 'd'
|
51
|
+
assert 'd'.starts_with? 'c', 'd'
|
52
|
+
|
53
|
+
assert_equal 'a', 'abcd'.starts_with?('a', 'b')
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_with_array
|
57
|
+
|
58
|
+
prefixes = %w{ a c def }
|
59
|
+
|
60
|
+
assert_not ''.starts_with?(*prefixes)
|
61
|
+
assert_nil ''.starts_with?(*prefixes)
|
62
|
+
assert 'abc'.starts_with?(*prefixes)
|
63
|
+
assert_not 'd'.starts_with?(*prefixes)
|
64
|
+
assert_nil 'd'.starts_with?(*prefixes)
|
65
|
+
assert 'defghi'.starts_with?(*prefixes)
|
66
|
+
end
|
67
67
|
end
|
68
68
|
|
69
69
|
|
@@ -9,43 +9,43 @@ require 'test/unit'
|
|
9
9
|
|
10
10
|
class Test_String_to_symbol < Test::Unit::TestCase
|
11
11
|
|
12
|
-
|
12
|
+
def test_empty_string
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
assert_nil ''.to_symbol
|
15
|
+
end
|
16
16
|
|
17
|
-
|
17
|
+
def test_simple_string
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
assert_equal :a, 'a'.to_symbol
|
20
|
+
end
|
21
21
|
|
22
|
-
|
22
|
+
def test_string_with_spaces
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
assert_equal :some_symbol, 'some symbol'.to_symbol
|
25
|
+
assert_nil 'some symbol'.to_symbol(reject_spaces: true)
|
26
|
+
assert_nil 'some symbol'.to_symbol(reject_whitespace: true)
|
27
|
+
end
|
28
28
|
|
29
|
-
|
29
|
+
def test_string_with_tabs
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
assert_equal :some_symbol, "some\tsymbol".to_symbol
|
32
|
+
assert_nil "some\tsymbol".to_symbol(reject_tabs: true)
|
33
|
+
assert_nil "some\tsymbol".to_symbol(reject_whitespace: true)
|
34
|
+
end
|
35
35
|
|
36
|
-
|
36
|
+
def test_string_with_hyphens
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
assert_equal :some_symbol, 'some-symbol'.to_symbol
|
39
|
+
assert_nil 'some-symbol'.to_symbol(reject_hyphens: true)
|
40
|
+
end
|
41
41
|
|
42
|
-
|
42
|
+
def test_string_with_transform_characters
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
assert_nil 'some#funky$symbol'.to_symbol
|
45
|
+
assert_nil 'some#funky$symbol'.to_symbol transform_characters: [ ?', ?$ ]
|
46
|
+
assert_nil 'some#funky$symbol'.to_symbol transform_characters: [ ?#, ?' ]
|
47
|
+
assert_equal :some_funky_symbol, 'some#funky$symbol'.to_symbol(transform_characters: [ ?#, ?$ ])
|
48
|
+
end
|
49
49
|
end
|
50
50
|
|
51
51
|
|
@@ -9,29 +9,29 @@ require 'test/unit'
|
|
9
9
|
|
10
10
|
class Test_String_truncate < Test::Unit::TestCase
|
11
11
|
|
12
|
-
|
12
|
+
def test_empty_string
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
assert_equal '', ''.truncate(0)
|
15
|
+
assert_equal '', ''.truncate(1)
|
16
|
+
assert_equal '', ''.truncate(10)
|
17
|
+
end
|
18
18
|
|
19
|
-
|
19
|
+
def test_short_string
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
assert_equal '.', 'ab'.truncate(1)
|
22
|
+
assert_equal 'ab', 'ab'.truncate(2)
|
23
|
+
assert_equal 'ab', 'ab'.truncate(10)
|
24
|
+
end
|
25
25
|
|
26
|
-
|
26
|
+
def test_shortish_string
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
assert_equal '.', 'abcde'.truncate(1)
|
29
|
+
assert_equal '..', 'abcde'.truncate(2)
|
30
|
+
assert_equal '...', 'abcde'.truncate(3)
|
31
|
+
assert_equal 'a...', 'abcde'.truncate(4)
|
32
|
+
assert_equal 'abcde', 'abcde'.truncate(5)
|
33
|
+
assert_equal 'abcde', 'abcde'.truncate(10)
|
34
|
+
end
|
35
35
|
end
|
36
36
|
|
37
37
|
|
@@ -8,31 +8,31 @@ require 'test/unit'
|
|
8
8
|
|
9
9
|
class Test_assert_raise_with_message < Test::Unit::TestCase
|
10
10
|
|
11
|
-
|
11
|
+
def test_no_class_and_specific_message
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
assert_raise_with_message(nil, 'the-message') { raise ArgumentError, 'the-message' }
|
14
|
+
end
|
15
15
|
|
16
|
-
|
16
|
+
def test_no_class_and_message_list
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
assert_raise_with_message(nil, [ 'first-message', 'a-message', 'the-message', 'last-message' ]) { raise ArgumentError, 'the-message' }
|
19
|
+
end
|
20
20
|
|
21
|
-
|
21
|
+
def test_specific_class_and_no_message
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
assert_raise_with_message(::ArgumentError, nil) { raise ::ArgumentError, 'the-message' }
|
24
|
+
end
|
25
25
|
|
26
|
-
|
26
|
+
def test_class_list_and_no_message
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
assert_raise_with_message([ ::ArgumentError, ::SystemExit ], nil) { raise ::ArgumentError, 'the-message' }
|
29
|
+
assert_raise_with_message([ ::SystemExit, ::ArgumentError ], nil) { raise ::ArgumentError, 'the-message' }
|
30
|
+
end
|
31
31
|
|
32
|
-
|
32
|
+
def test_class_and_regex_message
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
assert_raise_with_message(::RuntimeError, /the.*message/) { raise 'the-longer-message' }
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
38
|
|
@@ -8,17 +8,17 @@ require 'test/unit'
|
|
8
8
|
|
9
9
|
class Test_assert_subclass_of < Test::Unit::TestCase
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
class Grandparent; end
|
12
|
+
class Parent < Grandparent; end
|
13
|
+
class Child < Parent; end
|
14
14
|
|
15
|
-
|
15
|
+
def test_1
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
assert_subclass_of Object, Grandparent
|
18
|
+
assert_subclass_of Grandparent, Parent
|
19
|
+
assert_subclass_of Parent, Child
|
20
|
+
assert_subclass_of Grandparent, Child
|
21
|
+
end
|
22
22
|
end
|
23
23
|
|
24
24
|
|
@@ -8,17 +8,17 @@ require 'test/unit'
|
|
8
8
|
|
9
9
|
class Test_assert_superclass_of < Test::Unit::TestCase
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
class Grandparent; end
|
12
|
+
class Parent < Grandparent; end
|
13
|
+
class Child < Parent; end
|
14
14
|
|
15
|
-
|
15
|
+
def test_1
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
assert_superclass_of Grandparent, Object
|
18
|
+
assert_superclass_of Parent, Grandparent
|
19
|
+
assert_superclass_of Child, Parent
|
20
|
+
assert_superclass_of Child, Grandparent
|
21
|
+
end
|
22
22
|
end
|
23
23
|
|
24
24
|
|