Skip to content
Browse files

Removed all extra warnings from the unit tests.

Consolidated and cleaned tests.
Cleaned up the requires.
Updated for release.

[git-p4: depot-paths = "//src/heckle/dev/": change = 2798]
  • Loading branch information...
1 parent c4226a3 commit ca2062c7e0860e7ae66f2d6ccb34f9be168373e1 @zenspider zenspider committed Dec 20, 2006
Showing with 142 additions and 134 deletions.
  1. +3 −3 History.txt
  2. +2 −2 README.txt
  3. +0 −3 lib/heckle.rb
  4. +3 −0 lib/heckle/base.rb
  5. +2 −2 test/fixtures/heckled.rb
  6. +132 −124 test/test_heckle.rb
View
6 History.txt
@@ -1,8 +1,9 @@
-== 1.1.1 / 2006-12-19
+== 1.1.1 / 2006-12-20
-* 2 bug fixes:
+* 3 bug fixes:
* Load tests properly when supplying method name.
* Make sure random symbols have at least one character.
+ * Removed all extra warnings from the unit tests. Consolidated and cleaned.
== 1.1.0 / 2006-12-19
@@ -24,4 +25,3 @@
* 1 major enhancement
* Birthday!
-
View
4 README.txt
@@ -4,9 +4,9 @@ heckle
== DESCRIPTION:
-Heckle is a mutation tester. It modifies your code and runs your tests to make sure they fail. The idea is that if code can be changed and your tests dont notice, either that code isnt being covered or it doesnt do anything.
+Heckle is a mutation tester. It modifies your code and runs your tests to make sure they fail. The idea is that if code can be changed and your tests don't notice, either that code isn't being covered or it doesn't do anything.
-Its like hiring a white-hat hacker to try to break into your server and making sure you detect it. You learn the most by trying to break things and watching the outcome in an act of unit test sadism.
+It's like hiring a white-hat hacker to try to break into your server and making sure you detect it. You learn the most by trying to break things and watching the outcome in an act of unit test sadism.
== FEATURES/PROBLEMS:
View
3 lib/heckle.rb
@@ -1,6 +1,3 @@
require 'rubygems'
-require 'parse_tree'
-require 'ruby2ruby'
-require 'logger'
require 'heckle/reporter'
require 'heckle/base'
View
3 lib/heckle/base.rb
@@ -1,3 +1,6 @@
+require 'parse_tree'
+require 'ruby2ruby'
+
class String
def to_class
split(/::/).inject(Object) { |klass, name| klass.const_get(name) }
View
4 test/fixtures/heckled.rb
@@ -63,8 +63,8 @@ def uses_if
end
def uses_boolean
- true
- false
+ a = true
+ b = false
end
def uses_unless
View
256 test/test_heckle.rb
@@ -6,11 +6,34 @@
require 'test_unit_heckler'
require 'heckled'
+module Heckle
+ class Base
+ def rand(*args)
+ 5
+ end
+
+ alias_method :old_rand_string, :rand_string
+ def rand_string
+ "l33t h4x0r"
+ end
+
+ alias_method :old_rand_number, :rand_number
+ def rand_number(*args)
+ 5
+ end
+
+ alias_method :old_rand_symbol, :rand_symbol
+ def rand_symbol
+ :"l33t h4x0r"
+ end
+ end
+end
+
class TestHeckle < Test::Unit::TestCase
def setup
@heckler = Heckle::Base.new("Heckled", "uses_many_things")
end
-
+
def test_should_set_original_tree
expected = [:defn,
:uses_many_things,
@@ -30,10 +53,10 @@ def test_should_set_original_tree
[:return, [:false]]],
true],
[:lvar, :i]]]]]
-
+
assert_equal expected, @heckler.original_tree
end
-
+
def test_should_grab_mutatees_from_method
# expected is from tree of uses_while
expected = {
@@ -59,91 +82,79 @@ def test_should_grab_mutatees_from_method
true]],
:until => [[:until, [:vcall, :some_func], [:vcall, :some_other_func], true]]
}
-
+
assert_equal expected, @heckler.mutatees
end
-
+
def test_should_count_mutatees_left
assert_equal 10, @heckler.mutations_left
end
def test_reset
original_tree = @heckler.current_tree.deep_clone
original_mutatees = @heckler.mutatees.deep_clone
-
+
3.times { @heckler.process(@heckler.current_tree) }
-
+
assert_not_equal original_tree, @heckler.current_tree
assert_not_equal original_mutatees, @heckler.mutatees
-
+
@heckler.reset
assert_equal original_tree[2], @heckler.current_tree[2][1]
assert_equal original_mutatees, @heckler.mutatees
end
-
+
def test_reset_tree
original_tree = @heckler.current_tree.deep_clone
-
+
@heckler.process(@heckler.current_tree)
- assert_not_equal original_tree, @heckler.current_tree
-
+ assert_not_equal original_tree, @heckler.current_tree
+
@heckler.reset_tree
assert_equal original_tree, @heckler.current_tree
end
-
+
def test_reset_should_work_over_several_process_calls
original_tree = @heckler.current_tree.deep_clone
original_mutatees = @heckler.mutatees.deep_clone
-
+
@heckler.process(@heckler.current_tree)
assert_not_equal original_tree, @heckler.current_tree
assert_not_equal original_mutatees, @heckler.mutatees
-
+
@heckler.reset
assert_equal original_tree, @heckler.current_tree
assert_equal original_mutatees, @heckler.mutatees
-
+
3.times { @heckler.process(@heckler.current_tree) }
assert_not_equal original_tree, @heckler.current_tree
assert_not_equal original_mutatees, @heckler.mutatees
-
+
@heckler.reset
assert_equal original_tree, @heckler.current_tree
assert_equal original_mutatees, @heckler.mutatees
end
-
+
def test_reset_mutatees
original_mutatees = @heckler.mutatees.deep_clone
-
+
@heckler.process(@heckler.current_tree)
assert_not_equal original_mutatees, @heckler.mutatees
-
+
@heckler.reset_mutatees
assert_equal original_mutatees, @heckler.mutatees
end
-
+
def teardown
@heckler.reset
end
end
-module Heckle
- class Base
- def rand(*args)
- 5
- end
-
- def rand_number(*args)
- 5
- end
- end
-end
-
class TestHeckleNumbers < Test::Unit::TestCase
def setup
@heckler = Heckle::Base.new("Heckled", "uses_numeric_literals")
end
-
+
def test_literals_should_flip_one_at_a_time
assert_equal 3, @heckler.mutations_left
expected = [:defn,
@@ -154,12 +165,12 @@ def test_literals_should_flip_one_at_a_time
[:lasgn, :i, [:lit, 6]],
[:lasgn, :i, [:call, [:lvar, :i], :+, [:array, [:lit, 2147483648]]]],
[:lasgn, :i, [:call, [:lvar, :i], :-, [:array, [:lit, 3.5]]]]]]]
-
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_numeric_literals,
[:scope,
@@ -168,12 +179,12 @@ def test_literals_should_flip_one_at_a_time
[:lasgn, :i, [:lit, 1]],
[:lasgn, :i, [:call, [:lvar, :i], :+, [:array, [:lit, 2147483653]]]],
[:lasgn, :i, [:call, [:lvar, :i], :-, [:array, [:lit, 3.5]]]]]]]
-
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_numeric_literals,
[:scope,
@@ -182,29 +193,21 @@ def test_literals_should_flip_one_at_a_time
[:lasgn, :i, [:lit, 1]],
[:lasgn, :i, [:call, [:lvar, :i], :+, [:array, [:lit, 2147483648]]]],
[:lasgn, :i, [:call, [:lvar, :i], :-, [:array, [:lit, 8.5]]]]]]]
-
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
end
-
+
def teardown
@heckler.reset
end
end
-module Heckle
- class Base
- def rand_symbol
- :"l33t h4x0r"
- end
- end
-end
-
class TestHeckleSymbols < Test::Unit::TestCase
def setup
@heckler = Heckle::Base.new("Heckled", "uses_symbols")
end
-
+
def test_default_structure
expected = [:defn,
:uses_symbols,
@@ -216,8 +219,8 @@ def test_default_structure
[:lasgn, :i, [:lit, :and_blah]]]]]
assert_equal expected, @heckler.current_tree
end
-
-
+
+
def test_should_randomize_symbol
expected = [:defn,
:uses_symbols,
@@ -229,9 +232,9 @@ def test_should_randomize_symbol
[:lasgn, :i, [:lit, :and_blah]]]]]
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_symbols,
[:scope,
@@ -242,9 +245,9 @@ def test_should_randomize_symbol
[:lasgn, :i, [:lit, :and_blah]]]]]
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_symbols,
[:scope,
@@ -262,7 +265,7 @@ class TestHeckleRegexes < Test::Unit::TestCase
def setup
@heckler = Heckle::Base.new("Heckled", "uses_regexes")
end
-
+
def test_default_structure
expected = [:defn,
:uses_regexes,
@@ -274,8 +277,8 @@ def test_default_structure
[:lasgn, :i, [:lit, /123/]]]]]
assert_equal expected, @heckler.current_tree
end
-
-
+
+
def test_should_randomize_symbol
expected = [:defn,
:uses_regexes,
@@ -287,9 +290,9 @@ def test_should_randomize_symbol
[:lasgn, :i, [:lit, /123/]]]]]
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_regexes,
[:scope,
@@ -300,9 +303,9 @@ def test_should_randomize_symbol
[:lasgn, :i, [:lit, /123/]]]]]
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_regexes,
[:scope,
@@ -320,7 +323,7 @@ class TestHeckleRanges < Test::Unit::TestCase
def setup
@heckler = Heckle::Base.new("Heckled", "uses_ranges")
end
-
+
def test_default_structure
expected = [:defn,
:uses_ranges,
@@ -332,7 +335,7 @@ def test_default_structure
[:lasgn, :i, [:lit, 1..4]]]]]
assert_equal expected, @heckler.current_tree
end
-
+
def test_should_randomize_symbol
expected = [:defn,
:uses_ranges,
@@ -344,9 +347,9 @@ def test_should_randomize_symbol
[:lasgn, :i, [:lit, 1..4]]]]]
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_ranges,
[:scope,
@@ -357,9 +360,9 @@ def test_should_randomize_symbol
[:lasgn, :i, [:lit, 1..4]]]]]
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_ranges,
[:scope,
@@ -382,7 +385,7 @@ def setup
def teardown
@heckler.reset
end
-
+
def test_original_tree
expected = [:defn,
:uses_the_same_literal,
@@ -392,10 +395,10 @@ def test_original_tree
[:lasgn, :i, [:lit, 1]],
[:lasgn, :i, [:lit, 1]],
[:lasgn, :i, [:lit, 1]]]]]]
-
+
assert_equal expected, @heckler.current_tree
end
-
+
def test_literals_should_flip_one_at_a_time
# structure of uses_numeric_literals with first literal +5 (from stubbed rand)
expected = [:defn,
@@ -406,12 +409,12 @@ def test_literals_should_flip_one_at_a_time
[:lasgn, :i, [:lit, 6]],
[:lasgn, :i, [:lit, 1]],
[:lasgn, :i, [:lit, 1]]]]]
-
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_the_same_literal,
[:scope,
@@ -420,12 +423,12 @@ def test_literals_should_flip_one_at_a_time
[:lasgn, :i, [:lit, 1]],
[:lasgn, :i, [:lit, 6]],
[:lasgn, :i, [:lit, 1]]]]]
-
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_the_same_literal,
[:scope,
@@ -434,29 +437,21 @@ def test_literals_should_flip_one_at_a_time
[:lasgn, :i, [:lit, 1]],
[:lasgn, :i, [:lit, 1]],
[:lasgn, :i, [:lit, 6]]]]]
-
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
end
end
-module Heckle
- class Base
- def rand_string
- "l33t h4x0r"
- end
- end
-end
-
class TestHeckleStrings < Test::Unit::TestCase
def setup
@heckler = Heckle::Base.new("Heckled", "uses_strings")
end
-
+
def teardown
@heckler.reset
end
-
+
def test_default_structure
expected = [:defn,
:uses_strings,
@@ -468,7 +463,7 @@ def test_default_structure
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hi, Frank"]]]]]]
assert_equal expected, @heckler.current_tree
end
-
+
def test_should_heckle_string_literals
expected = [:defn,
:uses_strings,
@@ -480,9 +475,9 @@ def test_should_heckle_string_literals
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hi, Frank"]]]]]]
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_strings,
[:scope,
@@ -491,12 +486,12 @@ def test_should_heckle_string_literals
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hello, Robert"]]],
[:call, [:ivar, :@names], :<<, [:array, [:str, "l33t h4x0r"]]],
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hi, Frank"]]]]]]
-
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_strings,
[:scope,
@@ -505,7 +500,7 @@ def test_should_heckle_string_literals
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hello, Robert"]]],
[:call, [:ivar, :@names], :<<, [:array, [:str, "Hello, Jeff"]]],
[:call, [:ivar, :@names], :<<, [:array, [:str, "l33t h4x0r"]]]]]]
-
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
end
@@ -515,11 +510,11 @@ class TestHeckleIfs < Test::Unit::TestCase
def setup
@heckler = Heckle::Base.new("Heckled", "uses_if")
end
-
+
def teardown
@heckler.reset
end
-
+
def test_default_structure
expected = [:defn,
:uses_if,
@@ -530,11 +525,11 @@ def test_default_structure
[:vcall, :some_func],
[:if, [:vcall, :some_other_func], [:return], nil],
nil]]]]
-
-
+
+
assert_equal expected, @heckler.current_tree
end
-
+
def test_should_flip_if_to_unless
expected = [:defn,
:uses_if,
@@ -544,13 +539,13 @@ def test_should_flip_if_to_unless
[:if,
[:vcall, :some_func],
[:if, [:vcall, :some_other_func], nil, [:return]],
- nil]]]]
-
+ nil]]]]
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
+
expected = [:defn,
:uses_if,
[:scope,
@@ -559,8 +554,8 @@ def test_should_flip_if_to_unless
[:if,
[:vcall, :some_func],
nil,
- [:if, [:vcall, :some_other_func], [:return], nil]]]]]
-
+ [:if, [:vcall, :some_other_func], [:return], nil]]]]]
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
end
@@ -570,26 +565,39 @@ class TestHeckleBooleans < Test::Unit::TestCase
def setup
@heckler = Heckle::Base.new("Heckled", "uses_boolean")
end
-
+
def teardown
@heckler.reset
end
-
+
def test_default_structure
- expected = [:defn, :uses_boolean, [:scope, [:block, [:args], [:true], [:false]]]]
+ expected = [:defn, :uses_boolean,
+ [:scope,
+ [:block,
+ [:args],
+ [:lasgn, :a, [:true]],
+ [:lasgn, :b, [:false]]]]]
assert_equal expected, @heckler.current_tree
end
-
-
+
+
def test_should_flip_true_to_false_and_false_to_true
- expected = [:defn, :uses_boolean, [:scope, [:block, [:args], [:false], [:false]]]]
-
+ expected = [:defn, :uses_boolean,
+ [:scope,
+ [:block,
+ [:args],
+ [:lasgn, :a, [:false]],
+ [:lasgn, :b, [:false]]]]]
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
-
+
@heckler.reset_tree
-
- expected = [:defn, :uses_boolean, [:scope, [:block, [:args], [:true], [:true]]]]
+
+ # flip both bools from above to true
+ expected[2][1][2][2][0] = :true
+ expected[2][1][3][2][0] = :true
+
@heckler.process(@heckler.current_tree)
assert_equal expected, @heckler.current_tree
end
@@ -599,11 +607,11 @@ class TestHeckleWhile < Test::Unit::TestCase
def setup
@heckler = Heckle::Base.new("Heckled", "uses_while")
end
-
+
def teardown
@heckler.reset
end
-
+
def test_default_structure
expected = [:defn,
:uses_while,
@@ -613,7 +621,7 @@ def test_default_structure
[:while, [:vcall, :some_func], [:vcall, :some_other_func], true]]]]
assert_equal expected, @heckler.current_tree
end
-
+
def test_flips_while_to_until
expected = [:defn,
:uses_while,
@@ -630,11 +638,11 @@ class TestHeckleUntil < Test::Unit::TestCase
def setup
@heckler = Heckle::Base.new("Heckled", "uses_until")
end
-
+
def teardown
@heckler.reset
end
-
+
def test_default_structure
expected = [:defn,
:uses_until,
@@ -644,7 +652,7 @@ def test_default_structure
[:until, [:vcall, :some_func], [:vcall, :some_other_func], true]]]]
assert_equal expected, @heckler.current_tree
end
-
+
def test_flips_until_to_while
expected = [:defn,
:uses_until,

0 comments on commit ca2062c

Please sign in to comment.
Something went wrong with that request. Please try again.