TestRawParseTree

Public Instance Methods

setup() click to toggle source
# File test/test_parse_tree.rb, line 39
def setup
  super
  @processor = RawParseTree.new(false)
end
test_class_initialize() click to toggle source
# File test/test_parse_tree.rb, line 53
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 62
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 74
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 214
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 91
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 84
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 44
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_whole_class() click to toggle source
# File test/test_parse_tree.rb, line 220
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.