Parent

TestRawParseTree

Public Instance Methods

setup() click to toggle source
# File test/test_parse_tree.rb, line 52
def setup
  super
  @processor = RawParseTree.new(false)
end
test_class_initialize() click to toggle source
# File test/test_parse_tree.rb, line 66
def test_class_initialize
  expected = [[:class, :SomethingWithInitialize, [:const, :Object],
    [:defn, :initialize, [:scope, [:block, [:args], [:nil]]]],
    [:defn, :protected_meth, [:scope, [:block, [:args], [:nil]]]],
  ]]
  tree = @processor.parse_tree SomethingWithInitialize
  assert_equal expected, tree
end
test_class_translate_string() click to toggle source
# File test/test_parse_tree.rb, line 75
def test_class_translate_string
  str = "class A; def a; end; end"

  sexp = ParseTree.translate str

  expected = [:class, :A, nil,
               [:scope,
                 [:defn, :a, [:scope, [:block, [:args], [:nil]]]]]]

  assert_equal expected, sexp
end
test_class_translate_string_method() click to toggle source
# File test/test_parse_tree.rb, line 87
def test_class_translate_string_method
  str = "class A; def a; end; def b; end; end"

  sexp = ParseTree.translate str, :a

  expected = [:defn, :a, [:scope, [:block, [:args], [:nil]]]]

  assert_equal expected, sexp
end
test_missing() click to toggle source
# File test/test_parse_tree.rb, line 227
def test_missing
  assert_equal(@@missing,
               @processor.parse_tree_for_method(Something, :missing),
               "Must return #{@@missing.inspect} for missing methods")
end
test_parse_tree_for_str() click to toggle source
# File test/test_parse_tree.rb, line 104
def test_parse_tree_for_str
  actual   = @processor.parse_tree_for_str '1 + nil', '(string)', 1
  expected = [[:call, [:lit, 1], :+, [:array, [:nil]]]]

  assert_equal expected, actual
end
test_parse_tree_for_string() click to toggle source
# File test/test_parse_tree.rb, line 97
def test_parse_tree_for_string
  actual   = @processor.parse_tree_for_string '1 + nil', '(string)', 1
  expected = [[:call, [:lit, 1], :+, [:array, [:nil]]]]

  assert_equal expected, actual
end
test_parse_tree_for_string_with_newlines() click to toggle source
# File test/test_parse_tree.rb, line 57
def test_parse_tree_for_string_with_newlines
  @processor = RawParseTree.new(true)
  actual   = @processor.parse_tree_for_string "1 +\n nil", 'test.rb', 5
  expected = [[:newline, 6, "test.rb",
               [:call, [:lit, 1], :+, [:array, [:nil]]]]]

  assert_equal expected, actual
end
test_process_modules() click to toggle source
# File test/test_parse_tree.rb, line 239
def test_process_modules
  exp = [[:module, :Mod1, [:defn, :mod_method, [:bmethod, nil]]]]
  assert_equal exp, @processor.parse_tree(Mod1)

  exp = [[:module, :Mod2, [:fcall, :include, [:array, [:const, :Mod1]]]]]
  assert_equal exp, @processor.parse_tree(Mod2)

  exp = [[:class, :ClassInclude, [:const, :Object],
          [:fcall, :include, [:array, [:const, :Mod2]]]]]
  assert_equal exp, @processor.parse_tree(ClassInclude)
end
test_whole_class() click to toggle source
# File test/test_parse_tree.rb, line 233
def test_whole_class
  assert_equal([@@__all],
               @processor.parse_tree(Something),
               "Must return a lot of shit")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.