Permalink
Browse files

One test to go. Fixed up call everywhere.

[git-p4: depot-paths = "//src/heckle/dev/": change = 3482]
  • Loading branch information...
1 parent 6a15859 commit 6f8c90287a332bd137ed92d63e89e01bb0b191c3 @zenspider zenspider committed Aug 9, 2007
Showing with 30 additions and 28 deletions.
  1. +30 −28 test/test_heckle.rb
View
@@ -28,9 +28,13 @@ class HeckleTestCase < Test::Unit::TestCase
undef_method :default_test
def setup
@nodes ||= Heckle::MUTATABLE_NODES
- data = self.class.name["TestHeckle".size..-1].gsub(/([A-Z])/, '_\1').downcase
- data = "_many_things" if data.empty?
- @heckler = TestHeckler.new("Heckled", "uses#{data}", @nodes)
+ unless defined? @name then
+ data = self.class.name["TestHeckle".size..-1]
+ data = data.gsub(/([A-Z])/, '_\1').downcase
+ data = "_many_things" if data.empty?
+ @name = "uses#{data}"
+ end
+ @heckler = TestHeckler.new("Heckled", @name, @nodes)
end
def teardown
@@ -78,14 +82,14 @@ def test_should_set_original_tree
s(:block,
s(:lasgn, :i, s(:lit, 1)),
s(:while,
- s(:call, s(:lvar, :i), :<, s(:array, s(:lit, 10))),
+ s(:call, s(:lvar, :i), :<, s(:arglist, s(:lit, 10))),
s(:block,
- s(:lasgn, :i, s(:call, s(:lvar, :i), :+, s(:array, s(:lit, 1)))),
+ s(:lasgn, :i, s(:call, s(:lvar, :i), :+, s(:arglist, s(:lit, 1)))),
s(:until, s(:call, nil, :some_func, s(:arglist)),
s(:call, nil, :some_other_func, s(:arglist)), true),
s(:if,
s(:call, s(:str, "hi there"), :==,
- s(:array, s(:str, "changeling"))),
+ s(:arglist, s(:str, "changeling"))),
s(:return, s(:true)),
nil),
s(:return, s(:false))),
@@ -98,36 +102,36 @@ def test_should_set_original_tree
def test_should_grab_mutatees_from_method
# expected is from tree of uses_while
expected = {
- :call => [s(:call, s(:lvar, :i), :<, s(:array, s(:lit, 10))),
- s(:call, s(:lvar, :i), :+, s(:array, s(:lit, 1))),
+ :call => [s(:call, s(:lvar, :i), :<, s(:arglist, s(:lit, 10))),
+ s(:call, s(:lvar, :i), :+, s(:arglist, s(:lit, 1))),
s(:call, nil, :some_func, s(:arglist)), # FIX: why added?
s(:call, nil, :some_other_func, s(:arglist)), # FIX: why added?
s(:call, s(:str, "hi there"), :==,
- s(:array, s(:str, "changeling")))],
+ s(:arglist, s(:str, "changeling")))],
:cvasgn => [], # no cvasgns here
:dasgn => [], # no dasgns here
:dasgn_curr => [], # no dasgn_currs here
:iasgn => [], # no iasgns here
:gasgn => [], # no gasgns here
:lasgn => [s(:lasgn, :i, s(:lit, 1)),
- s(:lasgn, :i, s(:call, s(:lvar, :i), :+, s(:array, s(:lit, 1))))],
+ s(:lasgn, :i, s(:call, s(:lvar, :i), :+, s(:arglist, s(:lit, 1))))],
:lit => [s(:lit, 1), s(:lit, 10), s(:lit, 1)],
:if => [s(:if,
- s(:call, s(:str, "hi there"), :==, s(:array, s(:str, "changeling"))),
+ s(:call, s(:str, "hi there"), :==, s(:arglist, s(:str, "changeling"))),
s(:return, s(:true)),
nil)],
:str => [s(:str, "hi there"), s(:str, "changeling")],
:true => [s(:true)],
:false => [s(:false)],
:while => [s(:while,
- s(:call, s(:lvar, :i), :<, s(:array, s(:lit, 10))),
+ s(:call, s(:lvar, :i), :<, s(:arglist, s(:lit, 10))),
s(:block,
- s(:lasgn, :i, s(:call, s(:lvar, :i), :+, s(:array, s(:lit, 1)))),
+ s(:lasgn, :i, s(:call, s(:lvar, :i), :+, s(:arglist, s(:lit, 1)))),
s(:until, s(:call, nil, :some_func, s(:arglist)),
s(:call, nil, :some_other_func, s(:arglist)), true),
s(:if,
s(:call, s(:str, "hi there"), :==,
- s(:array, s(:str, "changeling"))),
+ s(:arglist, s(:str, "changeling"))),
s(:return, s(:true)),
nil),
s(:return, s(:false))),
@@ -213,8 +217,8 @@ def util_expected(n)
s(:block,
s(:lasgn, :i, s(:lit, toggle(1, 1 == n))),
s(:lasgn, :i, s(:call, s(:lvar, :i), :+,
- s(:array, s(:lit, toggle(2147483648, 2 == n))))),
- s(:lasgn, :i, s(:call, s(:lvar, :i), :-, s(:array, s(:lit, toggle(3.5, 3 == n))))))))
+ s(:arglist, s(:lit, toggle(2147483648, 2 == n))))),
+ s(:lasgn, :i, s(:call, s(:lvar, :i), :-, s(:arglist, s(:lit, toggle(3.5, 3 == n))))))))
end
end
@@ -282,9 +286,9 @@ def util_expected(n = nil)
s(:args),
s(:scope,
s(:block,
- s(:call, s(:ivar, :@names), :<<, s(:array, s(:str, toggle("Hello, Robert", n == 1)))),
- s(:call, s(:ivar, :@names), :<<, s(:array, s(:str, toggle("Hello, Jeff", n == 2)))),
- s(:call, s(:ivar, :@names), :<<, s(:array, s(:str, toggle("Hi, Frank", n == 3)))))))
+ s(:call, s(:ivar, :@names), :<<, s(:arglist, s(:str, toggle("Hello, Robert", n == 1)))),
+ s(:call, s(:ivar, :@names), :<<, s(:arglist, s(:str, toggle("Hello, Jeff", n == 2)))),
+ s(:call, s(:ivar, :@names), :<<, s(:arglist, s(:str, toggle("Hi, Frank", n == 3)))))))
end
end
@@ -452,7 +456,7 @@ def test_default_structure
s(:call,
s(:call, nil, :some_func, s(:arglist)),
:+,
- s(:array, s(:call, nil, :some_other_func, s(:arglist)))))))
+ s(:arglist, s(:call, nil, :some_other_func, s(:arglist)))))))
assert_equal expected, @heckler.current_tree
end
@@ -476,15 +480,15 @@ def test_default_structure
nil,
s(:lit, 1)))))
- assert_equal :foo, @heckler.current_tree
+ assert_equal expected, @heckler.current_tree
end
def test_callblock_deleted
expected = s(:defn, :uses_callblock,
s(:args),
s(:scope,
s(:block,
s(:iter,
- s(:call, s(:call, nil, :x, s(:arglist)), :y),
+ s(:call, s(:nil), :y, s(:arglist)),
nil,
s(:lit, 1)))))
@@ -493,13 +497,11 @@ def test_callblock_deleted
end
end
-class TestHeckleClassMethod < Test::Unit::TestCase
+class TestHeckleClassMethod < HeckleTestCase
def setup
- @heckler = TestHeckler.new("Heckled", "self.is_a_klass_method?")
- end
-
- def teardown
- @heckler.reset
+ @name = "self.is_a_klass_method?"
+ @nodes = s(:true)
+ super
end
def test_default_structure

0 comments on commit 6f8c902

Please sign in to comment.