miniunit 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +6 -0
- data/README.txt +46 -0
- data/Rakefile +15 -0
- data/lib/test/unit.rb +102 -0
- data/lib/test/unit/testcase.rb +2 -0
- metadata +59 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
miniunit by Ryan Davis
|
2
|
+
http://rubyforge.org/projects/bfts
|
3
|
+
|
4
|
+
== DESCRIPTION:
|
5
|
+
|
6
|
+
miniunit is a completely minimial drop-in replacement for ruby's
|
7
|
+
test/unit. This is meant for language implementors to have a minimal
|
8
|
+
set of methods to bootstrap a working unit test suite.
|
9
|
+
|
10
|
+
== FEATURES/PROBLEMS:
|
11
|
+
|
12
|
+
* Assertions are not yet complete, but enough for what we've ported
|
13
|
+
from rubicon/rubytest.
|
14
|
+
|
15
|
+
== REQUIREMENTS:
|
16
|
+
|
17
|
+
+ Ruby 1.8, maybe even 1.6 or lower. No magic is involved.
|
18
|
+
|
19
|
+
== INSTALL:
|
20
|
+
|
21
|
+
+ sudo gem install miniunit or sudo rake install
|
22
|
+
|
23
|
+
== LICENSE:
|
24
|
+
|
25
|
+
(The MIT License)
|
26
|
+
|
27
|
+
Copyright (c) 2006 Ryan Davis, Seattle.rb
|
28
|
+
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
30
|
+
a copy of this software and associated documentation files (the
|
31
|
+
'Software'), to deal in the Software without restriction, including
|
32
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
33
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
34
|
+
permit persons to whom the Software is furnished to do so, subject to
|
35
|
+
the following conditions:
|
36
|
+
|
37
|
+
The above copyright notice and this permission notice shall be
|
38
|
+
included in all copies or substantial portions of the Software.
|
39
|
+
|
40
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
41
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
42
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
43
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
44
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
45
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
46
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/test/unit.rb'
|
6
|
+
|
7
|
+
Hoe.new('miniunit', Test::Unit::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'bfts'
|
9
|
+
p.description = p.paragraphs_of('README.txt', 2).join("\n\n")
|
10
|
+
p.summary = p.description.split(/\. /)[0] + "."
|
11
|
+
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
12
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
13
|
+
end
|
14
|
+
|
15
|
+
# vim: syntax=Ruby
|
data/lib/test/unit.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
#
|
2
|
+
# Totally minimal (hopefully) drop-in replacement for test/unit
|
3
|
+
#
|
4
|
+
|
5
|
+
# TODO: document minimal core methods needed for this to work
|
6
|
+
|
7
|
+
at_exit { Test::Unit.autotest }
|
8
|
+
|
9
|
+
module Test
|
10
|
+
class Assertion < Exception; end
|
11
|
+
|
12
|
+
class Unit
|
13
|
+
VERSION = "1.0.0"
|
14
|
+
|
15
|
+
def self.autotest
|
16
|
+
ObjectSpace.each_object(Class) do |klass|
|
17
|
+
next unless klass < Test::Unit::TestCase
|
18
|
+
inst = klass.new
|
19
|
+
klass.public_instance_methods(true).each do |meth|
|
20
|
+
next unless meth.index("test") == 0
|
21
|
+
begin
|
22
|
+
inst.setup
|
23
|
+
inst.send meth.intern
|
24
|
+
inst.teardown
|
25
|
+
rescue Exception => e
|
26
|
+
# TODO: make output compatible with unit_diff
|
27
|
+
print "\n", (Test::Assertion === e ? "Failure: " : "Error: ")
|
28
|
+
puts "#{klass}.#{meth}: #{e}"
|
29
|
+
puts e.backtrace
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class TestCase
|
36
|
+
def setup; end
|
37
|
+
def teardown; end
|
38
|
+
|
39
|
+
def assert(test, msg="failed assertion (no message given)")
|
40
|
+
raise Test::Assertion, msg unless test
|
41
|
+
end
|
42
|
+
|
43
|
+
def assert_equal(exp, act, msg=nil)
|
44
|
+
assert exp == act, msg || "Expected #{act.inspect} to be equal to #{exp.inspect}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def assert_in_delta(exp, act, delta, msg=nil)
|
48
|
+
assert((exp.to_f - act.to_f).abs <= delta.to_f, msg || "Expected #{exp} to be within #{delta} of #{act}")
|
49
|
+
end
|
50
|
+
|
51
|
+
def assert_instance_of(cls, obj, msg=nil)
|
52
|
+
assert cls === obj, msg || "Expected #{obj} to be a #{cls}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def assert_kind_of(cls, obj, msg=nil)
|
56
|
+
assert obj.kind_of?(cls), msg || "Expected #{obj.inspect} to be a kind of #{cls}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def assert_match(exp, act, msg=nil)
|
60
|
+
assert act =~ exp, msg || "Expected #{act.inspect} to match #{exp.inspect}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def assert_nil(obj, msg=nil)
|
64
|
+
assert obj.nil?, msg || "Expected #{obj.inspect} to be nil"
|
65
|
+
end
|
66
|
+
|
67
|
+
def assert_not_equal(exp, act, msg=nil)
|
68
|
+
assert exp != act, msg || "Expected #{act.inspect} to not be equal to #{exp.inspect}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def assert_not_nil(obj, msg=nil)
|
72
|
+
assert ! obj.nil?, msg || "Expected #{obj.inspect} to not be nil"
|
73
|
+
end
|
74
|
+
|
75
|
+
def assert_not_same(exp, act, msg=nil)
|
76
|
+
assert ! exp.equal?(act), msg || "Expected #{act.inspect} to not be the same as #{exp.inspect}"
|
77
|
+
end
|
78
|
+
|
79
|
+
def assert_raises(exp, msg=nil)
|
80
|
+
begin
|
81
|
+
yield
|
82
|
+
assert false, "Expected #{exp} to be raised"
|
83
|
+
rescue Exception => e
|
84
|
+
assert exp === e, msg || "Expected #{exp} to be raised, but got #{e.class}"
|
85
|
+
return e
|
86
|
+
end
|
87
|
+
end
|
88
|
+
alias :assert_raise :assert_raises
|
89
|
+
|
90
|
+
def assert_same(exp, act, msg=nil)
|
91
|
+
assert exp.equal?(act), msg || "Expected #{act.inspect} to be the same as #{exp.inspect}"
|
92
|
+
end
|
93
|
+
|
94
|
+
def assert_operator(o1, op, o2, msg="")
|
95
|
+
assert o1.__send__(op, o2), msg || "Expected #{o1}.#{op}(#{o2}) to be true"
|
96
|
+
end
|
97
|
+
|
98
|
+
def assert_nothing_raised; yield; end
|
99
|
+
|
100
|
+
end # class TestCase
|
101
|
+
end # class Unit
|
102
|
+
end # module Test
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: miniunit
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2006-10-30 00:00:00 -08:00
|
8
|
+
summary: miniunit is a completely minimial drop-in replacement for ruby's test/unit.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: ryand-ruby@zenspider.com
|
12
|
+
homepage: " http://rubyforge.org/projects/bfts"
|
13
|
+
rubyforge_project: bfts
|
14
|
+
description: miniunit is a completely minimial drop-in replacement for ruby's test/unit. This is meant for language implementors to have a minimal set of methods to bootstrap a working unit test suite.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Ryan Davis
|
31
|
+
files:
|
32
|
+
- History.txt
|
33
|
+
- Manifest.txt
|
34
|
+
- README.txt
|
35
|
+
- Rakefile
|
36
|
+
- lib/test/unit.rb
|
37
|
+
- lib/test/unit/testcase.rb
|
38
|
+
test_files: []
|
39
|
+
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
executables: []
|
45
|
+
|
46
|
+
extensions: []
|
47
|
+
|
48
|
+
requirements: []
|
49
|
+
|
50
|
+
dependencies:
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: hoe
|
53
|
+
version_requirement:
|
54
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.1.2
|
59
|
+
version:
|