test-unit 1.2.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.
Files changed (49) hide show
  1. data/History.txt +5 -0
  2. data/Manifest.txt +48 -0
  3. data/README.txt +27 -0
  4. data/Rakefile +15 -0
  5. data/bin/testrb +5 -0
  6. data/lib/test/unit.rb +280 -0
  7. data/lib/test/unit/assertionfailederror.rb +14 -0
  8. data/lib/test/unit/assertions.rb +622 -0
  9. data/lib/test/unit/autorunner.rb +220 -0
  10. data/lib/test/unit/collector.rb +43 -0
  11. data/lib/test/unit/collector/dir.rb +108 -0
  12. data/lib/test/unit/collector/objectspace.rb +34 -0
  13. data/lib/test/unit/error.rb +56 -0
  14. data/lib/test/unit/failure.rb +51 -0
  15. data/lib/test/unit/testcase.rb +160 -0
  16. data/lib/test/unit/testresult.rb +80 -0
  17. data/lib/test/unit/testsuite.rb +76 -0
  18. data/lib/test/unit/ui/console/testrunner.rb +127 -0
  19. data/lib/test/unit/ui/fox/testrunner.rb +268 -0
  20. data/lib/test/unit/ui/gtk/testrunner.rb +416 -0
  21. data/lib/test/unit/ui/gtk2/testrunner.rb +465 -0
  22. data/lib/test/unit/ui/testrunnermediator.rb +68 -0
  23. data/lib/test/unit/ui/testrunnerutilities.rb +46 -0
  24. data/lib/test/unit/ui/tk/testrunner.rb +260 -0
  25. data/lib/test/unit/util/backtracefilter.rb +40 -0
  26. data/lib/test/unit/util/observable.rb +90 -0
  27. data/lib/test/unit/util/procwrapper.rb +48 -0
  28. data/lib/test/unit/version.rb +7 -0
  29. data/sample/adder.rb +13 -0
  30. data/sample/subtracter.rb +12 -0
  31. data/sample/tc_adder.rb +18 -0
  32. data/sample/tc_subtracter.rb +18 -0
  33. data/sample/ts_examples.rb +7 -0
  34. data/test/collector/test_dir.rb +406 -0
  35. data/test/collector/test_objectspace.rb +98 -0
  36. data/test/runit/test_assert.rb +402 -0
  37. data/test/runit/test_testcase.rb +91 -0
  38. data/test/runit/test_testresult.rb +144 -0
  39. data/test/runit/test_testsuite.rb +49 -0
  40. data/test/test_assertions.rb +528 -0
  41. data/test/test_error.rb +26 -0
  42. data/test/test_failure.rb +33 -0
  43. data/test/test_testcase.rb +275 -0
  44. data/test/test_testresult.rb +104 -0
  45. data/test/test_testsuite.rb +129 -0
  46. data/test/util/test_backtracefilter.rb +41 -0
  47. data/test/util/test_observable.rb +102 -0
  48. data/test/util/test_procwrapper.rb +36 -0
  49. metadata +128 -0
