xqsr3 0.19.3 → 0.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/xqsr3/extensions/test/unit.rb +1 -0
- data/lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb +78 -0
- data/lib/xqsr3/quality/parameter_checking.rb +4 -4
- data/lib/xqsr3/version.rb +3 -3
- data/test/unit/extensions/test/unit/tc_assert_raise_with_message.rb +33 -0
- data/test/unit/quality/tc_parameter_checking.rb +3 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bde7d3536cc91501c44bf9692223a3ca08635a74
|
4
|
+
data.tar.gz: 3cb71b348ae5a121dc557b2a99d23398f4066479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b8080d46eab81546cb68608e76562253a9b97c8009910cb69c2d6bdbf4ebeb9f205a745676146b69c7b6be9bae078cfeb390e5596299a452951aa42af2ee02d
|
7
|
+
data.tar.gz: 7f76211a83a76ad171756da8ede38687348d5e478f809998a3917be4c03b6c239b6f55a4e6427a95b561ef71f131faff049a599e0bb3dda6970e655fa1b1a48e
|
@@ -3,6 +3,7 @@ require 'xqsr3/extensions/test/unit/assert_eql'
|
|
3
3
|
require 'xqsr3/extensions/test/unit/assert_false'
|
4
4
|
require 'xqsr3/extensions/test/unit/assert_not'
|
5
5
|
require 'xqsr3/extensions/test/unit/assert_not_eql'
|
6
|
+
require 'xqsr3/extensions/test/unit/assert_raise_with_message'
|
6
7
|
require 'xqsr3/extensions/test/unit/assert_subclass_of'
|
7
8
|
require 'xqsr3/extensions/test/unit/assert_superclass_of'
|
8
9
|
require 'xqsr3/extensions/test/unit/assert_true'
|
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
module Test
|
3
|
+
module Unit
|
4
|
+
|
5
|
+
module Assertions
|
6
|
+
|
7
|
+
unless respond_to? :assert_raise_with_message
|
8
|
+
|
9
|
+
def assert_raise_with_message(type_spec, message_spec, failure_message = nil)
|
10
|
+
|
11
|
+
unless block_given?
|
12
|
+
|
13
|
+
msg = "WARNING: no block_given to assert_raise_with_message() called from: #{caller[0]}"
|
14
|
+
|
15
|
+
warn "\n#{msg}"
|
16
|
+
|
17
|
+
assert false, msg
|
18
|
+
end
|
19
|
+
|
20
|
+
case type_spec
|
21
|
+
when ::Array, nil
|
22
|
+
|
23
|
+
;
|
24
|
+
else
|
25
|
+
|
26
|
+
type_spec = [ type_spec ]
|
27
|
+
end
|
28
|
+
|
29
|
+
case message_spec
|
30
|
+
when ::Array, nil
|
31
|
+
|
32
|
+
;
|
33
|
+
else
|
34
|
+
|
35
|
+
message_spec = [ message_spec ]
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
begin
|
40
|
+
|
41
|
+
yield
|
42
|
+
|
43
|
+
assert false, "expected did not throw an exception"
|
44
|
+
rescue Exception => x
|
45
|
+
|
46
|
+
if type_spec
|
47
|
+
|
48
|
+
assert false, "exception not of any of required types (#{type_spec.join(', ')}); #{x.class} given" unless type_spec.any? { |c| x.is_a? c}
|
49
|
+
end
|
50
|
+
|
51
|
+
if message_spec
|
52
|
+
|
53
|
+
assert false, "exception message not of any of required messages; '#{x.message}' given" unless message_spec.any? do |m|
|
54
|
+
|
55
|
+
case m
|
56
|
+
when ::Regexp
|
57
|
+
|
58
|
+
x.message =~ m
|
59
|
+
when ::String
|
60
|
+
|
61
|
+
x.message == m
|
62
|
+
else
|
63
|
+
|
64
|
+
warn "\nunsupported message_spec entry '#{m}' (#{m.class})"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
assert true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end # class Assertions
|
75
|
+
end # module Unit
|
76
|
+
end # module Test
|
77
|
+
|
78
|
+
|
@@ -5,13 +5,13 @@
|
|
5
5
|
# Purpose: Definition of the ParameterChecking module
|
6
6
|
#
|
7
7
|
# Created: 12th February 2015
|
8
|
-
# Updated:
|
8
|
+
# Updated: 2nd January 2018
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
12
12
|
# Author: Matthew Wilson
|
13
13
|
#
|
14
|
-
# Copyright (c) 2015-
|
14
|
+
# Copyright (c) 2015-2018, Matthew Wilson and Synesis Software
|
15
15
|
# All rights reserved.
|
16
16
|
#
|
17
17
|
# Redistribution and use in source and binary forms, with or without
|
@@ -256,7 +256,7 @@ module ParameterChecking
|
|
256
256
|
types = [value.class] if types.empty?
|
257
257
|
|
258
258
|
warn "#{self}::check_parameter: options[:types] of type #{types.class} - should be #{::Array}" unless types.is_a?(Array)
|
259
|
-
warn "#{self}::check_parameter: options[:types] should contain only classes or arrays of classes" if types.is_a?(::Array) && !types.all? { |c| ::Class === c || (::Array === c
|
259
|
+
warn "#{self}::check_parameter: options[:types] - '#{options[:types]}' - should contain only classes or arrays of classes" if types.is_a?(::Array) && !types.all? { |c| ::Class === c || (::Array === c && c.all? { |c2| ::Class === c2 }) }
|
260
260
|
|
261
261
|
unless types.any? do |t|
|
262
262
|
|
@@ -269,7 +269,7 @@ module ParameterChecking
|
|
269
269
|
|
270
270
|
# the (presumed) vector argument's elements are the
|
271
271
|
# possible types
|
272
|
-
value.all? { |v| t.any? { |t2| v.is_a?(t2) }}
|
272
|
+
value.all? { |v| t.any? { |t2| v.is_a?(t2) }} if ::Array === value
|
273
273
|
end
|
274
274
|
end
|
275
275
|
|
data/lib/xqsr3/version.rb
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
# Purpose: Version for Xqsr3 library
|
6
6
|
#
|
7
7
|
# Created: 3rd April 2016
|
8
|
-
# Updated:
|
8
|
+
# Updated: 8th January 2018
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/xqsr3
|
11
11
|
#
|
12
12
|
# Author: Matthew Wilson
|
13
13
|
#
|
14
|
-
# Copyright (c) 2016-
|
14
|
+
# Copyright (c) 2016-2018, Matthew Wilson and Synesis Software
|
15
15
|
# All rights reserved.
|
16
16
|
#
|
17
17
|
# Redistribution and use in source and binary forms, with or without
|
@@ -50,7 +50,7 @@
|
|
50
50
|
module Xqsr3
|
51
51
|
|
52
52
|
# Current version of the Xqsr3 library
|
53
|
-
VERSION = '0.
|
53
|
+
VERSION = '0.20.3'
|
54
54
|
|
55
55
|
private
|
56
56
|
VERSION_PARTS_ = VERSION.split(/[.]/).collect { |n| n.to_i } # :nodoc:
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), *(['..']*5), 'lib')
|
4
|
+
|
5
|
+
require 'xqsr3/extensions/test/unit/assert_raise_with_message'
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
class Test_assert_raise_with_message < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def test_no_class_and_specific_message
|
12
|
+
|
13
|
+
assert_raise_with_message(nil, 'the-message') { raise ArgumentError, 'the-message' }
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_no_class_and_message_list
|
17
|
+
|
18
|
+
assert_raise_with_message(nil, [ 'first-message', 'a-message', 'the-message', 'last-message' ]) { raise ArgumentError, 'the-message' }
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_specific_class_and_no_message
|
22
|
+
|
23
|
+
assert_raise_with_message(::ArgumentError, nil) { raise ::ArgumentError, 'the-message' }
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_class_list_and_no_message
|
27
|
+
|
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
|
+
end
|
32
|
+
|
33
|
+
|
@@ -108,6 +108,9 @@ class Test_parameter_checks_as_included_module < Test::Unit::TestCase
|
|
108
108
|
end
|
109
109
|
assert_equal true, check_method_2(true, [ ::TrueClass ], nothrow: true)
|
110
110
|
assert_nil check_method_2(true, [ ::FalseClass ], nothrow: true)
|
111
|
+
assert_nil check_method_2('abc', [ ::Symbol, ::Regexp ], nothrow: true)
|
112
|
+
assert_nil check_method_2([ 'abc' ], [ [ ::Symbol ], ::Regexp ], nothrow: true)
|
113
|
+
assert_not_nil check_method_2([ 'abc' ], [ [ ::String ], ::Regexp ], nothrow: true)
|
111
114
|
end
|
112
115
|
|
113
116
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xqsr3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
eXtensions by fine Quantum for Standard Ruby and 3rd-party libraries is a
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/xqsr3/extensions/test/unit/assert_false.rb
|
53
53
|
- lib/xqsr3/extensions/test/unit/assert_not.rb
|
54
54
|
- lib/xqsr3/extensions/test/unit/assert_not_eql.rb
|
55
|
+
- lib/xqsr3/extensions/test/unit/assert_raise_with_message.rb
|
55
56
|
- lib/xqsr3/extensions/test/unit/assert_subclass_of.rb
|
56
57
|
- lib/xqsr3/extensions/test/unit/assert_superclass_of.rb
|
57
58
|
- lib/xqsr3/extensions/test/unit/assert_true.rb
|
@@ -99,6 +100,7 @@ files:
|
|
99
100
|
- test/unit/extensions/string/tc_to_symbol.rb
|
100
101
|
- test/unit/extensions/string/ts_all.rb
|
101
102
|
- test/unit/extensions/test/ts_all.rb
|
103
|
+
- test/unit/extensions/test/unit/tc_assert_raise_with_message.rb
|
102
104
|
- test/unit/extensions/test/unit/tc_assert_subclass_of.rb
|
103
105
|
- test/unit/extensions/test/unit/tc_assert_superclass_of.rb
|
104
106
|
- test/unit/extensions/test/unit/ts_all.rb
|