Class: TestRawParseTree

### Home Classes Methods

### In Files

- test/test_parse_tree.rb

### Parent

ParseTreeTestCase

### Methods

- #setup
- #test_class_initialize
- #test_class_translate_string
- #test_class_translate_string_method
- #test_missing
- #test_parse_tree_for_str
- #test_parse_tree_for_string
- #test_parse_tree_for_string_with_newlines
- #test_process_modules
- #test_whole_class

### Files

- History.txt
- Manifest.txt
- README.txt

### Class/Module Index

Quicksearch

- Class
- ClassInclude
- Method
- Mod1
- Mod2
- Module
- ParseTree
- ParseTreeGauntlet
- ParseTreeTestCase
- PostUnifier
- PreUnifier
- Proc
- ProcStoreTmp
- R2RTestCase
- RawParseTree
- Something
- SomethingWithInitialize
- TestParseTree
- TestRawParseTree
- TestUnifier
- UnboundMethod
- UnifiedRuby
- Unifier

No matching classes.

# TestRawParseTree

### Public Instance Methods

setup() click to toggle source

    # File test/test_parse_tree.rb, line 2335
    def setup
      super
      @processor = RawParseTree.new(false)
    end

test_class_initialize() click to toggle source

    # File test/test_parse_tree.rb, line 2349
    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 2358
    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 2370
    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 2510
    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 2387
    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 2380
    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 2340
    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 2522
    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 2516
    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.