rubyunit 0.0.4 → 0.0.5
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/README.md +4 -3
- data/example/RealNumberData.rb +48 -0
- data/example/RealNumberTest.rb +3 -49
- data/example/{test.rb → TestSet.rb} +3 -1
- data/lib/RubyUnit/Runner.rb +22 -13
- data/lib/RubyUnit/TestCase.rb +1 -1
- data/lib/RubyUnit.rb +33 -4
- metadata +3 -3
- data/lib/RubyUnit/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28a9809b472a236515ef571df2e8547159e86069
|
4
|
+
data.tar.gz: 0ea9d91b0c0ca5cc31d1a499d55ac511780117ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9ade60f35da0753441b01ac931cda5bf8d224815b7dc2465f00322e7eb8d4ca28b4528b47c481d80efb421cb57874010c3954caa307a742722629a45000d06d
|
7
|
+
data.tar.gz: 75897620958a179618807275c86c57e2813eecc712196b407ae125cc7cb37fee90d504f05c7e3c1ba1be93900696a8cdde204a8c41876e0b54a4d38821500b42
|
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
RubyUnit
|
2
2
|
========
|
3
3
|
|
4
|
-
[](http://badge.fury.io/rb/rubyunit)
|
5
|
+
[](https://codeclimate.com/github/RubyUnit/RubyUnit)
|
6
|
+
[](https://codeclimate.com/github/RubyUnit/RubyUnit)
|
5
7
|
|
6
|
-
<!-- This isn't up yet...
|
7
|
-
* http://rubyunit.github.io/ -->
|
8
8
|
|
9
|
+
* http://rubyunit.github.io/
|
9
10
|
* https://github.com/RubyUnit/RubyUnit
|
10
11
|
|
11
12
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Extend the class to add data providing functions
|
2
|
+
module RealNumberData
|
3
|
+
def positiveData
|
4
|
+
[
|
5
|
+
[ Integer(1),],
|
6
|
+
[ Integer(4242),],
|
7
|
+
[Integer(100000000000),],
|
8
|
+
[Integer(424200000000),],
|
9
|
+
[ Float(0.1),],
|
10
|
+
[ Float(1.0),],
|
11
|
+
[ Float(42.42),],
|
12
|
+
[ Rational(1,42),],
|
13
|
+
[ Rational(1,1),],
|
14
|
+
[ Rational(4242,42),],
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
def zeroData
|
19
|
+
[
|
20
|
+
[ Integer(0)],
|
21
|
+
[ Float(0.0)],
|
22
|
+
[Rational(0,1)],
|
23
|
+
]
|
24
|
+
end
|
25
|
+
|
26
|
+
def negativeData
|
27
|
+
[
|
28
|
+
[ Integer(-1),],
|
29
|
+
[ Integer(-4242),],
|
30
|
+
[Integer(-100000000000),],
|
31
|
+
[Integer(-424200000000),],
|
32
|
+
[ Float(-0.1),],
|
33
|
+
[ Float(-1.0),],
|
34
|
+
[ Float(-42.42),],
|
35
|
+
[ Rational(-1,42),],
|
36
|
+
[ Rational(-1,1),],
|
37
|
+
[ Rational(-4242,42),],
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
def notPositiveData
|
42
|
+
zeroData + negativeData
|
43
|
+
end
|
44
|
+
|
45
|
+
def notNegativeData
|
46
|
+
zeroData + positiveData
|
47
|
+
end
|
48
|
+
end
|
data/example/RealNumberTest.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require_relative 'RealNumber'
|
2
|
+
require_relative 'RealNumberData'
|
2
3
|
|
3
4
|
# Test for RealNumber mixin
|
4
5
|
class RealNumberTest < RubyUnit::TestCase
|
6
|
+
include RealNumberData
|
7
|
+
|
5
8
|
def positiveTest value
|
6
9
|
assert value.positive?, "#{value.class}:(#{value}) should be positive!"
|
7
10
|
end
|
@@ -18,52 +21,3 @@ class RealNumberTest < RubyUnit::TestCase
|
|
18
21
|
assertNot value.negative?, "#{value.class}:(#{value}) should not be negative!"
|
19
22
|
end
|
20
23
|
end
|
21
|
-
|
22
|
-
# Extend the class to add data providing functions
|
23
|
-
class RealNumberTest
|
24
|
-
def positiveData
|
25
|
-
[
|
26
|
-
[ Integer(1),],
|
27
|
-
[ Integer(4242),],
|
28
|
-
[Integer(100000000000),],
|
29
|
-
[Integer(424200000000),],
|
30
|
-
[ Float(0.1),],
|
31
|
-
[ Float(1.0),],
|
32
|
-
[ Float(42.42),],
|
33
|
-
[ Rational(1,42),],
|
34
|
-
[ Rational(1,1),],
|
35
|
-
[ Rational(4242,42),],
|
36
|
-
]
|
37
|
-
end
|
38
|
-
|
39
|
-
def zeroData
|
40
|
-
[
|
41
|
-
[ Integer(0)],
|
42
|
-
[ Float(0.0)],
|
43
|
-
[Rational(0,1)],
|
44
|
-
]
|
45
|
-
end
|
46
|
-
|
47
|
-
def negativeData
|
48
|
-
[
|
49
|
-
[ Integer(-1),],
|
50
|
-
[ Integer(-4242),],
|
51
|
-
[Integer(-100000000000),],
|
52
|
-
[Integer(-424200000000),],
|
53
|
-
[ Float(-0.1),],
|
54
|
-
[ Float(-1.0),],
|
55
|
-
[ Float(-42.42),],
|
56
|
-
[ Rational(-1,42),],
|
57
|
-
[ Rational(-1,1),],
|
58
|
-
[ Rational(-4242,42),],
|
59
|
-
]
|
60
|
-
end
|
61
|
-
|
62
|
-
def notPositiveData
|
63
|
-
zeroData + negativeData
|
64
|
-
end
|
65
|
-
|
66
|
-
def notNegativeData
|
67
|
-
zeroData + positiveData
|
68
|
-
end
|
69
|
-
end
|
data/lib/RubyUnit/Runner.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative 'TestCase'
|
2
|
+
require_relative 'AssertionFailure'
|
3
3
|
|
4
4
|
module RubyUnit
|
5
5
|
class Runner
|
6
|
-
protected
|
7
|
-
@@test_cases = []
|
8
|
-
@@failures = []
|
9
|
-
@@errors = []
|
10
|
-
@@tests = 0
|
11
|
-
@@start = nil
|
12
|
-
@@finish = nil
|
13
|
-
|
14
6
|
class << self
|
7
|
+
protected
|
8
|
+
@@test_cases = []
|
9
|
+
@@failures = []
|
10
|
+
@@errors = []
|
11
|
+
@@tests = 0
|
12
|
+
@@start = nil
|
13
|
+
@@finish = nil
|
14
|
+
@@autorun = true
|
15
|
+
|
15
16
|
public
|
16
17
|
def run
|
17
|
-
@@
|
18
|
-
|
18
|
+
@@autorun = false
|
19
|
+
@@start = Time.new
|
20
|
+
runner = new
|
19
21
|
TestCase.descendents.each do |object|
|
20
22
|
@@test_cases << object
|
21
23
|
|
@@ -39,12 +41,18 @@ module RubyUnit
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
@@finish = Time.new
|
42
|
-
report
|
44
|
+
report unless @@tests.zero?
|
45
|
+
@@failures.count + @@errors.count
|
46
|
+
end
|
47
|
+
|
48
|
+
def autorun?
|
49
|
+
@@autorun
|
43
50
|
end
|
44
51
|
|
45
52
|
protected
|
46
53
|
def report
|
47
54
|
# haven't figured out what I want to do for reporting yet but I need some results
|
55
|
+
puts "RubyUnit #{RubyUnit::version}"
|
48
56
|
puts "Started Tests #{@@start.strftime("%Y-%m-%d %H:%M:%S")}"
|
49
57
|
|
50
58
|
puts "#{@@errors.count} Errors:\n" if @@errors.count > 0
|
@@ -68,6 +76,7 @@ module RubyUnit
|
|
68
76
|
puts "%.3f tests/s, %.3f assertions/s" % [(@@tests * inverse).to_f, (TestCase.assertions * inverse).to_f]
|
69
77
|
puts "%d Tests, %d Assertions, %d Errors, %d Failures" % [@@tests, TestCase.assertions, @@errors.count, @@failures.count]
|
70
78
|
puts
|
79
|
+
|
71
80
|
end
|
72
81
|
end
|
73
82
|
|
data/lib/RubyUnit/TestCase.rb
CHANGED
data/lib/RubyUnit.rb
CHANGED
@@ -1,12 +1,41 @@
|
|
1
1
|
module RubyUnit
|
2
|
+
@@build = 5
|
3
|
+
VERSION = '0.0'
|
4
|
+
|
5
|
+
protected
|
6
|
+
public
|
7
|
+
def self.debug?
|
8
|
+
@@debug
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.build
|
12
|
+
@@build
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.version
|
16
|
+
"#{VERSION}.#{build}"
|
17
|
+
end
|
18
|
+
|
19
|
+
class GemInfo
|
20
|
+
class << self
|
21
|
+
def files
|
22
|
+
static = ['README.md', 'LICENSE']
|
23
|
+
libs = Dir['lib/**/*.rb']
|
24
|
+
examples = Dir['example/*.rb']
|
25
|
+
|
26
|
+
static + libs + examples
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
2
30
|
end
|
3
31
|
|
4
|
-
|
5
|
-
|
32
|
+
require_relative 'RubyUnit/TestCase'
|
33
|
+
require_relative 'RubyUnit/Runner'
|
34
|
+
|
6
35
|
# Automatically run test cases
|
7
36
|
Module.new do
|
8
|
-
|
9
|
-
|
37
|
+
at_exit do
|
38
|
+
if $ERROR_INFO.nil? and RubyUnit::Runner.autorun?
|
10
39
|
RubyUnit::Runner.run
|
11
40
|
end
|
12
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyunit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Clower
|
@@ -21,13 +21,13 @@ files:
|
|
21
21
|
- LICENSE
|
22
22
|
- README.md
|
23
23
|
- example/RealNumber.rb
|
24
|
+
- example/RealNumberData.rb
|
24
25
|
- example/RealNumberTest.rb
|
25
|
-
- example/
|
26
|
+
- example/TestSet.rb
|
26
27
|
- lib/RubyUnit.rb
|
27
28
|
- lib/RubyUnit/AssertionFailure.rb
|
28
29
|
- lib/RubyUnit/Runner.rb
|
29
30
|
- lib/RubyUnit/TestCase.rb
|
30
|
-
- lib/RubyUnit/version.rb
|
31
31
|
homepage: http://github.com/RubyUnit/RubyUnit
|
32
32
|
licenses:
|
33
33
|
- LGPL
|
data/lib/RubyUnit/version.rb
DELETED