# File test/test_parse_tree.rb, line 39
39: def setup
40: super
41: @processor = RawParseTree.new(false)
42: end
# 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
# 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
# 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
# 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
# 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
# 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
# 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
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.