ZenTest 3.4.3 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/History.txt +46 -3
  2. data/Manifest.txt +13 -0
  3. data/README.txt +1 -0
  4. data/Rakefile +20 -3
  5. data/bin/autotest +23 -37
  6. data/bin/multiruby +13 -7
  7. data/bin/unit_diff +1 -1
  8. data/example_dot_autotest.rb +14 -0
  9. data/lib/autotest.rb +77 -30
  10. data/lib/autotest/autoupdate.rb +26 -0
  11. data/lib/autotest/emacs.rb +29 -0
  12. data/lib/autotest/fixtures.rb +12 -0
  13. data/lib/autotest/growl.rb +7 -17
  14. data/lib/autotest/heckle.rb +14 -0
  15. data/lib/autotest/migrate.rb +7 -0
  16. data/lib/autotest/notify.rb +38 -0
  17. data/lib/autotest/redgreen.rb +7 -4
  18. data/lib/autotest/screen.rb +77 -0
  19. data/lib/autotest/shame.rb +45 -0
  20. data/lib/autotest/timestamp.rb +3 -1
  21. data/lib/camping_autotest.rb +37 -0
  22. data/lib/functional_test_matrix.rb +85 -0
  23. data/lib/rails_autotest.rb +49 -41
  24. data/lib/rspec_rails_autotest.rb +119 -0
  25. data/lib/test/rails.rb +28 -1
  26. data/lib/test/rails/controller_test_case.rb +27 -6
  27. data/lib/test/rails/functional_test_case.rb +3 -0
  28. data/lib/test/rails/helper_test_case.rb +3 -0
  29. data/lib/test/rails/view_test_case.rb +13 -5
  30. data/lib/test/zentest_assertions.rb +42 -23
  31. data/lib/unit_diff.rb +86 -69
  32. data/lib/zentest.rb +58 -87
  33. data/lib/zentest_mapping.rb +97 -0
  34. data/test/test_autotest.rb +23 -3
  35. data/test/test_help.rb +10 -4
  36. data/test/test_rails_autotest.rb +6 -4
  37. data/test/test_rails_controller_test_case.rb +10 -2
  38. data/test/test_ruby_fork.rb +12 -12
  39. data/test/test_unit_diff.rb +37 -33
  40. data/test/test_zentest.rb +15 -141
  41. data/test/test_zentest_assertions.rb +38 -18
  42. data/test/test_zentest_mapping.rb +213 -0
  43. metadata +18 -4
