Class: R2RTestCase

### Home Classes Methods

### In Files

- test/test_parse_tree_extensions.rb

### Parent

MiniTest::Unit::TestCase

### Methods

- #test_parse_tree_for_proc
- #test_proc_to_ruby
- #test_proc_to_ruby_args_1
- #test_proc_to_ruby_args_n
- #test_proc_to_sexp
- #test_proc_to_sexp_args_1
- #test_proc_to_sexp_args_n
- #test_unbound_method_to_ruby
- #util_setup_inline

### 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.

# R2RTestCase

### Public Instance Methods

test_parse_tree_for_proc() click to toggle source

    # File test/test_parse_tree_extensions.rb, line 79
    def test_parse_tree_for_proc # TODO: move?
      p = proc {|a, b, c|}
      s = s(:iter,
            s(:call, nil, :proc, s(:arglist)),
            s(:masgn, s(:array, s(:lasgn, :a), s(:lasgn, :b), s(:lasgn, :c))))

      pt = ParseTree.new(false)
      u = Unifier.new
      sexp = pt.parse_tree_for_proc p

      sexp = u.process(sexp)

      assert_equal s, sexp
    end

test_proc_to_ruby() click to toggle source

    # File test/test_parse_tree_extensions.rb, line 10
    def test_proc_to_ruby
      util_setup_inline
      block = proc { puts "something" }
      assert_equal 'proc { puts("something") }', block.to_ruby
    end

test_proc_to_ruby_args_1() click to toggle source

TODO: bus error

    def test_proc_to_ruby_args_0
      util_setup_inline
      block = proc { || puts 42 }
      assert_equal 'proc { || puts(42) }', block.to_ruby
    end

    # File test/test_parse_tree_extensions.rb, line 23
    def test_proc_to_ruby_args_1
      util_setup_inline
      block = proc { |x| puts x }
      assert_equal 'proc { |x| puts(x) }', block.to_ruby
    end

test_proc_to_ruby_args_n() click to toggle source

    # File test/test_parse_tree_extensions.rb, line 29
    def test_proc_to_ruby_args_n
      util_setup_inline
      block = proc { |x| puts x }
      assert_equal 'proc { |x| puts(x) }', block.to_ruby
    end

test_proc_to_sexp() click to toggle source

    # File test/test_parse_tree_extensions.rb, line 35
    def test_proc_to_sexp
      util_setup_inline
      p = proc { 1 + 1 }
      s = s(:iter,
            s(:call, nil, :proc, s(:arglist)),
            nil,
            s(:call, s(:lit, 1), :+, s(:arglist, s(:lit, 1))))
      assert_equal s, p.to_sexp
    end

test_proc_to_sexp_args_1() click to toggle source

TODO: bus error

    def test_proc_to_sexp_args_0
      util_setup_inline
      p = proc { || 1 + 1 }
      s = s(:iter,
            s(:call, nil, :proc, s(:arglist)),
            nil,
            s(:call, s(:lit, 1), :+, s(:arglist, s(:lit, 1))))
      assert_equal s, p.to_sexp
    end

    # File test/test_parse_tree_extensions.rb, line 56
    def test_proc_to_sexp_args_1
      util_setup_inline
      p = proc {|x| puts x }
      s = s(:iter,
            s(:call, nil, :proc, s(:arglist)),
            s(:lasgn, :x),
            s(:call, nil, :puts, s(:arglist, s(:lvar, :x))))

      assert_equal s, p.to_sexp
    end

test_proc_to_sexp_args_n() click to toggle source

    # File test/test_parse_tree_extensions.rb, line 67
    def test_proc_to_sexp_args_n
      util_setup_inline
      p = proc {|x, y| puts x + y }
      s = s(:iter,
            s(:call, nil, :proc, s(:arglist)),
            s(:masgn, s(:array, s(:lasgn, :x), s(:lasgn, :y))),
            s(:call, nil, :puts,
              s(:arglist, s(:call, s(:lvar, :x), :+, s(:arglist, s(:lvar, :y))))))

      assert_equal s, p.to_sexp
    end

test_unbound_method_to_ruby() click to toggle source

    # File test/test_parse_tree_extensions.rb, line 94
    def test_unbound_method_to_ruby
      util_setup_inline
      r = "proc { ||\n  util_setup_inline\n  p = proc { (1 + 1) }\n  s = s(:iter, s(:call, nil, :proc, s(:arglist)), nil, s(:call, s(:lit, 1), :+, s(:arglist, s(:lit, 1))))\n  assert_equal(s, p.to_sexp)\n}"
      m = self.class.instance_method(:test_proc_to_sexp)

      assert_equal r, m.to_ruby
    end

util_setup_inline() click to toggle source

    # File test/test_parse_tree_extensions.rb, line 102
    def util_setup_inline
      @rootdir = File.join(Dir.tmpdir, "test_ruby_to_ruby.#{$$}")
      Dir.mkdir @rootdir, 0700 unless test dd, @rootdir
      ENV['INLINEDIR'] = @rootdir
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.