zombie-chaser 0.0.3 → 0.1.0
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.
- data/History.txt +22 -0
- data/README.txt +57 -47
- data/Rakefile +26 -24
- data/bin/zombie-chaser +77 -79
- data/lib/{chaser.rb → zombie-chaser/chaser.rb} +392 -373
- data/lib/zombie-chaser/human.rb +312 -0
- data/{ui → lib/zombie-chaser}/icons/death.png +0 -0
- data/{ui → lib/zombie-chaser}/icons/robot.png +0 -0
- data/lib/zombie-chaser/interface.rb +153 -0
- data/{ui → lib/zombie-chaser}/sprites/robot-attacking.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/robot-dead.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/robot-dying.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/robot-idle.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/robot-moving.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/robot-turning.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/tank-attacking.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/tank-dead.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/tank-idle.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/tank-moving.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/tank-turning.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/witch-attacking.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/witch-dead.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/witch-idle.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/witch-moving.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/witch-turning.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/zombie-attacking.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/zombie-dead.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/zombie-dying.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/zombie-idle.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/zombie-moving.png +0 -0
- data/{ui → lib/zombie-chaser}/sprites/zombie-turning.png +0 -0
- data/lib/zombie-chaser/test_unit_handler.rb +78 -0
- data/{ui → lib/zombie-chaser}/tiles/grass.png +0 -0
- data/{ui → lib/zombie-chaser}/tiles/shrubbery.png +0 -0
- data/{ui → lib/zombie-chaser}/ui.rb +165 -127
- data/lib/{world.rb → zombie-chaser/world.rb} +105 -98
- data/lib/zombie-chaser/zombie_test_chaser.rb +139 -0
- data/test/fixtures/chased.rb +56 -56
- data/test/integration.rb +58 -0
- data/test/test_chaser.rb +150 -144
- data/test/test_unit.rb +2 -2
- data/test/test_zombie.rb +302 -108
- data/zombie-chaser.gemspec +88 -88
- metadata +40 -46
- data/lib/human.rb +0 -189
- data/lib/interface.rb +0 -86
- data/lib/test_unit_handler.rb +0 -43
- data/lib/zombie_test_chaser.rb +0 -133
@@ -0,0 +1,139 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "test/unit/collector/objectspace"
|
4
|
+
require "test/unit/ui/testrunnermediator"
|
5
|
+
require 'zombie-chaser/chaser'
|
6
|
+
|
7
|
+
# Make sure test/unit doesn't swallow our timeout
|
8
|
+
begin
|
9
|
+
Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS << Chaser::Timeout
|
10
|
+
rescue NameError
|
11
|
+
# ignore
|
12
|
+
end
|
13
|
+
|
14
|
+
class ZombieTestChaser < Chaser
|
15
|
+
|
16
|
+
VERSION = '0.1.0' #This should be used, but isn't, in Rakefile.
|
17
|
+
|
18
|
+
@@test_pattern = 'test/test_*.rb'
|
19
|
+
@@tests_loaded = false
|
20
|
+
@@world = nil
|
21
|
+
|
22
|
+
def self.test_pattern=(value)
|
23
|
+
@@test_pattern = value
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.create_world
|
27
|
+
@@tests_loaded = true
|
28
|
+
@@world = World.new_using_test_unit_handler(@@test_pattern)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.world
|
32
|
+
@@world
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.current_class_names(exclude_list)
|
36
|
+
result = []
|
37
|
+
ObjectSpace.each_object(Class) do |klass|
|
38
|
+
next if klass.to_s.include?("Class:0x")
|
39
|
+
next unless klass.ancestors.all? {|ancestor| (ancestor.to_s.split(/::/) & exclude_list).empty?}
|
40
|
+
result << klass.to_s
|
41
|
+
end
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.validate(klass_name = nil, method_name = nil, force = false)
|
46
|
+
pre_existing_class_names = self.current_class_names([]) unless klass_name
|
47
|
+
create_world
|
48
|
+
|
49
|
+
if klass_name
|
50
|
+
klass = klass_name.to_class
|
51
|
+
# Does the method exist?
|
52
|
+
klass_methods = klass.singleton_methods(false).collect {|meth| "self.#{meth}"}
|
53
|
+
if method_name
|
54
|
+
if method_name =~ /self\./
|
55
|
+
abort "Unknown method: #{klass_name}.#{method_name.gsub('self.', '')}" unless klass_methods.include? method_name
|
56
|
+
else
|
57
|
+
abort "Unknown method: #{klass_name}##{method_name}" unless klass.instance_methods(false).map{|sym| sym.to_s}.include? method_name
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
initial_time = Time.now
|
63
|
+
|
64
|
+
chaser = self.new(klass_name)
|
65
|
+
|
66
|
+
all_good = nil
|
67
|
+
|
68
|
+
chaser.while_world_running do
|
69
|
+
|
70
|
+
passed = chaser.human_survives?
|
71
|
+
|
72
|
+
unless force or passed then
|
73
|
+
abort "Initial run of tests failed... fix and run chaser again"
|
74
|
+
end
|
75
|
+
|
76
|
+
if self.guess_timeout? then
|
77
|
+
running_time = Time.now - initial_time
|
78
|
+
adjusted_timeout = (running_time * 2 < 5) ? 5 : (running_time * 2).ceil
|
79
|
+
self.timeout = adjusted_timeout
|
80
|
+
end
|
81
|
+
|
82
|
+
chaser.interface_puts "Timeout set to #{adjusted_timeout} seconds."
|
83
|
+
|
84
|
+
if passed then
|
85
|
+
chaser.interface_puts "Initial tests pass. Let's rumble."
|
86
|
+
else
|
87
|
+
chaser.interface_puts "Initial tests failed but you forced things. Let's rumble."
|
88
|
+
end
|
89
|
+
chaser.interface_puts
|
90
|
+
|
91
|
+
counts = Hash.new(0)
|
92
|
+
|
93
|
+
klass_names = klass_name ? Array(klass_name) : self.current_class_names(["Test"]) - pre_existing_class_names
|
94
|
+
klass_names.each do |block_klass_name|
|
95
|
+
block_klass = block_klass_name.to_class
|
96
|
+
|
97
|
+
methods = method_name ? Array(method_name) : block_klass.instance_methods(false) + block_klass.singleton_methods(false).collect {|meth| "self.#{meth}"}
|
98
|
+
|
99
|
+
methods.sort_by{|x| x.to_s}.each do |block_method_name|
|
100
|
+
result = self.new(block_klass_name, block_method_name).validate
|
101
|
+
counts[result] += 1
|
102
|
+
end
|
103
|
+
end
|
104
|
+
all_good = counts[false] == 0
|
105
|
+
|
106
|
+
chaser.interface_puts "Chaser Results:",
|
107
|
+
"",
|
108
|
+
"Passed : %3d" % counts[true],
|
109
|
+
"Failed : %3d" % counts[false],
|
110
|
+
""
|
111
|
+
|
112
|
+
if all_good then
|
113
|
+
chaser.interface_puts "All chasing was thwarted! YAY!!!"
|
114
|
+
else
|
115
|
+
chaser.interface_puts "Improve the tests and try again."
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
all_good
|
120
|
+
end
|
121
|
+
|
122
|
+
def human_survives?
|
123
|
+
self.class.world.run_human
|
124
|
+
end
|
125
|
+
|
126
|
+
def zombie_survives?
|
127
|
+
self.class.world.run_next_zombie
|
128
|
+
end
|
129
|
+
|
130
|
+
def while_world_running
|
131
|
+
self.class.world.while_world_running{yield}
|
132
|
+
end
|
133
|
+
|
134
|
+
def initialize(klass_name=nil, method_name=nil)
|
135
|
+
self.class.create_world unless @@tests_loaded
|
136
|
+
super(klass_name, method_name, Reporter.new(self.class.world.interface))
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
data/test/fixtures/chased.rb
CHANGED
@@ -1,56 +1,56 @@
|
|
1
|
-
class Chased
|
2
|
-
def add(a,b)
|
3
|
-
a + b
|
4
|
-
end
|
5
|
-
|
6
|
-
def say_hello
|
7
|
-
"G'day!"
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.static_method
|
11
|
-
"Zap!"
|
12
|
-
end
|
13
|
-
|
14
|
-
def block_using_instance_method
|
15
|
-
result = []
|
16
|
-
block_yielding_instance_method do |i|
|
17
|
-
result << i * 2
|
18
|
-
end
|
19
|
-
result
|
20
|
-
end
|
21
|
-
|
22
|
-
def block_yielding_instance_method
|
23
|
-
yield 1
|
24
|
-
yield 2
|
25
|
-
yield 3
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.block_using_class_method
|
29
|
-
result = []
|
30
|
-
block_yielding_class_method do |i|
|
31
|
-
result << i * 2
|
32
|
-
end
|
33
|
-
result
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.block_yielding_class_method
|
37
|
-
yield 1
|
38
|
-
yield 2
|
39
|
-
end
|
40
|
-
|
41
|
-
def [](x)
|
42
|
-
x * 2
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.[](x)
|
46
|
-
x * 2
|
47
|
-
end
|
48
|
-
|
49
|
-
def question?
|
50
|
-
"exclamation!"
|
51
|
-
end
|
52
|
-
|
53
|
-
def foo=(x)
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
end
|
1
|
+
class Chased
|
2
|
+
def add(a,b)
|
3
|
+
a + b
|
4
|
+
end
|
5
|
+
|
6
|
+
def say_hello
|
7
|
+
"G'day!"
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.static_method
|
11
|
+
"Zap!"
|
12
|
+
end
|
13
|
+
|
14
|
+
def block_using_instance_method
|
15
|
+
result = []
|
16
|
+
block_yielding_instance_method do |i|
|
17
|
+
result << i * 2
|
18
|
+
end
|
19
|
+
result
|
20
|
+
end
|
21
|
+
|
22
|
+
def block_yielding_instance_method
|
23
|
+
yield 1
|
24
|
+
yield 2
|
25
|
+
yield 3
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.block_using_class_method
|
29
|
+
result = []
|
30
|
+
block_yielding_class_method do |i|
|
31
|
+
result << i * 2
|
32
|
+
end
|
33
|
+
result
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.block_yielding_class_method
|
37
|
+
yield 1
|
38
|
+
yield 2
|
39
|
+
end
|
40
|
+
|
41
|
+
def [](x)
|
42
|
+
x * 2
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.[](x)
|
46
|
+
x * 2
|
47
|
+
end
|
48
|
+
|
49
|
+
def question?
|
50
|
+
"exclamation!"
|
51
|
+
end
|
52
|
+
|
53
|
+
def foo=(x)
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
data/test/integration.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
|
3
|
+
module TestIntegrationHelper
|
4
|
+
def output_text_for_command(command)
|
5
|
+
output_file = IO.popen(command)
|
6
|
+
output_text = output_file.read
|
7
|
+
output_text
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class TestIntegration < Test::Unit::TestCase
|
12
|
+
include TestIntegrationHelper
|
13
|
+
|
14
|
+
EXAMPLE_DIRECTORY = "../exemplor-chaser-sample_target/"
|
15
|
+
LARGE_TEST_EXAMPLE_DIRECTORY = "../bioruby-blessed/"
|
16
|
+
BIT_BUCKET_FILENAME = RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null'
|
17
|
+
|
18
|
+
def setup
|
19
|
+
raise "Don't have example directory" unless File.exist?(EXAMPLE_DIRECTORY)
|
20
|
+
raise "Don't have large test example directory" unless File.exist?(LARGE_TEST_EXAMPLE_DIRECTORY)
|
21
|
+
raise "Don't have bit bucket filename" unless File.exist?(BIT_BUCKET_FILENAME)
|
22
|
+
@execution_command = "ruby -Ilib"
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_exit_value_for_partial_test
|
26
|
+
assert_equal false, system("#{@execution_command} -I../exemplor-chaser-sample_target bin/zombie-chaser MyMath --tests ../exemplor-chaser-sample_target/partial_test_unit.rb --console > #{BIT_BUCKET_FILENAME}"), "Doesn't regard incomplete tests as a failure"
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_exit_value_for_full_test
|
30
|
+
assert_equal true, system("#{@execution_command} -I../exemplor-chaser-sample_target bin/zombie-chaser MyMath --tests ../exemplor-chaser-sample_target/full_test_unit.rb --console > #{BIT_BUCKET_FILENAME}"), "Doesn't regard complete tests as a success"
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_class_methods_dont_cause_errors
|
34
|
+
output_text = output_text_for_command("#{@execution_command} -I../bioruby-blessed/lib/ bin/zombie-chaser Bio::Sequence::NA --test ../bioruby-blessed/test/unit/bio/sequence/test_na.rb --console")
|
35
|
+
assert_match(/Chaser Results/, output_text, "Error raised during test due to class methods")
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_messages_arent_on_same_line_as_nethack_representation
|
39
|
+
output_text = output_text_for_command("#{@execution_command} -I../exemplor-chaser-sample_target bin/zombie-chaser MyMath --tests ../exemplor-chaser-sample_target/full_test_unit.rb --console")
|
40
|
+
assert_no_match(/@.*The mutant didn't survive/, output_text, "Doesn't put messages on a new line")
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_output_ends_with_newline
|
44
|
+
output_text = output_text_for_command("#{@execution_command} -I../exemplor-chaser-sample_target bin/zombie-chaser MyMath --tests ../exemplor-chaser-sample_target/full_test_unit.rb --console")
|
45
|
+
assert_equal "\n", output_text[-1..-1], "Doesn't end with a newline, causing problems for command lines"
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_console_width_configurable
|
49
|
+
output_text = output_text_for_command("#{@execution_command} -I../bioruby-blessed/lib/ bin/zombie-chaser Bio::Sequence::NA --test ../bioruby-blessed/test/unit/bio/sequence/test_na.rb --console --width 10")
|
50
|
+
assert_no_match(/\.\.\.\.\.\.\.\.\.\.\./, output_text, "Doesn't allow console width to be configurable")
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_summary_not_interrupted_by_progress_bar
|
54
|
+
output_text = output_text_for_command("#{@execution_command} -I../bioruby-blessed/lib/ bin/zombie-chaser Bio::Sequence::NA --test ../bioruby-blessed/test/unit/bio/sequence/test_na.rb --console")
|
55
|
+
assert_match(/Chaser Results:..Passed : +\d+.Failed : +\d+/m, output_text, "Summary interrupted by progress bar")
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
data/test/test_chaser.rb
CHANGED
@@ -1,144 +1,150 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
@chaser
|
57
|
-
chased
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@chaser
|
67
|
-
assert_equal "
|
68
|
-
@chaser.
|
69
|
-
assert_equal "
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
@chaser
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
@chaser
|
86
|
-
assert_equal [
|
87
|
-
@chaser.
|
88
|
-
assert_equal [
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
@chaser
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
@chaser
|
105
|
-
assert_equal
|
106
|
-
@chaser.
|
107
|
-
assert_equal
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
@chaser
|
125
|
-
chased
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
1
|
+
require 'test/unit/testcase'
|
2
|
+
require 'test/unit' if $0 == __FILE__
|
3
|
+
require 'zombie-chaser/zombie_test_chaser'
|
4
|
+
require 'fixtures/chased'
|
5
|
+
|
6
|
+
class TestChaser < Chaser
|
7
|
+
def rand(*args)
|
8
|
+
5
|
9
|
+
end
|
10
|
+
|
11
|
+
def rand_string
|
12
|
+
"l33t h4x0r"
|
13
|
+
end
|
14
|
+
|
15
|
+
def rand_number(*args)
|
16
|
+
5
|
17
|
+
end
|
18
|
+
|
19
|
+
def rand_symbol
|
20
|
+
:"l33t h4x0r"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module ChaserTestCaseHelper
|
25
|
+
def create_chaser(klass_name, method_name)
|
26
|
+
# Fixme the third variable is for a reporter. The fact that it's not being used suggests that we're not using
|
27
|
+
# the whole of the TestChaser, and ought to split it up into smaller classes
|
28
|
+
TestChaser.new(klass_name, method_name, nil)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class ChaserTestCase < Test::Unit::TestCase
|
33
|
+
include ChaserTestCaseHelper
|
34
|
+
|
35
|
+
unless defined? Mini then
|
36
|
+
undef_method :default_test
|
37
|
+
alias :refute_equal :assert_not_equal
|
38
|
+
end
|
39
|
+
|
40
|
+
def setup
|
41
|
+
end
|
42
|
+
|
43
|
+
def teardown
|
44
|
+
@chaser.unmodify_method if defined?(@chaser) && @chaser
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_unmodified_behaves_as_expected
|
48
|
+
chased = Chased.new
|
49
|
+
assert_equal 5, chased.add(2,3), "Unmodified version should equal 5"
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_modify_and_unmodify_instance_method
|
53
|
+
@chaser = create_chaser("Chased", "add")
|
54
|
+
chased = Chased.new
|
55
|
+
assert_equal 5, chased.add(2,3), "method has been modified before it should have been"
|
56
|
+
@chaser.modify_method
|
57
|
+
assert_equal 10, chased.add(2,3), "method hasn't been modified"
|
58
|
+
@chaser.unmodify_method
|
59
|
+
assert_equal 5, chased.add(2,3), "method should be back to normal, but it isn't"
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_modify_and_unmodify_string
|
63
|
+
@chaser = create_chaser("Chased", "say_hello")
|
64
|
+
chased = Chased.new
|
65
|
+
assert_equal "G'day!", chased.say_hello, "method has been modified before it should have been"
|
66
|
+
@chaser.modify_method
|
67
|
+
assert_equal "l33t h4x0r", chased.say_hello, "method hasn't been modified"
|
68
|
+
@chaser.unmodify_method
|
69
|
+
assert_equal "G'day!", chased.say_hello, "method should be back to normal, but it isn't"
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_modify_and_unmodify_class_method
|
73
|
+
@chaser = create_chaser("Chased", "self.static_method")
|
74
|
+
assert_equal "Zap!", Chased.static_method, "class method has been modified before it should have been"
|
75
|
+
@chaser.modify_method
|
76
|
+
assert_equal "l33t h4x0r", Chased.static_method, "class method hasn't been modified"
|
77
|
+
@chaser.unmodify_method
|
78
|
+
assert_equal "Zap!", Chased.static_method, "class method should be back to normal, but it isn't"
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_pass_blocks_on_in_instance_methods
|
82
|
+
@chaser = create_chaser("Chased", "block_yielding_instance_method")
|
83
|
+
chased = Chased.new
|
84
|
+
assert_equal [2,4,6], chased.block_using_instance_method, "block yielding instance method has been modified before it should have been"
|
85
|
+
@chaser.modify_method
|
86
|
+
assert_equal [12, 14, 16], chased.block_using_instance_method, "yielded values haven't been modified"
|
87
|
+
@chaser.unmodify_method
|
88
|
+
assert_equal [2,4,6], chased.block_using_instance_method, "block yielding instance method has been modified before it should have been"
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_pass_blocks_on_in_class_methods
|
92
|
+
@chaser = create_chaser("Chased", "self.block_yielding_class_method")
|
93
|
+
assert_equal [2,4], Chased.block_using_class_method, "block yielding class method has been modified before it should have been"
|
94
|
+
@chaser.modify_method
|
95
|
+
assert_equal [12, 14], Chased.block_using_class_method, "yielded values haven't been modified"
|
96
|
+
@chaser.unmodify_method
|
97
|
+
assert_equal [2,4], Chased.block_using_class_method, "block yielding class method has been modified before it should have been"
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_handle_funny_characters_in_instance_method_names
|
101
|
+
@chaser = create_chaser("Chased", "[]")
|
102
|
+
chased = Chased.new
|
103
|
+
assert_equal 2, chased[1], "Original doesn't work"
|
104
|
+
@chaser.modify_method
|
105
|
+
assert_equal 7, chased[1], "Modified doesn't work"
|
106
|
+
@chaser.unmodify_method
|
107
|
+
assert_equal 2, chased[1], "Modified then unmodified doesn't work"
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_handle_funny_characters_in_class_method_names
|
111
|
+
@chaser = create_chaser("Chased", "self.[]")
|
112
|
+
assert_equal 2, Chased[1], "Original doesn't work"
|
113
|
+
@chaser.modify_method
|
114
|
+
assert_equal 7, Chased[1], "Modified doesn't work"
|
115
|
+
@chaser.unmodify_method
|
116
|
+
assert_equal 2, Chased[1], "Modified then unmodified doesn't work"
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_more_funny_characters
|
120
|
+
assert_nothing_raised("Can't handle certain characters") do
|
121
|
+
@chaser = create_chaser("Chased", "question?")
|
122
|
+
chased = Chased.new
|
123
|
+
chased.question?
|
124
|
+
@chaser.modify_method
|
125
|
+
chased.question?
|
126
|
+
@chaser.unmodify_method
|
127
|
+
chased.question?
|
128
|
+
end
|
129
|
+
|
130
|
+
assert_nothing_raised("Can't handle equal signs") do
|
131
|
+
@chaser = create_chaser("Chased", "foo=")
|
132
|
+
chased = Chased.new
|
133
|
+
chased.foo= 1
|
134
|
+
@chaser.modify_method
|
135
|
+
chased.foo = 2
|
136
|
+
@chaser.unmodify_method
|
137
|
+
chased.foo = 3
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
class ZombieTestChaserCase < Test::Unit::TestCase
|
144
|
+
def test_detects_invalid_glob
|
145
|
+
incorrect_glob = 'test\test_chaser.rb'
|
146
|
+
assert_raise(RuntimeError, "Can't detect an incorrect glob") do
|
147
|
+
TestUnitHandler.new(incorrect_glob)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|