@@ -0,0 +1,97 @@
1
+ ##
2
+ # ZenTestMapping - mapping method names from impl to test.
3
+ #
4
+ # Method names are mapped bidirectionally in the following way:
5
+ #
6
+ # method test_method
7
+ # method? test_method_eh (too much exposure to Canadians :)
8
+ # method! test_method_bang
9
+ # method= test_method_equals
10
+ # [] test_index
11
+ # * test_times
12
+ # == test_equals2
13
+ # === test_equals3
14
+ #
15
+ # Further, any of the test methods should be able to have arbitrary
16
+ # extensions put on the name to distinguish edge cases:
17
+ #
18
+ # method test_method
19
+ # method test_method_simple
20
+ # method test_method_no_network
21
+ #
22
+ # To allow for unmapped test methods (ie, non-unit tests), name them:
23
+ #
24
+ # test_integration_.*
25
+
26
+ module ZenTestMapping
27
+
28
+ @@orig_method_map = {
29
+ '!' => 'bang',
30
+ '%' => 'percent',
31
+ '&' => 'and',
32
+ '*' => 'times',
33
+ '**' => 'times2',
34
+ '+' => 'plus',
35
+ '-' => 'minus',
36
+ '/' => 'div',
37
+ '<' => 'lt',
38
+ '<=' => 'lte',
39
+ '<=>' => 'spaceship',
40
+ "<\<" => 'lt2',
41
+ '==' => 'equals2',
42
+ '===' => 'equals3',
43
+ '=~' => 'equalstilde',
44
+ '>' => 'gt',
45
+ '>=' => 'ge',
46
+ '>>' => 'gt2',
47
+ '+@' => 'unary_plus',
48
+ '-@' => 'unary_minus',
49
+ '[]' => 'index',
50
+ '[]=' => 'index_equals',
51
+ '^' => 'carat',
52
+ '|' => 'or',
53
+ '~' => 'tilde',
54
+ }
55
+
56
+ @@method_map = @@orig_method_map.merge(@@orig_method_map.invert)
57
+
58
+ # Generates a test method name from a normal method,
59
+ # taking into account names composed of metacharacters
60
+ # (used for arithmetic, etc
61
+ def normal_to_test(name)
62
+ name = name.dup # wtf?
63
+ is_cls_method = name.sub!(/^self\./, '')
64
+ name = @@method_map[name] if @@method_map.has_key? name
65
+ name = name.sub(/=$/, '_equals')
66
+ name = name.sub(/\?$/, '_eh')
67
+ name = name.sub(/\!$/, '_bang')
68
+ name = "class_" + name if is_cls_method
69
+ "test_#{name}"
70
+ end
71
+
72
+ # Converts a method name beginning with test to its
73
+ # corresponding normal method name, taking into account
74
+ # symbolic names which may have been anglicised by
75
+ # #normal_to_test().
76
+ def test_to_normal(name, klassname=nil)
77
+ known_methods = (@inherited_methods[klassname] || {}).keys.sort.reverse
78
+
79
+ mapped_re = @@orig_method_map.values.sort_by { |k| k.length }.map {|s| Regexp.escape(s)}.reverse.join("|")
80
+ known_methods_re = known_methods.map {|s| Regexp.escape(s)}.join("|")
81
+
82
+ name = name.sub(/^test_/, '')
83
+ name = name.sub(/_equals/, '=') unless name =~ /index/
84
+ name = name.sub(/_bang.*$/, '!') # FIX: deal w/ extensions separately
85
+ name = name.sub(/_eh/, '?')
86
+ is_cls_method = name.sub!(/^class_/, '')
87
+ name = name.sub(/^(#{mapped_re})(.*)$/) {$1}
88
+ name = name.sub(/^(#{known_methods_re})(.*)$/) {$1} unless known_methods_re.empty?
89
+
90
+ # look up in method map
91
+ name = @@method_map[name] if @@method_map.has_key? name
92
+
93
+ name = 'self.' + name if is_cls_method
94
+
95
+ name
96
+ end
97
+ end
@@ -172,19 +172,39 @@ test_fail2(#{@test_class}) [#{@test}:60]:
172
172
  test_error1(#{@test_class}):
173
173
  3) Error:
174
174
  test_error2(#{@test_class}):
175
+
176
+ 12 tests, 18 assertions, 2 failures, 2 errors
175
177
  "
176
178
 
177
179
  @a.handle_results(s2)
178
180
  expected = { @test => %w( test_fail1 test_fail2 test_error1 test_error2 ) }
179
181
  assert_equal expected, @a.files_to_test
182
+ assert @a.tainted
180
183
 
181
184
  @a.handle_results(s1)
182
185
  assert_equal empty, @a.files_to_test
183
- end
184
186
 
185
- # TODO BUG /usr/local/bin/ruby -I.:lib:test test/test_rails_autotest.rb -n "/^(test_hooks)$/" | unit_diff -u; /usr/local/bin/ruby -I.:lib:test test/test_autotest.rb -n "/^(test_hooks|test_hooks)$/" | unit_diff -u
187
+ s3 = '
188
+ /opt/bin/ruby -I.:lib:test -rtest/unit -e "%w[#{@test}].each { |f| require f }" | unit_diff -u
189
+ -e:1:in `require\': ./#{@test}:23: parse error, unexpected tIDENTIFIER, expecting \'}\' (SyntaxError)
190
+ settings_fields.each {|e| assert_equal e, version.send e.intern}
191
+ ^ from -e:1
192
+ from -e:1:in `each\'
193
+ from -e:1
194
+ '
195
+ @a.files_to_test[@test] = Time.at(42)
196
+ @a.files[@test] = []
197
+ expected = { @test => Time.at(42) }
198
+ assert_equal expected, @a.files_to_test
199
+ @a.handle_results(s3)
200
+ assert_equal expected, @a.files_to_test
201
+ assert @a.tainted
202
+ @a.tainted = false
186
203
 
187
- # TODO BUG /usr/local/bin/ruby -I.:lib:test test/test_rails_autotest.rb -n "/^(test_hook|test_hooks)$/" | unit_diff -u; /usr/local/bin/ruby -I.:lib:test test/test_autotest.rb -n "/^(test_hooks|test_hooks)$/" | unit_diff -u
204
+ @a.handle_results(s1)
205
+ assert_equal empty, @a.files_to_test
206
+ assert ! @a.tainted
207
+ end
188
208
 
189
209
  def test_hook_overlap
190
210
  Autotest.clear_hooks
@@ -1,8 +1,8 @@
1
1
  # ActionPack
2
2
  module ActionController; end
3
3
  module ActionController::Flash; end
4
- class ActionController::Flash::FlashHash; end
5
- class ActionController::TestSession < Hash; end
4
+ class ActionController::Flash::FlashHash < Hash; end
5
+ class ActionController::TestSession; end
6
6
 
7
7
  class ActionController::TestRequest
8
8
  attr_accessor :session
@@ -15,16 +15,22 @@ module ActionView; end
15
15
  module ActionView::Helpers; end
16
16
  module ActionView::Helpers::ActiveRecordHelper; end
17
17
  module ActionView::Helpers::TagHelper; end
18
+ module ActionView::Helpers::TextHelper; end
18
19
  module ActionView::Helpers::FormTagHelper; end
19
20
  module ActionView::Helpers::FormOptionsHelper; end
20
21
  module ActionView::Helpers::FormHelper; end
21
22
  module ActionView::Helpers::UrlHelper; end
22
23
  module ActionView::Helpers::AssetTagHelper; end
23
24
 
24
- # ActionMailer
25
+ class << Test::Unit::TestCase
26
+ attr_accessor :use_transactional_fixtures
27
+ attr_accessor :use_instantiated_fixtures
28
+ end
25
29
 
30
+ # ActionMailer
26
31
  module ActionMailer; end
27
32
  class ActionMailer::Base
28
- def self.deliveries=(arg); end
33
+ def self.deliveries=(arg); end unless defined? @@defined
34
+ @@defined = true
29
35
  end
30
36
 
@@ -1,5 +1,5 @@
1
1
  require 'test/unit' if $0 == __FILE__
2
- require 'test_autotest'
2
+ require 'test/test_autotest'
3
3
  require 'rails_autotest'
4
4
 
5
5
  class TestRailsAutotest < TestAutotest
@@ -77,8 +77,9 @@ class TestRailsAutotest < TestAutotest
77
77
  'test/functional/admin/themes_controller_test.rb')
78
78
 
79
79
  util_tests_for_file('app/controllers/application.rb',
80
- 'test/controllers/dummy_controller_test.rb',
81
- 'test/functional/dummy_controller_test.rb')
80
+ @rails_controller_tests,
81
+ @rails_view_tests,
82
+ @rails_functional_tests)
82
83
 
83
84
  util_tests_for_file('app/controllers/route_controller.rb',
84
85
  'test/controllers/route_controller_test.rb',
@@ -88,7 +89,8 @@ class TestRailsAutotest < TestAutotest
88
89
 
89
90
  # helpers
90
91
  util_tests_for_file('app/helpers/application_helper.rb',
91
- @rails_view_tests + @rails_functional_tests)
92
+ @rails_view_tests,
93
+ @rails_functional_tests)
92
94
 
93
95
  util_tests_for_file('app/helpers/route_helper.rb',
94
96
  'test/views/route_view_test.rb',
@@ -13,7 +13,7 @@ class TRController < ApplicationController
13
13
  end if $TESTING_RTC
14
14
 
15
15
  class TestRailsControllerTestCase < Test::Rails::ControllerTestCase
16
-
16
+
17
17
  def setup
18
18
  @controller_class_name = 'TRController'
19
19
  super
@@ -31,9 +31,17 @@ class TestRailsControllerTestCase < Test::Rails::ControllerTestCase
31
31
  assert_assigned :no_ivar
32
32
  end
33
33
 
34
- assert_raise Test::Unit::AssertionFailedError do
34
+ e = assert_raise Test::Unit::AssertionFailedError do
35
35
  assert_assigned :ivar, 'bad_value'
36
36
  end
37
+
38
+ expected = <<-EOF.strip
39
+ assert_assigned :ivar.
40
+ <\"bad_value\"> expected but was
41
+ <\"value\">.
42
+ EOF
43
+
44
+ assert_equal expected, e.message
37
45
  end
38
46
 
39
47
  def test_deny_assigned
@@ -50,18 +50,6 @@ class TestRubyFork < Test::Unit::TestCase
50
50
  assert_equal expected, settings
51
51
  end
52
52
 
53
- def test_parse_server_args_execute
54
- expected = util_make_settings [], ['foo']
55
-
56
- settings = RubyFork.parse_server_args ['-e', 'foo']
57
- assert_equal expected, settings
58
-
59
- expected = util_make_settings [], ['foo', 'bar']
60
-
61
- settings = RubyFork.parse_server_args ['-e', 'foo', '-e', 'bar']
62
- assert_equal expected, settings
63
- end
64
-
65
53
  def test_parse_server_args_include
66
54
  expected = util_make_settings nil, nil, ['lib'], nil, false
67
55
 
@@ -102,6 +90,18 @@ class TestRubyFork < Test::Unit::TestCase
102
90
  end
103
91
 
104
92
  def test_parse_server_args_execute
93
+ expected = util_make_settings [], ['foo'], nil, nil, false
94
+
95
+ settings = RubyFork.parse_server_args ['-e', 'foo']
96
+ assert_equal expected, settings
97
+
98
+ expected = util_make_settings [], ['foo', 'bar'], nil, nil, false
99
+
100
+ settings = RubyFork.parse_server_args ['-e', 'foo', '-e', 'bar']
101
+ assert_equal expected, settings
102
+ end
103
+
104
+ def test_parse_server_args_execute_duplicate_test? # FIX
105
105
  expected = util_make_settings ['zentest'], nil, nil, nil, false
106
106
 
107
107
  settings = RubyFork.parse_server_args ['-r', 'zentest']
@@ -1,6 +1,7 @@
1
1
  #!/usr/local/bin/ruby -w
2
2
 
3
3
  require 'test/unit'
4
+ require 'stringio'
4
5
 
5
6
  $TESTING = true
6
7
 
@@ -13,25 +14,21 @@ class TestUnitDiff < Test::Unit::TestCase
13
14
  end
14
15
 
15
16
  def test_input
16
- input = "Loaded suite ./blah\nStarted\nFF\nFinished in 0.035332 seconds.\n\n 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n 2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n<\"line1\"> expected but was\n<\"line2\\nline3\\n\\n\">.\n\n2 tests, 2 assertions, 2 failures, 0 errors\n"
17
+ header = "Loaded suite ./blah\nStarted\nFF\nFinished in 0.035332 seconds.\n\n"
18
+ input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n 2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n<\"line1\"> expected but was\n<\"line2\\nline3\\n\\n\">.\n\n2 tests, 2 assertions, 2 failures, 0 errors\n"
17
19
 
18
20
  # TODO: I think I'd like a separate footer array as well
19
- expected = [
20
- ["Loaded suite ./blah\n", "Started\n", "FF\n", "Finished in 0.035332 seconds.\n"],
21
- [
22
- [" 1) Failure:\n", "test_test1(TestBlah) [./blah.rb:25]:\n", "<\"line1\\nline2\\nline3\\n\"> expected but was\n", "<\"line4\\nline5\\nline6\\n\">.\n"],
23
- [" 2) Failure:\n", "test_test2(TestBlah) [./blah.rb:29]:\n", "<\"line1\"> expected but was\n", "<\"line2\\nline3\\n\\n\">.\n"],
24
- ],
25
- ["\n", "2 tests, 2 assertions, 2 failures, 0 errors\n"]
26
- ]
21
+ expected = [[[" 1) Failure:\n", "test_test1(TestBlah) [./blah.rb:25]:\n", "<\"line1\\nline2\\nline3\\n\"> expected but was\n", "<\"line4\\nline5\\nline6\\n\">.\n"],
22
+ [" 2) Failure:\n", "test_test2(TestBlah) [./blah.rb:29]:\n", "<\"line1\"> expected but was\n", "<\"line2\\nline3\\n\\n\">.\n"]],
23
+ ["\n", "2 tests, 2 assertions, 2 failures, 0 errors\n"]]
27
24
 
28
- assert_equal expected, @diff.input(input)
25
+ util_unit_diff(header, input, expected, :parse_input)
29
26
  end
30
27
 
31
28
  def test_unit_diff_empty # simulates broken pipe at the least
32
29
  input = ""
33
30
  expected = ""
34
- assert_equal expected, @diff.unit_diff(input)
31
+ util_unit_diff("", "", "")
35
32
  end
36
33
 
37
34
  def test_parse_diff_angles
@@ -112,52 +109,59 @@ class TestUnitDiff < Test::Unit::TestCase
112
109
  end
113
110
 
114
111
  def test_unit_diff_angles
115
- input = "Loaded suite ./blah\nStarted\nF\nFinished in 0.035332 seconds.\n\n 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"<html>\"> expected but was\n<\"<body>\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors\n"
116
-
117
- expected = "Loaded suite ./blah\nStarted\nF\nFinished in 0.035332 seconds.\n\n1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1c1\n< <html>\n---\n> <body>\n\n1 tests, 1 assertions, 1 failures, 0 errors"
112
+ header = "Loaded suite ./blah\nStarted\nF\nFinished in 0.035332 seconds.\n\n"
113
+ input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"<html>\"> expected but was\n<\"<body>\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors\n"
114
+ expected = "1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1c1\n< <html>\n---\n> <body>\n\n1 tests, 1 assertions, 1 failures, 0 errors"
118
115
 
119
- assert_equal expected, @diff.unit_diff(input)
116
+ util_unit_diff(header, input, expected)
120
117
  end
121
118
 
122
119
  def test_unit_diff1
123
- input = "Loaded suite ./blah\nStarted\nF\nFinished in 0.035332 seconds.\n\n 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors\n"
120
+ header = "Loaded suite ./blah\nStarted\nF\nFinished in 0.035332 seconds.\n\n"
121
+ input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors\n"
122
+ expected = "1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1,3c1,3\n< line1\n< line2\n< line3\n---\n> line4\n> line5\n> line6\n\n1 tests, 1 assertions, 1 failures, 0 errors"
124
123
 
125
- expected = "Loaded suite ./blah\nStarted\nF\nFinished in 0.035332 seconds.\n\n1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1,3c1,3\n< line1\n< line2\n< line3\n---\n> line4\n> line5\n> line6\n\n1 tests, 1 assertions, 1 failures, 0 errors"
126
-
127
- assert_equal expected, @diff.unit_diff(input)
124
+ util_unit_diff(header, input, expected)
128
125
  end
129
126
 
130
127
  def test_unit_diff2
131
- input = "Loaded suite ./blah\nStarted\nFF\nFinished in 0.035332 seconds.\n\n 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n 2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n<\"line1\"> expected but was\n<\"line2\\nline3\\n\\n\">.\n\n2 tests, 2 assertions, 2 failures, 0 errors\n"
132
-
133
- expected = "Loaded suite ./blah\nStarted\nFF\nFinished in 0.035332 seconds.\n\n1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1,3c1,3\n< line1\n< line2\n< line3\n---\n> line4\n> line5\n> line6\n\n2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n1c1,4\n< line1\n---\n> line2\n> line3\n> \n> \n\n2 tests, 2 assertions, 2 failures, 0 errors"
128
+ header = "Loaded suite ./blah\nStarted\nFF\nFinished in 0.035332 seconds.\n\n"
129
+ input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n 2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n<\"line1\"> expected but was\n<\"line2\\nline3\\n\\n\">.\n\n2 tests, 2 assertions, 2 failures, 0 errors\n"
130
+ expected = "1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n1,3c1,3\n< line1\n< line2\n< line3\n---\n> line4\n> line5\n> line6\n\n2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n1c1,4\n< line1\n---\n> line2\n> line3\n> \n> \n\n2 tests, 2 assertions, 2 failures, 0 errors"
134
131
 
135
- assert_equal expected, @diff.unit_diff(input)
132
+ util_unit_diff(header, input, expected)
136
133
  end
137
134
 
138
135
  def test_unit_diff3
136
+ header = ""
139
137
  input = " 13) Failure:\ntest_case_stmt(TestRubyToRubyC) [./r2ctestcase.rb:1198]:\nUnknown expected data.\n<false> is not true.\n"
140
-
141
138
  expected = "13) Failure:\ntest_case_stmt(TestRubyToRubyC) [./r2ctestcase.rb:1198]:\nUnknown expected data.\n<false> is not true."
142
139
 
143
- assert_equal expected, @diff.unit_diff(input)
140
+ util_unit_diff(header, input, expected)
144
141
  end
145
142
 
146
143
  def test_unit_diff_suspect_equals
147
- input = ".............................................F............................................\nFinished in 0.834671 seconds.\n\n 1) Failure:\ntest_unit_diff_suspect_equals(TestUnitDiff) [./test/test_unit_diff.rb:122]:\n<\"out\"> expected but was\n<\"out\">.\n\n90 tests, 241 assertions, 1 failures, 0 errors"
148
-
149
- expected = ".............................................F............................................\nFinished in 0.834671 seconds.\n\n1) Failure:\ntest_unit_diff_suspect_equals(TestUnitDiff) [./test/test_unit_diff.rb:122]:\n[no difference--suspect ==]\n\n90 tests, 241 assertions, 1 failures, 0 errors"
144
+ header = "Loaded suite ./blah\nStarted\n.............................................F............................................\nFinished in 0.834671 seconds.\n\n"
145
+ footer = "90 tests, 241 assertions, 1 failures, 0 errors"
146
+ input = "#{header} 1) Failure:\ntest_unit_diff_suspect_equals(TestUnitDiff) [./test/test_unit_diff.rb:122]:\n<\"out\"> expected but was\n<\"out\">.\n\n#{footer}"
147
+ expected = "1) Failure:\ntest_unit_diff_suspect_equals(TestUnitDiff) [./test/test_unit_diff.rb:122]:\n[no difference--suspect ==]\n\n#{footer}"
150
148
 
151
- assert_equal expected, @diff.unit_diff(input)
149
+ util_unit_diff(header, input, expected)
152
150
  end
153
151
 
154
152
  def test_unit_diff_NOT_suspect_equals
155
- input = ".\nFinished in 0.0 seconds.\n\n 1) Failure:\ntest_blah(TestBlah)\n<\"out\"> expected but was\n<\"out\\n\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors"
153
+ header = "Loaded suite ./blah\nStarted\n.\nFinished in 0.0 seconds.\n\n"
154
+ input = "#{header} 1) Failure:\ntest_blah(TestBlah)\n<\"out\"> expected but was\n<\"out\\n\">.\n\n1 tests, 1 assertions, 1 failures, 0 errors"
155
+ expected = "1) Failure:\ntest_blah(TestBlah)\n1a2\n> \n\n1 tests, 1 assertions, 1 failures, 0 errors"
156
156
 
157
- expected = ".\nFinished in 0.0 seconds.\n\n1) Failure:\ntest_blah(TestBlah)\n1a2\n> \n\n1 tests, 1 assertions, 1 failures, 0 errors"
158
-
159
- assert_equal expected, @diff.unit_diff(input)
157
+ util_unit_diff(header, input, expected)
160
158
  end
161
159
 
160
+ def util_unit_diff(header, input, expected, msg=:unit_diff)
161
+ output = StringIO.new("")
162
+ actual = @diff.send(msg, StringIO.new(input), output)
163
+ assert_equal header, output.string
164
+ assert_equal expected, actual
165
+ end
162
166
  end
163
167
 
@@ -10,25 +10,25 @@ require 'zentest' unless defined? $ZENTEST
10
10
  # These are just classes set up for quick testing.
11
11
  # TODO: need to test a compound class name Mod::Cls
12
12
 
13
- class Cls1 # ZenTest SKIP
13
+ class Cls1 # ZenTest SKIP
14
14
  def meth1; end
15
15
  def self.meth2; end
16
16
  end
17
17
 
18
- class TestCls1 # ZenTest SKIP
18
+ class TestCls1 # ZenTest SKIP
19
19
  def setup; end
20
20
  def teardown; end
21
21
  def test_meth1; end
22
22
  def test_meth2; assert(true, "something"); end
23
23
  end
24
24
 
25
- class SuperDuper # ZenTest SKIP
25
+ class SuperDuper # ZenTest SKIP
26
26
  def self.cls_inherited; end
27
27
  def inherited; end
28
28
  def overridden; end
29
29
  end
30
30
 
31
- class LowlyOne < SuperDuper # ZenTest SKIP
31
+ class LowlyOne < SuperDuper # ZenTest SKIP
32
32
  def self.cls_extended; end
33
33
  def overridden; end
34
34
  def extended; end
@@ -235,20 +235,20 @@ end
235
235
  def test_is_test_class
236
236
  # classes
237
237
  assert(@tester.is_test_class(TestCls1),
238
- "All test classes must start with Test")
238
+ "All test classes must start with Test")
239
239
  assert(!@tester.is_test_class(Cls1),
240
- "Classes not starting with Test must not be test classes")
240
+ "Classes not starting with Test must not be test classes")
241
241
  # strings
242
242
  assert(@tester.is_test_class("TestCls1"),
243
- "All test classes must start with Test")
243
+ "All test classes must start with Test")
244
244
  assert(@tester.is_test_class("TestMod::TestCls1"),
245
- "All test modules must start with test as well")
245
+ "All test modules must start with test as well")
246
246
  assert(!@tester.is_test_class("Cls1"),
247
- "Classes not starting with Test must not be test classes")
247
+ "Classes not starting with Test must not be test classes")
248
248
  assert(!@tester.is_test_class("NotTestMod::TestCls1"),
249
- "Modules not starting with Test must not be test classes")
249
+ "Modules not starting with Test must not be test classes")
250
250
  assert(!@tester.is_test_class("NotTestMod::NotTestCls1"),
251
- "All names must start with Test to be test classes")
251
+ "All names must start with Test to be test classes")
252
252
  end