@@ -0,0 +1,41 @@
1
+ require 'test/unit'
2
+
3
+ require 'test/unit/util/backtracefilter'
4
+
5
+ module Test::Unit::Util
6
+ class TestBacktraceFilter < Test::Unit::TestCase
7
+ include BacktraceFilter
8
+
9
+ def test_filter_backtrace
10
+ backtrace = [%q{C:\some\old\path/test/unit/assertions.rb:44:in 'assert'},
11
+ %q{tc_thing.rb:4:in 'a'},
12
+ %q{tc_thing.rb:4:in 'test_stuff'},
13
+ %q{C:\some\old\path/test/unit/testcase.rb:44:in 'send'},
14
+ %q{C:\some\old\path\test\unit\testcase.rb:44:in 'run'},
15
+ %q{C:\some\old\path\test\unit.rb:44:in 'run'},
16
+ %q{tc_thing.rb:3}]
17
+ assert_equal(backtrace[1..2], filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Should filter out all TestUnit-specific lines")
18
+
19
+ backtrace = [%q{tc_thing.rb:4:in 'a'},
20
+ %q{tc_thing.rb:4:in 'test_stuff'},
21
+ %q{tc_thing.rb:3}]
22
+ assert_equal(backtrace, filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Shouldn't filter too much")
23
+
24
+ backtrace = [%q{C:\some\old\path/test/unit/assertions.rb:44:in 'assert'},
25
+ %q{tc_thing.rb:4:in 'a'},
26
+ %q{tc_thing.rb:4:in 'test_stuff'},
27
+ %q{tc_thing.rb:3}]
28
+ assert_equal(backtrace[1..3], filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Should filter out all TestUnit-specific lines")
29
+
30
+ backtrace = [%q{C:\some\old\path/test/unit/assertions.rb:44:in 'assert'},
31
+ %q{C:\some\old\path/test/unit/testcase.rb:44:in 'send'},
32
+ %q{C:\some\old\path\test\unit\testcase.rb:44:in 'run'},
33
+ %q{C:\some\old\path\test\unit.rb:44:in 'run'}]
34
+ assert_equal(backtrace, filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Should filter out all TestUnit-specific lines")
35
+ end
36
+
37
+ def test_nil_backtrace
38
+ assert_equal(["No backtrace"], filter_backtrace(nil))
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,102 @@
1
+ # Author:: Nathaniel Talbott.
2
+ # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
3
+ # License:: Ruby license.
4
+
5
+ require 'test/unit/util/observable'
6
+
7
+ module Test
8
+ module Unit
9
+ module Util
10
+ class TC_Observable < TestCase
11
+
12
+ class TF_Observable
13
+ include Observable
14
+ end
15
+
16
+ def setup
17
+ @observable = TF_Observable.new
18
+ end
19
+
20
+ def test_simple_observation
21
+ assert_raises(ArgumentError, "add_listener should throw an exception if no callback is supplied") do
22
+ @observable.add_listener(:property, "a")
23
+ end
24
+
25
+ heard = false
26
+ callback = proc { heard = true }
27
+ assert_equal("a", @observable.add_listener(:property, "a", &callback), "add_listener should return the listener that was added")
28
+
29
+ count = 0
30
+ @observable.instance_eval do
31
+ count = notify_listeners(:property)
32
+ end
33
+ assert_equal(1, count, "notify_listeners should have returned the number of listeners that were notified")
34
+ assert(heard, "Should have heard the property changed")
35
+
36
+ heard = false
37
+ assert_equal(callback, @observable.remove_listener(:property, "a"), "remove_listener should return the callback")
38
+
39
+ count = 1
40
+ @observable.instance_eval do
41
+ count = notify_listeners(:property)
42
+ end
43
+ assert_equal(0, count, "notify_listeners should have returned the number of listeners that were notified")
44
+ assert(!heard, "Should not have heard the property change")
45
+ end
46
+
47
+ def test_value_observation
48
+ value = nil
49
+ @observable.add_listener(:property, "a") do |passed_value|
50
+ value = passed_value
51
+ end
52
+ count = 0
53
+ @observable.instance_eval do
54
+ count = notify_listeners(:property, "stuff")
55
+ end
56
+ assert_equal(1, count, "Should have update the correct number of listeners")
57
+ assert_equal("stuff", value, "Should have received the value as an argument to the listener")
58
+ end
59
+
60
+ def test_multiple_value_observation
61
+ values = []
62
+ @observable.add_listener(:property, "a") do |first_value, second_value|
63
+ values = [first_value, second_value]
64
+ end
65
+ count = 0
66
+ @observable.instance_eval do
67
+ count = notify_listeners(:property, "stuff", "more stuff")
68
+ end
69
+ assert_equal(1, count, "Should have update the correct number of listeners")
70
+ assert_equal(["stuff", "more stuff"], values, "Should have received the value as an argument to the listener")
71
+ end
72
+
73
+ def test_add_remove_with_default_listener
74
+ assert_raises(ArgumentError, "add_listener should throw an exception if no callback is supplied") do
75
+ @observable.add_listener(:property)
76
+ end
77
+
78
+ heard = false
79
+ callback = proc { heard = true }
80
+ assert_equal(callback, @observable.add_listener(:property, &callback), "add_listener should return the listener that was added")
81
+
82
+ count = 0
83
+ @observable.instance_eval do
84
+ count = notify_listeners(:property)
85
+ end
86
+ assert_equal(1, count, "notify_listeners should have returned the number of listeners that were notified")
87
+ assert(heard, "Should have heard the property changed")
88
+
89
+ heard = false
90
+ assert_equal(callback, @observable.remove_listener(:property, callback), "remove_listener should return the callback")
91
+
92
+ count = 1
93
+ @observable.instance_eval do
94
+ count = notify_listeners(:property)
95
+ end
96
+ assert_equal(0, count, "notify_listeners should have returned the number of listeners that were notified")
97
+ assert(!heard, "Should not have heard the property change")
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,36 @@
1
+ # Author:: Nathaniel Talbott.
2
+ # Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
3
+ # License:: Ruby license.
4
+
5
+ require 'test/unit'
6
+ require 'test/unit/util/procwrapper'
7
+
8
+ module Test
9
+ module Unit
10
+ module Util
11
+ class TC_ProcWrapper < TestCase
12
+ def munge_proc(&a_proc)
13
+ return a_proc
14
+ end
15
+ def setup
16
+ @original = proc {}
17
+ @munged = munge_proc(&@original)
18
+ @wrapped_original = ProcWrapper.new(@original)
19
+ @wrapped_munged = ProcWrapper.new(@munged)
20
+ end
21
+ def test_wrapping
22
+ assert_same(@original, @wrapped_original.to_proc, "The wrapper should return what was wrapped")
23
+ end
24
+ def test_hashing
25
+
26
+ assert_equal(@wrapped_original.hash, @wrapped_munged.hash, "The original and munged should have the same hash when wrapped")
27
+ assert_equal(@wrapped_original, @wrapped_munged, "The wrappers should be equivalent")
28
+
29
+ a_hash = {@wrapped_original => @original}
30
+ assert(a_hash[@wrapped_original], "Should be able to access the wrapper in the hash")
31
+ assert_equal(a_hash[@wrapped_original], @original, "Should be able to access the wrapper in the hash")
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test-unit
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.3
5
+ platform: ruby
6
+ authors:
7
+ - Kouhei Sutou
8
+ - Ryan Davis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-03-20 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: hoe
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.5.1
24
+ version:
25
+ description: Test::Unit (Classic) - Nathaniel Talbott's originial test-unit, externalized from the ruby project as a gem (for tool developers).
26
+ email:
27
+ - kou@cozmixng.org
28
+ - ryand-ruby@zenspider.com
29
+ executables:
30
+ - testrb
31
+ extensions: []
32
+
33
+ extra_rdoc_files:
34
+ - History.txt
35
+ - Manifest.txt
36
+ - README.txt
37
+ files:
38
+ - History.txt
39
+ - Manifest.txt
40
+ - README.txt
41
+ - Rakefile
42
+ - bin/testrb
43
+ - lib/test/unit.rb
44
+ - lib/test/unit/assertionfailederror.rb
45
+ - lib/test/unit/assertions.rb
46
+ - lib/test/unit/autorunner.rb
47
+ - lib/test/unit/collector.rb
48
+ - lib/test/unit/collector/dir.rb
49
+ - lib/test/unit/collector/objectspace.rb
50
+ - lib/test/unit/error.rb
51
+ - lib/test/unit/failure.rb
52
+ - lib/test/unit/testcase.rb
53
+ - lib/test/unit/testresult.rb
54
+ - lib/test/unit/testsuite.rb
55
+ - lib/test/unit/ui/console/testrunner.rb
56
+ - lib/test/unit/ui/fox/testrunner.rb
57
+ - lib/test/unit/ui/gtk/testrunner.rb
58
+ - lib/test/unit/ui/gtk2/testrunner.rb
59
+ - lib/test/unit/ui/testrunnermediator.rb
60
+ - lib/test/unit/ui/testrunnerutilities.rb
61
+ - lib/test/unit/ui/tk/testrunner.rb
62
+ - lib/test/unit/util/backtracefilter.rb
63
+ - lib/test/unit/util/observable.rb
64
+ - lib/test/unit/util/procwrapper.rb
65
+ - lib/test/unit/version.rb
66
+ - sample/adder.rb
67
+ - sample/subtracter.rb
68
+ - sample/tc_adder.rb
69
+ - sample/tc_subtracter.rb
70
+ - sample/ts_examples.rb
71
+ - test/collector/test_dir.rb
72
+ - test/collector/test_objectspace.rb
73
+ - test/runit/test_assert.rb
74
+ - test/runit/test_testcase.rb
75
+ - test/runit/test_testresult.rb
76
+ - test/runit/test_testsuite.rb
77
+ - test/test_assertions.rb
78
+ - test/test_error.rb
79
+ - test/test_failure.rb
80
+ - test/test_testcase.rb
81
+ - test/test_testresult.rb
82
+ - test/test_testsuite.rb
83
+ - test/util/test_backtracefilter.rb
84
+ - test/util/test_observable.rb
85
+ - test/util/test_procwrapper.rb
86
+ has_rdoc: true
87
+ homepage: http://rubyforge.org/projects/test-unit/
88
+ post_install_message:
89
+ rdoc_options:
90
+ - --main
91
+ - README.txt
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ version:
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: "0"
105
+ version:
106
+ requirements: []
107
+
108
+ rubyforge_project: test-unit
109
+ rubygems_version: 1.0.1
110
+ signing_key:
111
+ specification_version: 2
112
+ summary: Test::Unit (Classic) - Nathaniel Talbott's originial test-unit, externalized from the ruby project as a gem (for tool developers).
113
+ test_files:
114
+ - test/collector/test_dir.rb
115
+ - test/collector/test_objectspace.rb
116
+ - test/runit/test_assert.rb
117
+ - test/runit/test_testcase.rb
118
+ - test/runit/test_testresult.rb
119
+ - test/runit/test_testsuite.rb
120
+ - test/test_assertions.rb
121
+ - test/test_error.rb
122
+ - test/test_failure.rb
123
+ - test/test_testcase.rb
124
+ - test/test_testresult.rb
125
+ - test/test_testsuite.rb
126
+ - test/util/test_backtracefilter.rb
127
+ - test/util/test_observable.rb
128
+ - test/util/test_procwrapper.rb