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
@@ -1,16 +1,17 @@
|
|
1
1
|
|
2
2
|
# ######################################################################## #
|
3
|
-
# File:
|
3
|
+
# File: lib/xqsr3/extensions/kernel/integer.rb
|
4
4
|
#
|
5
|
-
# Purpose:
|
5
|
+
# Purpose: Adds a Integer 'overload' to the Kernel module
|
6
6
|
#
|
7
|
-
# Created:
|
8
|
-
# Updated:
|
7
|
+
# Created: 21st November 2017
|
8
|
+
# Updated: 29th March 2024
|
9
9
|
#
|
10
|
-
# Home:
|
10
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
12
|
-
# Author:
|
12
|
+
# Author: Matthew Wilson
|
13
13
|
#
|
14
|
+
# Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
|
14
15
|
# Copyright (c) 2017-2019, Matthew Wilson and Synesis Software
|
15
16
|
# All rights reserved.
|
16
17
|
#
|
@@ -25,7 +26,7 @@
|
|
25
26
|
# notice, this list of conditions and the following disclaimer in the
|
26
27
|
# documentation and/or other materials provided with the distribution.
|
27
28
|
#
|
28
|
-
# * Neither the names of the copyright
|
29
|
+
# * Neither the names of the copyright holders nor the names of its
|
29
30
|
# contributors may be used to endorse or promote products derived from
|
30
31
|
# this software without specific prior written permission.
|
31
32
|
#
|
@@ -54,29 +55,28 @@ require 'xqsr3/conversion/integer_parser'
|
|
54
55
|
|
55
56
|
module Kernel
|
56
57
|
|
57
|
-
|
58
|
+
alias xqsr3_Integer_original_method Integer
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
60
|
+
# A monkey-patch extension of +Kernel#Integer+ with +options+
|
61
|
+
#
|
62
|
+
# === Signature
|
63
|
+
#
|
64
|
+
# * *Parameters:*
|
65
|
+
# - +arg+ The argument to be converted (to +Fixnum+ or +Bignum+)
|
66
|
+
# - +base+ A value of 0, or between 2 and 36. Defaults to 0
|
67
|
+
# - +options+ An options hash, containing any of the following options
|
68
|
+
# - +block+ An optional caller-supplied block that will be invoked with the +ArgumentError+ exception, allowing the caller to take additional action. If the block returns then its return value will be returned to the caller
|
69
|
+
#
|
70
|
+
# * *Options:*
|
71
|
+
# - +:default+ A default value to be used when +arg+ is +nil+ or cannot be converted by (the original) +Kernel#Integer+
|
72
|
+
# - +:nil+ Returns +nil+ if +arg+ is +nil+ or cannot be converted by (the original) +Kernel#Integer+. Ignored if +:default+ is specified
|
73
|
+
def Integer(arg, base = 0, **options, &block)
|
73
74
|
|
74
|
-
|
75
|
-
|
75
|
+
::Xqsr3::Conversion::IntegerParser.to_integer arg, base = 0, **options, &block
|
76
|
+
end
|
76
77
|
|
77
|
-
|
78
|
+
private :xqsr3_Integer_original_method
|
78
79
|
end # module Kernel
|
79
80
|
|
80
81
|
# ############################## end of file ############################# #
|
81
82
|
|
82
|
-
|
@@ -1,17 +1,18 @@
|
|
1
1
|
|
2
2
|
# ######################################################################## #
|
3
|
-
# File:
|
3
|
+
# File: lib/xqsr3/extensions/kernel/raise_with_options.rb
|
4
4
|
#
|
5
|
-
# Purpose:
|
5
|
+
# Purpose: Adds a raise_with_options() method to the Kernel module
|
6
6
|
#
|
7
|
-
# Created:
|
8
|
-
# Updated:
|
7
|
+
# Created: 12th February 2015
|
8
|
+
# Updated: 29th March 2024
|
9
9
|
#
|
10
|
-
# Home:
|
10
|
+
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
12
|
-
# Author:
|
12
|
+
# Author: Matthew Wilson
|
13
13
|
#
|
14
|
-
# Copyright (c)
|
14
|
+
# Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
|
15
|
+
# Copyright (c) 2015-2019, Matthew Wilson and Synesis Software
|
15
16
|
# All rights reserved.
|
16
17
|
#
|
17
18
|
# Redistribution and use in source and binary forms, with or without
|
@@ -25,7 +26,7 @@
|
|
25
26
|
# notice, this list of conditions and the following disclaimer in the
|
26
27
|
# documentation and/or other materials provided with the distribution.
|
27
28
|
#
|
28
|
-
# * Neither the names of the copyright
|
29
|
+
# * Neither the names of the copyright holders nor the names of its
|
29
30
|
# contributors may be used to endorse or promote products derived from
|
30
31
|
# this software without specific prior written permission.
|
31
32
|
#
|
@@ -54,14 +55,14 @@ require 'xqsr3/diagnostics/exception_utilities'
|
|
54
55
|
|
55
56
|
module Kernel
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
# Extends +Kernel+ module with the ::Xqsr3::Diagnostics::ExceptionUtilities::raise_with_options
|
59
|
+
# method
|
60
|
+
def raise_with_options *args, **options
|
60
61
|
|
61
|
-
|
62
|
+
options ||= {}
|
62
63
|
|
63
|
-
|
64
|
-
|
64
|
+
::Xqsr3::Diagnostics::ExceptionUtilities.raise_with_options(*args, **(options.merge({ :called_indirectly_06d353cb_5a6c_47ca_8dbe_ff76359c7e96 => 1})))
|
65
|
+
end
|
65
66
|
end # module Kernel
|
66
67
|
|
67
68
|
# ############################## end of file ############################# #
|
@@ -3,15 +3,14 @@ require 'xqsr3/command_line_utilities/map_option_string'
|
|
3
3
|
|
4
4
|
class String
|
5
5
|
|
6
|
-
|
6
|
+
include ::Xqsr3::CommandLineUtilities::MapOptionString
|
7
7
|
end # class String
|
8
8
|
|
9
9
|
class NilClass
|
10
10
|
|
11
|
-
|
11
|
+
def map_option_string *args
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
nil
|
14
|
+
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
@@ -3,14 +3,13 @@ require 'xqsr3/conversion/bool_parser'
|
|
3
3
|
|
4
4
|
class String
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
# Attempts to convert instance to a Boolean value, based on the given
|
7
|
+
# +options+
|
8
|
+
#
|
9
|
+
# See Xqsr3::Conversion::BoolParser
|
10
|
+
def to_bool **options
|
11
|
+
|
12
|
+
return ::Xqsr3::Conversion::BoolParser.to_bool self, **options
|
13
|
+
end
|
14
14
|
end # class String
|
15
15
|
|
16
|
-
|
@@ -4,17 +4,17 @@ module Unit
|
|
4
4
|
|
5
5
|
module Assertions
|
6
6
|
|
7
|
-
|
7
|
+
unless respond_to? :assert_eql
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
# Assert that +expected+ and +actual+ have the same hash key, as
|
10
|
+
# evaluated by the instance method +eq?+
|
11
|
+
def assert_eql(expected, actual, failure_message = '')
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
assert expected.eql?(actual), failure_message
|
14
|
+
end
|
15
|
+
end
|
15
16
|
|
16
17
|
end # class Assertions
|
17
18
|
end # module Unit
|
18
19
|
end # module Test
|
19
20
|
|
20
|
-
|
@@ -4,17 +4,16 @@ module Unit
|
|
4
4
|
|
5
5
|
module Assertions
|
6
6
|
|
7
|
-
|
7
|
+
unless respond_to? :assert_false
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
# Assert that +expression+ is +false+ (and not merely _falsey_)
|
10
|
+
def assert_false(expression, failure_message = '')
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
assert ::FalseClass === (expression), failure_message
|
13
|
+
end
|
14
|
+
end
|
15
15
|
|
16
16
|
end # class Assertions
|
17
17
|
end # module Unit
|
18
18
|
end # module Test
|
19
19
|
|
20
|
-
|
@@ -4,17 +4,16 @@ module Unit
|
|
4
4
|
|
5
5
|
module Assertions
|
6
6
|
|
7
|
-
|
7
|
+
unless respond_to? :assert_not
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
# Assert that +expression+ is _falsey_
|
10
|
+
def assert_not(expression, failure_message = '')
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
assert !(expression), failure_message
|
13
|
+
end
|
14
|
+
end
|
15
15
|
|
16
16
|
end # class Assertions
|
17
17
|
end # module Unit
|
18
18
|
end # module Test
|
19
19
|
|
20
|
-
|
@@ -4,17 +4,17 @@ module Unit
|
|
4
4
|
|
5
5
|
module Assertions
|
6
6
|
|
7
|
-
|
7
|
+
unless respond_to? :assert_not_eql
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
# Assert that +expected+ and +actual+ have different hash keys, as
|
10
|
+
# evaluated by the instance method +eq?+
|
11
|
+
def assert_not_eql(expected, actual, failure_message = '')
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
assert !(expected.eql?(actual)), failure_message
|
14
|
+
end
|
15
|
+
end
|
15
16
|
|
16
17
|
end # class Assertions
|
17
18
|
end # module Unit
|
18
19
|
end # module Test
|
19
20
|
|
20
|
-
|
@@ -9,13 +9,13 @@ module Internal_ # :nodoc: all
|
|
9
9
|
# @!visibility private
|
10
10
|
module X_assert_raise_with_message_ # :nodoc: all
|
11
11
|
|
12
|
-
|
12
|
+
if TestUnitVersion_.is_at_least? [ 3, 0, 8 ]
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
AssertionFailedError_ = Test::Unit::AssertionFailedError # :nodoc:
|
15
|
+
else
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
class AssertionFailedError_ < ArgumentError; end # :nodoc:
|
18
|
+
end
|
19
19
|
|
20
20
|
end # module X_assert_raise_with_message_
|
21
21
|
end # module Internal_
|
@@ -28,91 +28,90 @@ module Unit
|
|
28
28
|
|
29
29
|
module Assertions
|
30
30
|
|
31
|
-
|
31
|
+
undef :assert_raise_with_message if respond_to? :assert_raise_with_message
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
33
|
+
# Asserts that the attached block raises an exception of one of the
|
34
|
+
# exceptions defined by +type_spec+ and/or has a message matching
|
35
|
+
# +message_spec+
|
36
|
+
#
|
37
|
+
# === Signature
|
38
|
+
#
|
39
|
+
# * *Parameters:*
|
40
|
+
# - +type_spec+ (String, Regexp, [String], [Regexp], nil) Specification of type expectation(s)
|
41
|
+
# - +message_spec+ (String, Regexp, [String], [Regexp], nil) Specification of message expectation(s)
|
42
|
+
# - +failure_message+ (String, nil) Optional message to be used if the matching fails
|
43
|
+
#
|
44
|
+
# * *Block*
|
45
|
+
# A required block containing code that is expected to raise an exception
|
46
|
+
def assert_raise_with_message(type_spec, message_spec, failure_message = nil, &block)
|
47
47
|
|
48
|
-
|
48
|
+
unless block_given?
|
49
49
|
|
50
|
-
|
50
|
+
msg = "WARNING: no block_given to assert_raise_with_message() called from: #{caller[0]}"
|
51
51
|
|
52
|
-
|
52
|
+
warn "\n#{msg}"
|
53
53
|
|
54
|
-
|
55
|
-
|
54
|
+
assert false, msg
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
|
57
|
+
case type_spec
|
58
|
+
when ::Array, nil
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
;
|
61
|
+
else
|
62
62
|
|
63
|
-
|
64
|
-
|
63
|
+
type_spec = [ type_spec ]
|
64
|
+
end
|
65
65
|
|
66
|
-
|
67
|
-
|
66
|
+
case message_spec
|
67
|
+
when ::Array, nil
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
;
|
70
|
+
else
|
71
71
|
|
72
|
-
|
73
|
-
|
72
|
+
message_spec = [ message_spec ]
|
73
|
+
end
|
74
74
|
|
75
75
|
|
76
|
-
|
76
|
+
begin
|
77
77
|
|
78
|
-
|
78
|
+
yield
|
79
79
|
|
80
|
-
|
81
|
-
|
80
|
+
assert false, 'the block did not throw an exception as was expected'
|
81
|
+
rescue ::Xqsr3::Internal_::X_assert_raise_with_message_::AssertionFailedError_
|
82
82
|
|
83
|
-
|
84
|
-
|
83
|
+
raise
|
84
|
+
rescue Exception => x
|
85
85
|
|
86
|
-
|
86
|
+
if type_spec
|
87
87
|
|
88
|
-
|
89
|
-
|
88
|
+
assert false, "exception (#{x.class}) - message: '#{x.message}' - not of any of required types (#{type_spec.join(', ')}); #{x.class} given" unless type_spec.any? { |c| x.is_a? c}
|
89
|
+
end
|
90
90
|
|
91
|
-
|
91
|
+
if message_spec
|
92
92
|
|
93
|
-
|
93
|
+
assert false, "exception message not of any of required messages; '#{x.message}' given" unless message_spec.any? do |m|
|
94
94
|
|
95
|
-
|
96
|
-
|
95
|
+
case m
|
96
|
+
when ::Regexp
|
97
97
|
|
98
|
-
|
99
|
-
|
98
|
+
x.message =~ m
|
99
|
+
when ::String
|
100
100
|
|
101
|
-
|
102
|
-
|
101
|
+
x.message == m
|
102
|
+
else
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
warn "\nunsupported message_spec entry '#{m}' (#{m.class})"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
109
|
+
assert true
|
110
|
+
end
|
111
|
+
end
|
112
112
|
end # class Assertions
|
113
113
|
end # module Unit
|
114
114
|
end # module Test
|
115
115
|
|
116
116
|
# ############################## end of file ############################# #
|
117
117
|
|
118
|
-
|
@@ -4,19 +4,18 @@ module Unit
|
|
4
4
|
|
5
5
|
module Assertions
|
6
6
|
|
7
|
-
|
7
|
+
unless respond_to? :assert_subclass_of
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
# Assert that +tested_class+ is a sub-class of +parent_class+
|
10
|
+
def assert_subclass_of(parent_class, tested_class, failure_message = nil)
|
11
11
|
|
12
|
-
|
12
|
+
failure_message ||= "#{tested_class} is not a subclass of #{parent_class}"
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
assert(tested_class < parent_class, failure_message)
|
15
|
+
end
|
16
|
+
end
|
17
17
|
|
18
18
|
end # class Assertions
|
19
19
|
end # module Unit
|
20
20
|
end # module Test
|
21
21
|
|
22
|
-
|
@@ -4,19 +4,18 @@ module Unit
|
|
4
4
|
|
5
5
|
module Assertions
|
6
6
|
|
7
|
-
|
7
|
+
unless respond_to? :assert_superclass_of
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
# Assert that +tested_class+ is a super-class of +child_class+
|
10
|
+
def assert_superclass_of(child_class, tested_class, failure_message = nil)
|
11
11
|
|
12
|
-
|
12
|
+
failure_message ||= "#{tested_class} is not a superclass of #{child_class}"
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
assert(child_class < tested_class, failure_message)
|
15
|
+
end
|
16
|
+
end
|
17
17
|
|
18
18
|
end # class Assertions
|
19
19
|
end # module Unit
|
20
20
|
end # module Test
|
21
21
|
|
22
|
-
|
@@ -4,17 +4,16 @@ module Unit
|
|
4
4
|
|
5
5
|
module Assertions
|
6
6
|
|
7
|
-
|
7
|
+
unless respond_to? :assert_true
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
# Assert that +expression+ is +true+ (and not merely _truey_)
|
10
|
+
def assert_true(expression, failure_message = '')
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
assert ::TrueClass === (expression), failure_message
|
13
|
+
end
|
14
|
+
end
|
15
15
|
|
16
16
|
end # class Assertions
|
17
17
|
end # module Unit
|
18
18
|
end # module Test
|
19
19
|
|
20
|
-
|