253
253
 
254
254
  def test_is_test_class_reversed
@@ -272,9 +272,9 @@ end
272
272
  assert_equal('TestCls1', @tester.convert_class_name('Cls1'))
273
273
 
274
274
  assert_equal('TestModule::TestCls1',
275
- @tester.convert_class_name('Module::Cls1'))
275
+ @tester.convert_class_name('Module::Cls1'))
276
276
  assert_equal('Module::Cls1',
277
- @tester.convert_class_name('TestModule::TestCls1'))
277
+ @tester.convert_class_name('TestModule::TestCls1'))
278
278
  end
279
279
 
280
280
  def test_convert_class_name_reversed
@@ -288,9 +288,9 @@ end
288
288
  assert_equal('Cls1Test', @tester.convert_class_name('Cls1'))
289
289
 
290
290
  assert_equal('ModuleTest::Cls1Test',
291
- @tester.convert_class_name('Module::Cls1'))
291
+ @tester.convert_class_name('Module::Cls1'))
292
292
  assert_equal('Module::Cls1',
293
- @tester.convert_class_name('ModuleTest::Cls1Test'))
293
+ @tester.convert_class_name('ModuleTest::Cls1Test'))
294
294
  $r = old
295
295
  end
296
296
 
@@ -452,130 +452,6 @@ end
452
452
  assert_equal({}, @tester.inherited_methods["SuperDuper"])
