Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

finally got the tests passing again. Partially miniunit incompatibili…

…ty (@name), partially parsetree incompatibility, partially overly clever.

[git-p4: depot-paths = "//src/heckle/dev/": change = 4298]
  • Loading branch information...
commit abe4156a1a37dcc8f6dd157d4ef9434739eaf112 1 parent 144f9d2
@zenspider zenspider authored
Showing with 25 additions and 19 deletions.
  1. +7 −4 lib/heckle.rb
  2. +18 −15 test/test_heckle.rb
View
11 lib/heckle.rb
@@ -1,7 +1,6 @@
require 'rubygems'
require 'parse_tree'
require 'sexp_processor'
-require 'unified_ruby'
require 'ruby2ruby'
require 'timeout'
require 'tempfile'
@@ -19,8 +18,6 @@ class Heckle < SexpProcessor
class Timeout < Timeout::Error; end
- include UnifiedRuby
-
##
# The version of Heckle you are using.
@@ -502,7 +499,13 @@ def grab_mutatees
end
def current_tree
- rewrite Sexp.from_array(ParseTree.translate(klass_name.to_class, method_name))
+ ur = Unifier.new
+
+ sexp = ParseTree.translate(klass_name.to_class, method_name)
+ raise "sexp invalid for #{klass_name}##{method_name}" if sexp == [nil]
+ sexp = ur.process(sexp)
+
+ rewrite sexp
end
def reset
View
33 test/test_heckle.rb
@@ -25,21 +25,24 @@ def rand_symbol
end
class HeckleTestCase < Test::Unit::TestCase
- undef_method :default_test unless defined? Mini
+ unless defined? Mini then
+ undef_method :default_test
+ alias :refute_equal :assert_not_equal
+ end
def setup
@nodes ||= Heckle::MUTATABLE_NODES
- unless defined? @name then
- data = self.class.name["TestHeckle".size..-1]
+ unless defined? @method_name then
+ data = self.class.name.sub(/HeckleTestCase/, '').sub(/TestHeckle/, '')
data = data.gsub(/([A-Z])/, '_\1').downcase
data = "_many_things" if data.empty?
- @name = "uses#{data}"
+ @method_name = "uses#{data}"
end
- @heckler = TestHeckler.new("Heckled", @name, @nodes)
+ @heckler = TestHeckler.new("Heckled", @method_name, @nodes) rescue nil
end
def teardown
- @heckler.reset if defined? @heckler
+ @heckler.reset if defined?(@heckler) && @heckler
end
end
@@ -157,8 +160,8 @@ def test_reset
3.times { @heckler.process(@heckler.current_tree) }
- assert_not_equal original_tree, @heckler.current_tree
- assert_not_equal original_mutatees, @heckler.mutatees
+ refute_equal original_tree, @heckler.current_tree
+ refute_equal original_mutatees, @heckler.mutatees
@heckler.reset
assert_equal original_tree[2], @heckler.current_tree[2]
@@ -169,7 +172,7 @@ def test_reset_tree
original_tree = @heckler.current_tree.deep_clone
@heckler.process(@heckler.current_tree)
- assert_not_equal original_tree, @heckler.current_tree
+ refute_equal original_tree, @heckler.current_tree
@heckler.reset_tree
assert_equal original_tree, @heckler.current_tree
@@ -180,16 +183,16 @@ def test_reset_should_work_over_several_process_calls
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
+ refute_equal original_tree, @heckler.current_tree
+ refute_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
+ refute_equal original_tree, @heckler.current_tree
+ refute_equal original_mutatees, @heckler.mutatees
@heckler.reset
assert_equal original_tree, @heckler.current_tree
@@ -200,7 +203,7 @@ def test_reset_mutatees
original_mutatees = @heckler.mutatees.deep_clone
@heckler.process(@heckler.current_tree)
- assert_not_equal original_mutatees, @heckler.mutatees
+ refute_equal original_mutatees, @heckler.mutatees
@heckler.reset_mutatees
assert_equal original_mutatees, @heckler.mutatees
@@ -501,7 +504,7 @@ def test_callblock_deleted
class TestHeckleClassMethod < HeckleTestCase
def setup
- @name = "self.is_a_klass_method?"
+ @method_name = "self.is_a_klass_method?"
@nodes = s(:true)
super
end
Please sign in to comment.
Something went wrong with that request. Please try again.