TestRawParseTree

Public Instance Methods

setup() click to toggle source
    # File test/test_parse_tree.rb, line 39
39:   def setup
40:     super
41:     @processor = RawParseTree.new(false)
42:   end
test_class_initialize() click to toggle source
    # File test/test_parse_tree.rb, line 53
53:   def test_class_initialize
54:     expected = [[:class, :SomethingWithInitialize, [:const, :Object],
55:       [:defn, :initialize, [:scope, [:block, [:args], [:nil]]]],
56:       [:defn, :protected_meth, [:scope, [:block, [:args], [:nil]]]],
57:     ]]
58:     tree = @processor.parse_tree SomethingWithInitialize
59:     assert_equal expected, tree
60:   end
test_class_translate_string() click to toggle source
    # File test/test_parse_tree.rb, line 62
62:   def test_class_translate_string
63:     str = "class A; def a; end; end"
64: 
65:     sexp = ParseTree.translate str
66: 
67:     expected = [:class, :A, nil,
68:                  [:scope,
69:                    [:defn, :a, [:scope, [:block, [:args], [:nil]]]]]]
70: 
71:     assert_equal expected, sexp
72:   end
test_class_translate_string_method() click to toggle source
    # File test/test_parse_tree.rb, line 74
74:   def test_class_translate_string_method
75:     str = "class A; def a; end; def b; end; end"
76: 
77:     sexp = ParseTree.translate str, :a
78: 
79:     expected = [:defn, :a, [:scope, [:block, [:args], [:nil]]]]
80: 
81:     assert_equal expected, sexp
82:   end
test_missing() click to toggle source
     # File test/test_parse_tree.rb, line 214
214:   def test_missing
215:     assert_equal(@@missing,
216:                  @processor.parse_tree_for_method(Something, :missing),
217:                  "Must return #{@@missing.inspect} for missing methods")
218:   end
test_parse_tree_for_str() click to toggle source
    # File test/test_parse_tree.rb, line 91
91:   def test_parse_tree_for_str
92:     actual   = @processor.parse_tree_for_str '1 + nil', '(string)', 1
93:     expected = [[:call, [:lit, 1], :+, [:array, [:nil]]]]
94: 
95:     assert_equal expected, actual
96:   end
test_parse_tree_for_string() click to toggle source
    # File test/test_parse_tree.rb, line 84
84:   def test_parse_tree_for_string
85:     actual   = @processor.parse_tree_for_string '1 + nil', '(string)', 1
86:     expected = [[:call, [:lit, 1], :+, [:array, [:nil]]]]
87: 
88:     assert_equal expected, actual
89:   end
test_parse_tree_for_string_with_newlines() click to toggle source
    # File test/test_parse_tree.rb, line 44
44:   def test_parse_tree_for_string_with_newlines
45:     @processor = RawParseTree.new(true)
46:     actual   = @processor.parse_tree_for_string "1 +\n nil", 'test.rb', 5
47:     expected = [[:newline, 6, "test.rb",
48:                  [:call, [:lit, 1], :+, [:array, [:nil]]]]]
49: 
50:     assert_equal expected, actual
51:   end
test_whole_class() click to toggle source
     # File test/test_parse_tree.rb, line 220
220:   def test_whole_class
221:     assert_equal([@@__all],
222:                  @processor.parse_tree(Something),
223:                  "Must return a lot of shit")
224:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.