453
453
  end
454
454
 
455
- def test_normal_to_test
456
- self.util_simple_setup
457
- assert_equal("test_method1", @tester.normal_to_test("method1"))
458
- assert_equal("test_method1_bang", @tester.normal_to_test("method1!"))
459
- assert_equal("test_method1_eh", @tester.normal_to_test("method1?"))
460
- assert_equal("test_method1_equals", @tester.normal_to_test("method1="))
461
- end
462
-
463
- def test_normal_to_test_cls
464
- self.util_simple_setup
465
- assert_equal("test_class_method1", @tester.normal_to_test("self.method1"))
466
- assert_equal("test_class_method1_bang", @tester.normal_to_test("self.method1!"))
467
- assert_equal("test_class_method1_eh", @tester.normal_to_test("self.method1?"))
468
- assert_equal("test_class_method1_equals", @tester.normal_to_test("self.method1="))
469
- end
470
-
471
- def test_normal_to_test_operators
472
- self.util_simple_setup
473
- assert_equal("test_and", @tester.normal_to_test("&"))
474
- assert_equal("test_bang", @tester.normal_to_test("!"))
475
- assert_equal("test_carat", @tester.normal_to_test("^"))
476
- assert_equal("test_div", @tester.normal_to_test("/"))
477
- assert_equal("test_equalstilde", @tester.normal_to_test("=~"))
478
- assert_equal("test_minus", @tester.normal_to_test("-"))
479
- assert_equal("test_or", @tester.normal_to_test("|"))
480
- assert_equal("test_percent", @tester.normal_to_test("%"))
481
- assert_equal("test_plus", @tester.normal_to_test("+"))
482
- assert_equal("test_tilde", @tester.normal_to_test("~"))
483
- end
484
-
485
- def test_normal_to_test_overlap
486
- self.util_simple_setup
487
- assert_equal("test_equals2", @tester.normal_to_test("=="))
488
- assert_equal("test_equals3", @tester.normal_to_test("==="))
489
- assert_equal("test_ge", @tester.normal_to_test(">="))
490
- assert_equal("test_gt", @tester.normal_to_test(">"))
491
- assert_equal("test_gt2", @tester.normal_to_test(">>"))
492
- assert_equal("test_index", @tester.normal_to_test("[]"))
493
- assert_equal("test_index_equals", @tester.normal_to_test("[]="))
494
- assert_equal("test_lt", @tester.normal_to_test("<"))
495
- assert_equal("test_lt2", @tester.normal_to_test("<\<"))
496
- assert_equal("test_lte", @tester.normal_to_test("<="))
497
- assert_equal("test_method", @tester.normal_to_test("method"))
498
- assert_equal("test_method_equals", @tester.normal_to_test("method="))
499
- assert_equal("test_spaceship", @tester.normal_to_test("<=>"))
500
- assert_equal("test_times", @tester.normal_to_test("*"))
501
- assert_equal("test_times2", @tester.normal_to_test("**"))
502
- assert_equal("test_unary_minus", @tester.normal_to_test("-@"))
503
- assert_equal("test_unary_plus", @tester.normal_to_test("+@"))
504
- assert_equal("test_class_index", @tester.normal_to_test("self.[]"))
505
- end
506
-
507
- def test_test_to_normal
508
- self.util_simple_setup
509
- assert_equal("method1!", @tester.test_to_normal("test_method1_bang", "Something"))
510
- assert_equal("method1", @tester.test_to_normal("test_method1", "Something"))
511
- assert_equal("method1=", @tester.test_to_normal("test_method1_equals", "Something"))
512
- assert_equal("method1?", @tester.test_to_normal("test_method1_eh", "Something"))
513
- end
514
-
515
- def test_test_to_normal_cls
516
- self.util_simple_setup
517
- assert_equal("self.method1", @tester.test_to_normal("test_class_method1"))
518
- assert_equal("self.method1!", @tester.test_to_normal("test_class_method1_bang"))
519
- assert_equal("self.method1?", @tester.test_to_normal("test_class_method1_eh"))
520
- assert_equal("self.method1=", @tester.test_to_normal("test_class_method1_equals"))
521
- assert_equal("self.[]", @tester.test_to_normal("test_class_index"))
522
- end
523
-
524
- def test_test_to_normal_extended
525
- self.util_simple_setup
526
- assert_equal("equal?", @tester.test_to_normal("test_equal_eh_extension", "Something"))
527
- assert_equal("equal?", @tester.test_to_normal("test_equal_eh_extension_again", "Something"))
528
- assert_equal("method1", @tester.test_to_normal("test_method1_extension", "Something"))
529
- assert_equal("method1", @tester.test_to_normal("test_method1_extension_again", "Something"))
530
- end
531
-
532
- def test_test_to_normal_mapped
533
- self.util_simple_setup
534
- assert_equal("*", @tester.test_to_normal("test_times"))
535
- assert_equal("*", @tester.test_to_normal("test_times_ext"))
536
- assert_equal("==", @tester.test_to_normal("test_equals2"))
537
- assert_equal("==", @tester.test_to_normal("test_equals2_ext"))
538
- assert_equal("===", @tester.test_to_normal("test_equals3"))
539
- assert_equal("===", @tester.test_to_normal("test_equals3_ext"))
540
- assert_equal("[]", @tester.test_to_normal("test_index"))
541
- assert_equal("[]", @tester.test_to_normal("test_index_ext"))
542
- assert_equal("[]=", @tester.test_to_normal("test_index_equals"))
543
- assert_equal("[]=", @tester.test_to_normal("test_index_equals_ext"))
544
- end
545
-
546
- def test_test_to_normal_operators
547
- self.util_simple_setup
548
- assert_equal("&", @tester.test_to_normal("test_and"))
549
- assert_equal("!", @tester.test_to_normal("test_bang"))
550
- assert_equal("^", @tester.test_to_normal("test_carat"))
551
- assert_equal("/", @tester.test_to_normal("test_div"))
552
- assert_equal("=~", @tester.test_to_normal("test_equalstilde"))
553
- assert_equal("-", @tester.test_to_normal("test_minus"))
554
- assert_equal("|", @tester.test_to_normal("test_or"))
555
- assert_equal("%", @tester.test_to_normal("test_percent"))
556
- assert_equal("+", @tester.test_to_normal("test_plus"))
557
- assert_equal("~", @tester.test_to_normal("test_tilde"))
558
- end
559
-
560
- def test_test_to_normal_overlap
561
- self.util_simple_setup
562
- assert_equal("==", @tester.test_to_normal("test_equals2"))
563
- assert_equal("===", @tester.test_to_normal("test_equals3"))
564
- assert_equal(">=", @tester.test_to_normal("test_ge"))
565
- assert_equal(">", @tester.test_to_normal("test_gt"))
566
- assert_equal(">>", @tester.test_to_normal("test_gt2"))
567
- assert_equal("[]", @tester.test_to_normal("test_index"))
568
- assert_equal("[]=", @tester.test_to_normal("test_index_equals"))
569
- assert_equal("<", @tester.test_to_normal("test_lt"))
570
- assert_equal("<\<", @tester.test_to_normal("test_lt2"))
571
- assert_equal("<=", @tester.test_to_normal("test_lte"))
572
- assert_equal("<=>", @tester.test_to_normal("test_spaceship"))
573
- assert_equal("*", @tester.test_to_normal("test_times"))
574
- assert_equal("**", @tester.test_to_normal("test_times2"))
575
- assert_equal("-@", @tester.test_to_normal("test_unary_minus"))
576
- assert_equal("+@", @tester.test_to_normal("test_unary_plus"))
577
- end
578
-
579
455
  def test_klasses_equals
580
456
  self.util_simple_setup
581
457
  assert_equal({"Something"=> {
@@ -662,6 +538,4 @@ assert_equal expected, util_testcase("Something2::Blah2", "TestSomething2::TestB
662
538
 
663
539
  assert_equal expected, util_testcase("TestTrueClass")
664
540
  end
665
-
666
541
  end
667
-