Parent

R2RTestCase

Public Instance Methods

test_parse_tree_for_proc() click to toggle source
    # File test/test_parse_tree_extensions.rb, line 79
79:   def test_parse_tree_for_proc # TODO: move?
80:     p = proc {|a, b, c|}
81:     s = s(:iter,
82:           s(:call, nil, :proc, s(:arglist)),
83:           s(:masgn, s(:array, s(:lasgn, :a), s(:lasgn, :b), s(:lasgn, :c))))
84: 
85:     pt = ParseTree.new(false)
86:     u = Unifier.new
87:     sexp = pt.parse_tree_for_proc p
88: 
89:     sexp = u.process(sexp)
90: 
91:     assert_equal s, sexp
92:   end
test_proc_to_ruby() click to toggle source
    # File test/test_parse_tree_extensions.rb, line 10
10:   def test_proc_to_ruby
11:     util_setup_inline
12:     block = proc { puts "something" }
13:     assert_equal 'proc { puts("something") }', block.to_ruby
14:   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
23:   def test_proc_to_ruby_args_1
24:     util_setup_inline
25:     block = proc { |x| puts x }
26:     assert_equal 'proc { |x| puts(x) }', block.to_ruby
27:   end
test_proc_to_ruby_args_n() click to toggle source
    # File test/test_parse_tree_extensions.rb, line 29
29:   def test_proc_to_ruby_args_n
30:     util_setup_inline
31:     block = proc { |x| puts x }
32:     assert_equal 'proc { |x| puts(x) }', block.to_ruby
33:   end
test_proc_to_sexp() click to toggle source
    # File test/test_parse_tree_extensions.rb, line 35
35:   def test_proc_to_sexp
36:     util_setup_inline
37:     p = proc { 1 + 1 }
38:     s = s(:iter,
39:           s(:call, nil, :proc, s(:arglist)),
40:           nil,
41:           s(:call, s(:lit, 1), :+, s(:arglist, s(:lit, 1))))
42:     assert_equal s, p.to_sexp
43:   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
56:   def test_proc_to_sexp_args_1
57:     util_setup_inline
58:     p = proc {|x| puts x }
59:     s = s(:iter,
60:           s(:call, nil, :proc, s(:arglist)),
61:           s(:lasgn, :x),
62:           s(:call, nil, :puts, s(:arglist, s(:lvar, :x))))
63: 
64:     assert_equal s, p.to_sexp
65:   end
test_proc_to_sexp_args_n() click to toggle source
    # File test/test_parse_tree_extensions.rb, line 67
67:   def test_proc_to_sexp_args_n
68:     util_setup_inline
69:     p = proc {|x, y| puts x + y }
70:     s = s(:iter,
71:           s(:call, nil, :proc, s(:arglist)),
72:           s(:masgn, s(:array, s(:lasgn, :x), s(:lasgn, :y))),
73:           s(:call, nil, :puts,
74:             s(:arglist, s(:call, s(:lvar, :x), :+, s(:arglist, s(:lvar, :y))))))
75: 
76:     assert_equal s, p.to_sexp
77:   end
test_unbound_method_to_ruby() click to toggle source
     # File test/test_parse_tree_extensions.rb, line 94
 94:   def test_unbound_method_to_ruby
 95:     util_setup_inline
 96:     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}"
 97:     m = self.class.instance_method(:test_proc_to_sexp)
 98: 
 99:     assert_equal r, m.to_ruby
100:   end
util_setup_inline() click to toggle source
     # File test/test_parse_tree_extensions.rb, line 102
102:   def util_setup_inline
103:     @rootdir = File.join(Dir.tmpdir, "test_ruby_to_ruby.#{$$}")
104:     Dir.mkdir @rootdir, 0700 unless test dd, @rootdir
105:     ENV['INLINEDIR'] = @rootdir
106:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.